babylon.module.d.ts 5.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757
  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. * Stores a left-handed perspective projection into a given matrix with depth reversed
  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 not used as infinity is used as far clip
  4496. * @param result defines the target matrix
  4497. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4498. */
  4499. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4500. /**
  4501. * Creates a right-handed perspective projection matrix
  4502. * @param fov defines the horizontal field of view
  4503. * @param aspect defines the aspect ratio
  4504. * @param znear defines the near clip plane
  4505. * @param zfar defines the far clip plane
  4506. * @returns a new matrix as a right-handed perspective projection matrix
  4507. */
  4508. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4509. /**
  4510. * Stores a right-handed perspective projection into a given matrix
  4511. * @param fov defines the horizontal field of view
  4512. * @param aspect defines the aspect ratio
  4513. * @param znear defines the near clip plane
  4514. * @param zfar defines the far clip plane
  4515. * @param result defines the target matrix
  4516. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4517. */
  4518. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4519. /**
  4520. * Stores a right-handed perspective projection into a given matrix
  4521. * @param fov defines the horizontal field of view
  4522. * @param aspect defines the aspect ratio
  4523. * @param znear defines the near clip plane
  4524. * @param zfar not used as infinity is used as far clip
  4525. * @param result defines the target matrix
  4526. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4527. */
  4528. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4529. /**
  4530. * Stores a perspective projection for WebVR info a given matrix
  4531. * @param fov defines the field of view
  4532. * @param znear defines the near clip plane
  4533. * @param zfar defines the far clip plane
  4534. * @param result defines the target matrix
  4535. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4536. */
  4537. static PerspectiveFovWebVRToRef(fov: {
  4538. upDegrees: number;
  4539. downDegrees: number;
  4540. leftDegrees: number;
  4541. rightDegrees: number;
  4542. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4543. /**
  4544. * Computes a complete transformation matrix
  4545. * @param viewport defines the viewport to use
  4546. * @param world defines the world matrix
  4547. * @param view defines the view matrix
  4548. * @param projection defines the projection matrix
  4549. * @param zmin defines the near clip plane
  4550. * @param zmax defines the far clip plane
  4551. * @returns the transformation matrix
  4552. */
  4553. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4554. /**
  4555. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4556. * @param matrix defines the matrix to use
  4557. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4558. */
  4559. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4560. /**
  4561. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4562. * @param matrix defines the matrix to use
  4563. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4564. */
  4565. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4566. /**
  4567. * Compute the transpose of a given matrix
  4568. * @param matrix defines the matrix to transpose
  4569. * @returns the new matrix
  4570. */
  4571. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4572. /**
  4573. * Compute the transpose of a matrix and store it in a target matrix
  4574. * @param matrix defines the matrix to transpose
  4575. * @param result defines the target matrix
  4576. */
  4577. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4578. /**
  4579. * Computes a reflection matrix from a plane
  4580. * @param plane defines the reflection plane
  4581. * @returns a new matrix
  4582. */
  4583. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4584. /**
  4585. * Computes a reflection matrix from a plane
  4586. * @param plane defines the reflection plane
  4587. * @param result defines the target matrix
  4588. */
  4589. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4590. /**
  4591. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4592. * @param xaxis defines the value of the 1st axis
  4593. * @param yaxis defines the value of the 2nd axis
  4594. * @param zaxis defines the value of the 3rd axis
  4595. * @param result defines the target matrix
  4596. */
  4597. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4598. /**
  4599. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4600. * @param quat defines the quaternion to use
  4601. * @param result defines the target matrix
  4602. */
  4603. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4604. }
  4605. /**
  4606. * @hidden
  4607. */
  4608. export class TmpVectors {
  4609. static Vector2: Vector2[];
  4610. static Vector3: Vector3[];
  4611. static Vector4: Vector4[];
  4612. static Quaternion: Quaternion[];
  4613. static Matrix: Matrix[];
  4614. }
  4615. }
  4616. declare module "babylonjs/Maths/math.path" {
  4617. import { DeepImmutable, Nullable } from "babylonjs/types";
  4618. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4619. /**
  4620. * Defines potential orientation for back face culling
  4621. */
  4622. export enum Orientation {
  4623. /**
  4624. * Clockwise
  4625. */
  4626. CW = 0,
  4627. /** Counter clockwise */
  4628. CCW = 1
  4629. }
  4630. /** Class used to represent a Bezier curve */
  4631. export class BezierCurve {
  4632. /**
  4633. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4634. * @param t defines the time
  4635. * @param x1 defines the left coordinate on X axis
  4636. * @param y1 defines the left coordinate on Y axis
  4637. * @param x2 defines the right coordinate on X axis
  4638. * @param y2 defines the right coordinate on Y axis
  4639. * @returns the interpolated value
  4640. */
  4641. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4642. }
  4643. /**
  4644. * Defines angle representation
  4645. */
  4646. export class Angle {
  4647. private _radians;
  4648. /**
  4649. * Creates an Angle object of "radians" radians (float).
  4650. * @param radians the angle in radians
  4651. */
  4652. constructor(radians: number);
  4653. /**
  4654. * Get value in degrees
  4655. * @returns the Angle value in degrees (float)
  4656. */
  4657. degrees(): number;
  4658. /**
  4659. * Get value in radians
  4660. * @returns the Angle value in radians (float)
  4661. */
  4662. radians(): number;
  4663. /**
  4664. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4665. * @param a defines first vector
  4666. * @param b defines second vector
  4667. * @returns a new Angle
  4668. */
  4669. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4670. /**
  4671. * Gets a new Angle object from the given float in radians
  4672. * @param radians defines the angle value in radians
  4673. * @returns a new Angle
  4674. */
  4675. static FromRadians(radians: number): Angle;
  4676. /**
  4677. * Gets a new Angle object from the given float in degrees
  4678. * @param degrees defines the angle value in degrees
  4679. * @returns a new Angle
  4680. */
  4681. static FromDegrees(degrees: number): Angle;
  4682. }
  4683. /**
  4684. * This represents an arc in a 2d space.
  4685. */
  4686. export class Arc2 {
  4687. /** Defines the start point of the arc */
  4688. startPoint: Vector2;
  4689. /** Defines the mid point of the arc */
  4690. midPoint: Vector2;
  4691. /** Defines the end point of the arc */
  4692. endPoint: Vector2;
  4693. /**
  4694. * Defines the center point of the arc.
  4695. */
  4696. centerPoint: Vector2;
  4697. /**
  4698. * Defines the radius of the arc.
  4699. */
  4700. radius: number;
  4701. /**
  4702. * Defines the angle of the arc (from mid point to end point).
  4703. */
  4704. angle: Angle;
  4705. /**
  4706. * Defines the start angle of the arc (from start point to middle point).
  4707. */
  4708. startAngle: Angle;
  4709. /**
  4710. * Defines the orientation of the arc (clock wise/counter clock wise).
  4711. */
  4712. orientation: Orientation;
  4713. /**
  4714. * Creates an Arc object from the three given points : start, middle and end.
  4715. * @param startPoint Defines the start point of the arc
  4716. * @param midPoint Defines the midlle point of the arc
  4717. * @param endPoint Defines the end point of the arc
  4718. */
  4719. constructor(
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2,
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2,
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2);
  4726. }
  4727. /**
  4728. * Represents a 2D path made up of multiple 2D points
  4729. */
  4730. export class Path2 {
  4731. private _points;
  4732. private _length;
  4733. /**
  4734. * If the path start and end point are the same
  4735. */
  4736. closed: boolean;
  4737. /**
  4738. * Creates a Path2 object from the starting 2D coordinates x and y.
  4739. * @param x the starting points x value
  4740. * @param y the starting points y value
  4741. */
  4742. constructor(x: number, y: number);
  4743. /**
  4744. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4745. * @param x the added points x value
  4746. * @param y the added points y value
  4747. * @returns the updated Path2.
  4748. */
  4749. addLineTo(x: number, y: number): Path2;
  4750. /**
  4751. * 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.
  4752. * @param midX middle point x value
  4753. * @param midY middle point y value
  4754. * @param endX end point x value
  4755. * @param endY end point y value
  4756. * @param numberOfSegments (default: 36)
  4757. * @returns the updated Path2.
  4758. */
  4759. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4760. /**
  4761. * Closes the Path2.
  4762. * @returns the Path2.
  4763. */
  4764. close(): Path2;
  4765. /**
  4766. * Gets the sum of the distance between each sequential point in the path
  4767. * @returns the Path2 total length (float).
  4768. */
  4769. length(): number;
  4770. /**
  4771. * Gets the points which construct the path
  4772. * @returns the Path2 internal array of points.
  4773. */
  4774. getPoints(): Vector2[];
  4775. /**
  4776. * Retreives the point at the distance aways from the starting point
  4777. * @param normalizedLengthPosition the length along the path to retreive the point from
  4778. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4779. */
  4780. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4781. /**
  4782. * Creates a new path starting from an x and y position
  4783. * @param x starting x value
  4784. * @param y starting y value
  4785. * @returns a new Path2 starting at the coordinates (x, y).
  4786. */
  4787. static StartingAt(x: number, y: number): Path2;
  4788. }
  4789. /**
  4790. * Represents a 3D path made up of multiple 3D points
  4791. */
  4792. export class Path3D {
  4793. /**
  4794. * an array of Vector3, the curve axis of the Path3D
  4795. */
  4796. path: Vector3[];
  4797. private _curve;
  4798. private _distances;
  4799. private _tangents;
  4800. private _normals;
  4801. private _binormals;
  4802. private _raw;
  4803. private _alignTangentsWithPath;
  4804. private readonly _pointAtData;
  4805. /**
  4806. * new Path3D(path, normal, raw)
  4807. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4808. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4809. * @param path an array of Vector3, the curve axis of the Path3D
  4810. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4811. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4812. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4813. */
  4814. constructor(
  4815. /**
  4816. * an array of Vector3, the curve axis of the Path3D
  4817. */
  4818. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4819. /**
  4820. * Returns the Path3D array of successive Vector3 designing its curve.
  4821. * @returns the Path3D array of successive Vector3 designing its curve.
  4822. */
  4823. getCurve(): Vector3[];
  4824. /**
  4825. * Returns the Path3D array of successive Vector3 designing its curve.
  4826. * @returns the Path3D array of successive Vector3 designing its curve.
  4827. */
  4828. getPoints(): Vector3[];
  4829. /**
  4830. * @returns the computed length (float) of the path.
  4831. */
  4832. length(): number;
  4833. /**
  4834. * Returns an array populated with tangent vectors on each Path3D curve point.
  4835. * @returns an array populated with tangent vectors on each Path3D curve point.
  4836. */
  4837. getTangents(): Vector3[];
  4838. /**
  4839. * Returns an array populated with normal vectors on each Path3D curve point.
  4840. * @returns an array populated with normal vectors on each Path3D curve point.
  4841. */
  4842. getNormals(): Vector3[];
  4843. /**
  4844. * Returns an array populated with binormal vectors on each Path3D curve point.
  4845. * @returns an array populated with binormal vectors on each Path3D curve point.
  4846. */
  4847. getBinormals(): Vector3[];
  4848. /**
  4849. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4850. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4851. */
  4852. getDistances(): number[];
  4853. /**
  4854. * Returns an interpolated point along this path
  4855. * @param position the position of the point along this path, from 0.0 to 1.0
  4856. * @returns a new Vector3 as the point
  4857. */
  4858. getPointAt(position: number): Vector3;
  4859. /**
  4860. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4861. * @param position the position of the point along this path, from 0.0 to 1.0
  4862. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4863. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4864. */
  4865. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4866. /**
  4867. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4868. * @param position the position of the point along this path, from 0.0 to 1.0
  4869. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4870. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4871. */
  4872. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4873. /**
  4874. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4875. * @param position the position of the point along this path, from 0.0 to 1.0
  4876. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4877. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4878. */
  4879. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4880. /**
  4881. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4882. * @param position the position of the point along this path, from 0.0 to 1.0
  4883. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4884. */
  4885. getDistanceAt(position: number): number;
  4886. /**
  4887. * Returns the array index of the previous point of an interpolated point along this path
  4888. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4889. * @returns the array index
  4890. */
  4891. getPreviousPointIndexAt(position: number): number;
  4892. /**
  4893. * 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)
  4894. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4895. * @returns the sub position
  4896. */
  4897. getSubPositionAt(position: number): number;
  4898. /**
  4899. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4900. * @param target the vector of which to get the closest position to
  4901. * @returns the position of the closest virtual point on this path to the target vector
  4902. */
  4903. getClosestPositionTo(target: Vector3): number;
  4904. /**
  4905. * Returns a sub path (slice) of this path
  4906. * @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
  4907. * @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
  4908. * @returns a sub path (slice) of this path
  4909. */
  4910. slice(start?: number, end?: number): Path3D;
  4911. /**
  4912. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4913. * @param path path which all values are copied into the curves points
  4914. * @param firstNormal which should be projected onto the curve
  4915. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4916. * @returns the same object updated.
  4917. */
  4918. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4919. private _compute;
  4920. private _getFirstNonNullVector;
  4921. private _getLastNonNullVector;
  4922. private _normalVector;
  4923. /**
  4924. * Updates the point at data for an interpolated point along this curve
  4925. * @param position the position of the point along this curve, from 0.0 to 1.0
  4926. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4927. * @returns the (updated) point at data
  4928. */
  4929. private _updatePointAtData;
  4930. /**
  4931. * Updates the point at data from the specified parameters
  4932. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4933. * @param point the interpolated point
  4934. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4935. */
  4936. private _setPointAtData;
  4937. /**
  4938. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4939. */
  4940. private _updateInterpolationMatrix;
  4941. }
  4942. /**
  4943. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4944. * A Curve3 is designed from a series of successive Vector3.
  4945. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4946. */
  4947. export class Curve3 {
  4948. private _points;
  4949. private _length;
  4950. /**
  4951. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4952. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4953. * @param v1 (Vector3) the control point
  4954. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4955. * @param nbPoints (integer) the wanted number of points in the curve
  4956. * @returns the created Curve3
  4957. */
  4958. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4959. /**
  4960. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4961. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4962. * @param v1 (Vector3) the first control point
  4963. * @param v2 (Vector3) the second control point
  4964. * @param v3 (Vector3) the end point of the Cubic Bezier
  4965. * @param nbPoints (integer) the wanted number of points in the curve
  4966. * @returns the created Curve3
  4967. */
  4968. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4969. /**
  4970. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4971. * @param p1 (Vector3) the origin point of the Hermite Spline
  4972. * @param t1 (Vector3) the tangent vector at the origin point
  4973. * @param p2 (Vector3) the end point of the Hermite Spline
  4974. * @param t2 (Vector3) the tangent vector at the end point
  4975. * @param nbPoints (integer) the wanted number of points in the curve
  4976. * @returns the created Curve3
  4977. */
  4978. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4979. /**
  4980. * Returns a Curve3 object along a CatmullRom Spline curve :
  4981. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4982. * @param nbPoints (integer) the wanted number of points between each curve control points
  4983. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4984. * @returns the created Curve3
  4985. */
  4986. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4987. /**
  4988. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4989. * A Curve3 is designed from a series of successive Vector3.
  4990. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4991. * @param points points which make up the curve
  4992. */
  4993. constructor(points: Vector3[]);
  4994. /**
  4995. * @returns the Curve3 stored array of successive Vector3
  4996. */
  4997. getPoints(): Vector3[];
  4998. /**
  4999. * @returns the computed length (float) of the curve.
  5000. */
  5001. length(): number;
  5002. /**
  5003. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5004. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5005. * curveA and curveB keep unchanged.
  5006. * @param curve the curve to continue from this curve
  5007. * @returns the newly constructed curve
  5008. */
  5009. continue(curve: DeepImmutable<Curve3>): Curve3;
  5010. private _computeLength;
  5011. }
  5012. }
  5013. declare module "babylonjs/Animations/easing" {
  5014. /**
  5015. * This represents the main contract an easing function should follow.
  5016. * Easing functions are used throughout the animation system.
  5017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5018. */
  5019. export interface IEasingFunction {
  5020. /**
  5021. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5022. * of the easing function.
  5023. * The link below provides some of the most common examples of easing functions.
  5024. * @see https://easings.net/
  5025. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5026. * @returns the corresponding value on the curve defined by the easing function
  5027. */
  5028. ease(gradient: number): number;
  5029. }
  5030. /**
  5031. * Base class used for every default easing function.
  5032. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5033. */
  5034. export class EasingFunction implements IEasingFunction {
  5035. /**
  5036. * Interpolation follows the mathematical formula associated with the easing function.
  5037. */
  5038. static readonly EASINGMODE_EASEIN: number;
  5039. /**
  5040. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5041. */
  5042. static readonly EASINGMODE_EASEOUT: number;
  5043. /**
  5044. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5045. */
  5046. static readonly EASINGMODE_EASEINOUT: number;
  5047. private _easingMode;
  5048. /**
  5049. * Sets the easing mode of the current function.
  5050. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5051. */
  5052. setEasingMode(easingMode: number): void;
  5053. /**
  5054. * Gets the current easing mode.
  5055. * @returns the easing mode
  5056. */
  5057. getEasingMode(): number;
  5058. /**
  5059. * @hidden
  5060. */
  5061. easeInCore(gradient: number): number;
  5062. /**
  5063. * Given an input gradient between 0 and 1, this returns the corresponding value
  5064. * of the easing function.
  5065. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5066. * @returns the corresponding value on the curve defined by the easing function
  5067. */
  5068. ease(gradient: number): number;
  5069. }
  5070. /**
  5071. * Easing function with a circle shape (see link below).
  5072. * @see https://easings.net/#easeInCirc
  5073. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5074. */
  5075. export class CircleEase extends EasingFunction implements IEasingFunction {
  5076. /** @hidden */
  5077. easeInCore(gradient: number): number;
  5078. }
  5079. /**
  5080. * Easing function with a ease back shape (see link below).
  5081. * @see https://easings.net/#easeInBack
  5082. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5083. */
  5084. export class BackEase extends EasingFunction implements IEasingFunction {
  5085. /** Defines the amplitude of the function */
  5086. amplitude: number;
  5087. /**
  5088. * Instantiates a back ease easing
  5089. * @see https://easings.net/#easeInBack
  5090. * @param amplitude Defines the amplitude of the function
  5091. */
  5092. constructor(
  5093. /** Defines the amplitude of the function */
  5094. amplitude?: number);
  5095. /** @hidden */
  5096. easeInCore(gradient: number): number;
  5097. }
  5098. /**
  5099. * Easing function with a bouncing shape (see link below).
  5100. * @see https://easings.net/#easeInBounce
  5101. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5102. */
  5103. export class BounceEase extends EasingFunction implements IEasingFunction {
  5104. /** Defines the number of bounces */
  5105. bounces: number;
  5106. /** Defines the amplitude of the bounce */
  5107. bounciness: number;
  5108. /**
  5109. * Instantiates a bounce easing
  5110. * @see https://easings.net/#easeInBounce
  5111. * @param bounces Defines the number of bounces
  5112. * @param bounciness Defines the amplitude of the bounce
  5113. */
  5114. constructor(
  5115. /** Defines the number of bounces */
  5116. bounces?: number,
  5117. /** Defines the amplitude of the bounce */
  5118. bounciness?: number);
  5119. /** @hidden */
  5120. easeInCore(gradient: number): number;
  5121. }
  5122. /**
  5123. * Easing function with a power of 3 shape (see link below).
  5124. * @see https://easings.net/#easeInCubic
  5125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5126. */
  5127. export class CubicEase extends EasingFunction implements IEasingFunction {
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with an elastic shape (see link below).
  5133. * @see https://easings.net/#easeInElastic
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of oscillations*/
  5138. oscillations: number;
  5139. /** Defines the amplitude of the oscillations*/
  5140. springiness: number;
  5141. /**
  5142. * Instantiates an elastic easing function
  5143. * @see https://easings.net/#easeInElastic
  5144. * @param oscillations Defines the number of oscillations
  5145. * @param springiness Defines the amplitude of the oscillations
  5146. */
  5147. constructor(
  5148. /** Defines the number of oscillations*/
  5149. oscillations?: number,
  5150. /** Defines the amplitude of the oscillations*/
  5151. springiness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with an exponential shape (see link below).
  5157. * @see https://easings.net/#easeInExpo
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5161. /** Defines the exponent of the function */
  5162. exponent: number;
  5163. /**
  5164. * Instantiates an exponential easing function
  5165. * @see https://easings.net/#easeInExpo
  5166. * @param exponent Defines the exponent of the function
  5167. */
  5168. constructor(
  5169. /** Defines the exponent of the function */
  5170. exponent?: number);
  5171. /** @hidden */
  5172. easeInCore(gradient: number): number;
  5173. }
  5174. /**
  5175. * Easing function with a power shape (see link below).
  5176. * @see https://easings.net/#easeInQuad
  5177. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5178. */
  5179. export class PowerEase extends EasingFunction implements IEasingFunction {
  5180. /** Defines the power of the function */
  5181. power: number;
  5182. /**
  5183. * Instantiates an power base easing function
  5184. * @see https://easings.net/#easeInQuad
  5185. * @param power Defines the power of the function
  5186. */
  5187. constructor(
  5188. /** Defines the power of the function */
  5189. power?: number);
  5190. /** @hidden */
  5191. easeInCore(gradient: number): number;
  5192. }
  5193. /**
  5194. * Easing function with a power of 2 shape (see link below).
  5195. * @see https://easings.net/#easeInQuad
  5196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5197. */
  5198. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5199. /** @hidden */
  5200. easeInCore(gradient: number): number;
  5201. }
  5202. /**
  5203. * Easing function with a power of 4 shape (see link below).
  5204. * @see https://easings.net/#easeInQuart
  5205. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5206. */
  5207. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5208. /** @hidden */
  5209. easeInCore(gradient: number): number;
  5210. }
  5211. /**
  5212. * Easing function with a power of 5 shape (see link below).
  5213. * @see https://easings.net/#easeInQuint
  5214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5215. */
  5216. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5217. /** @hidden */
  5218. easeInCore(gradient: number): number;
  5219. }
  5220. /**
  5221. * Easing function with a sin shape (see link below).
  5222. * @see https://easings.net/#easeInSine
  5223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5224. */
  5225. export class SineEase extends EasingFunction implements IEasingFunction {
  5226. /** @hidden */
  5227. easeInCore(gradient: number): number;
  5228. }
  5229. /**
  5230. * Easing function with a bezier shape (see link below).
  5231. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5232. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5233. */
  5234. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5235. /** Defines the x component of the start tangent in the bezier curve */
  5236. x1: number;
  5237. /** Defines the y component of the start tangent in the bezier curve */
  5238. y1: number;
  5239. /** Defines the x component of the end tangent in the bezier curve */
  5240. x2: number;
  5241. /** Defines the y component of the end tangent in the bezier curve */
  5242. y2: number;
  5243. /**
  5244. * Instantiates a bezier function
  5245. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5246. * @param x1 Defines the x component of the start tangent in the bezier curve
  5247. * @param y1 Defines the y component of the start tangent in the bezier curve
  5248. * @param x2 Defines the x component of the end tangent in the bezier curve
  5249. * @param y2 Defines the y component of the end tangent in the bezier curve
  5250. */
  5251. constructor(
  5252. /** Defines the x component of the start tangent in the bezier curve */
  5253. x1?: number,
  5254. /** Defines the y component of the start tangent in the bezier curve */
  5255. y1?: number,
  5256. /** Defines the x component of the end tangent in the bezier curve */
  5257. x2?: number,
  5258. /** Defines the y component of the end tangent in the bezier curve */
  5259. y2?: number);
  5260. /** @hidden */
  5261. easeInCore(gradient: number): number;
  5262. }
  5263. }
  5264. declare module "babylonjs/Maths/math.color" {
  5265. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5266. /**
  5267. * Class used to hold a RBG color
  5268. */
  5269. export class Color3 {
  5270. /**
  5271. * Defines the red component (between 0 and 1, default is 0)
  5272. */
  5273. r: number;
  5274. /**
  5275. * Defines the green component (between 0 and 1, default is 0)
  5276. */
  5277. g: number;
  5278. /**
  5279. * Defines the blue component (between 0 and 1, default is 0)
  5280. */
  5281. b: number;
  5282. /**
  5283. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5284. * @param r defines the red component (between 0 and 1, default is 0)
  5285. * @param g defines the green component (between 0 and 1, default is 0)
  5286. * @param b defines the blue component (between 0 and 1, default is 0)
  5287. */
  5288. constructor(
  5289. /**
  5290. * Defines the red component (between 0 and 1, default is 0)
  5291. */
  5292. r?: number,
  5293. /**
  5294. * Defines the green component (between 0 and 1, default is 0)
  5295. */
  5296. g?: number,
  5297. /**
  5298. * Defines the blue component (between 0 and 1, default is 0)
  5299. */
  5300. b?: number);
  5301. /**
  5302. * Creates a string with the Color3 current values
  5303. * @returns the string representation of the Color3 object
  5304. */
  5305. toString(): string;
  5306. /**
  5307. * Returns the string "Color3"
  5308. * @returns "Color3"
  5309. */
  5310. getClassName(): string;
  5311. /**
  5312. * Compute the Color3 hash code
  5313. * @returns an unique number that can be used to hash Color3 objects
  5314. */
  5315. getHashCode(): number;
  5316. /**
  5317. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5318. * @param array defines the array where to store the r,g,b components
  5319. * @param index defines an optional index in the target array to define where to start storing values
  5320. * @returns the current Color3 object
  5321. */
  5322. toArray(array: FloatArray, index?: number): Color3;
  5323. /**
  5324. * Returns a new Color4 object from the current Color3 and the given alpha
  5325. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5326. * @returns a new Color4 object
  5327. */
  5328. toColor4(alpha?: number): Color4;
  5329. /**
  5330. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5331. * @returns the new array
  5332. */
  5333. asArray(): number[];
  5334. /**
  5335. * Returns the luminance value
  5336. * @returns a float value
  5337. */
  5338. toLuminance(): number;
  5339. /**
  5340. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5341. * @param otherColor defines the second operand
  5342. * @returns the new Color3 object
  5343. */
  5344. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5345. /**
  5346. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5347. * @param otherColor defines the second operand
  5348. * @param result defines the Color3 object where to store the result
  5349. * @returns the current Color3
  5350. */
  5351. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5352. /**
  5353. * Determines equality between Color3 objects
  5354. * @param otherColor defines the second operand
  5355. * @returns true if the rgb values are equal to the given ones
  5356. */
  5357. equals(otherColor: DeepImmutable<Color3>): boolean;
  5358. /**
  5359. * Determines equality between the current Color3 object and a set of r,b,g values
  5360. * @param r defines the red component to check
  5361. * @param g defines the green component to check
  5362. * @param b defines the blue component to check
  5363. * @returns true if the rgb values are equal to the given ones
  5364. */
  5365. equalsFloats(r: number, g: number, b: number): boolean;
  5366. /**
  5367. * Multiplies in place each rgb value by scale
  5368. * @param scale defines the scaling factor
  5369. * @returns the updated Color3
  5370. */
  5371. scale(scale: number): Color3;
  5372. /**
  5373. * Multiplies the rgb values by scale and stores the result into "result"
  5374. * @param scale defines the scaling factor
  5375. * @param result defines the Color3 object where to store the result
  5376. * @returns the unmodified current Color3
  5377. */
  5378. scaleToRef(scale: number, result: Color3): Color3;
  5379. /**
  5380. * Scale the current Color3 values by a factor and add the result to a given Color3
  5381. * @param scale defines the scale factor
  5382. * @param result defines color to store the result into
  5383. * @returns the unmodified current Color3
  5384. */
  5385. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5386. /**
  5387. * Clamps the rgb values by the min and max values and stores the result into "result"
  5388. * @param min defines minimum clamping value (default is 0)
  5389. * @param max defines maximum clamping value (default is 1)
  5390. * @param result defines color to store the result into
  5391. * @returns the original Color3
  5392. */
  5393. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5394. /**
  5395. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5396. * @param otherColor defines the second operand
  5397. * @returns the new Color3
  5398. */
  5399. add(otherColor: DeepImmutable<Color3>): Color3;
  5400. /**
  5401. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5402. * @param otherColor defines the second operand
  5403. * @param result defines Color3 object to store the result into
  5404. * @returns the unmodified current Color3
  5405. */
  5406. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5407. /**
  5408. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5409. * @param otherColor defines the second operand
  5410. * @returns the new Color3
  5411. */
  5412. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5413. /**
  5414. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5415. * @param otherColor defines the second operand
  5416. * @param result defines Color3 object to store the result into
  5417. * @returns the unmodified current Color3
  5418. */
  5419. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5420. /**
  5421. * Copy the current object
  5422. * @returns a new Color3 copied the current one
  5423. */
  5424. clone(): Color3;
  5425. /**
  5426. * Copies the rgb values from the source in the current Color3
  5427. * @param source defines the source Color3 object
  5428. * @returns the updated Color3 object
  5429. */
  5430. copyFrom(source: DeepImmutable<Color3>): Color3;
  5431. /**
  5432. * Updates the Color3 rgb values from the given floats
  5433. * @param r defines the red component to read from
  5434. * @param g defines the green component to read from
  5435. * @param b defines the blue component to read from
  5436. * @returns the current Color3 object
  5437. */
  5438. copyFromFloats(r: number, g: number, b: number): Color3;
  5439. /**
  5440. * Updates the Color3 rgb values from the given floats
  5441. * @param r defines the red component to read from
  5442. * @param g defines the green component to read from
  5443. * @param b defines the blue component to read from
  5444. * @returns the current Color3 object
  5445. */
  5446. set(r: number, g: number, b: number): Color3;
  5447. /**
  5448. * Compute the Color3 hexadecimal code as a string
  5449. * @returns a string containing the hexadecimal representation of the Color3 object
  5450. */
  5451. toHexString(): string;
  5452. /**
  5453. * Computes a new Color3 converted from the current one to linear space
  5454. * @returns a new Color3 object
  5455. */
  5456. toLinearSpace(): Color3;
  5457. /**
  5458. * Converts current color in rgb space to HSV values
  5459. * @returns a new color3 representing the HSV values
  5460. */
  5461. toHSV(): Color3;
  5462. /**
  5463. * Converts current color in rgb space to HSV values
  5464. * @param result defines the Color3 where to store the HSV values
  5465. */
  5466. toHSVToRef(result: Color3): void;
  5467. /**
  5468. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5469. * @param convertedColor defines the Color3 object where to store the linear space version
  5470. * @returns the unmodified Color3
  5471. */
  5472. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5473. /**
  5474. * Computes a new Color3 converted from the current one to gamma space
  5475. * @returns a new Color3 object
  5476. */
  5477. toGammaSpace(): Color3;
  5478. /**
  5479. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5480. * @param convertedColor defines the Color3 object where to store the gamma space version
  5481. * @returns the unmodified Color3
  5482. */
  5483. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5484. private static _BlackReadOnly;
  5485. /**
  5486. * Convert Hue, saturation and value to a Color3 (RGB)
  5487. * @param hue defines the hue
  5488. * @param saturation defines the saturation
  5489. * @param value defines the value
  5490. * @param result defines the Color3 where to store the RGB values
  5491. */
  5492. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5493. /**
  5494. * Creates a new Color3 from the string containing valid hexadecimal values
  5495. * @param hex defines a string containing valid hexadecimal values
  5496. * @returns a new Color3 object
  5497. */
  5498. static FromHexString(hex: string): Color3;
  5499. /**
  5500. * Creates a new Color3 from the starting index of the given array
  5501. * @param array defines the source array
  5502. * @param offset defines an offset in the source array
  5503. * @returns a new Color3 object
  5504. */
  5505. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5506. /**
  5507. * Creates a new Color3 from integer values (< 256)
  5508. * @param r defines the red component to read from (value between 0 and 255)
  5509. * @param g defines the green component to read from (value between 0 and 255)
  5510. * @param b defines the blue component to read from (value between 0 and 255)
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromInts(r: number, g: number, b: number): Color3;
  5514. /**
  5515. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5516. * @param start defines the start Color3 value
  5517. * @param end defines the end Color3 value
  5518. * @param amount defines the gradient value between start and end
  5519. * @returns a new Color3 object
  5520. */
  5521. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5522. /**
  5523. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5524. * @param left defines the start value
  5525. * @param right defines the end value
  5526. * @param amount defines the gradient factor
  5527. * @param result defines the Color3 object where to store the result
  5528. */
  5529. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5530. /**
  5531. * Returns a Color3 value containing a red color
  5532. * @returns a new Color3 object
  5533. */
  5534. static Red(): Color3;
  5535. /**
  5536. * Returns a Color3 value containing a green color
  5537. * @returns a new Color3 object
  5538. */
  5539. static Green(): Color3;
  5540. /**
  5541. * Returns a Color3 value containing a blue color
  5542. * @returns a new Color3 object
  5543. */
  5544. static Blue(): Color3;
  5545. /**
  5546. * Returns a Color3 value containing a black color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Black(): Color3;
  5550. /**
  5551. * Gets a Color3 value containing a black color that must not be updated
  5552. */
  5553. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5554. /**
  5555. * Returns a Color3 value containing a white color
  5556. * @returns a new Color3 object
  5557. */
  5558. static White(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a purple color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Purple(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a magenta color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Magenta(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a yellow color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Yellow(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a gray color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Gray(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a teal color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Teal(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a random color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Random(): Color3;
  5589. }
  5590. /**
  5591. * Class used to hold a RBGA color
  5592. */
  5593. export class Color4 {
  5594. /**
  5595. * Defines the red component (between 0 and 1, default is 0)
  5596. */
  5597. r: number;
  5598. /**
  5599. * Defines the green component (between 0 and 1, default is 0)
  5600. */
  5601. g: number;
  5602. /**
  5603. * Defines the blue component (between 0 and 1, default is 0)
  5604. */
  5605. b: number;
  5606. /**
  5607. * Defines the alpha component (between 0 and 1, default is 1)
  5608. */
  5609. a: number;
  5610. /**
  5611. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5612. * @param r defines the red component (between 0 and 1, default is 0)
  5613. * @param g defines the green component (between 0 and 1, default is 0)
  5614. * @param b defines the blue component (between 0 and 1, default is 0)
  5615. * @param a defines the alpha component (between 0 and 1, default is 1)
  5616. */
  5617. constructor(
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r?: number,
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g?: number,
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b?: number,
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a?: number);
  5634. /**
  5635. * Adds in place the given Color4 values to the current Color4 object
  5636. * @param right defines the second operand
  5637. * @returns the current updated Color4 object
  5638. */
  5639. addInPlace(right: DeepImmutable<Color4>): Color4;
  5640. /**
  5641. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5642. * @returns the new array
  5643. */
  5644. asArray(): number[];
  5645. /**
  5646. * Stores from the starting index in the given array the Color4 successive values
  5647. * @param array defines the array where to store the r,g,b components
  5648. * @param index defines an optional index in the target array to define where to start storing values
  5649. * @returns the current Color4 object
  5650. */
  5651. toArray(array: number[], index?: number): Color4;
  5652. /**
  5653. * Determines equality between Color4 objects
  5654. * @param otherColor defines the second operand
  5655. * @returns true if the rgba values are equal to the given ones
  5656. */
  5657. equals(otherColor: DeepImmutable<Color4>): boolean;
  5658. /**
  5659. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5660. * @param right defines the second operand
  5661. * @returns a new Color4 object
  5662. */
  5663. add(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5666. * @param right defines the second operand
  5667. * @returns a new Color4 object
  5668. */
  5669. subtract(right: DeepImmutable<Color4>): Color4;
  5670. /**
  5671. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5672. * @param right defines the second operand
  5673. * @param result defines the Color4 object where to store the result
  5674. * @returns the current Color4 object
  5675. */
  5676. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5677. /**
  5678. * Creates a new Color4 with the current Color4 values multiplied by scale
  5679. * @param scale defines the scaling factor to apply
  5680. * @returns a new Color4 object
  5681. */
  5682. scale(scale: number): Color4;
  5683. /**
  5684. * Multiplies the current Color4 values by scale and stores the result in "result"
  5685. * @param scale defines the scaling factor to apply
  5686. * @param result defines the Color4 object where to store the result
  5687. * @returns the current unmodified Color4
  5688. */
  5689. scaleToRef(scale: number, result: Color4): Color4;
  5690. /**
  5691. * Scale the current Color4 values by a factor and add the result to a given Color4
  5692. * @param scale defines the scale factor
  5693. * @param result defines the Color4 object where to store the result
  5694. * @returns the unmodified current Color4
  5695. */
  5696. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5697. /**
  5698. * Clamps the rgb values by the min and max values and stores the result into "result"
  5699. * @param min defines minimum clamping value (default is 0)
  5700. * @param max defines maximum clamping value (default is 1)
  5701. * @param result defines color to store the result into.
  5702. * @returns the cuurent Color4
  5703. */
  5704. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5705. /**
  5706. * Multipy an Color4 value by another and return a new Color4 object
  5707. * @param color defines the Color4 value to multiply by
  5708. * @returns a new Color4 object
  5709. */
  5710. multiply(color: Color4): Color4;
  5711. /**
  5712. * Multipy a Color4 value by another and push the result in a reference value
  5713. * @param color defines the Color4 value to multiply by
  5714. * @param result defines the Color4 to fill the result in
  5715. * @returns the result Color4
  5716. */
  5717. multiplyToRef(color: Color4, result: Color4): Color4;
  5718. /**
  5719. * Creates a string with the Color4 current values
  5720. * @returns the string representation of the Color4 object
  5721. */
  5722. toString(): string;
  5723. /**
  5724. * Returns the string "Color4"
  5725. * @returns "Color4"
  5726. */
  5727. getClassName(): string;
  5728. /**
  5729. * Compute the Color4 hash code
  5730. * @returns an unique number that can be used to hash Color4 objects
  5731. */
  5732. getHashCode(): number;
  5733. /**
  5734. * Creates a new Color4 copied from the current one
  5735. * @returns a new Color4 object
  5736. */
  5737. clone(): Color4;
  5738. /**
  5739. * Copies the given Color4 values into the current one
  5740. * @param source defines the source Color4 object
  5741. * @returns the current updated Color4 object
  5742. */
  5743. copyFrom(source: Color4): Color4;
  5744. /**
  5745. * Copies the given float values into the current one
  5746. * @param r defines the red component to read from
  5747. * @param g defines the green component to read from
  5748. * @param b defines the blue component to read from
  5749. * @param a defines the alpha component to read from
  5750. * @returns the current updated Color4 object
  5751. */
  5752. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5753. /**
  5754. * Copies the given float values into the current one
  5755. * @param r defines the red component to read from
  5756. * @param g defines the green component to read from
  5757. * @param b defines the blue component to read from
  5758. * @param a defines the alpha component to read from
  5759. * @returns the current updated Color4 object
  5760. */
  5761. set(r: number, g: number, b: number, a: number): Color4;
  5762. /**
  5763. * Compute the Color4 hexadecimal code as a string
  5764. * @returns a string containing the hexadecimal representation of the Color4 object
  5765. */
  5766. toHexString(): string;
  5767. /**
  5768. * Computes a new Color4 converted from the current one to linear space
  5769. * @returns a new Color4 object
  5770. */
  5771. toLinearSpace(): Color4;
  5772. /**
  5773. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5774. * @param convertedColor defines the Color4 object where to store the linear space version
  5775. * @returns the unmodified Color4
  5776. */
  5777. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5778. /**
  5779. * Computes a new Color4 converted from the current one to gamma space
  5780. * @returns a new Color4 object
  5781. */
  5782. toGammaSpace(): Color4;
  5783. /**
  5784. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5785. * @param convertedColor defines the Color4 object where to store the gamma space version
  5786. * @returns the unmodified Color4
  5787. */
  5788. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5789. /**
  5790. * Creates a new Color4 from the string containing valid hexadecimal values
  5791. * @param hex defines a string containing valid hexadecimal values
  5792. * @returns a new Color4 object
  5793. */
  5794. static FromHexString(hex: string): Color4;
  5795. /**
  5796. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5797. * @param left defines the start value
  5798. * @param right defines the end value
  5799. * @param amount defines the gradient factor
  5800. * @returns a new Color4 object
  5801. */
  5802. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5803. /**
  5804. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5805. * @param left defines the start value
  5806. * @param right defines the end value
  5807. * @param amount defines the gradient factor
  5808. * @param result defines the Color4 object where to store data
  5809. */
  5810. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5811. /**
  5812. * Creates a new Color4 from a Color3 and an alpha value
  5813. * @param color3 defines the source Color3 to read from
  5814. * @param alpha defines the alpha component (1.0 by default)
  5815. * @returns a new Color4 object
  5816. */
  5817. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5818. /**
  5819. * Creates a new Color4 from the starting index element of the given array
  5820. * @param array defines the source array to read from
  5821. * @param offset defines the offset in the source array
  5822. * @returns a new Color4 object
  5823. */
  5824. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5825. /**
  5826. * Creates a new Color3 from integer values (< 256)
  5827. * @param r defines the red component to read from (value between 0 and 255)
  5828. * @param g defines the green component to read from (value between 0 and 255)
  5829. * @param b defines the blue component to read from (value between 0 and 255)
  5830. * @param a defines the alpha component to read from (value between 0 and 255)
  5831. * @returns a new Color3 object
  5832. */
  5833. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5834. /**
  5835. * Check the content of a given array and convert it to an array containing RGBA data
  5836. * If the original array was already containing count * 4 values then it is returned directly
  5837. * @param colors defines the array to check
  5838. * @param count defines the number of RGBA data to expect
  5839. * @returns an array containing count * 4 values (RGBA)
  5840. */
  5841. static CheckColors4(colors: number[], count: number): number[];
  5842. }
  5843. /**
  5844. * @hidden
  5845. */
  5846. export class TmpColors {
  5847. static Color3: Color3[];
  5848. static Color4: Color4[];
  5849. }
  5850. }
  5851. declare module "babylonjs/Animations/animationKey" {
  5852. /**
  5853. * Defines an interface which represents an animation key frame
  5854. */
  5855. export interface IAnimationKey {
  5856. /**
  5857. * Frame of the key frame
  5858. */
  5859. frame: number;
  5860. /**
  5861. * Value at the specifies key frame
  5862. */
  5863. value: any;
  5864. /**
  5865. * The input tangent for the cubic hermite spline
  5866. */
  5867. inTangent?: any;
  5868. /**
  5869. * The output tangent for the cubic hermite spline
  5870. */
  5871. outTangent?: any;
  5872. /**
  5873. * The animation interpolation type
  5874. */
  5875. interpolation?: AnimationKeyInterpolation;
  5876. }
  5877. /**
  5878. * Enum for the animation key frame interpolation type
  5879. */
  5880. export enum AnimationKeyInterpolation {
  5881. /**
  5882. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5883. */
  5884. STEP = 1
  5885. }
  5886. }
  5887. declare module "babylonjs/Animations/animationRange" {
  5888. /**
  5889. * Represents the range of an animation
  5890. */
  5891. export class AnimationRange {
  5892. /**The name of the animation range**/
  5893. name: string;
  5894. /**The starting frame of the animation */
  5895. from: number;
  5896. /**The ending frame of the animation*/
  5897. to: number;
  5898. /**
  5899. * Initializes the range of an animation
  5900. * @param name The name of the animation range
  5901. * @param from The starting frame of the animation
  5902. * @param to The ending frame of the animation
  5903. */
  5904. constructor(
  5905. /**The name of the animation range**/
  5906. name: string,
  5907. /**The starting frame of the animation */
  5908. from: number,
  5909. /**The ending frame of the animation*/
  5910. to: number);
  5911. /**
  5912. * Makes a copy of the animation range
  5913. * @returns A copy of the animation range
  5914. */
  5915. clone(): AnimationRange;
  5916. }
  5917. }
  5918. declare module "babylonjs/Animations/animationEvent" {
  5919. /**
  5920. * Composed of a frame, and an action function
  5921. */
  5922. export class AnimationEvent {
  5923. /** The frame for which the event is triggered **/
  5924. frame: number;
  5925. /** The event to perform when triggered **/
  5926. action: (currentFrame: number) => void;
  5927. /** Specifies if the event should be triggered only once**/
  5928. onlyOnce?: boolean | undefined;
  5929. /**
  5930. * Specifies if the animation event is done
  5931. */
  5932. isDone: boolean;
  5933. /**
  5934. * Initializes the animation event
  5935. * @param frame The frame for which the event is triggered
  5936. * @param action The event to perform when triggered
  5937. * @param onlyOnce Specifies if the event should be triggered only once
  5938. */
  5939. constructor(
  5940. /** The frame for which the event is triggered **/
  5941. frame: number,
  5942. /** The event to perform when triggered **/
  5943. action: (currentFrame: number) => void,
  5944. /** Specifies if the event should be triggered only once**/
  5945. onlyOnce?: boolean | undefined);
  5946. /** @hidden */
  5947. _clone(): AnimationEvent;
  5948. }
  5949. }
  5950. declare module "babylonjs/Behaviors/behavior" {
  5951. import { Nullable } from "babylonjs/types";
  5952. /**
  5953. * Interface used to define a behavior
  5954. */
  5955. export interface Behavior<T> {
  5956. /** gets or sets behavior's name */
  5957. name: string;
  5958. /**
  5959. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5960. */
  5961. init(): void;
  5962. /**
  5963. * Called when the behavior is attached to a target
  5964. * @param target defines the target where the behavior is attached to
  5965. */
  5966. attach(target: T): void;
  5967. /**
  5968. * Called when the behavior is detached from its target
  5969. */
  5970. detach(): void;
  5971. }
  5972. /**
  5973. * Interface implemented by classes supporting behaviors
  5974. */
  5975. export interface IBehaviorAware<T> {
  5976. /**
  5977. * Attach a behavior
  5978. * @param behavior defines the behavior to attach
  5979. * @returns the current host
  5980. */
  5981. addBehavior(behavior: Behavior<T>): T;
  5982. /**
  5983. * Remove a behavior from the current object
  5984. * @param behavior defines the behavior to detach
  5985. * @returns the current host
  5986. */
  5987. removeBehavior(behavior: Behavior<T>): T;
  5988. /**
  5989. * Gets a behavior using its name to search
  5990. * @param name defines the name to search
  5991. * @returns the behavior or null if not found
  5992. */
  5993. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5994. }
  5995. }
  5996. declare module "babylonjs/Misc/smartArray" {
  5997. /**
  5998. * Defines an array and its length.
  5999. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6000. */
  6001. export interface ISmartArrayLike<T> {
  6002. /**
  6003. * The data of the array.
  6004. */
  6005. data: Array<T>;
  6006. /**
  6007. * The active length of the array.
  6008. */
  6009. length: number;
  6010. }
  6011. /**
  6012. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6013. */
  6014. export class SmartArray<T> implements ISmartArrayLike<T> {
  6015. /**
  6016. * The full set of data from the array.
  6017. */
  6018. data: Array<T>;
  6019. /**
  6020. * The active length of the array.
  6021. */
  6022. length: number;
  6023. protected _id: number;
  6024. /**
  6025. * Instantiates a Smart Array.
  6026. * @param capacity defines the default capacity of the array.
  6027. */
  6028. constructor(capacity: number);
  6029. /**
  6030. * Pushes a value at the end of the active data.
  6031. * @param value defines the object to push in the array.
  6032. */
  6033. push(value: T): void;
  6034. /**
  6035. * Iterates over the active data and apply the lambda to them.
  6036. * @param func defines the action to apply on each value.
  6037. */
  6038. forEach(func: (content: T) => void): void;
  6039. /**
  6040. * Sorts the full sets of data.
  6041. * @param compareFn defines the comparison function to apply.
  6042. */
  6043. sort(compareFn: (a: T, b: T) => number): void;
  6044. /**
  6045. * Resets the active data to an empty array.
  6046. */
  6047. reset(): void;
  6048. /**
  6049. * Releases all the data from the array as well as the array.
  6050. */
  6051. dispose(): void;
  6052. /**
  6053. * Concats the active data with a given array.
  6054. * @param array defines the data to concatenate with.
  6055. */
  6056. concat(array: any): void;
  6057. /**
  6058. * Returns the position of a value in the active data.
  6059. * @param value defines the value to find the index for
  6060. * @returns the index if found in the active data otherwise -1
  6061. */
  6062. indexOf(value: T): number;
  6063. /**
  6064. * Returns whether an element is part of the active data.
  6065. * @param value defines the value to look for
  6066. * @returns true if found in the active data otherwise false
  6067. */
  6068. contains(value: T): boolean;
  6069. private static _GlobalId;
  6070. }
  6071. /**
  6072. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6073. * The data in this array can only be present once
  6074. */
  6075. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6076. private _duplicateId;
  6077. /**
  6078. * Pushes a value at the end of the active data.
  6079. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6080. * @param value defines the object to push in the array.
  6081. */
  6082. push(value: T): void;
  6083. /**
  6084. * Pushes a value at the end of the active data.
  6085. * If the data is already present, it won t be added again
  6086. * @param value defines the object to push in the array.
  6087. * @returns true if added false if it was already present
  6088. */
  6089. pushNoDuplicate(value: T): boolean;
  6090. /**
  6091. * Resets the active data to an empty array.
  6092. */
  6093. reset(): void;
  6094. /**
  6095. * Concats the active data with a given array.
  6096. * This ensures no dupplicate will be present in the result.
  6097. * @param array defines the data to concatenate with.
  6098. */
  6099. concatWithNoDuplicate(array: any): void;
  6100. }
  6101. }
  6102. declare module "babylonjs/Cameras/cameraInputsManager" {
  6103. import { Nullable } from "babylonjs/types";
  6104. import { Camera } from "babylonjs/Cameras/camera";
  6105. /**
  6106. * @ignore
  6107. * This is a list of all the different input types that are available in the application.
  6108. * Fo instance: ArcRotateCameraGamepadInput...
  6109. */
  6110. export var CameraInputTypes: {};
  6111. /**
  6112. * This is the contract to implement in order to create a new input class.
  6113. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6114. */
  6115. export interface ICameraInput<TCamera extends Camera> {
  6116. /**
  6117. * Defines the camera the input is attached to.
  6118. */
  6119. camera: Nullable<TCamera>;
  6120. /**
  6121. * Gets the class name of the current intput.
  6122. * @returns the class name
  6123. */
  6124. getClassName(): string;
  6125. /**
  6126. * Get the friendly name associated with the input class.
  6127. * @returns the input friendly name
  6128. */
  6129. getSimpleName(): string;
  6130. /**
  6131. * Attach the input controls to a specific dom element to get the input from.
  6132. * @param element Defines the element the controls should be listened from
  6133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6134. */
  6135. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6136. /**
  6137. * Detach the current controls from the specified dom element.
  6138. * @param element Defines the element to stop listening the inputs from
  6139. */
  6140. detachControl(element: Nullable<HTMLElement>): void;
  6141. /**
  6142. * Update the current camera state depending on the inputs that have been used this frame.
  6143. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6144. */
  6145. checkInputs?: () => void;
  6146. }
  6147. /**
  6148. * Represents a map of input types to input instance or input index to input instance.
  6149. */
  6150. export interface CameraInputsMap<TCamera extends Camera> {
  6151. /**
  6152. * Accessor to the input by input type.
  6153. */
  6154. [name: string]: ICameraInput<TCamera>;
  6155. /**
  6156. * Accessor to the input by input index.
  6157. */
  6158. [idx: number]: ICameraInput<TCamera>;
  6159. }
  6160. /**
  6161. * This represents the input manager used within a camera.
  6162. * It helps dealing with all the different kind of input attached to a camera.
  6163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6164. */
  6165. export class CameraInputsManager<TCamera extends Camera> {
  6166. /**
  6167. * Defines the list of inputs attahed to the camera.
  6168. */
  6169. attached: CameraInputsMap<TCamera>;
  6170. /**
  6171. * Defines the dom element the camera is collecting inputs from.
  6172. * This is null if the controls have not been attached.
  6173. */
  6174. attachedElement: Nullable<HTMLElement>;
  6175. /**
  6176. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6177. */
  6178. noPreventDefault: boolean;
  6179. /**
  6180. * Defined the camera the input manager belongs to.
  6181. */
  6182. camera: TCamera;
  6183. /**
  6184. * Update the current camera state depending on the inputs that have been used this frame.
  6185. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6186. */
  6187. checkInputs: () => void;
  6188. /**
  6189. * Instantiate a new Camera Input Manager.
  6190. * @param camera Defines the camera the input manager blongs to
  6191. */
  6192. constructor(camera: TCamera);
  6193. /**
  6194. * Add an input method to a camera
  6195. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6196. * @param input camera input method
  6197. */
  6198. add(input: ICameraInput<TCamera>): void;
  6199. /**
  6200. * Remove a specific input method from a camera
  6201. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6202. * @param inputToRemove camera input method
  6203. */
  6204. remove(inputToRemove: ICameraInput<TCamera>): void;
  6205. /**
  6206. * Remove a specific input type from a camera
  6207. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6208. * @param inputType the type of the input to remove
  6209. */
  6210. removeByType(inputType: string): void;
  6211. private _addCheckInputs;
  6212. /**
  6213. * Attach the input controls to the currently attached dom element to listen the events from.
  6214. * @param input Defines the input to attach
  6215. */
  6216. attachInput(input: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6219. * @param element Defines the dom element to collect the events from
  6220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6221. */
  6222. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6223. /**
  6224. * Detach the current manager inputs controls from a specific dom element.
  6225. * @param element Defines the dom element to collect the events from
  6226. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6227. */
  6228. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6229. /**
  6230. * Rebuild the dynamic inputCheck function from the current list of
  6231. * defined inputs in the manager.
  6232. */
  6233. rebuildInputCheck(): void;
  6234. /**
  6235. * Remove all attached input methods from a camera
  6236. */
  6237. clear(): void;
  6238. /**
  6239. * Serialize the current input manager attached to a camera.
  6240. * This ensures than once parsed,
  6241. * the input associated to the camera will be identical to the current ones
  6242. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6243. */
  6244. serialize(serializedCamera: any): void;
  6245. /**
  6246. * Parses an input manager serialized JSON to restore the previous list of inputs
  6247. * and states associated to a camera.
  6248. * @param parsedCamera Defines the JSON to parse
  6249. */
  6250. parse(parsedCamera: any): void;
  6251. }
  6252. }
  6253. declare module "babylonjs/Meshes/buffer" {
  6254. import { Nullable, DataArray } from "babylonjs/types";
  6255. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6256. /**
  6257. * Class used to store data that will be store in GPU memory
  6258. */
  6259. export class Buffer {
  6260. private _engine;
  6261. private _buffer;
  6262. /** @hidden */
  6263. _data: Nullable<DataArray>;
  6264. private _updatable;
  6265. private _instanced;
  6266. private _divisor;
  6267. /**
  6268. * Gets the byte stride.
  6269. */
  6270. readonly byteStride: number;
  6271. /**
  6272. * Constructor
  6273. * @param engine the engine
  6274. * @param data the data to use for this buffer
  6275. * @param updatable whether the data is updatable
  6276. * @param stride the stride (optional)
  6277. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6278. * @param instanced whether the buffer is instanced (optional)
  6279. * @param useBytes set to true if the stride in in bytes (optional)
  6280. * @param divisor sets an optional divisor for instances (1 by default)
  6281. */
  6282. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6283. /**
  6284. * Create a new VertexBuffer based on the current buffer
  6285. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6286. * @param offset defines offset in the buffer (0 by default)
  6287. * @param size defines the size in floats of attributes (position is 3 for instance)
  6288. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6289. * @param instanced defines if the vertex buffer contains indexed data
  6290. * @param useBytes defines if the offset and stride are in bytes *
  6291. * @param divisor sets an optional divisor for instances (1 by default)
  6292. * @returns the new vertex buffer
  6293. */
  6294. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6295. /**
  6296. * Gets a boolean indicating if the Buffer is updatable?
  6297. * @returns true if the buffer is updatable
  6298. */
  6299. isUpdatable(): boolean;
  6300. /**
  6301. * Gets current buffer's data
  6302. * @returns a DataArray or null
  6303. */
  6304. getData(): Nullable<DataArray>;
  6305. /**
  6306. * Gets underlying native buffer
  6307. * @returns underlying native buffer
  6308. */
  6309. getBuffer(): Nullable<DataBuffer>;
  6310. /**
  6311. * Gets the stride in float32 units (i.e. byte stride / 4).
  6312. * May not be an integer if the byte stride is not divisible by 4.
  6313. * DEPRECATED. Use byteStride instead.
  6314. * @returns the stride in float32 units
  6315. */
  6316. getStrideSize(): number;
  6317. /**
  6318. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6319. * @param data defines the data to store
  6320. */
  6321. create(data?: Nullable<DataArray>): void;
  6322. /** @hidden */
  6323. _rebuild(): void;
  6324. /**
  6325. * Update current buffer data
  6326. * @param data defines the data to store
  6327. */
  6328. update(data: DataArray): void;
  6329. /**
  6330. * Updates the data directly.
  6331. * @param data the new data
  6332. * @param offset the new offset
  6333. * @param vertexCount the vertex count (optional)
  6334. * @param useBytes set to true if the offset is in bytes
  6335. */
  6336. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6337. /**
  6338. * Release all resources
  6339. */
  6340. dispose(): void;
  6341. }
  6342. /**
  6343. * Specialized buffer used to store vertex data
  6344. */
  6345. export class VertexBuffer {
  6346. /** @hidden */
  6347. _buffer: Buffer;
  6348. private _kind;
  6349. private _size;
  6350. private _ownsBuffer;
  6351. private _instanced;
  6352. private _instanceDivisor;
  6353. /**
  6354. * The byte type.
  6355. */
  6356. static readonly BYTE: number;
  6357. /**
  6358. * The unsigned byte type.
  6359. */
  6360. static readonly UNSIGNED_BYTE: number;
  6361. /**
  6362. * The short type.
  6363. */
  6364. static readonly SHORT: number;
  6365. /**
  6366. * The unsigned short type.
  6367. */
  6368. static readonly UNSIGNED_SHORT: number;
  6369. /**
  6370. * The integer type.
  6371. */
  6372. static readonly INT: number;
  6373. /**
  6374. * The unsigned integer type.
  6375. */
  6376. static readonly UNSIGNED_INT: number;
  6377. /**
  6378. * The float type.
  6379. */
  6380. static readonly FLOAT: number;
  6381. /**
  6382. * Gets or sets the instance divisor when in instanced mode
  6383. */
  6384. instanceDivisor: number;
  6385. /**
  6386. * Gets the byte stride.
  6387. */
  6388. readonly byteStride: number;
  6389. /**
  6390. * Gets the byte offset.
  6391. */
  6392. readonly byteOffset: number;
  6393. /**
  6394. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6395. */
  6396. readonly normalized: boolean;
  6397. /**
  6398. * Gets the data type of each component in the array.
  6399. */
  6400. readonly type: number;
  6401. /**
  6402. * Constructor
  6403. * @param engine the engine
  6404. * @param data the data to use for this vertex buffer
  6405. * @param kind the vertex buffer kind
  6406. * @param updatable whether the data is updatable
  6407. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6408. * @param stride the stride (optional)
  6409. * @param instanced whether the buffer is instanced (optional)
  6410. * @param offset the offset of the data (optional)
  6411. * @param size the number of components (optional)
  6412. * @param type the type of the component (optional)
  6413. * @param normalized whether the data contains normalized data (optional)
  6414. * @param useBytes set to true if stride and offset are in bytes (optional)
  6415. * @param divisor defines the instance divisor to use (1 by default)
  6416. */
  6417. 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);
  6418. /** @hidden */
  6419. _rebuild(): void;
  6420. /**
  6421. * Returns the kind of the VertexBuffer (string)
  6422. * @returns a string
  6423. */
  6424. getKind(): string;
  6425. /**
  6426. * Gets a boolean indicating if the VertexBuffer is updatable?
  6427. * @returns true if the buffer is updatable
  6428. */
  6429. isUpdatable(): boolean;
  6430. /**
  6431. * Gets current buffer's data
  6432. * @returns a DataArray or null
  6433. */
  6434. getData(): Nullable<DataArray>;
  6435. /**
  6436. * Gets underlying native buffer
  6437. * @returns underlying native buffer
  6438. */
  6439. getBuffer(): Nullable<DataBuffer>;
  6440. /**
  6441. * Gets the stride in float32 units (i.e. byte stride / 4).
  6442. * May not be an integer if the byte stride is not divisible by 4.
  6443. * DEPRECATED. Use byteStride instead.
  6444. * @returns the stride in float32 units
  6445. */
  6446. getStrideSize(): number;
  6447. /**
  6448. * Returns the offset as a multiple of the type byte length.
  6449. * DEPRECATED. Use byteOffset instead.
  6450. * @returns the offset in bytes
  6451. */
  6452. getOffset(): number;
  6453. /**
  6454. * Returns the number of components per vertex attribute (integer)
  6455. * @returns the size in float
  6456. */
  6457. getSize(): number;
  6458. /**
  6459. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6460. * @returns true if this buffer is instanced
  6461. */
  6462. getIsInstanced(): boolean;
  6463. /**
  6464. * Returns the instancing divisor, zero for non-instanced (integer).
  6465. * @returns a number
  6466. */
  6467. getInstanceDivisor(): number;
  6468. /**
  6469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6470. * @param data defines the data to store
  6471. */
  6472. create(data?: DataArray): void;
  6473. /**
  6474. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6475. * This function will create a new buffer if the current one is not updatable
  6476. * @param data defines the data to store
  6477. */
  6478. update(data: DataArray): void;
  6479. /**
  6480. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6481. * Returns the directly updated WebGLBuffer.
  6482. * @param data the new data
  6483. * @param offset the new offset
  6484. * @param useBytes set to true if the offset is in bytes
  6485. */
  6486. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6487. /**
  6488. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6489. */
  6490. dispose(): void;
  6491. /**
  6492. * Enumerates each value of this vertex buffer as numbers.
  6493. * @param count the number of values to enumerate
  6494. * @param callback the callback function called for each value
  6495. */
  6496. forEach(count: number, callback: (value: number, index: number) => void): void;
  6497. /**
  6498. * Positions
  6499. */
  6500. static readonly PositionKind: string;
  6501. /**
  6502. * Normals
  6503. */
  6504. static readonly NormalKind: string;
  6505. /**
  6506. * Tangents
  6507. */
  6508. static readonly TangentKind: string;
  6509. /**
  6510. * Texture coordinates
  6511. */
  6512. static readonly UVKind: string;
  6513. /**
  6514. * Texture coordinates 2
  6515. */
  6516. static readonly UV2Kind: string;
  6517. /**
  6518. * Texture coordinates 3
  6519. */
  6520. static readonly UV3Kind: string;
  6521. /**
  6522. * Texture coordinates 4
  6523. */
  6524. static readonly UV4Kind: string;
  6525. /**
  6526. * Texture coordinates 5
  6527. */
  6528. static readonly UV5Kind: string;
  6529. /**
  6530. * Texture coordinates 6
  6531. */
  6532. static readonly UV6Kind: string;
  6533. /**
  6534. * Colors
  6535. */
  6536. static readonly ColorKind: string;
  6537. /**
  6538. * Matrix indices (for bones)
  6539. */
  6540. static readonly MatricesIndicesKind: string;
  6541. /**
  6542. * Matrix weights (for bones)
  6543. */
  6544. static readonly MatricesWeightsKind: string;
  6545. /**
  6546. * Additional matrix indices (for bones)
  6547. */
  6548. static readonly MatricesIndicesExtraKind: string;
  6549. /**
  6550. * Additional matrix weights (for bones)
  6551. */
  6552. static readonly MatricesWeightsExtraKind: string;
  6553. /**
  6554. * Deduces the stride given a kind.
  6555. * @param kind The kind string to deduce
  6556. * @returns The deduced stride
  6557. */
  6558. static DeduceStride(kind: string): number;
  6559. /**
  6560. * Gets the byte length of the given type.
  6561. * @param type the type
  6562. * @returns the number of bytes
  6563. */
  6564. static GetTypeByteLength(type: number): number;
  6565. /**
  6566. * Enumerates each value of the given parameters as numbers.
  6567. * @param data the data to enumerate
  6568. * @param byteOffset the byte offset of the data
  6569. * @param byteStride the byte stride of the data
  6570. * @param componentCount the number of components per element
  6571. * @param componentType the type of the component
  6572. * @param count the number of values to enumerate
  6573. * @param normalized whether the data is normalized
  6574. * @param callback the callback function called for each value
  6575. */
  6576. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6577. private static _GetFloatValue;
  6578. }
  6579. }
  6580. declare module "babylonjs/Collisions/intersectionInfo" {
  6581. import { Nullable } from "babylonjs/types";
  6582. /**
  6583. * @hidden
  6584. */
  6585. export class IntersectionInfo {
  6586. bu: Nullable<number>;
  6587. bv: Nullable<number>;
  6588. distance: number;
  6589. faceId: number;
  6590. subMeshId: number;
  6591. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6592. }
  6593. }
  6594. declare module "babylonjs/Maths/math.plane" {
  6595. import { DeepImmutable } from "babylonjs/types";
  6596. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6597. /**
  6598. * Represens a plane by the equation ax + by + cz + d = 0
  6599. */
  6600. export class Plane {
  6601. private static _TmpMatrix;
  6602. /**
  6603. * Normal of the plane (a,b,c)
  6604. */
  6605. normal: Vector3;
  6606. /**
  6607. * d component of the plane
  6608. */
  6609. d: number;
  6610. /**
  6611. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6612. * @param a a component of the plane
  6613. * @param b b component of the plane
  6614. * @param c c component of the plane
  6615. * @param d d component of the plane
  6616. */
  6617. constructor(a: number, b: number, c: number, d: number);
  6618. /**
  6619. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6620. */
  6621. asArray(): number[];
  6622. /**
  6623. * @returns a new plane copied from the current Plane.
  6624. */
  6625. clone(): Plane;
  6626. /**
  6627. * @returns the string "Plane".
  6628. */
  6629. getClassName(): string;
  6630. /**
  6631. * @returns the Plane hash code.
  6632. */
  6633. getHashCode(): number;
  6634. /**
  6635. * Normalize the current Plane in place.
  6636. * @returns the updated Plane.
  6637. */
  6638. normalize(): Plane;
  6639. /**
  6640. * Applies a transformation the plane and returns the result
  6641. * @param transformation the transformation matrix to be applied to the plane
  6642. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6643. */
  6644. transform(transformation: DeepImmutable<Matrix>): Plane;
  6645. /**
  6646. * Calcualtte the dot product between the point and the plane normal
  6647. * @param point point to calculate the dot product with
  6648. * @returns the dot product (float) of the point coordinates and the plane normal.
  6649. */
  6650. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6651. /**
  6652. * Updates the current Plane from the plane defined by the three given points.
  6653. * @param point1 one of the points used to contruct the plane
  6654. * @param point2 one of the points used to contruct the plane
  6655. * @param point3 one of the points used to contruct the plane
  6656. * @returns the updated Plane.
  6657. */
  6658. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6659. /**
  6660. * Checks if the plane is facing a given direction
  6661. * @param direction the direction to check if the plane is facing
  6662. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6663. * @returns True is the vector "direction" is the same side than the plane normal.
  6664. */
  6665. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6666. /**
  6667. * Calculates the distance to a point
  6668. * @param point point to calculate distance to
  6669. * @returns the signed distance (float) from the given point to the Plane.
  6670. */
  6671. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6672. /**
  6673. * Creates a plane from an array
  6674. * @param array the array to create a plane from
  6675. * @returns a new Plane from the given array.
  6676. */
  6677. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6678. /**
  6679. * Creates a plane from three points
  6680. * @param point1 point used to create the plane
  6681. * @param point2 point used to create the plane
  6682. * @param point3 point used to create the plane
  6683. * @returns a new Plane defined by the three given points.
  6684. */
  6685. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6686. /**
  6687. * Creates a plane from an origin point and a normal
  6688. * @param origin origin of the plane to be constructed
  6689. * @param normal normal of the plane to be constructed
  6690. * @returns a new Plane the normal vector to this plane at the given origin point.
  6691. * Note : the vector "normal" is updated because normalized.
  6692. */
  6693. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Calculates the distance from a plane and a point
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @param point point to calculate distance to
  6699. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6700. */
  6701. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6702. }
  6703. }
  6704. declare module "babylonjs/Culling/boundingSphere" {
  6705. import { DeepImmutable } from "babylonjs/types";
  6706. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6707. import { Plane } from "babylonjs/Maths/math.plane";
  6708. /**
  6709. * Class used to store bounding sphere information
  6710. */
  6711. export class BoundingSphere {
  6712. /**
  6713. * Gets the center of the bounding sphere in local space
  6714. */
  6715. readonly center: Vector3;
  6716. /**
  6717. * Radius of the bounding sphere in local space
  6718. */
  6719. radius: number;
  6720. /**
  6721. * Gets the center of the bounding sphere in world space
  6722. */
  6723. readonly centerWorld: Vector3;
  6724. /**
  6725. * Radius of the bounding sphere in world space
  6726. */
  6727. radiusWorld: number;
  6728. /**
  6729. * Gets the minimum vector in local space
  6730. */
  6731. readonly minimum: Vector3;
  6732. /**
  6733. * Gets the maximum vector in local space
  6734. */
  6735. readonly maximum: Vector3;
  6736. private _worldMatrix;
  6737. private static readonly TmpVector3;
  6738. /**
  6739. * Creates a new bounding sphere
  6740. * @param min defines the minimum vector (in local space)
  6741. * @param max defines the maximum vector (in local space)
  6742. * @param worldMatrix defines the new world matrix
  6743. */
  6744. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6745. /**
  6746. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6747. * @param min defines the new minimum vector (in local space)
  6748. * @param max defines the new maximum vector (in local space)
  6749. * @param worldMatrix defines the new world matrix
  6750. */
  6751. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6752. /**
  6753. * Scale the current bounding sphere by applying a scale factor
  6754. * @param factor defines the scale factor to apply
  6755. * @returns the current bounding box
  6756. */
  6757. scale(factor: number): BoundingSphere;
  6758. /**
  6759. * Gets the world matrix of the bounding box
  6760. * @returns a matrix
  6761. */
  6762. getWorldMatrix(): DeepImmutable<Matrix>;
  6763. /** @hidden */
  6764. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6765. /**
  6766. * Tests if the bounding sphere is intersecting the frustum planes
  6767. * @param frustumPlanes defines the frustum planes to test
  6768. * @returns true if there is an intersection
  6769. */
  6770. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6771. /**
  6772. * Tests if the bounding sphere center is in between the frustum planes.
  6773. * Used for optimistic fast inclusion.
  6774. * @param frustumPlanes defines the frustum planes to test
  6775. * @returns true if the sphere center is in between the frustum planes
  6776. */
  6777. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6778. /**
  6779. * Tests if a point is inside the bounding sphere
  6780. * @param point defines the point to test
  6781. * @returns true if the point is inside the bounding sphere
  6782. */
  6783. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6784. /**
  6785. * Checks if two sphere intersct
  6786. * @param sphere0 sphere 0
  6787. * @param sphere1 sphere 1
  6788. * @returns true if the speres intersect
  6789. */
  6790. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6791. }
  6792. }
  6793. declare module "babylonjs/Culling/boundingBox" {
  6794. import { DeepImmutable } from "babylonjs/types";
  6795. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6796. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6797. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6798. import { Plane } from "babylonjs/Maths/math.plane";
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module "babylonjs/Collisions/collider" {
  6944. import { Nullable, IndicesArray } from "babylonjs/types";
  6945. import { Vector3 } from "babylonjs/Maths/math.vector";
  6946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6947. import { Plane } from "babylonjs/Maths/math.plane";
  6948. /** @hidden */
  6949. export class Collider {
  6950. /** Define if a collision was found */
  6951. collisionFound: boolean;
  6952. /**
  6953. * Define last intersection point in local space
  6954. */
  6955. intersectionPoint: Vector3;
  6956. /**
  6957. * Define last collided mesh
  6958. */
  6959. collidedMesh: Nullable<AbstractMesh>;
  6960. private _collisionPoint;
  6961. private _planeIntersectionPoint;
  6962. private _tempVector;
  6963. private _tempVector2;
  6964. private _tempVector3;
  6965. private _tempVector4;
  6966. private _edge;
  6967. private _baseToVertex;
  6968. private _destinationPoint;
  6969. private _slidePlaneNormal;
  6970. private _displacementVector;
  6971. /** @hidden */
  6972. _radius: Vector3;
  6973. /** @hidden */
  6974. _retry: number;
  6975. private _velocity;
  6976. private _basePoint;
  6977. private _epsilon;
  6978. /** @hidden */
  6979. _velocityWorldLength: number;
  6980. /** @hidden */
  6981. _basePointWorld: Vector3;
  6982. private _velocityWorld;
  6983. private _normalizedVelocity;
  6984. /** @hidden */
  6985. _initialVelocity: Vector3;
  6986. /** @hidden */
  6987. _initialPosition: Vector3;
  6988. private _nearestDistance;
  6989. private _collisionMask;
  6990. collisionMask: number;
  6991. /**
  6992. * Gets the plane normal used to compute the sliding response (in local space)
  6993. */
  6994. readonly slidePlaneNormal: Vector3;
  6995. /** @hidden */
  6996. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6997. /** @hidden */
  6998. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6999. /** @hidden */
  7000. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7001. /** @hidden */
  7002. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7003. /** @hidden */
  7004. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7005. /** @hidden */
  7006. _getResponse(pos: Vector3, vel: Vector3): void;
  7007. }
  7008. }
  7009. declare module "babylonjs/Culling/boundingInfo" {
  7010. import { DeepImmutable } from "babylonjs/types";
  7011. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7012. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7013. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7014. import { Plane } from "babylonjs/Maths/math.plane";
  7015. import { Collider } from "babylonjs/Collisions/collider";
  7016. /**
  7017. * Interface for cullable objects
  7018. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7019. */
  7020. export interface ICullable {
  7021. /**
  7022. * Checks if the object or part of the object is in the frustum
  7023. * @param frustumPlanes Camera near/planes
  7024. * @returns true if the object is in frustum otherwise false
  7025. */
  7026. isInFrustum(frustumPlanes: Plane[]): boolean;
  7027. /**
  7028. * Checks if a cullable object (mesh...) is in the camera frustum
  7029. * Unlike isInFrustum this cheks the full bounding box
  7030. * @param frustumPlanes Camera near/planes
  7031. * @returns true if the object is in frustum otherwise false
  7032. */
  7033. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7034. }
  7035. /**
  7036. * Info for a bounding data of a mesh
  7037. */
  7038. export class BoundingInfo implements ICullable {
  7039. /**
  7040. * Bounding box for the mesh
  7041. */
  7042. readonly boundingBox: BoundingBox;
  7043. /**
  7044. * Bounding sphere for the mesh
  7045. */
  7046. readonly boundingSphere: BoundingSphere;
  7047. private _isLocked;
  7048. private static readonly TmpVector3;
  7049. /**
  7050. * Constructs bounding info
  7051. * @param minimum min vector of the bounding box/sphere
  7052. * @param maximum max vector of the bounding box/sphere
  7053. * @param worldMatrix defines the new world matrix
  7054. */
  7055. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7056. /**
  7057. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7058. * @param min defines the new minimum vector (in local space)
  7059. * @param max defines the new maximum vector (in local space)
  7060. * @param worldMatrix defines the new world matrix
  7061. */
  7062. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7063. /**
  7064. * min vector of the bounding box/sphere
  7065. */
  7066. readonly minimum: Vector3;
  7067. /**
  7068. * max vector of the bounding box/sphere
  7069. */
  7070. readonly maximum: Vector3;
  7071. /**
  7072. * If the info is locked and won't be updated to avoid perf overhead
  7073. */
  7074. isLocked: boolean;
  7075. /**
  7076. * Updates the bounding sphere and box
  7077. * @param world world matrix to be used to update
  7078. */
  7079. update(world: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7082. * @param center New center of the bounding info
  7083. * @param extend New extend of the bounding info
  7084. * @returns the current bounding info
  7085. */
  7086. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7087. /**
  7088. * Scale the current bounding info by applying a scale factor
  7089. * @param factor defines the scale factor to apply
  7090. * @returns the current bounding info
  7091. */
  7092. scale(factor: number): BoundingInfo;
  7093. /**
  7094. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7095. * @param frustumPlanes defines the frustum to test
  7096. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7097. * @returns true if the bounding info is in the frustum planes
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7100. /**
  7101. * Gets the world distance between the min and max points of the bounding box
  7102. */
  7103. readonly diagonalLength: number;
  7104. /**
  7105. * Checks if a cullable object (mesh...) is in the camera frustum
  7106. * Unlike isInFrustum this cheks the full bounding box
  7107. * @param frustumPlanes Camera near/planes
  7108. * @returns true if the object is in frustum otherwise false
  7109. */
  7110. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7111. /** @hidden */
  7112. _checkCollision(collider: Collider): boolean;
  7113. /**
  7114. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7115. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7116. * @param point the point to check intersection with
  7117. * @returns if the point intersects
  7118. */
  7119. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7120. /**
  7121. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7122. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7123. * @param boundingInfo the bounding info to check intersection with
  7124. * @param precise if the intersection should be done using OBB
  7125. * @returns if the bounding info intersects
  7126. */
  7127. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7128. }
  7129. }
  7130. declare module "babylonjs/Maths/math.functions" {
  7131. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7132. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7161. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7162. /** @hidden */
  7163. export class WebGLDataBuffer extends DataBuffer {
  7164. private _buffer;
  7165. constructor(resource: WebGLBuffer);
  7166. readonly underlyingResource: any;
  7167. }
  7168. }
  7169. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7170. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7171. import { Nullable } from "babylonjs/types";
  7172. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7173. /** @hidden */
  7174. export class WebGLPipelineContext implements IPipelineContext {
  7175. engine: ThinEngine;
  7176. program: Nullable<WebGLProgram>;
  7177. context?: WebGLRenderingContext;
  7178. vertexShader?: WebGLShader;
  7179. fragmentShader?: WebGLShader;
  7180. isParallelCompiled: boolean;
  7181. onCompiled?: () => void;
  7182. transformFeedback?: WebGLTransformFeedback | null;
  7183. readonly isAsync: boolean;
  7184. readonly isReady: boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. }
  7187. }
  7188. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7189. import { FloatArray, Nullable } from "babylonjs/types";
  7190. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7191. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7192. module "babylonjs/Engines/thinEngine" {
  7193. interface ThinEngine {
  7194. /**
  7195. * Create an uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param elements defines the content of the uniform buffer
  7198. * @returns the webGL uniform buffer
  7199. */
  7200. createUniformBuffer(elements: FloatArray): DataBuffer;
  7201. /**
  7202. * Create a dynamic uniform buffer
  7203. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7204. * @param elements defines the content of the uniform buffer
  7205. * @returns the webGL uniform buffer
  7206. */
  7207. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7208. /**
  7209. * Update an existing uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param uniformBuffer defines the target uniform buffer
  7212. * @param elements defines the content to update
  7213. * @param offset defines the offset in the uniform buffer where update should start
  7214. * @param count defines the size of the data to update
  7215. */
  7216. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7217. /**
  7218. * Bind an uniform buffer to the current webGL context
  7219. * @param buffer defines the buffer to bind
  7220. */
  7221. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7222. /**
  7223. * Bind a buffer to the current webGL context at a given location
  7224. * @param buffer defines the buffer to bind
  7225. * @param location defines the index where to bind the buffer
  7226. */
  7227. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7228. /**
  7229. * Bind a specific block at a given index in a specific shader program
  7230. * @param pipelineContext defines the pipeline context to use
  7231. * @param blockName defines the block name
  7232. * @param index defines the index where to bind the block
  7233. */
  7234. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7235. }
  7236. }
  7237. }
  7238. declare module "babylonjs/Materials/uniformBuffer" {
  7239. import { Nullable, FloatArray } from "babylonjs/types";
  7240. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7241. import { Engine } from "babylonjs/Engines/engine";
  7242. import { Effect } from "babylonjs/Materials/effect";
  7243. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7244. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7245. import { Color3 } from "babylonjs/Maths/math.color";
  7246. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7247. /**
  7248. * Uniform buffer objects.
  7249. *
  7250. * Handles blocks of uniform on the GPU.
  7251. *
  7252. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7253. *
  7254. * For more information, please refer to :
  7255. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7256. */
  7257. export class UniformBuffer {
  7258. private _engine;
  7259. private _buffer;
  7260. private _data;
  7261. private _bufferData;
  7262. private _dynamic?;
  7263. private _uniformLocations;
  7264. private _uniformSizes;
  7265. private _uniformLocationPointer;
  7266. private _needSync;
  7267. private _noUBO;
  7268. private _currentEffect;
  7269. /** @hidden */
  7270. _alreadyBound: boolean;
  7271. private static _MAX_UNIFORM_SIZE;
  7272. private static _tempBuffer;
  7273. /**
  7274. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7275. * This is dynamic to allow compat with webgl 1 and 2.
  7276. * You will need to pass the name of the uniform as well as the value.
  7277. */
  7278. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7279. /**
  7280. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7281. * This is dynamic to allow compat with webgl 1 and 2.
  7282. * You will need to pass the name of the uniform as well as the value.
  7283. */
  7284. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7285. /**
  7286. * Lambda to Update a single float in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateFloat: (name: string, x: number) => void;
  7291. /**
  7292. * Lambda to Update a vec2 of float in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7297. /**
  7298. * Lambda to Update a vec3 of float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7303. /**
  7304. * Lambda to Update a vec4 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateMatrix: (name: string, mat: Matrix) => void;
  7315. /**
  7316. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateVector3: (name: string, vector: Vector3) => void;
  7321. /**
  7322. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateVector4: (name: string, vector: Vector4) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7339. /**
  7340. * Instantiates a new Uniform buffer objects.
  7341. *
  7342. * Handles blocks of uniform on the GPU.
  7343. *
  7344. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7345. *
  7346. * For more information, please refer to :
  7347. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7348. * @param engine Define the engine the buffer is associated with
  7349. * @param data Define the data contained in the buffer
  7350. * @param dynamic Define if the buffer is updatable
  7351. */
  7352. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7353. /**
  7354. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7355. * or just falling back on setUniformXXX calls.
  7356. */
  7357. readonly useUbo: boolean;
  7358. /**
  7359. * Indicates if the WebGL underlying uniform buffer is in sync
  7360. * with the javascript cache data.
  7361. */
  7362. readonly isSync: boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7365. * Also, a dynamic UniformBuffer will disable cache verification and always
  7366. * update the underlying WebGL uniform buffer to the GPU.
  7367. * @returns if Dynamic, otherwise false
  7368. */
  7369. isDynamic(): boolean;
  7370. /**
  7371. * The data cache on JS side.
  7372. * @returns the underlying data as a float array
  7373. */
  7374. getData(): Float32Array;
  7375. /**
  7376. * The underlying WebGL Uniform buffer.
  7377. * @returns the webgl buffer
  7378. */
  7379. getBuffer(): Nullable<DataBuffer>;
  7380. /**
  7381. * std140 layout specifies how to align data within an UBO structure.
  7382. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7383. * for specs.
  7384. */
  7385. private _fillAlignment;
  7386. /**
  7387. * Adds an uniform in the buffer.
  7388. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7389. * for the layout to be correct !
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param size Data size, or data directly.
  7392. */
  7393. addUniform(name: string, size: number | number[]): void;
  7394. /**
  7395. * Adds a Matrix 4x4 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param mat A 4x4 matrix.
  7398. */
  7399. addMatrix(name: string, mat: Matrix): void;
  7400. /**
  7401. * Adds a vec2 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param x Define the x component value of the vec2
  7404. * @param y Define the y component value of the vec2
  7405. */
  7406. addFloat2(name: string, x: number, y: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param x Define the x component value of the vec3
  7411. * @param y Define the y component value of the vec3
  7412. * @param z Define the z component value of the vec3
  7413. */
  7414. addFloat3(name: string, x: number, y: number, z: number): void;
  7415. /**
  7416. * Adds a vec3 to the uniform buffer.
  7417. * @param name Name of the uniform, as used in the uniform block in the shader.
  7418. * @param color Define the vec3 from a Color
  7419. */
  7420. addColor3(name: string, color: Color3): void;
  7421. /**
  7422. * Adds a vec4 to the uniform buffer.
  7423. * @param name Name of the uniform, as used in the uniform block in the shader.
  7424. * @param color Define the rgb components from a Color
  7425. * @param alpha Define the a component of the vec4
  7426. */
  7427. addColor4(name: string, color: Color3, alpha: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param vector Define the vec3 components from a Vector
  7432. */
  7433. addVector3(name: string, vector: Vector3): void;
  7434. /**
  7435. * Adds a Matrix 3x3 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. */
  7438. addMatrix3x3(name: string): void;
  7439. /**
  7440. * Adds a Matrix 2x2 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix2x2(name: string): void;
  7444. /**
  7445. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7446. */
  7447. create(): void;
  7448. /** @hidden */
  7449. _rebuild(): void;
  7450. /**
  7451. * Updates the WebGL Uniform Buffer on the GPU.
  7452. * If the `dynamic` flag is set to true, no cache comparison is done.
  7453. * Otherwise, the buffer will be updated only if the cache differs.
  7454. */
  7455. update(): void;
  7456. /**
  7457. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7458. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7459. * @param data Define the flattened data
  7460. * @param size Define the size of the data.
  7461. */
  7462. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7463. private _valueCache;
  7464. private _cacheMatrix;
  7465. private _updateMatrix3x3ForUniform;
  7466. private _updateMatrix3x3ForEffect;
  7467. private _updateMatrix2x2ForEffect;
  7468. private _updateMatrix2x2ForUniform;
  7469. private _updateFloatForEffect;
  7470. private _updateFloatForUniform;
  7471. private _updateFloat2ForEffect;
  7472. private _updateFloat2ForUniform;
  7473. private _updateFloat3ForEffect;
  7474. private _updateFloat3ForUniform;
  7475. private _updateFloat4ForEffect;
  7476. private _updateFloat4ForUniform;
  7477. private _updateMatrixForEffect;
  7478. private _updateMatrixForUniform;
  7479. private _updateVector3ForEffect;
  7480. private _updateVector3ForUniform;
  7481. private _updateVector4ForEffect;
  7482. private _updateVector4ForUniform;
  7483. private _updateColor3ForEffect;
  7484. private _updateColor3ForUniform;
  7485. private _updateColor4ForEffect;
  7486. private _updateColor4ForUniform;
  7487. /**
  7488. * Sets a sampler uniform on the effect.
  7489. * @param name Define the name of the sampler.
  7490. * @param texture Define the texture to set in the sampler
  7491. */
  7492. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7493. /**
  7494. * Directly updates the value of the uniform in the cache AND on the GPU.
  7495. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7496. * @param data Define the flattened data
  7497. */
  7498. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7499. /**
  7500. * Binds this uniform buffer to an effect.
  7501. * @param effect Define the effect to bind the buffer to
  7502. * @param name Name of the uniform block in the shader.
  7503. */
  7504. bindToEffect(effect: Effect, name: string): void;
  7505. /**
  7506. * Disposes the uniform buffer.
  7507. */
  7508. dispose(): void;
  7509. }
  7510. }
  7511. declare module "babylonjs/Misc/iInspectable" {
  7512. /**
  7513. * Enum that determines the text-wrapping mode to use.
  7514. */
  7515. export enum InspectableType {
  7516. /**
  7517. * Checkbox for booleans
  7518. */
  7519. Checkbox = 0,
  7520. /**
  7521. * Sliders for numbers
  7522. */
  7523. Slider = 1,
  7524. /**
  7525. * Vector3
  7526. */
  7527. Vector3 = 2,
  7528. /**
  7529. * Quaternions
  7530. */
  7531. Quaternion = 3,
  7532. /**
  7533. * Color3
  7534. */
  7535. Color3 = 4,
  7536. /**
  7537. * String
  7538. */
  7539. String = 5
  7540. }
  7541. /**
  7542. * Interface used to define custom inspectable properties.
  7543. * This interface is used by the inspector to display custom property grids
  7544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7545. */
  7546. export interface IInspectable {
  7547. /**
  7548. * Gets the label to display
  7549. */
  7550. label: string;
  7551. /**
  7552. * Gets the name of the property to edit
  7553. */
  7554. propertyName: string;
  7555. /**
  7556. * Gets the type of the editor to use
  7557. */
  7558. type: InspectableType;
  7559. /**
  7560. * Gets the minimum value of the property when using in "slider" mode
  7561. */
  7562. min?: number;
  7563. /**
  7564. * Gets the maximum value of the property when using in "slider" mode
  7565. */
  7566. max?: number;
  7567. /**
  7568. * Gets the setp to use when using in "slider" mode
  7569. */
  7570. step?: number;
  7571. }
  7572. }
  7573. declare module "babylonjs/Misc/timingTools" {
  7574. /**
  7575. * Class used to provide helper for timing
  7576. */
  7577. export class TimingTools {
  7578. /**
  7579. * Polyfill for setImmediate
  7580. * @param action defines the action to execute after the current execution block
  7581. */
  7582. static SetImmediate(action: () => void): void;
  7583. }
  7584. }
  7585. declare module "babylonjs/Misc/instantiationTools" {
  7586. /**
  7587. * Class used to enable instatition of objects by class name
  7588. */
  7589. export class InstantiationTools {
  7590. /**
  7591. * Use this object to register external classes like custom textures or material
  7592. * to allow the laoders to instantiate them
  7593. */
  7594. static RegisteredExternalClasses: {
  7595. [key: string]: Object;
  7596. };
  7597. /**
  7598. * Tries to instantiate a new object from a given class name
  7599. * @param className defines the class name to instantiate
  7600. * @returns the new object or null if the system was not able to do the instantiation
  7601. */
  7602. static Instantiate(className: string): any;
  7603. }
  7604. }
  7605. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7606. /**
  7607. * Define options used to create a depth texture
  7608. */
  7609. export class DepthTextureCreationOptions {
  7610. /** Specifies whether or not a stencil should be allocated in the texture */
  7611. generateStencil?: boolean;
  7612. /** Specifies whether or not bilinear filtering is enable on the texture */
  7613. bilinearFiltering?: boolean;
  7614. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7615. comparisonFunction?: number;
  7616. /** Specifies if the created texture is a cube texture */
  7617. isCube?: boolean;
  7618. }
  7619. }
  7620. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7621. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7622. import { Nullable } from "babylonjs/types";
  7623. import { Scene } from "babylonjs/scene";
  7624. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7625. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7626. module "babylonjs/Engines/thinEngine" {
  7627. interface ThinEngine {
  7628. /**
  7629. * Creates a depth stencil cube texture.
  7630. * This is only available in WebGL 2.
  7631. * @param size The size of face edge in the cube texture.
  7632. * @param options The options defining the cube texture.
  7633. * @returns The cube texture
  7634. */
  7635. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7649. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7650. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. 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;
  7654. /**
  7655. * Creates a cube texture
  7656. * @param rootUrl defines the url where the files to load is located
  7657. * @param scene defines the current scene
  7658. * @param files defines the list of files to load (1 per face)
  7659. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7660. * @param onLoad defines an optional callback raised when the texture is loaded
  7661. * @param onError defines an optional callback raised if there is an issue to load the texture
  7662. * @param format defines the format of the data
  7663. * @param forcedExtension defines the extension to use to pick the right loader
  7664. * @returns the cube texture as an InternalTexture
  7665. */
  7666. 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;
  7667. /**
  7668. * Creates a cube texture
  7669. * @param rootUrl defines the url where the files to load is located
  7670. * @param scene defines the current scene
  7671. * @param files defines the list of files to load (1 per face)
  7672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7673. * @param onLoad defines an optional callback raised when the texture is loaded
  7674. * @param onError defines an optional callback raised if there is an issue to load the texture
  7675. * @param format defines the format of the data
  7676. * @param forcedExtension defines the extension to use to pick the right loader
  7677. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7680. * @returns the cube texture as an InternalTexture
  7681. */
  7682. 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;
  7683. /** @hidden */
  7684. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7687. /** @hidden */
  7688. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7689. /** @hidden */
  7690. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7691. /**
  7692. * @hidden
  7693. */
  7694. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7695. }
  7696. }
  7697. }
  7698. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7699. import { Nullable } from "babylonjs/types";
  7700. import { Scene } from "babylonjs/scene";
  7701. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7703. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * The url of the texture
  7711. */
  7712. url: string;
  7713. /**
  7714. * Gets or sets the center of the bounding box associated with the cube texture.
  7715. * It must define where the camera used to render the texture was set
  7716. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7717. */
  7718. boundingBoxPosition: Vector3;
  7719. private _boundingBoxSize;
  7720. /**
  7721. * Gets or sets the size of the bounding box associated with the cube texture
  7722. * When defined, the cubemap will switch to local mode
  7723. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7724. * @example https://www.babylonjs-playground.com/#RNASML
  7725. */
  7726. /**
  7727. * Returns the bounding box size
  7728. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7729. */
  7730. boundingBoxSize: Vector3;
  7731. protected _rotationY: number;
  7732. /**
  7733. * Sets texture matrix rotation angle around Y axis in radians.
  7734. */
  7735. /**
  7736. * Gets texture matrix rotation angle around Y axis radians.
  7737. */
  7738. rotationY: number;
  7739. /**
  7740. * Are mip maps generated for this texture or not.
  7741. */
  7742. readonly noMipmap: boolean;
  7743. private _noMipmap;
  7744. private _files;
  7745. protected _forcedExtension: Nullable<string>;
  7746. private _extensions;
  7747. private _textureMatrix;
  7748. private _format;
  7749. private _createPolynomials;
  7750. /** @hidden */
  7751. _prefiltered: boolean;
  7752. /**
  7753. * Creates a cube texture from an array of image urls
  7754. * @param files defines an array of image urls
  7755. * @param scene defines the hosting scene
  7756. * @param noMipmap specifies if mip maps are not used
  7757. * @returns a cube texture
  7758. */
  7759. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7760. /**
  7761. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7762. * @param url defines the url of the prefiltered texture
  7763. * @param scene defines the scene the texture is attached to
  7764. * @param forcedExtension defines the extension of the file if different from the url
  7765. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7766. * @return the prefiltered texture
  7767. */
  7768. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7769. /**
  7770. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7771. * as prefiltered data.
  7772. * @param rootUrl defines the url of the texture or the root name of the six images
  7773. * @param scene defines the scene the texture is attached to
  7774. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7775. * @param noMipmap defines if mipmaps should be created or not
  7776. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7777. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7778. * @param onError defines a callback triggered in case of error during load
  7779. * @param format defines the internal format to use for the texture once loaded
  7780. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7781. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7782. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7783. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7784. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7785. * @return the cube texture
  7786. */
  7787. 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);
  7788. /**
  7789. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7790. */
  7791. readonly isPrefiltered: boolean;
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. */
  7803. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7804. /**
  7805. * Delays loading of the cube texture
  7806. * @param forcedExtension defines the extension to use
  7807. */
  7808. delayLoad(forcedExtension?: string): void;
  7809. /**
  7810. * Returns the reflection texture matrix
  7811. * @returns the reflection texture matrix
  7812. */
  7813. getReflectionTextureMatrix(): Matrix;
  7814. /**
  7815. * Sets the reflection texture matrix
  7816. * @param value Reflection texture matrix
  7817. */
  7818. setReflectionTextureMatrix(value: Matrix): void;
  7819. /**
  7820. * Parses text to create a cube texture
  7821. * @param parsedTexture define the serialized text to read from
  7822. * @param scene defines the hosting scene
  7823. * @param rootUrl defines the root url of the cube texture
  7824. * @returns a cube texture
  7825. */
  7826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7827. /**
  7828. * Makes a clone, or deep copy, of the cube texture
  7829. * @returns a new cube texture
  7830. */
  7831. clone(): CubeTexture;
  7832. }
  7833. }
  7834. declare module "babylonjs/Materials/materialDefines" {
  7835. /**
  7836. * Manages the defines for the Material
  7837. */
  7838. export class MaterialDefines {
  7839. /** @hidden */
  7840. protected _keys: string[];
  7841. private _isDirty;
  7842. /** @hidden */
  7843. _renderId: number;
  7844. /** @hidden */
  7845. _areLightsDirty: boolean;
  7846. /** @hidden */
  7847. _areLightsDisposed: boolean;
  7848. /** @hidden */
  7849. _areAttributesDirty: boolean;
  7850. /** @hidden */
  7851. _areTexturesDirty: boolean;
  7852. /** @hidden */
  7853. _areFresnelDirty: boolean;
  7854. /** @hidden */
  7855. _areMiscDirty: boolean;
  7856. /** @hidden */
  7857. _areImageProcessingDirty: boolean;
  7858. /** @hidden */
  7859. _normals: boolean;
  7860. /** @hidden */
  7861. _uvs: boolean;
  7862. /** @hidden */
  7863. _needNormals: boolean;
  7864. /** @hidden */
  7865. _needUVs: boolean;
  7866. [id: string]: any;
  7867. /**
  7868. * Specifies if the material needs to be re-calculated
  7869. */
  7870. readonly isDirty: boolean;
  7871. /**
  7872. * Marks the material to indicate that it has been re-calculated
  7873. */
  7874. markAsProcessed(): void;
  7875. /**
  7876. * Marks the material to indicate that it needs to be re-calculated
  7877. */
  7878. markAsUnprocessed(): void;
  7879. /**
  7880. * Marks the material to indicate all of its defines need to be re-calculated
  7881. */
  7882. markAllAsDirty(): void;
  7883. /**
  7884. * Marks the material to indicate that image processing needs to be re-calculated
  7885. */
  7886. markAsImageProcessingDirty(): void;
  7887. /**
  7888. * Marks the material to indicate the lights need to be re-calculated
  7889. * @param disposed Defines whether the light is dirty due to dispose or not
  7890. */
  7891. markAsLightDirty(disposed?: boolean): void;
  7892. /**
  7893. * Marks the attribute state as changed
  7894. */
  7895. markAsAttributesDirty(): void;
  7896. /**
  7897. * Marks the texture state as changed
  7898. */
  7899. markAsTexturesDirty(): void;
  7900. /**
  7901. * Marks the fresnel state as changed
  7902. */
  7903. markAsFresnelDirty(): void;
  7904. /**
  7905. * Marks the misc state as changed
  7906. */
  7907. markAsMiscDirty(): void;
  7908. /**
  7909. * Rebuilds the material defines
  7910. */
  7911. rebuild(): void;
  7912. /**
  7913. * Specifies if two material defines are equal
  7914. * @param other - A material define instance to compare to
  7915. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7916. */
  7917. isEqual(other: MaterialDefines): boolean;
  7918. /**
  7919. * Clones this instance's defines to another instance
  7920. * @param other - material defines to clone values to
  7921. */
  7922. cloneTo(other: MaterialDefines): void;
  7923. /**
  7924. * Resets the material define values
  7925. */
  7926. reset(): void;
  7927. /**
  7928. * Converts the material define values to a string
  7929. * @returns - String of material define information
  7930. */
  7931. toString(): string;
  7932. }
  7933. }
  7934. declare module "babylonjs/Materials/colorCurves" {
  7935. import { Effect } from "babylonjs/Materials/effect";
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * 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;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * 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).
  7958. */
  7959. /**
  7960. * Sets the global Hue value.
  7961. * 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).
  7962. */
  7963. globalHue: number;
  7964. /**
  7965. * Gets the global Density value.
  7966. * 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.
  7967. * Values less than zero provide a filter of opposite hue.
  7968. */
  7969. /**
  7970. * Sets the global Density value.
  7971. * 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.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. globalDensity: number;
  7975. /**
  7976. * Gets the global Saturation value.
  7977. * 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.
  7978. */
  7979. /**
  7980. * Sets the global Saturation value.
  7981. * 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.
  7982. */
  7983. globalSaturation: number;
  7984. /**
  7985. * Gets the global Exposure value.
  7986. * 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.
  7987. */
  7988. /**
  7989. * Sets the global Exposure value.
  7990. * 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.
  7991. */
  7992. globalExposure: number;
  7993. private _highlightsHue;
  7994. private _highlightsDensity;
  7995. private _highlightsSaturation;
  7996. private _highlightsExposure;
  7997. /**
  7998. * Gets the highlights Hue value.
  7999. * 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).
  8000. */
  8001. /**
  8002. * Sets the highlights Hue value.
  8003. * 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).
  8004. */
  8005. highlightsHue: number;
  8006. /**
  8007. * Gets the highlights Density value.
  8008. * 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.
  8009. * Values less than zero provide a filter of opposite hue.
  8010. */
  8011. /**
  8012. * Sets the highlights Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. highlightsDensity: number;
  8017. /**
  8018. * Gets the highlights Saturation value.
  8019. * 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.
  8020. */
  8021. /**
  8022. * Sets the highlights Saturation value.
  8023. * 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.
  8024. */
  8025. highlightsSaturation: number;
  8026. /**
  8027. * Gets the highlights Exposure value.
  8028. * 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.
  8029. */
  8030. /**
  8031. * Sets the highlights Exposure value.
  8032. * 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.
  8033. */
  8034. highlightsExposure: number;
  8035. private _midtonesHue;
  8036. private _midtonesDensity;
  8037. private _midtonesSaturation;
  8038. private _midtonesExposure;
  8039. /**
  8040. * Gets the midtones Hue value.
  8041. * 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).
  8042. */
  8043. /**
  8044. * Sets the midtones Hue value.
  8045. * 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).
  8046. */
  8047. midtonesHue: number;
  8048. /**
  8049. * Gets the midtones Density value.
  8050. * 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.
  8051. * Values less than zero provide a filter of opposite hue.
  8052. */
  8053. /**
  8054. * Sets the midtones Density value.
  8055. * 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.
  8056. * Values less than zero provide a filter of opposite hue.
  8057. */
  8058. midtonesDensity: number;
  8059. /**
  8060. * Gets the midtones Saturation value.
  8061. * 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.
  8062. */
  8063. /**
  8064. * Sets the midtones Saturation value.
  8065. * 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.
  8066. */
  8067. midtonesSaturation: number;
  8068. /**
  8069. * Gets the midtones Exposure value.
  8070. * 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.
  8071. */
  8072. /**
  8073. * Sets the midtones Exposure value.
  8074. * 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.
  8075. */
  8076. midtonesExposure: number;
  8077. private _shadowsHue;
  8078. private _shadowsDensity;
  8079. private _shadowsSaturation;
  8080. private _shadowsExposure;
  8081. /**
  8082. * Gets the shadows Hue value.
  8083. * 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).
  8084. */
  8085. /**
  8086. * Sets the shadows Hue value.
  8087. * 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).
  8088. */
  8089. shadowsHue: number;
  8090. /**
  8091. * Gets the shadows Density value.
  8092. * 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.
  8093. * Values less than zero provide a filter of opposite hue.
  8094. */
  8095. /**
  8096. * Sets the shadows Density value.
  8097. * 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.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. shadowsDensity: number;
  8101. /**
  8102. * Gets the shadows Saturation value.
  8103. * 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.
  8104. */
  8105. /**
  8106. * Sets the shadows Saturation value.
  8107. * 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.
  8108. */
  8109. shadowsSaturation: number;
  8110. /**
  8111. * Gets the shadows Exposure value.
  8112. * 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.
  8113. */
  8114. /**
  8115. * Sets the shadows Exposure value.
  8116. * 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.
  8117. */
  8118. shadowsExposure: number;
  8119. /**
  8120. * Returns the class name
  8121. * @returns The class name
  8122. */
  8123. getClassName(): string;
  8124. /**
  8125. * Binds the color curves to the shader.
  8126. * @param colorCurves The color curve to bind
  8127. * @param effect The effect to bind to
  8128. * @param positiveUniform The positive uniform shader parameter
  8129. * @param neutralUniform The neutral uniform shader parameter
  8130. * @param negativeUniform The negative uniform shader parameter
  8131. */
  8132. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8133. /**
  8134. * Prepare the list of uniforms associated with the ColorCurves effects.
  8135. * @param uniformsList The list of uniforms used in the effect
  8136. */
  8137. static PrepareUniforms(uniformsList: string[]): void;
  8138. /**
  8139. * Returns color grading data based on a hue, density, saturation and exposure value.
  8140. * @param filterHue The hue of the color filter.
  8141. * @param filterDensity The density of the color filter.
  8142. * @param saturation The saturation.
  8143. * @param exposure The exposure.
  8144. * @param result The result data container.
  8145. */
  8146. private getColorGradingDataToRef;
  8147. /**
  8148. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8149. * @param value The input slider value in range [-100,100].
  8150. * @returns Adjusted value.
  8151. */
  8152. private static applyColorGradingSliderNonlinear;
  8153. /**
  8154. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8155. * @param hue The hue (H) input.
  8156. * @param saturation The saturation (S) input.
  8157. * @param brightness The brightness (B) input.
  8158. * @result An RGBA color represented as Vector4.
  8159. */
  8160. private static fromHSBToRef;
  8161. /**
  8162. * Returns a value clamped between min and max
  8163. * @param value The value to clamp
  8164. * @param min The minimum of value
  8165. * @param max The maximum of value
  8166. * @returns The clamped value.
  8167. */
  8168. private static clamp;
  8169. /**
  8170. * Clones the current color curve instance.
  8171. * @return The cloned curves
  8172. */
  8173. clone(): ColorCurves;
  8174. /**
  8175. * Serializes the current color curve instance to a json representation.
  8176. * @return a JSON representation
  8177. */
  8178. serialize(): any;
  8179. /**
  8180. * Parses the color curve from a json representation.
  8181. * @param source the JSON source to parse
  8182. * @return The parsed curves
  8183. */
  8184. static Parse(source: any): ColorCurves;
  8185. }
  8186. }
  8187. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8188. import { Observable } from "babylonjs/Misc/observable";
  8189. import { Nullable } from "babylonjs/types";
  8190. import { Color4 } from "babylonjs/Maths/math.color";
  8191. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8192. import { Effect } from "babylonjs/Materials/effect";
  8193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8194. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8195. /**
  8196. * Interface to follow in your material defines to integrate easily the
  8197. * Image proccessing functions.
  8198. * @hidden
  8199. */
  8200. export interface IImageProcessingConfigurationDefines {
  8201. IMAGEPROCESSING: boolean;
  8202. VIGNETTE: boolean;
  8203. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8204. VIGNETTEBLENDMODEOPAQUE: boolean;
  8205. TONEMAPPING: boolean;
  8206. TONEMAPPING_ACES: boolean;
  8207. CONTRAST: boolean;
  8208. EXPOSURE: boolean;
  8209. COLORCURVES: boolean;
  8210. COLORGRADING: boolean;
  8211. COLORGRADING3D: boolean;
  8212. SAMPLER3DGREENDEPTH: boolean;
  8213. SAMPLER3DBGRMAP: boolean;
  8214. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8215. }
  8216. /**
  8217. * @hidden
  8218. */
  8219. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8220. IMAGEPROCESSING: boolean;
  8221. VIGNETTE: boolean;
  8222. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8223. VIGNETTEBLENDMODEOPAQUE: boolean;
  8224. TONEMAPPING: boolean;
  8225. TONEMAPPING_ACES: boolean;
  8226. CONTRAST: boolean;
  8227. COLORCURVES: boolean;
  8228. COLORGRADING: boolean;
  8229. COLORGRADING3D: boolean;
  8230. SAMPLER3DGREENDEPTH: boolean;
  8231. SAMPLER3DBGRMAP: boolean;
  8232. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8233. EXPOSURE: boolean;
  8234. constructor();
  8235. }
  8236. /**
  8237. * This groups together the common properties used for image processing either in direct forward pass
  8238. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8239. * or not.
  8240. */
  8241. export class ImageProcessingConfiguration {
  8242. /**
  8243. * Default tone mapping applied in BabylonJS.
  8244. */
  8245. static readonly TONEMAPPING_STANDARD: number;
  8246. /**
  8247. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8248. * to other engines rendering to increase portability.
  8249. */
  8250. static readonly TONEMAPPING_ACES: number;
  8251. /**
  8252. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8253. */
  8254. colorCurves: Nullable<ColorCurves>;
  8255. private _colorCurvesEnabled;
  8256. /**
  8257. * Gets wether the color curves effect is enabled.
  8258. */
  8259. /**
  8260. * Sets wether the color curves effect is enabled.
  8261. */
  8262. colorCurvesEnabled: boolean;
  8263. private _colorGradingTexture;
  8264. /**
  8265. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8266. */
  8267. /**
  8268. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8269. */
  8270. colorGradingTexture: Nullable<BaseTexture>;
  8271. private _colorGradingEnabled;
  8272. /**
  8273. * Gets wether the color grading effect is enabled.
  8274. */
  8275. /**
  8276. * Sets wether the color grading effect is enabled.
  8277. */
  8278. colorGradingEnabled: boolean;
  8279. private _colorGradingWithGreenDepth;
  8280. /**
  8281. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8282. */
  8283. /**
  8284. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8285. */
  8286. colorGradingWithGreenDepth: boolean;
  8287. private _colorGradingBGR;
  8288. /**
  8289. * Gets wether the color grading texture contains BGR values.
  8290. */
  8291. /**
  8292. * Sets wether the color grading texture contains BGR values.
  8293. */
  8294. colorGradingBGR: boolean;
  8295. /** @hidden */
  8296. _exposure: number;
  8297. /**
  8298. * Gets the Exposure used in the effect.
  8299. */
  8300. /**
  8301. * Sets the Exposure used in the effect.
  8302. */
  8303. exposure: number;
  8304. private _toneMappingEnabled;
  8305. /**
  8306. * Gets wether the tone mapping effect is enabled.
  8307. */
  8308. /**
  8309. * Sets wether the tone mapping effect is enabled.
  8310. */
  8311. toneMappingEnabled: boolean;
  8312. private _toneMappingType;
  8313. /**
  8314. * Gets the type of tone mapping effect.
  8315. */
  8316. /**
  8317. * Sets the type of tone mapping effect used in BabylonJS.
  8318. */
  8319. toneMappingType: number;
  8320. protected _contrast: number;
  8321. /**
  8322. * Gets the contrast used in the effect.
  8323. */
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. contrast: number;
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. /**
  8358. * Sets the vignette blend mode allowing different kind of effect.
  8359. */
  8360. vignetteBlendMode: number;
  8361. private _vignetteEnabled;
  8362. /**
  8363. * Gets wether the vignette effect is enabled.
  8364. */
  8365. /**
  8366. * Sets wether the vignette effect is enabled.
  8367. */
  8368. vignetteEnabled: boolean;
  8369. private _applyByPostProcess;
  8370. /**
  8371. * Gets wether the image processing is applied through a post process or not.
  8372. */
  8373. /**
  8374. * Sets wether the image processing is applied through a post process or not.
  8375. */
  8376. applyByPostProcess: boolean;
  8377. private _isEnabled;
  8378. /**
  8379. * Gets wether the image processing is enabled or not.
  8380. */
  8381. /**
  8382. * Sets wether the image processing is enabled or not.
  8383. */
  8384. isEnabled: boolean;
  8385. /**
  8386. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8387. */
  8388. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8389. /**
  8390. * Method called each time the image processing information changes requires to recompile the effect.
  8391. */
  8392. protected _updateParameters(): void;
  8393. /**
  8394. * Gets the current class name.
  8395. * @return "ImageProcessingConfiguration"
  8396. */
  8397. getClassName(): string;
  8398. /**
  8399. * Prepare the list of uniforms associated with the Image Processing effects.
  8400. * @param uniforms The list of uniforms used in the effect
  8401. * @param defines the list of defines currently in use
  8402. */
  8403. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8404. /**
  8405. * Prepare the list of samplers associated with the Image Processing effects.
  8406. * @param samplersList The list of uniforms used in the effect
  8407. * @param defines the list of defines currently in use
  8408. */
  8409. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8410. /**
  8411. * Prepare the list of defines associated to the shader.
  8412. * @param defines the list of defines to complete
  8413. * @param forPostProcess Define if we are currently in post process mode or not
  8414. */
  8415. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8416. /**
  8417. * Returns true if all the image processing information are ready.
  8418. * @returns True if ready, otherwise, false
  8419. */
  8420. isReady(): boolean;
  8421. /**
  8422. * Binds the image processing to the shader.
  8423. * @param effect The effect to bind to
  8424. * @param overrideAspectRatio Override the aspect ratio of the effect
  8425. */
  8426. bind(effect: Effect, overrideAspectRatio?: number): void;
  8427. /**
  8428. * Clones the current image processing instance.
  8429. * @return The cloned image processing
  8430. */
  8431. clone(): ImageProcessingConfiguration;
  8432. /**
  8433. * Serializes the current image processing instance to a json representation.
  8434. * @return a JSON representation
  8435. */
  8436. serialize(): any;
  8437. /**
  8438. * Parses the image processing from a json representation.
  8439. * @param source the JSON source to parse
  8440. * @return The parsed image processing
  8441. */
  8442. static Parse(source: any): ImageProcessingConfiguration;
  8443. private static _VIGNETTEMODE_MULTIPLY;
  8444. private static _VIGNETTEMODE_OPAQUE;
  8445. /**
  8446. * Used to apply the vignette as a mix with the pixel color.
  8447. */
  8448. static readonly VIGNETTEMODE_MULTIPLY: number;
  8449. /**
  8450. * Used to apply the vignette as a replacement of the pixel color.
  8451. */
  8452. static readonly VIGNETTEMODE_OPAQUE: number;
  8453. }
  8454. }
  8455. declare module "babylonjs/Shaders/postprocess.vertex" {
  8456. /** @hidden */
  8457. export var postprocessVertexShader: {
  8458. name: string;
  8459. shader: string;
  8460. };
  8461. }
  8462. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8463. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8464. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8465. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8466. module "babylonjs/Engines/thinEngine" {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8478. /**
  8479. * Creates a depth stencil texture.
  8480. * This is only available in WebGL 2 or with the depth texture extension available.
  8481. * @param size The size of face edge in the texture.
  8482. * @param options The options defining the texture.
  8483. * @returns The texture
  8484. */
  8485. createDepthStencilTexture(size: number | {
  8486. width: number;
  8487. height: number;
  8488. }, options: DepthTextureCreationOptions): InternalTexture;
  8489. /** @hidden */
  8490. _createDepthStencilTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. }, options: DepthTextureCreationOptions): InternalTexture;
  8494. }
  8495. }
  8496. }
  8497. declare module "babylonjs/Maths/math.axis" {
  8498. import { Vector3 } from "babylonjs/Maths/math.vector";
  8499. /** Defines supported spaces */
  8500. export enum Space {
  8501. /** Local (object) space */
  8502. LOCAL = 0,
  8503. /** World space */
  8504. WORLD = 1,
  8505. /** Bone space */
  8506. BONE = 2
  8507. }
  8508. /** Defines the 3 main axes */
  8509. export class Axis {
  8510. /** X axis */
  8511. static X: Vector3;
  8512. /** Y axis */
  8513. static Y: Vector3;
  8514. /** Z axis */
  8515. static Z: Vector3;
  8516. }
  8517. }
  8518. declare module "babylonjs/Cameras/targetCamera" {
  8519. import { Nullable } from "babylonjs/types";
  8520. import { Camera } from "babylonjs/Cameras/camera";
  8521. import { Scene } from "babylonjs/scene";
  8522. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8523. /**
  8524. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8525. * This is the base of the follow, arc rotate cameras and Free camera
  8526. * @see http://doc.babylonjs.com/features/cameras
  8527. */
  8528. export class TargetCamera extends Camera {
  8529. private static _RigCamTransformMatrix;
  8530. private static _TargetTransformMatrix;
  8531. private static _TargetFocalPoint;
  8532. /**
  8533. * Define the current direction the camera is moving to
  8534. */
  8535. cameraDirection: Vector3;
  8536. /**
  8537. * Define the current rotation the camera is rotating to
  8538. */
  8539. cameraRotation: Vector2;
  8540. /**
  8541. * When set, the up vector of the camera will be updated by the rotation of the camera
  8542. */
  8543. updateUpVectorFromRotation: boolean;
  8544. private _tmpQuaternion;
  8545. /**
  8546. * Define the current rotation of the camera
  8547. */
  8548. rotation: Vector3;
  8549. /**
  8550. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8551. */
  8552. rotationQuaternion: Quaternion;
  8553. /**
  8554. * Define the current speed of the camera
  8555. */
  8556. speed: number;
  8557. /**
  8558. * Add constraint to the camera to prevent it to move freely in all directions and
  8559. * around all axis.
  8560. */
  8561. noRotationConstraint: boolean;
  8562. /**
  8563. * Define the current target of the camera as an object or a position.
  8564. */
  8565. lockedTarget: any;
  8566. /** @hidden */
  8567. _currentTarget: Vector3;
  8568. /** @hidden */
  8569. _initialFocalDistance: number;
  8570. /** @hidden */
  8571. _viewMatrix: Matrix;
  8572. /** @hidden */
  8573. _camMatrix: Matrix;
  8574. /** @hidden */
  8575. _cameraTransformMatrix: Matrix;
  8576. /** @hidden */
  8577. _cameraRotationMatrix: Matrix;
  8578. /** @hidden */
  8579. _referencePoint: Vector3;
  8580. /** @hidden */
  8581. _transformedReferencePoint: Vector3;
  8582. protected _globalCurrentTarget: Vector3;
  8583. protected _globalCurrentUpVector: Vector3;
  8584. /** @hidden */
  8585. _reset: () => void;
  8586. private _defaultUp;
  8587. /**
  8588. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8589. * This is the base of the follow, arc rotate cameras and Free camera
  8590. * @see http://doc.babylonjs.com/features/cameras
  8591. * @param name Defines the name of the camera in the scene
  8592. * @param position Defines the start position of the camera in the scene
  8593. * @param scene Defines the scene the camera belongs to
  8594. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8595. */
  8596. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8597. /**
  8598. * Gets the position in front of the camera at a given distance.
  8599. * @param distance The distance from the camera we want the position to be
  8600. * @returns the position
  8601. */
  8602. getFrontPosition(distance: number): Vector3;
  8603. /** @hidden */
  8604. _getLockedTargetPosition(): Nullable<Vector3>;
  8605. private _storedPosition;
  8606. private _storedRotation;
  8607. private _storedRotationQuaternion;
  8608. /**
  8609. * Store current camera state of the camera (fov, position, rotation, etc..)
  8610. * @returns the camera
  8611. */
  8612. storeState(): Camera;
  8613. /**
  8614. * Restored camera state. You must call storeState() first
  8615. * @returns whether it was successful or not
  8616. * @hidden
  8617. */
  8618. _restoreStateValues(): boolean;
  8619. /** @hidden */
  8620. _initCache(): void;
  8621. /** @hidden */
  8622. _updateCache(ignoreParentClass?: boolean): void;
  8623. /** @hidden */
  8624. _isSynchronizedViewMatrix(): boolean;
  8625. /** @hidden */
  8626. _computeLocalCameraSpeed(): number;
  8627. /**
  8628. * Defines the target the camera should look at.
  8629. * @param target Defines the new target as a Vector or a mesh
  8630. */
  8631. setTarget(target: Vector3): void;
  8632. /**
  8633. * Return the current target position of the camera. This value is expressed in local space.
  8634. * @returns the target position
  8635. */
  8636. getTarget(): Vector3;
  8637. /** @hidden */
  8638. _decideIfNeedsToMove(): boolean;
  8639. /** @hidden */
  8640. _updatePosition(): void;
  8641. /** @hidden */
  8642. _checkInputs(): void;
  8643. protected _updateCameraRotationMatrix(): void;
  8644. /**
  8645. * 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)
  8646. * @returns the current camera
  8647. */
  8648. private _rotateUpVectorWithCameraRotationMatrix;
  8649. private _cachedRotationZ;
  8650. private _cachedQuaternionRotationZ;
  8651. /** @hidden */
  8652. _getViewMatrix(): Matrix;
  8653. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8654. /**
  8655. * @hidden
  8656. */
  8657. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8658. /**
  8659. * @hidden
  8660. */
  8661. _updateRigCameras(): void;
  8662. private _getRigCamPositionAndTarget;
  8663. /**
  8664. * Gets the current object class name.
  8665. * @return the class name
  8666. */
  8667. getClassName(): string;
  8668. }
  8669. }
  8670. declare module "babylonjs/Events/keyboardEvents" {
  8671. /**
  8672. * Gather the list of keyboard event types as constants.
  8673. */
  8674. export class KeyboardEventTypes {
  8675. /**
  8676. * The keydown event is fired when a key becomes active (pressed).
  8677. */
  8678. static readonly KEYDOWN: number;
  8679. /**
  8680. * The keyup event is fired when a key has been released.
  8681. */
  8682. static readonly KEYUP: number;
  8683. }
  8684. /**
  8685. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8686. */
  8687. export class KeyboardInfo {
  8688. /**
  8689. * Defines the type of event (KeyboardEventTypes)
  8690. */
  8691. type: number;
  8692. /**
  8693. * Defines the related dom event
  8694. */
  8695. event: KeyboardEvent;
  8696. /**
  8697. * Instantiates a new keyboard info.
  8698. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8699. * @param type Defines the type of event (KeyboardEventTypes)
  8700. * @param event Defines the related dom event
  8701. */
  8702. constructor(
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number,
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent);
  8711. }
  8712. /**
  8713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8714. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8715. */
  8716. export class KeyboardInfoPre extends KeyboardInfo {
  8717. /**
  8718. * Defines the type of event (KeyboardEventTypes)
  8719. */
  8720. type: number;
  8721. /**
  8722. * Defines the related dom event
  8723. */
  8724. event: KeyboardEvent;
  8725. /**
  8726. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8727. */
  8728. skipOnPointerObservable: boolean;
  8729. /**
  8730. * Instantiates a new keyboard pre info.
  8731. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8732. * @param type Defines the type of event (KeyboardEventTypes)
  8733. * @param event Defines the related dom event
  8734. */
  8735. constructor(
  8736. /**
  8737. * Defines the type of event (KeyboardEventTypes)
  8738. */
  8739. type: number,
  8740. /**
  8741. * Defines the related dom event
  8742. */
  8743. event: KeyboardEvent);
  8744. }
  8745. }
  8746. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8747. import { Nullable } from "babylonjs/types";
  8748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8749. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8750. /**
  8751. * Manage the keyboard inputs to control the movement of a free camera.
  8752. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8753. */
  8754. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8755. /**
  8756. * Defines the camera the input is attached to.
  8757. */
  8758. camera: FreeCamera;
  8759. /**
  8760. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8761. */
  8762. keysUp: number[];
  8763. /**
  8764. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8765. */
  8766. keysDown: number[];
  8767. /**
  8768. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8769. */
  8770. keysLeft: number[];
  8771. /**
  8772. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8773. */
  8774. keysRight: number[];
  8775. private _keys;
  8776. private _onCanvasBlurObserver;
  8777. private _onKeyboardObserver;
  8778. private _engine;
  8779. private _scene;
  8780. /**
  8781. * Attach the input controls to a specific dom element to get the input from.
  8782. * @param element Defines the element the controls should be listened from
  8783. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8784. */
  8785. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8786. /**
  8787. * Detach the current controls from the specified dom element.
  8788. * @param element Defines the element to stop listening the inputs from
  8789. */
  8790. detachControl(element: Nullable<HTMLElement>): void;
  8791. /**
  8792. * Update the current camera state depending on the inputs that have been used this frame.
  8793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8794. */
  8795. checkInputs(): void;
  8796. /**
  8797. * Gets the class name of the current intput.
  8798. * @returns the class name
  8799. */
  8800. getClassName(): string;
  8801. /** @hidden */
  8802. _onLostFocus(): void;
  8803. /**
  8804. * Get the friendly name associated with the input class.
  8805. * @returns the input friendly name
  8806. */
  8807. getSimpleName(): string;
  8808. }
  8809. }
  8810. declare module "babylonjs/Lights/shadowLight" {
  8811. import { Camera } from "babylonjs/Cameras/camera";
  8812. import { Scene } from "babylonjs/scene";
  8813. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8815. import { Light } from "babylonjs/Lights/light";
  8816. /**
  8817. * Interface describing all the common properties and methods a shadow light needs to implement.
  8818. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8819. * as well as binding the different shadow properties to the effects.
  8820. */
  8821. export interface IShadowLight extends Light {
  8822. /**
  8823. * The light id in the scene (used in scene.findLighById for instance)
  8824. */
  8825. id: string;
  8826. /**
  8827. * The position the shdow will be casted from.
  8828. */
  8829. position: Vector3;
  8830. /**
  8831. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8832. */
  8833. direction: Vector3;
  8834. /**
  8835. * The transformed position. Position of the light in world space taking parenting in account.
  8836. */
  8837. transformedPosition: Vector3;
  8838. /**
  8839. * The transformed direction. Direction of the light in world space taking parenting in account.
  8840. */
  8841. transformedDirection: Vector3;
  8842. /**
  8843. * The friendly name of the light in the scene.
  8844. */
  8845. name: string;
  8846. /**
  8847. * Defines the shadow projection clipping minimum z value.
  8848. */
  8849. shadowMinZ: number;
  8850. /**
  8851. * Defines the shadow projection clipping maximum z value.
  8852. */
  8853. shadowMaxZ: number;
  8854. /**
  8855. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8856. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8857. */
  8858. computeTransformedInformation(): boolean;
  8859. /**
  8860. * Gets the scene the light belongs to.
  8861. * @returns The scene
  8862. */
  8863. getScene(): Scene;
  8864. /**
  8865. * Callback defining a custom Projection Matrix Builder.
  8866. * This can be used to override the default projection matrix computation.
  8867. */
  8868. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8869. /**
  8870. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8871. * @param matrix The materix to updated with the projection information
  8872. * @param viewMatrix The transform matrix of the light
  8873. * @param renderList The list of mesh to render in the map
  8874. * @returns The current light
  8875. */
  8876. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8877. /**
  8878. * Gets the current depth scale used in ESM.
  8879. * @returns The scale
  8880. */
  8881. getDepthScale(): number;
  8882. /**
  8883. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8884. * @returns true if a cube texture needs to be use
  8885. */
  8886. needCube(): boolean;
  8887. /**
  8888. * Detects if the projection matrix requires to be recomputed this frame.
  8889. * @returns true if it requires to be recomputed otherwise, false.
  8890. */
  8891. needProjectionMatrixCompute(): boolean;
  8892. /**
  8893. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8894. */
  8895. forceProjectionMatrixCompute(): void;
  8896. /**
  8897. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8898. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8899. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8900. */
  8901. getShadowDirection(faceIndex?: number): Vector3;
  8902. /**
  8903. * Gets the minZ used for shadow according to both the scene and the light.
  8904. * @param activeCamera The camera we are returning the min for
  8905. * @returns the depth min z
  8906. */
  8907. getDepthMinZ(activeCamera: Camera): number;
  8908. /**
  8909. * Gets the maxZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the max for
  8911. * @returns the depth max z
  8912. */
  8913. getDepthMaxZ(activeCamera: Camera): number;
  8914. }
  8915. /**
  8916. * Base implementation IShadowLight
  8917. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8918. */
  8919. export abstract class ShadowLight extends Light implements IShadowLight {
  8920. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8921. protected _position: Vector3;
  8922. protected _setPosition(value: Vector3): void;
  8923. /**
  8924. * Sets the position the shadow will be casted from. Also use as the light position for both
  8925. * point and spot lights.
  8926. */
  8927. /**
  8928. * Sets the position the shadow will be casted from. Also use as the light position for both
  8929. * point and spot lights.
  8930. */
  8931. position: Vector3;
  8932. protected _direction: Vector3;
  8933. protected _setDirection(value: Vector3): void;
  8934. /**
  8935. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8936. * Also use as the light direction on spot and directional lights.
  8937. */
  8938. /**
  8939. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8940. * Also use as the light direction on spot and directional lights.
  8941. */
  8942. direction: Vector3;
  8943. private _shadowMinZ;
  8944. /**
  8945. * Gets the shadow projection clipping minimum z value.
  8946. */
  8947. /**
  8948. * Sets the shadow projection clipping minimum z value.
  8949. */
  8950. shadowMinZ: number;
  8951. private _shadowMaxZ;
  8952. /**
  8953. * Sets the shadow projection clipping maximum z value.
  8954. */
  8955. /**
  8956. * Gets the shadow projection clipping maximum z value.
  8957. */
  8958. shadowMaxZ: number;
  8959. /**
  8960. * Callback defining a custom Projection Matrix Builder.
  8961. * This can be used to override the default projection matrix computation.
  8962. */
  8963. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8964. /**
  8965. * The transformed position. Position of the light in world space taking parenting in account.
  8966. */
  8967. transformedPosition: Vector3;
  8968. /**
  8969. * The transformed direction. Direction of the light in world space taking parenting in account.
  8970. */
  8971. transformedDirection: Vector3;
  8972. private _needProjectionMatrixCompute;
  8973. /**
  8974. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8975. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8976. */
  8977. computeTransformedInformation(): boolean;
  8978. /**
  8979. * Return the depth scale used for the shadow map.
  8980. * @returns the depth scale.
  8981. */
  8982. getDepthScale(): number;
  8983. /**
  8984. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8985. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8986. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8987. */
  8988. getShadowDirection(faceIndex?: number): Vector3;
  8989. /**
  8990. * Returns the ShadowLight absolute position in the World.
  8991. * @returns the position vector in world space
  8992. */
  8993. getAbsolutePosition(): Vector3;
  8994. /**
  8995. * Sets the ShadowLight direction toward the passed target.
  8996. * @param target The point to target in local space
  8997. * @returns the updated ShadowLight direction
  8998. */
  8999. setDirectionToTarget(target: Vector3): Vector3;
  9000. /**
  9001. * Returns the light rotation in euler definition.
  9002. * @returns the x y z rotation in local space.
  9003. */
  9004. getRotation(): Vector3;
  9005. /**
  9006. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9007. * @returns true if a cube texture needs to be use
  9008. */
  9009. needCube(): boolean;
  9010. /**
  9011. * Detects if the projection matrix requires to be recomputed this frame.
  9012. * @returns true if it requires to be recomputed otherwise, false.
  9013. */
  9014. needProjectionMatrixCompute(): boolean;
  9015. /**
  9016. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9017. */
  9018. forceProjectionMatrixCompute(): void;
  9019. /** @hidden */
  9020. _initCache(): void;
  9021. /** @hidden */
  9022. _isSynchronized(): boolean;
  9023. /**
  9024. * Computes the world matrix of the node
  9025. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9026. * @returns the world matrix
  9027. */
  9028. computeWorldMatrix(force?: boolean): Matrix;
  9029. /**
  9030. * Gets the minZ used for shadow according to both the scene and the light.
  9031. * @param activeCamera The camera we are returning the min for
  9032. * @returns the depth min z
  9033. */
  9034. getDepthMinZ(activeCamera: Camera): number;
  9035. /**
  9036. * Gets the maxZ used for shadow according to both the scene and the light.
  9037. * @param activeCamera The camera we are returning the max for
  9038. * @returns the depth max z
  9039. */
  9040. getDepthMaxZ(activeCamera: Camera): number;
  9041. /**
  9042. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9043. * @param matrix The materix to updated with the projection information
  9044. * @param viewMatrix The transform matrix of the light
  9045. * @param renderList The list of mesh to render in the map
  9046. * @returns The current light
  9047. */
  9048. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9049. }
  9050. }
  9051. declare module "babylonjs/Materials/effectFallbacks" {
  9052. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9053. import { Effect } from "babylonjs/Materials/effect";
  9054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9055. /**
  9056. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9057. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9058. */
  9059. export class EffectFallbacks implements IEffectFallbacks {
  9060. private _defines;
  9061. private _currentRank;
  9062. private _maxRank;
  9063. private _mesh;
  9064. /**
  9065. * Removes the fallback from the bound mesh.
  9066. */
  9067. unBindMesh(): void;
  9068. /**
  9069. * Adds a fallback on the specified property.
  9070. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9071. * @param define The name of the define in the shader
  9072. */
  9073. addFallback(rank: number, define: string): void;
  9074. /**
  9075. * Sets the mesh to use CPU skinning when needing to fallback.
  9076. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9077. * @param mesh The mesh to use the fallbacks.
  9078. */
  9079. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9080. /**
  9081. * Checks to see if more fallbacks are still availible.
  9082. */
  9083. readonly hasMoreFallbacks: boolean;
  9084. /**
  9085. * Removes the defines that should be removed when falling back.
  9086. * @param currentDefines defines the current define statements for the shader.
  9087. * @param effect defines the current effect we try to compile
  9088. * @returns The resulting defines with defines of the current rank removed.
  9089. */
  9090. reduce(currentDefines: string, effect: Effect): string;
  9091. }
  9092. }
  9093. declare module "babylonjs/Materials/materialHelper" {
  9094. import { Nullable } from "babylonjs/types";
  9095. import { Scene } from "babylonjs/scene";
  9096. import { Engine } from "babylonjs/Engines/engine";
  9097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9098. import { Light } from "babylonjs/Lights/light";
  9099. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9100. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9102. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9103. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9104. /**
  9105. * "Static Class" containing the most commonly used helper while dealing with material for
  9106. * rendering purpose.
  9107. *
  9108. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9109. *
  9110. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9111. */
  9112. export class MaterialHelper {
  9113. /**
  9114. * Bind the current view position to an effect.
  9115. * @param effect The effect to be bound
  9116. * @param scene The scene the eyes position is used from
  9117. */
  9118. static BindEyePosition(effect: Effect, scene: Scene): void;
  9119. /**
  9120. * Helps preparing the defines values about the UVs in used in the effect.
  9121. * UVs are shared as much as we can accross channels in the shaders.
  9122. * @param texture The texture we are preparing the UVs for
  9123. * @param defines The defines to update
  9124. * @param key The channel key "diffuse", "specular"... used in the shader
  9125. */
  9126. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9127. /**
  9128. * Binds a texture matrix value to its corrsponding uniform
  9129. * @param texture The texture to bind the matrix for
  9130. * @param uniformBuffer The uniform buffer receivin the data
  9131. * @param key The channel key "diffuse", "specular"... used in the shader
  9132. */
  9133. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9134. /**
  9135. * Gets the current status of the fog (should it be enabled?)
  9136. * @param mesh defines the mesh to evaluate for fog support
  9137. * @param scene defines the hosting scene
  9138. * @returns true if fog must be enabled
  9139. */
  9140. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9141. /**
  9142. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9143. * @param mesh defines the current mesh
  9144. * @param scene defines the current scene
  9145. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9146. * @param pointsCloud defines if point cloud rendering has to be turned on
  9147. * @param fogEnabled defines if fog has to be turned on
  9148. * @param alphaTest defines if alpha testing has to be turned on
  9149. * @param defines defines the current list of defines
  9150. */
  9151. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9152. /**
  9153. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9154. * @param scene defines the current scene
  9155. * @param engine defines the current engine
  9156. * @param defines specifies the list of active defines
  9157. * @param useInstances defines if instances have to be turned on
  9158. * @param useClipPlane defines if clip plane have to be turned on
  9159. */
  9160. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9161. /**
  9162. * Prepares the defines for bones
  9163. * @param mesh The mesh containing the geometry data we will draw
  9164. * @param defines The defines to update
  9165. */
  9166. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9167. /**
  9168. * Prepares the defines for morph targets
  9169. * @param mesh The mesh containing the geometry data we will draw
  9170. * @param defines The defines to update
  9171. */
  9172. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9173. /**
  9174. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9175. * @param mesh The mesh containing the geometry data we will draw
  9176. * @param defines The defines to update
  9177. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9178. * @param useBones Precise whether bones should be used or not (override mesh info)
  9179. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9180. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9181. * @returns false if defines are considered not dirty and have not been checked
  9182. */
  9183. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9184. /**
  9185. * Prepares the defines related to multiview
  9186. * @param scene The scene we are intending to draw
  9187. * @param defines The defines to update
  9188. */
  9189. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9190. /**
  9191. * Prepares the defines related to the light information passed in parameter
  9192. * @param scene The scene we are intending to draw
  9193. * @param mesh The mesh the effect is compiling for
  9194. * @param light The light the effect is compiling for
  9195. * @param lightIndex The index of the light
  9196. * @param defines The defines to update
  9197. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9198. * @param state Defines the current state regarding what is needed (normals, etc...)
  9199. */
  9200. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9201. needNormals: boolean;
  9202. needRebuild: boolean;
  9203. shadowEnabled: boolean;
  9204. specularEnabled: boolean;
  9205. lightmapMode: boolean;
  9206. }): void;
  9207. /**
  9208. * Prepares the defines related to the light information passed in parameter
  9209. * @param scene The scene we are intending to draw
  9210. * @param mesh The mesh the effect is compiling for
  9211. * @param defines The defines to update
  9212. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9213. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9214. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9215. * @returns true if normals will be required for the rest of the effect
  9216. */
  9217. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9218. /**
  9219. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9220. * @param lightIndex defines the light index
  9221. * @param uniformsList The uniform list
  9222. * @param samplersList The sampler list
  9223. * @param projectedLightTexture defines if projected texture must be used
  9224. * @param uniformBuffersList defines an optional list of uniform buffers
  9225. */
  9226. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9227. /**
  9228. * Prepares the uniforms and samplers list to be used in the effect
  9229. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9230. * @param samplersList The sampler list
  9231. * @param defines The defines helping in the list generation
  9232. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9233. */
  9234. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9235. /**
  9236. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9237. * @param defines The defines to update while falling back
  9238. * @param fallbacks The authorized effect fallbacks
  9239. * @param maxSimultaneousLights The maximum number of lights allowed
  9240. * @param rank the current rank of the Effect
  9241. * @returns The newly affected rank
  9242. */
  9243. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9244. private static _TmpMorphInfluencers;
  9245. /**
  9246. * Prepares the list of attributes required for morph targets according to the effect defines.
  9247. * @param attribs The current list of supported attribs
  9248. * @param mesh The mesh to prepare the morph targets attributes for
  9249. * @param influencers The number of influencers
  9250. */
  9251. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9252. /**
  9253. * Prepares the list of attributes required for morph targets according to the effect defines.
  9254. * @param attribs The current list of supported attribs
  9255. * @param mesh The mesh to prepare the morph targets attributes for
  9256. * @param defines The current Defines of the effect
  9257. */
  9258. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9259. /**
  9260. * Prepares the list of attributes required for bones according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param mesh The mesh to prepare the bones attributes for
  9263. * @param defines The current Defines of the effect
  9264. * @param fallbacks The current efffect fallback strategy
  9265. */
  9266. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9267. /**
  9268. * Check and prepare the list of attributes required for instances according to the effect defines.
  9269. * @param attribs The current list of supported attribs
  9270. * @param defines The current MaterialDefines of the effect
  9271. */
  9272. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9273. /**
  9274. * Add the list of attributes required for instances to the attribs array.
  9275. * @param attribs The current list of supported attribs
  9276. */
  9277. static PushAttributesForInstances(attribs: string[]): void;
  9278. /**
  9279. * Binds the light information to the effect.
  9280. * @param light The light containing the generator
  9281. * @param effect The effect we are binding the data to
  9282. * @param lightIndex The light index in the effect used to render
  9283. */
  9284. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9285. /**
  9286. * Binds the lights information from the scene to the effect for the given mesh.
  9287. * @param light Light to bind
  9288. * @param lightIndex Light index
  9289. * @param scene The scene where the light belongs to
  9290. * @param effect The effect we are binding the data to
  9291. * @param useSpecular Defines if specular is supported
  9292. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9293. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9294. */
  9295. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9296. /**
  9297. * Binds the lights information from the scene to the effect for the given mesh.
  9298. * @param scene The scene the lights belongs to
  9299. * @param mesh The mesh we are binding the information to render
  9300. * @param effect The effect we are binding the data to
  9301. * @param defines The generated defines for the effect
  9302. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9303. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9304. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9305. */
  9306. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9307. private static _tempFogColor;
  9308. /**
  9309. * Binds the fog information from the scene to the effect for the given mesh.
  9310. * @param scene The scene the lights belongs to
  9311. * @param mesh The mesh we are binding the information to render
  9312. * @param effect The effect we are binding the data to
  9313. * @param linearSpace Defines if the fog effect is applied in linear space
  9314. */
  9315. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9316. /**
  9317. * Binds the bones information from the mesh to the effect.
  9318. * @param mesh The mesh we are binding the information to render
  9319. * @param effect The effect we are binding the data to
  9320. */
  9321. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9322. /**
  9323. * Binds the morph targets information from the mesh to the effect.
  9324. * @param abstractMesh The mesh we are binding the information to render
  9325. * @param effect The effect we are binding the data to
  9326. */
  9327. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9328. /**
  9329. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9330. * @param defines The generated defines used in the effect
  9331. * @param effect The effect we are binding the data to
  9332. * @param scene The scene we are willing to render with logarithmic scale for
  9333. */
  9334. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9335. /**
  9336. * Binds the clip plane information from the scene to the effect.
  9337. * @param scene The scene the clip plane information are extracted from
  9338. * @param effect The effect we are binding the data to
  9339. */
  9340. static BindClipPlane(effect: Effect, scene: Scene): void;
  9341. }
  9342. }
  9343. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9344. /** @hidden */
  9345. export var packingFunctions: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9351. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9352. /** @hidden */
  9353. export var shadowMapPixelShader: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9359. /** @hidden */
  9360. export var bonesDeclaration: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9366. /** @hidden */
  9367. export var morphTargetsVertexGlobalDeclaration: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9373. /** @hidden */
  9374. export var morphTargetsVertexDeclaration: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9380. /** @hidden */
  9381. export var instancesDeclaration: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9387. /** @hidden */
  9388. export var helperFunctions: {
  9389. name: string;
  9390. shader: string;
  9391. };
  9392. }
  9393. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9394. /** @hidden */
  9395. export var morphTargetsVertex: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9401. /** @hidden */
  9402. export var instancesVertex: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9408. /** @hidden */
  9409. export var bonesVertex: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9415. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9417. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9418. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9419. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9420. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9421. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9422. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9423. /** @hidden */
  9424. export var shadowMapVertexShader: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9430. /** @hidden */
  9431. export var depthBoxBlurPixelShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9437. import { Nullable } from "babylonjs/types";
  9438. import { Scene } from "babylonjs/scene";
  9439. import { Matrix } from "babylonjs/Maths/math.vector";
  9440. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9442. import { Mesh } from "babylonjs/Meshes/mesh";
  9443. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9444. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9445. import { Effect } from "babylonjs/Materials/effect";
  9446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9447. import "babylonjs/Shaders/shadowMap.fragment";
  9448. import "babylonjs/Shaders/shadowMap.vertex";
  9449. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9450. import { Observable } from "babylonjs/Misc/observable";
  9451. /**
  9452. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9453. */
  9454. export interface ICustomShaderOptions {
  9455. /**
  9456. * Gets or sets the custom shader name to use
  9457. */
  9458. shaderName: string;
  9459. /**
  9460. * The list of attribute names used in the shader
  9461. */
  9462. attributes?: string[];
  9463. /**
  9464. * The list of unifrom names used in the shader
  9465. */
  9466. uniforms?: string[];
  9467. /**
  9468. * The list of sampler names used in the shader
  9469. */
  9470. samplers?: string[];
  9471. /**
  9472. * The list of defines used in the shader
  9473. */
  9474. defines?: string[];
  9475. }
  9476. /**
  9477. * Interface to implement to create a shadow generator compatible with BJS.
  9478. */
  9479. export interface IShadowGenerator {
  9480. /**
  9481. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9482. * @returns The render target texture if present otherwise, null
  9483. */
  9484. getShadowMap(): Nullable<RenderTargetTexture>;
  9485. /**
  9486. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9487. * @returns The render target texture if the shadow map is present otherwise, null
  9488. */
  9489. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9490. /**
  9491. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9492. * @param subMesh The submesh we want to render in the shadow map
  9493. * @param useInstances Defines wether will draw in the map using instances
  9494. * @returns true if ready otherwise, false
  9495. */
  9496. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9497. /**
  9498. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9499. * @param defines Defines of the material we want to update
  9500. * @param lightIndex Index of the light in the enabled light list of the material
  9501. */
  9502. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9503. /**
  9504. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9505. * defined in the generator but impacting the effect).
  9506. * It implies the unifroms available on the materials are the standard BJS ones.
  9507. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9508. * @param effect The effect we are binfing the information for
  9509. */
  9510. bindShadowLight(lightIndex: string, effect: Effect): void;
  9511. /**
  9512. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9513. * (eq to shadow prjection matrix * light transform matrix)
  9514. * @returns The transform matrix used to create the shadow map
  9515. */
  9516. getTransformMatrix(): Matrix;
  9517. /**
  9518. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9519. * Cube and 2D textures for instance.
  9520. */
  9521. recreateShadowMap(): void;
  9522. /**
  9523. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9524. * @param onCompiled Callback triggered at the and of the effects compilation
  9525. * @param options Sets of optional options forcing the compilation with different modes
  9526. */
  9527. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9528. useInstances: boolean;
  9529. }>): void;
  9530. /**
  9531. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9532. * @param options Sets of optional options forcing the compilation with different modes
  9533. * @returns A promise that resolves when the compilation completes
  9534. */
  9535. forceCompilationAsync(options?: Partial<{
  9536. useInstances: boolean;
  9537. }>): Promise<void>;
  9538. /**
  9539. * Serializes the shadow generator setup to a json object.
  9540. * @returns The serialized JSON object
  9541. */
  9542. serialize(): any;
  9543. /**
  9544. * Disposes the Shadow map and related Textures and effects.
  9545. */
  9546. dispose(): void;
  9547. }
  9548. /**
  9549. * Default implementation IShadowGenerator.
  9550. * This is the main object responsible of generating shadows in the framework.
  9551. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9552. */
  9553. export class ShadowGenerator implements IShadowGenerator {
  9554. /**
  9555. * Shadow generator mode None: no filtering applied.
  9556. */
  9557. static readonly FILTER_NONE: number;
  9558. /**
  9559. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9560. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9561. */
  9562. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9563. /**
  9564. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9565. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9566. */
  9567. static readonly FILTER_POISSONSAMPLING: number;
  9568. /**
  9569. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9570. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9571. */
  9572. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9573. /**
  9574. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9575. * edge artifacts on steep falloff.
  9576. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9577. */
  9578. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9579. /**
  9580. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9581. * edge artifacts on steep falloff.
  9582. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9583. */
  9584. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9585. /**
  9586. * Shadow generator mode PCF: Percentage Closer Filtering
  9587. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9588. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9589. */
  9590. static readonly FILTER_PCF: number;
  9591. /**
  9592. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9593. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9594. * Contact Hardening
  9595. */
  9596. static readonly FILTER_PCSS: number;
  9597. /**
  9598. * Reserved for PCF and PCSS
  9599. * Highest Quality.
  9600. *
  9601. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9602. *
  9603. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9604. */
  9605. static readonly QUALITY_HIGH: number;
  9606. /**
  9607. * Reserved for PCF and PCSS
  9608. * Good tradeoff for quality/perf cross devices
  9609. *
  9610. * Execute PCF on a 3*3 kernel.
  9611. *
  9612. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9613. */
  9614. static readonly QUALITY_MEDIUM: number;
  9615. /**
  9616. * Reserved for PCF and PCSS
  9617. * The lowest quality but the fastest.
  9618. *
  9619. * Execute PCF on a 1*1 kernel.
  9620. *
  9621. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9622. */
  9623. static readonly QUALITY_LOW: number;
  9624. /** Gets or sets the custom shader name to use */
  9625. customShaderOptions: ICustomShaderOptions;
  9626. /**
  9627. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9628. */
  9629. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9630. /**
  9631. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9632. */
  9633. onAfterShadowMapRenderObservable: Observable<Effect>;
  9634. /**
  9635. * Observable triggered before a mesh is rendered in the shadow map.
  9636. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9637. */
  9638. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9639. /**
  9640. * Observable triggered after a mesh is rendered in the shadow map.
  9641. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9642. */
  9643. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9644. private _bias;
  9645. /**
  9646. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9647. */
  9648. /**
  9649. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9650. */
  9651. bias: number;
  9652. private _normalBias;
  9653. /**
  9654. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9655. */
  9656. /**
  9657. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9658. */
  9659. normalBias: number;
  9660. private _blurBoxOffset;
  9661. /**
  9662. * Gets the blur box offset: offset applied during the blur pass.
  9663. * Only useful if useKernelBlur = false
  9664. */
  9665. /**
  9666. * Sets the blur box offset: offset applied during the blur pass.
  9667. * Only useful if useKernelBlur = false
  9668. */
  9669. blurBoxOffset: number;
  9670. private _blurScale;
  9671. /**
  9672. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9673. * 2 means half of the size.
  9674. */
  9675. /**
  9676. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9677. * 2 means half of the size.
  9678. */
  9679. blurScale: number;
  9680. private _blurKernel;
  9681. /**
  9682. * Gets the blur kernel: kernel size of the blur pass.
  9683. * Only useful if useKernelBlur = true
  9684. */
  9685. /**
  9686. * Sets the blur kernel: kernel size of the blur pass.
  9687. * Only useful if useKernelBlur = true
  9688. */
  9689. blurKernel: number;
  9690. private _useKernelBlur;
  9691. /**
  9692. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9693. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9694. */
  9695. /**
  9696. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9697. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9698. */
  9699. useKernelBlur: boolean;
  9700. private _depthScale;
  9701. /**
  9702. * Gets the depth scale used in ESM mode.
  9703. */
  9704. /**
  9705. * Sets the depth scale used in ESM mode.
  9706. * This can override the scale stored on the light.
  9707. */
  9708. depthScale: number;
  9709. private _filter;
  9710. /**
  9711. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9712. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9713. */
  9714. /**
  9715. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9716. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9717. */
  9718. filter: number;
  9719. /**
  9720. * Gets if the current filter is set to Poisson Sampling.
  9721. */
  9722. /**
  9723. * Sets the current filter to Poisson Sampling.
  9724. */
  9725. usePoissonSampling: boolean;
  9726. /**
  9727. * Gets if the current filter is set to ESM.
  9728. */
  9729. /**
  9730. * Sets the current filter is to ESM.
  9731. */
  9732. useExponentialShadowMap: boolean;
  9733. /**
  9734. * Gets if the current filter is set to filtered ESM.
  9735. */
  9736. /**
  9737. * Gets if the current filter is set to filtered ESM.
  9738. */
  9739. useBlurExponentialShadowMap: boolean;
  9740. /**
  9741. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9742. * exponential to prevent steep falloff artifacts).
  9743. */
  9744. /**
  9745. * Sets the current filter to "close ESM" (using the inverse of the
  9746. * exponential to prevent steep falloff artifacts).
  9747. */
  9748. useCloseExponentialShadowMap: boolean;
  9749. /**
  9750. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9751. * exponential to prevent steep falloff artifacts).
  9752. */
  9753. /**
  9754. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9755. * exponential to prevent steep falloff artifacts).
  9756. */
  9757. useBlurCloseExponentialShadowMap: boolean;
  9758. /**
  9759. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9760. */
  9761. /**
  9762. * Sets the current filter to "PCF" (percentage closer filtering).
  9763. */
  9764. usePercentageCloserFiltering: boolean;
  9765. private _filteringQuality;
  9766. /**
  9767. * Gets the PCF or PCSS Quality.
  9768. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9769. */
  9770. /**
  9771. * Sets the PCF or PCSS Quality.
  9772. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9773. */
  9774. filteringQuality: number;
  9775. /**
  9776. * Gets if the current filter is set to "PCSS" (contact hardening).
  9777. */
  9778. /**
  9779. * Sets the current filter to "PCSS" (contact hardening).
  9780. */
  9781. useContactHardeningShadow: boolean;
  9782. private _contactHardeningLightSizeUVRatio;
  9783. /**
  9784. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9785. * Using a ratio helps keeping shape stability independently of the map size.
  9786. *
  9787. * It does not account for the light projection as it was having too much
  9788. * instability during the light setup or during light position changes.
  9789. *
  9790. * Only valid if useContactHardeningShadow is true.
  9791. */
  9792. /**
  9793. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9794. * Using a ratio helps keeping shape stability independently of the map size.
  9795. *
  9796. * It does not account for the light projection as it was having too much
  9797. * instability during the light setup or during light position changes.
  9798. *
  9799. * Only valid if useContactHardeningShadow is true.
  9800. */
  9801. contactHardeningLightSizeUVRatio: number;
  9802. private _darkness;
  9803. /** Gets or sets the actual darkness of a shadow */
  9804. darkness: number;
  9805. /**
  9806. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9807. * 0 means strongest and 1 would means no shadow.
  9808. * @returns the darkness.
  9809. */
  9810. getDarkness(): number;
  9811. /**
  9812. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9813. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9814. * @returns the shadow generator allowing fluent coding.
  9815. */
  9816. setDarkness(darkness: number): ShadowGenerator;
  9817. private _transparencyShadow;
  9818. /** Gets or sets the ability to have transparent shadow */
  9819. transparencyShadow: boolean;
  9820. /**
  9821. * Sets the ability to have transparent shadow (boolean).
  9822. * @param transparent True if transparent else False
  9823. * @returns the shadow generator allowing fluent coding
  9824. */
  9825. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9826. private _shadowMap;
  9827. private _shadowMap2;
  9828. /**
  9829. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9830. * @returns The render target texture if present otherwise, null
  9831. */
  9832. getShadowMap(): Nullable<RenderTargetTexture>;
  9833. /**
  9834. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9835. * @returns The render target texture if the shadow map is present otherwise, null
  9836. */
  9837. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9838. /**
  9839. * Gets the class name of that object
  9840. * @returns "ShadowGenerator"
  9841. */
  9842. getClassName(): string;
  9843. /**
  9844. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9845. * @param mesh Mesh to add
  9846. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9847. * @returns the Shadow Generator itself
  9848. */
  9849. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9850. /**
  9851. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9852. * @param mesh Mesh to remove
  9853. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9854. * @returns the Shadow Generator itself
  9855. */
  9856. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9857. /**
  9858. * Controls the extent to which the shadows fade out at the edge of the frustum
  9859. * Used only by directionals and spots
  9860. */
  9861. frustumEdgeFalloff: number;
  9862. private _light;
  9863. /**
  9864. * Returns the associated light object.
  9865. * @returns the light generating the shadow
  9866. */
  9867. getLight(): IShadowLight;
  9868. /**
  9869. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9870. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9871. * It might on the other hand introduce peter panning.
  9872. */
  9873. forceBackFacesOnly: boolean;
  9874. private _scene;
  9875. private _lightDirection;
  9876. private _effect;
  9877. private _viewMatrix;
  9878. private _projectionMatrix;
  9879. private _transformMatrix;
  9880. private _cachedPosition;
  9881. private _cachedDirection;
  9882. private _cachedDefines;
  9883. private _currentRenderID;
  9884. private _boxBlurPostprocess;
  9885. private _kernelBlurXPostprocess;
  9886. private _kernelBlurYPostprocess;
  9887. private _blurPostProcesses;
  9888. private _mapSize;
  9889. private _currentFaceIndex;
  9890. private _currentFaceIndexCache;
  9891. private _textureType;
  9892. private _defaultTextureMatrix;
  9893. private _storedUniqueId;
  9894. /** @hidden */
  9895. static _SceneComponentInitialization: (scene: Scene) => void;
  9896. /**
  9897. * Creates a ShadowGenerator object.
  9898. * A ShadowGenerator is the required tool to use the shadows.
  9899. * Each light casting shadows needs to use its own ShadowGenerator.
  9900. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9901. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9902. * @param light The light object generating the shadows.
  9903. * @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.
  9904. */
  9905. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9906. private _initializeGenerator;
  9907. private _initializeShadowMap;
  9908. private _initializeBlurRTTAndPostProcesses;
  9909. private _renderForShadowMap;
  9910. private _renderSubMeshForShadowMap;
  9911. private _applyFilterValues;
  9912. /**
  9913. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9914. * @param onCompiled Callback triggered at the and of the effects compilation
  9915. * @param options Sets of optional options forcing the compilation with different modes
  9916. */
  9917. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9918. useInstances: boolean;
  9919. }>): void;
  9920. /**
  9921. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9922. * @param options Sets of optional options forcing the compilation with different modes
  9923. * @returns A promise that resolves when the compilation completes
  9924. */
  9925. forceCompilationAsync(options?: Partial<{
  9926. useInstances: boolean;
  9927. }>): Promise<void>;
  9928. /**
  9929. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9930. * @param subMesh The submesh we want to render in the shadow map
  9931. * @param useInstances Defines wether will draw in the map using instances
  9932. * @returns true if ready otherwise, false
  9933. */
  9934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9935. /**
  9936. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9937. * @param defines Defines of the material we want to update
  9938. * @param lightIndex Index of the light in the enabled light list of the material
  9939. */
  9940. prepareDefines(defines: any, lightIndex: number): void;
  9941. /**
  9942. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9943. * defined in the generator but impacting the effect).
  9944. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9945. * @param effect The effect we are binfing the information for
  9946. */
  9947. bindShadowLight(lightIndex: string, effect: Effect): void;
  9948. /**
  9949. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9950. * (eq to shadow prjection matrix * light transform matrix)
  9951. * @returns The transform matrix used to create the shadow map
  9952. */
  9953. getTransformMatrix(): Matrix;
  9954. /**
  9955. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9956. * Cube and 2D textures for instance.
  9957. */
  9958. recreateShadowMap(): void;
  9959. private _disposeBlurPostProcesses;
  9960. private _disposeRTTandPostProcesses;
  9961. /**
  9962. * Disposes the ShadowGenerator.
  9963. * Returns nothing.
  9964. */
  9965. dispose(): void;
  9966. /**
  9967. * Serializes the shadow generator setup to a json object.
  9968. * @returns The serialized JSON object
  9969. */
  9970. serialize(): any;
  9971. /**
  9972. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9973. * @param parsedShadowGenerator The JSON object to parse
  9974. * @param scene The scene to create the shadow map for
  9975. * @returns The parsed shadow generator
  9976. */
  9977. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9978. }
  9979. }
  9980. declare module "babylonjs/Lights/light" {
  9981. import { Nullable } from "babylonjs/types";
  9982. import { Scene } from "babylonjs/scene";
  9983. import { Vector3 } from "babylonjs/Maths/math.vector";
  9984. import { Color3 } from "babylonjs/Maths/math.color";
  9985. import { Node } from "babylonjs/node";
  9986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9987. import { Effect } from "babylonjs/Materials/effect";
  9988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9989. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9990. /**
  9991. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9992. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9993. * 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.
  9994. */
  9995. export abstract class Light extends Node {
  9996. /**
  9997. * Falloff Default: light is falling off following the material specification:
  9998. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9999. */
  10000. static readonly FALLOFF_DEFAULT: number;
  10001. /**
  10002. * Falloff Physical: light is falling off following the inverse squared distance law.
  10003. */
  10004. static readonly FALLOFF_PHYSICAL: number;
  10005. /**
  10006. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10007. * to enhance interoperability with other engines.
  10008. */
  10009. static readonly FALLOFF_GLTF: number;
  10010. /**
  10011. * Falloff Standard: light is falling off like in the standard material
  10012. * to enhance interoperability with other materials.
  10013. */
  10014. static readonly FALLOFF_STANDARD: number;
  10015. /**
  10016. * If every light affecting the material is in this lightmapMode,
  10017. * material.lightmapTexture adds or multiplies
  10018. * (depends on material.useLightmapAsShadowmap)
  10019. * after every other light calculations.
  10020. */
  10021. static readonly LIGHTMAP_DEFAULT: number;
  10022. /**
  10023. * material.lightmapTexture as only diffuse lighting from this light
  10024. * adds only specular lighting from this light
  10025. * adds dynamic shadows
  10026. */
  10027. static readonly LIGHTMAP_SPECULAR: number;
  10028. /**
  10029. * material.lightmapTexture as only lighting
  10030. * no light calculation from this light
  10031. * only adds dynamic shadows from this light
  10032. */
  10033. static readonly LIGHTMAP_SHADOWSONLY: number;
  10034. /**
  10035. * Each light type uses the default quantity according to its type:
  10036. * point/spot lights use luminous intensity
  10037. * directional lights use illuminance
  10038. */
  10039. static readonly INTENSITYMODE_AUTOMATIC: number;
  10040. /**
  10041. * lumen (lm)
  10042. */
  10043. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10044. /**
  10045. * candela (lm/sr)
  10046. */
  10047. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10048. /**
  10049. * lux (lm/m^2)
  10050. */
  10051. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10052. /**
  10053. * nit (cd/m^2)
  10054. */
  10055. static readonly INTENSITYMODE_LUMINANCE: number;
  10056. /**
  10057. * Light type const id of the point light.
  10058. */
  10059. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10060. /**
  10061. * Light type const id of the directional light.
  10062. */
  10063. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10064. /**
  10065. * Light type const id of the spot light.
  10066. */
  10067. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10068. /**
  10069. * Light type const id of the hemispheric light.
  10070. */
  10071. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10072. /**
  10073. * Diffuse gives the basic color to an object.
  10074. */
  10075. diffuse: Color3;
  10076. /**
  10077. * Specular produces a highlight color on an object.
  10078. * Note: This is note affecting PBR materials.
  10079. */
  10080. specular: Color3;
  10081. /**
  10082. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10083. * falling off base on range or angle.
  10084. * This can be set to any values in Light.FALLOFF_x.
  10085. *
  10086. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10087. * other types of materials.
  10088. */
  10089. falloffType: number;
  10090. /**
  10091. * Strength of the light.
  10092. * Note: By default it is define in the framework own unit.
  10093. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10094. */
  10095. intensity: number;
  10096. private _range;
  10097. protected _inverseSquaredRange: number;
  10098. /**
  10099. * Defines how far from the source the light is impacting in scene units.
  10100. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10101. */
  10102. /**
  10103. * Defines how far from the source the light is impacting in scene units.
  10104. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10105. */
  10106. range: number;
  10107. /**
  10108. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10109. * of light.
  10110. */
  10111. private _photometricScale;
  10112. private _intensityMode;
  10113. /**
  10114. * Gets the photometric scale used to interpret the intensity.
  10115. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10116. */
  10117. /**
  10118. * Sets the photometric scale used to interpret the intensity.
  10119. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10120. */
  10121. intensityMode: number;
  10122. private _radius;
  10123. /**
  10124. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10125. */
  10126. /**
  10127. * sets the light radius used by PBR Materials to simulate soft area lights.
  10128. */
  10129. radius: number;
  10130. private _renderPriority;
  10131. /**
  10132. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10133. * exceeding the number allowed of the materials.
  10134. */
  10135. renderPriority: number;
  10136. private _shadowEnabled;
  10137. /**
  10138. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10139. * the current shadow generator.
  10140. */
  10141. /**
  10142. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10143. * the current shadow generator.
  10144. */
  10145. shadowEnabled: boolean;
  10146. private _includedOnlyMeshes;
  10147. /**
  10148. * Gets the only meshes impacted by this light.
  10149. */
  10150. /**
  10151. * Sets the only meshes impacted by this light.
  10152. */
  10153. includedOnlyMeshes: AbstractMesh[];
  10154. private _excludedMeshes;
  10155. /**
  10156. * Gets the meshes not impacted by this light.
  10157. */
  10158. /**
  10159. * Sets the meshes not impacted by this light.
  10160. */
  10161. excludedMeshes: AbstractMesh[];
  10162. private _excludeWithLayerMask;
  10163. /**
  10164. * Gets the layer id use to find what meshes are not impacted by the light.
  10165. * Inactive if 0
  10166. */
  10167. /**
  10168. * Sets the layer id use to find what meshes are not impacted by the light.
  10169. * Inactive if 0
  10170. */
  10171. excludeWithLayerMask: number;
  10172. private _includeOnlyWithLayerMask;
  10173. /**
  10174. * Gets the layer id use to find what meshes are impacted by the light.
  10175. * Inactive if 0
  10176. */
  10177. /**
  10178. * Sets the layer id use to find what meshes are impacted by the light.
  10179. * Inactive if 0
  10180. */
  10181. includeOnlyWithLayerMask: number;
  10182. private _lightmapMode;
  10183. /**
  10184. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10185. */
  10186. /**
  10187. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10188. */
  10189. lightmapMode: number;
  10190. /**
  10191. * Shadow generator associted to the light.
  10192. * @hidden Internal use only.
  10193. */
  10194. _shadowGenerator: Nullable<IShadowGenerator>;
  10195. /**
  10196. * @hidden Internal use only.
  10197. */
  10198. _excludedMeshesIds: string[];
  10199. /**
  10200. * @hidden Internal use only.
  10201. */
  10202. _includedOnlyMeshesIds: string[];
  10203. /**
  10204. * The current light unifom buffer.
  10205. * @hidden Internal use only.
  10206. */
  10207. _uniformBuffer: UniformBuffer;
  10208. /** @hidden */
  10209. _renderId: number;
  10210. /**
  10211. * Creates a Light object in the scene.
  10212. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10213. * @param name The firendly name of the light
  10214. * @param scene The scene the light belongs too
  10215. */
  10216. constructor(name: string, scene: Scene);
  10217. protected abstract _buildUniformLayout(): void;
  10218. /**
  10219. * Sets the passed Effect "effect" with the Light information.
  10220. * @param effect The effect to update
  10221. * @param lightIndex The index of the light in the effect to update
  10222. * @returns The light
  10223. */
  10224. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10225. /**
  10226. * Sets the passed Effect "effect" with the Light information.
  10227. * @param effect The effect to update
  10228. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10229. * @returns The light
  10230. */
  10231. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10232. /**
  10233. * Returns the string "Light".
  10234. * @returns the class name
  10235. */
  10236. getClassName(): string;
  10237. /** @hidden */
  10238. readonly _isLight: boolean;
  10239. /**
  10240. * Converts the light information to a readable string for debug purpose.
  10241. * @param fullDetails Supports for multiple levels of logging within scene loading
  10242. * @returns the human readable light info
  10243. */
  10244. toString(fullDetails?: boolean): string;
  10245. /** @hidden */
  10246. protected _syncParentEnabledState(): void;
  10247. /**
  10248. * Set the enabled state of this node.
  10249. * @param value - the new enabled state
  10250. */
  10251. setEnabled(value: boolean): void;
  10252. /**
  10253. * Returns the Light associated shadow generator if any.
  10254. * @return the associated shadow generator.
  10255. */
  10256. getShadowGenerator(): Nullable<IShadowGenerator>;
  10257. /**
  10258. * Returns a Vector3, the absolute light position in the World.
  10259. * @returns the world space position of the light
  10260. */
  10261. getAbsolutePosition(): Vector3;
  10262. /**
  10263. * Specifies if the light will affect the passed mesh.
  10264. * @param mesh The mesh to test against the light
  10265. * @return true the mesh is affected otherwise, false.
  10266. */
  10267. canAffectMesh(mesh: AbstractMesh): boolean;
  10268. /**
  10269. * Sort function to order lights for rendering.
  10270. * @param a First Light object to compare to second.
  10271. * @param b Second Light object to compare first.
  10272. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10273. */
  10274. static CompareLightsPriority(a: Light, b: Light): number;
  10275. /**
  10276. * Releases resources associated with this node.
  10277. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10278. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10279. */
  10280. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10281. /**
  10282. * Returns the light type ID (integer).
  10283. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10284. */
  10285. getTypeID(): number;
  10286. /**
  10287. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10288. * @returns the scaled intensity in intensity mode unit
  10289. */
  10290. getScaledIntensity(): number;
  10291. /**
  10292. * Returns a new Light object, named "name", from the current one.
  10293. * @param name The name of the cloned light
  10294. * @returns the new created light
  10295. */
  10296. clone(name: string): Nullable<Light>;
  10297. /**
  10298. * Serializes the current light into a Serialization object.
  10299. * @returns the serialized object.
  10300. */
  10301. serialize(): any;
  10302. /**
  10303. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10304. * This new light is named "name" and added to the passed scene.
  10305. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10306. * @param name The friendly name of the light
  10307. * @param scene The scene the new light will belong to
  10308. * @returns the constructor function
  10309. */
  10310. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10311. /**
  10312. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10313. * @param parsedLight The JSON representation of the light
  10314. * @param scene The scene to create the parsed light in
  10315. * @returns the created light after parsing
  10316. */
  10317. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10318. private _hookArrayForExcluded;
  10319. private _hookArrayForIncludedOnly;
  10320. private _resyncMeshes;
  10321. /**
  10322. * Forces the meshes to update their light related information in their rendering used effects
  10323. * @hidden Internal Use Only
  10324. */
  10325. _markMeshesAsLightDirty(): void;
  10326. /**
  10327. * Recomputes the cached photometric scale if needed.
  10328. */
  10329. private _computePhotometricScale;
  10330. /**
  10331. * Returns the Photometric Scale according to the light type and intensity mode.
  10332. */
  10333. private _getPhotometricScale;
  10334. /**
  10335. * Reorder the light in the scene according to their defined priority.
  10336. * @hidden Internal Use Only
  10337. */
  10338. _reorderLightsInScene(): void;
  10339. /**
  10340. * Prepares the list of defines specific to the light type.
  10341. * @param defines the list of defines
  10342. * @param lightIndex defines the index of the light for the effect
  10343. */
  10344. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10345. }
  10346. }
  10347. declare module "babylonjs/Actions/action" {
  10348. import { Observable } from "babylonjs/Misc/observable";
  10349. import { Condition } from "babylonjs/Actions/condition";
  10350. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10351. import { ActionManager } from "babylonjs/Actions/actionManager";
  10352. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10353. /**
  10354. * Interface used to define Action
  10355. */
  10356. export interface IAction {
  10357. /**
  10358. * Trigger for the action
  10359. */
  10360. trigger: number;
  10361. /** Options of the trigger */
  10362. triggerOptions: any;
  10363. /**
  10364. * Gets the trigger parameters
  10365. * @returns the trigger parameters
  10366. */
  10367. getTriggerParameter(): any;
  10368. /**
  10369. * Internal only - executes current action event
  10370. * @hidden
  10371. */
  10372. _executeCurrent(evt?: ActionEvent): void;
  10373. /**
  10374. * Serialize placeholder for child classes
  10375. * @param parent of child
  10376. * @returns the serialized object
  10377. */
  10378. serialize(parent: any): any;
  10379. /**
  10380. * Internal only
  10381. * @hidden
  10382. */
  10383. _prepare(): void;
  10384. /**
  10385. * Internal only - manager for action
  10386. * @hidden
  10387. */
  10388. _actionManager: AbstractActionManager;
  10389. /**
  10390. * Adds action to chain of actions, may be a DoNothingAction
  10391. * @param action defines the next action to execute
  10392. * @returns The action passed in
  10393. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10394. */
  10395. then(action: IAction): IAction;
  10396. }
  10397. /**
  10398. * The action to be carried out following a trigger
  10399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10400. */
  10401. export class Action implements IAction {
  10402. /** the trigger, with or without parameters, for the action */
  10403. triggerOptions: any;
  10404. /**
  10405. * Trigger for the action
  10406. */
  10407. trigger: number;
  10408. /**
  10409. * Internal only - manager for action
  10410. * @hidden
  10411. */
  10412. _actionManager: ActionManager;
  10413. private _nextActiveAction;
  10414. private _child;
  10415. private _condition?;
  10416. private _triggerParameter;
  10417. /**
  10418. * An event triggered prior to action being executed.
  10419. */
  10420. onBeforeExecuteObservable: Observable<Action>;
  10421. /**
  10422. * Creates a new Action
  10423. * @param triggerOptions the trigger, with or without parameters, for the action
  10424. * @param condition an optional determinant of action
  10425. */
  10426. constructor(
  10427. /** the trigger, with or without parameters, for the action */
  10428. triggerOptions: any, condition?: Condition);
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. _prepare(): void;
  10434. /**
  10435. * Gets the trigger parameters
  10436. * @returns the trigger parameters
  10437. */
  10438. getTriggerParameter(): any;
  10439. /**
  10440. * Internal only - executes current action event
  10441. * @hidden
  10442. */
  10443. _executeCurrent(evt?: ActionEvent): void;
  10444. /**
  10445. * Execute placeholder for child classes
  10446. * @param evt optional action event
  10447. */
  10448. execute(evt?: ActionEvent): void;
  10449. /**
  10450. * Skips to next active action
  10451. */
  10452. skipToNextActiveAction(): void;
  10453. /**
  10454. * Adds action to chain of actions, may be a DoNothingAction
  10455. * @param action defines the next action to execute
  10456. * @returns The action passed in
  10457. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10458. */
  10459. then(action: Action): Action;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _getProperty(propertyPath: string): string;
  10465. /**
  10466. * Internal only
  10467. * @hidden
  10468. */
  10469. _getEffectiveTarget(target: any, propertyPath: string): any;
  10470. /**
  10471. * Serialize placeholder for child classes
  10472. * @param parent of child
  10473. * @returns the serialized object
  10474. */
  10475. serialize(parent: any): any;
  10476. /**
  10477. * Internal only called by serialize
  10478. * @hidden
  10479. */
  10480. protected _serialize(serializedAction: any, parent?: any): any;
  10481. /**
  10482. * Internal only
  10483. * @hidden
  10484. */
  10485. static _SerializeValueAsString: (value: any) => string;
  10486. /**
  10487. * Internal only
  10488. * @hidden
  10489. */
  10490. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10491. name: string;
  10492. targetType: string;
  10493. value: string;
  10494. };
  10495. }
  10496. }
  10497. declare module "babylonjs/Actions/condition" {
  10498. import { ActionManager } from "babylonjs/Actions/actionManager";
  10499. /**
  10500. * A Condition applied to an Action
  10501. */
  10502. export class Condition {
  10503. /**
  10504. * Internal only - manager for action
  10505. * @hidden
  10506. */
  10507. _actionManager: ActionManager;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */
  10512. _evaluationId: number;
  10513. /**
  10514. * Internal only
  10515. * @hidden
  10516. */
  10517. _currentResult: boolean;
  10518. /**
  10519. * Creates a new Condition
  10520. * @param actionManager the manager of the action the condition is applied to
  10521. */
  10522. constructor(actionManager: ActionManager);
  10523. /**
  10524. * Check if the current condition is valid
  10525. * @returns a boolean
  10526. */
  10527. isValid(): boolean;
  10528. /**
  10529. * Internal only
  10530. * @hidden
  10531. */
  10532. _getProperty(propertyPath: string): string;
  10533. /**
  10534. * Internal only
  10535. * @hidden
  10536. */
  10537. _getEffectiveTarget(target: any, propertyPath: string): any;
  10538. /**
  10539. * Serialize placeholder for child classes
  10540. * @returns the serialized object
  10541. */
  10542. serialize(): any;
  10543. /**
  10544. * Internal only
  10545. * @hidden
  10546. */
  10547. protected _serialize(serializedCondition: any): any;
  10548. }
  10549. /**
  10550. * Defines specific conditional operators as extensions of Condition
  10551. */
  10552. export class ValueCondition extends Condition {
  10553. /** path to specify the property of the target the conditional operator uses */
  10554. propertyPath: string;
  10555. /** the value compared by the conditional operator against the current value of the property */
  10556. value: any;
  10557. /** the conditional operator, default ValueCondition.IsEqual */
  10558. operator: number;
  10559. /**
  10560. * Internal only
  10561. * @hidden
  10562. */
  10563. private static _IsEqual;
  10564. /**
  10565. * Internal only
  10566. * @hidden
  10567. */
  10568. private static _IsDifferent;
  10569. /**
  10570. * Internal only
  10571. * @hidden
  10572. */
  10573. private static _IsGreater;
  10574. /**
  10575. * Internal only
  10576. * @hidden
  10577. */
  10578. private static _IsLesser;
  10579. /**
  10580. * returns the number for IsEqual
  10581. */
  10582. static readonly IsEqual: number;
  10583. /**
  10584. * Returns the number for IsDifferent
  10585. */
  10586. static readonly IsDifferent: number;
  10587. /**
  10588. * Returns the number for IsGreater
  10589. */
  10590. static readonly IsGreater: number;
  10591. /**
  10592. * Returns the number for IsLesser
  10593. */
  10594. static readonly IsLesser: number;
  10595. /**
  10596. * Internal only The action manager for the condition
  10597. * @hidden
  10598. */
  10599. _actionManager: ActionManager;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. private _target;
  10605. /**
  10606. * Internal only
  10607. * @hidden
  10608. */
  10609. private _effectiveTarget;
  10610. /**
  10611. * Internal only
  10612. * @hidden
  10613. */
  10614. private _property;
  10615. /**
  10616. * Creates a new ValueCondition
  10617. * @param actionManager manager for the action the condition applies to
  10618. * @param target for the action
  10619. * @param propertyPath path to specify the property of the target the conditional operator uses
  10620. * @param value the value compared by the conditional operator against the current value of the property
  10621. * @param operator the conditional operator, default ValueCondition.IsEqual
  10622. */
  10623. constructor(actionManager: ActionManager, target: any,
  10624. /** path to specify the property of the target the conditional operator uses */
  10625. propertyPath: string,
  10626. /** the value compared by the conditional operator against the current value of the property */
  10627. value: any,
  10628. /** the conditional operator, default ValueCondition.IsEqual */
  10629. operator?: number);
  10630. /**
  10631. * Compares the given value with the property value for the specified conditional operator
  10632. * @returns the result of the comparison
  10633. */
  10634. isValid(): boolean;
  10635. /**
  10636. * Serialize the ValueCondition into a JSON compatible object
  10637. * @returns serialization object
  10638. */
  10639. serialize(): any;
  10640. /**
  10641. * Gets the name of the conditional operator for the ValueCondition
  10642. * @param operator the conditional operator
  10643. * @returns the name
  10644. */
  10645. static GetOperatorName(operator: number): string;
  10646. }
  10647. /**
  10648. * Defines a predicate condition as an extension of Condition
  10649. */
  10650. export class PredicateCondition extends Condition {
  10651. /** defines the predicate function used to validate the condition */
  10652. predicate: () => boolean;
  10653. /**
  10654. * Internal only - manager for action
  10655. * @hidden
  10656. */
  10657. _actionManager: ActionManager;
  10658. /**
  10659. * Creates a new PredicateCondition
  10660. * @param actionManager manager for the action the condition applies to
  10661. * @param predicate defines the predicate function used to validate the condition
  10662. */
  10663. constructor(actionManager: ActionManager,
  10664. /** defines the predicate function used to validate the condition */
  10665. predicate: () => boolean);
  10666. /**
  10667. * @returns the validity of the predicate condition
  10668. */
  10669. isValid(): boolean;
  10670. }
  10671. /**
  10672. * Defines a state condition as an extension of Condition
  10673. */
  10674. export class StateCondition extends Condition {
  10675. /** Value to compare with target state */
  10676. value: string;
  10677. /**
  10678. * Internal only - manager for action
  10679. * @hidden
  10680. */
  10681. _actionManager: ActionManager;
  10682. /**
  10683. * Internal only
  10684. * @hidden
  10685. */
  10686. private _target;
  10687. /**
  10688. * Creates a new StateCondition
  10689. * @param actionManager manager for the action the condition applies to
  10690. * @param target of the condition
  10691. * @param value to compare with target state
  10692. */
  10693. constructor(actionManager: ActionManager, target: any,
  10694. /** Value to compare with target state */
  10695. value: string);
  10696. /**
  10697. * Gets a boolean indicating if the current condition is met
  10698. * @returns the validity of the state
  10699. */
  10700. isValid(): boolean;
  10701. /**
  10702. * Serialize the StateCondition into a JSON compatible object
  10703. * @returns serialization object
  10704. */
  10705. serialize(): any;
  10706. }
  10707. }
  10708. declare module "babylonjs/Actions/directActions" {
  10709. import { Action } from "babylonjs/Actions/action";
  10710. import { Condition } from "babylonjs/Actions/condition";
  10711. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10712. /**
  10713. * This defines an action responsible to toggle a boolean once triggered.
  10714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10715. */
  10716. export class SwitchBooleanAction extends Action {
  10717. /**
  10718. * The path to the boolean property in the target object
  10719. */
  10720. propertyPath: string;
  10721. private _target;
  10722. private _effectiveTarget;
  10723. private _property;
  10724. /**
  10725. * Instantiate the action
  10726. * @param triggerOptions defines the trigger options
  10727. * @param target defines the object containing the boolean
  10728. * @param propertyPath defines the path to the boolean property in the target object
  10729. * @param condition defines the trigger related conditions
  10730. */
  10731. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10732. /** @hidden */
  10733. _prepare(): void;
  10734. /**
  10735. * Execute the action toggle the boolean value.
  10736. */
  10737. execute(): void;
  10738. /**
  10739. * Serializes the actions and its related information.
  10740. * @param parent defines the object to serialize in
  10741. * @returns the serialized object
  10742. */
  10743. serialize(parent: any): any;
  10744. }
  10745. /**
  10746. * This defines an action responsible to set a the state field of the target
  10747. * to a desired value once triggered.
  10748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10749. */
  10750. export class SetStateAction extends Action {
  10751. /**
  10752. * The value to store in the state field.
  10753. */
  10754. value: string;
  10755. private _target;
  10756. /**
  10757. * Instantiate the action
  10758. * @param triggerOptions defines the trigger options
  10759. * @param target defines the object containing the state property
  10760. * @param value defines the value to store in the state field
  10761. * @param condition defines the trigger related conditions
  10762. */
  10763. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10764. /**
  10765. * Execute the action and store the value on the target state property.
  10766. */
  10767. execute(): void;
  10768. /**
  10769. * Serializes the actions and its related information.
  10770. * @param parent defines the object to serialize in
  10771. * @returns the serialized object
  10772. */
  10773. serialize(parent: any): any;
  10774. }
  10775. /**
  10776. * This defines an action responsible to set a property of the target
  10777. * to a desired value once triggered.
  10778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10779. */
  10780. export class SetValueAction extends Action {
  10781. /**
  10782. * The path of the property to set in the target.
  10783. */
  10784. propertyPath: string;
  10785. /**
  10786. * The value to set in the property
  10787. */
  10788. value: any;
  10789. private _target;
  10790. private _effectiveTarget;
  10791. private _property;
  10792. /**
  10793. * Instantiate the action
  10794. * @param triggerOptions defines the trigger options
  10795. * @param target defines the object containing the property
  10796. * @param propertyPath defines the path of the property to set in the target
  10797. * @param value defines the value to set in the property
  10798. * @param condition defines the trigger related conditions
  10799. */
  10800. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10801. /** @hidden */
  10802. _prepare(): void;
  10803. /**
  10804. * Execute the action and set the targetted property to the desired value.
  10805. */
  10806. execute(): void;
  10807. /**
  10808. * Serializes the actions and its related information.
  10809. * @param parent defines the object to serialize in
  10810. * @returns the serialized object
  10811. */
  10812. serialize(parent: any): any;
  10813. }
  10814. /**
  10815. * This defines an action responsible to increment the target value
  10816. * to a desired value once triggered.
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10818. */
  10819. export class IncrementValueAction extends Action {
  10820. /**
  10821. * The path of the property to increment in the target.
  10822. */
  10823. propertyPath: string;
  10824. /**
  10825. * The value we should increment the property by.
  10826. */
  10827. value: any;
  10828. private _target;
  10829. private _effectiveTarget;
  10830. private _property;
  10831. /**
  10832. * Instantiate the action
  10833. * @param triggerOptions defines the trigger options
  10834. * @param target defines the object containing the property
  10835. * @param propertyPath defines the path of the property to increment in the target
  10836. * @param value defines the value value we should increment the property by
  10837. * @param condition defines the trigger related conditions
  10838. */
  10839. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10840. /** @hidden */
  10841. _prepare(): void;
  10842. /**
  10843. * Execute the action and increment the target of the value amount.
  10844. */
  10845. execute(): void;
  10846. /**
  10847. * Serializes the actions and its related information.
  10848. * @param parent defines the object to serialize in
  10849. * @returns the serialized object
  10850. */
  10851. serialize(parent: any): any;
  10852. }
  10853. /**
  10854. * This defines an action responsible to start an animation once triggered.
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10856. */
  10857. export class PlayAnimationAction extends Action {
  10858. /**
  10859. * Where the animation should start (animation frame)
  10860. */
  10861. from: number;
  10862. /**
  10863. * Where the animation should stop (animation frame)
  10864. */
  10865. to: number;
  10866. /**
  10867. * Define if the animation should loop or stop after the first play.
  10868. */
  10869. loop?: boolean;
  10870. private _target;
  10871. /**
  10872. * Instantiate the action
  10873. * @param triggerOptions defines the trigger options
  10874. * @param target defines the target animation or animation name
  10875. * @param from defines from where the animation should start (animation frame)
  10876. * @param end defines where the animation should stop (animation frame)
  10877. * @param loop defines if the animation should loop or stop after the first play
  10878. * @param condition defines the trigger related conditions
  10879. */
  10880. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10881. /** @hidden */
  10882. _prepare(): void;
  10883. /**
  10884. * Execute the action and play the animation.
  10885. */
  10886. execute(): void;
  10887. /**
  10888. * Serializes the actions and its related information.
  10889. * @param parent defines the object to serialize in
  10890. * @returns the serialized object
  10891. */
  10892. serialize(parent: any): any;
  10893. }
  10894. /**
  10895. * This defines an action responsible to stop an animation once triggered.
  10896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10897. */
  10898. export class StopAnimationAction extends Action {
  10899. private _target;
  10900. /**
  10901. * Instantiate the action
  10902. * @param triggerOptions defines the trigger options
  10903. * @param target defines the target animation or animation name
  10904. * @param condition defines the trigger related conditions
  10905. */
  10906. constructor(triggerOptions: any, target: any, condition?: Condition);
  10907. /** @hidden */
  10908. _prepare(): void;
  10909. /**
  10910. * Execute the action and stop the animation.
  10911. */
  10912. execute(): void;
  10913. /**
  10914. * Serializes the actions and its related information.
  10915. * @param parent defines the object to serialize in
  10916. * @returns the serialized object
  10917. */
  10918. serialize(parent: any): any;
  10919. }
  10920. /**
  10921. * This defines an action responsible that does nothing once triggered.
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10923. */
  10924. export class DoNothingAction extends Action {
  10925. /**
  10926. * Instantiate the action
  10927. * @param triggerOptions defines the trigger options
  10928. * @param condition defines the trigger related conditions
  10929. */
  10930. constructor(triggerOptions?: any, condition?: Condition);
  10931. /**
  10932. * Execute the action and do nothing.
  10933. */
  10934. execute(): void;
  10935. /**
  10936. * Serializes the actions and its related information.
  10937. * @param parent defines the object to serialize in
  10938. * @returns the serialized object
  10939. */
  10940. serialize(parent: any): any;
  10941. }
  10942. /**
  10943. * This defines an action responsible to trigger several actions once triggered.
  10944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10945. */
  10946. export class CombineAction extends Action {
  10947. /**
  10948. * The list of aggregated animations to run.
  10949. */
  10950. children: Action[];
  10951. /**
  10952. * Instantiate the action
  10953. * @param triggerOptions defines the trigger options
  10954. * @param children defines the list of aggregated animations to run
  10955. * @param condition defines the trigger related conditions
  10956. */
  10957. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10958. /** @hidden */
  10959. _prepare(): void;
  10960. /**
  10961. * Execute the action and executes all the aggregated actions.
  10962. */
  10963. execute(evt: ActionEvent): void;
  10964. /**
  10965. * Serializes the actions and its related information.
  10966. * @param parent defines the object to serialize in
  10967. * @returns the serialized object
  10968. */
  10969. serialize(parent: any): any;
  10970. }
  10971. /**
  10972. * This defines an action responsible to run code (external event) once triggered.
  10973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10974. */
  10975. export class ExecuteCodeAction extends Action {
  10976. /**
  10977. * The callback function to run.
  10978. */
  10979. func: (evt: ActionEvent) => void;
  10980. /**
  10981. * Instantiate the action
  10982. * @param triggerOptions defines the trigger options
  10983. * @param func defines the callback function to run
  10984. * @param condition defines the trigger related conditions
  10985. */
  10986. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10987. /**
  10988. * Execute the action and run the attached code.
  10989. */
  10990. execute(evt: ActionEvent): void;
  10991. }
  10992. /**
  10993. * This defines an action responsible to set the parent property of the target once triggered.
  10994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10995. */
  10996. export class SetParentAction extends Action {
  10997. private _parent;
  10998. private _target;
  10999. /**
  11000. * Instantiate the action
  11001. * @param triggerOptions defines the trigger options
  11002. * @param target defines the target containing the parent property
  11003. * @param parent defines from where the animation should start (animation frame)
  11004. * @param condition defines the trigger related conditions
  11005. */
  11006. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11007. /** @hidden */
  11008. _prepare(): void;
  11009. /**
  11010. * Execute the action and set the parent property.
  11011. */
  11012. execute(): void;
  11013. /**
  11014. * Serializes the actions and its related information.
  11015. * @param parent defines the object to serialize in
  11016. * @returns the serialized object
  11017. */
  11018. serialize(parent: any): any;
  11019. }
  11020. }
  11021. declare module "babylonjs/Actions/actionManager" {
  11022. import { Nullable } from "babylonjs/types";
  11023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11024. import { Scene } from "babylonjs/scene";
  11025. import { IAction } from "babylonjs/Actions/action";
  11026. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11027. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11028. /**
  11029. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11030. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11032. */
  11033. export class ActionManager extends AbstractActionManager {
  11034. /**
  11035. * Nothing
  11036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11037. */
  11038. static readonly NothingTrigger: number;
  11039. /**
  11040. * On pick
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11042. */
  11043. static readonly OnPickTrigger: number;
  11044. /**
  11045. * On left pick
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnLeftPickTrigger: number;
  11049. /**
  11050. * On right pick
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnRightPickTrigger: number;
  11054. /**
  11055. * On center pick
  11056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11057. */
  11058. static readonly OnCenterPickTrigger: number;
  11059. /**
  11060. * On pick down
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11062. */
  11063. static readonly OnPickDownTrigger: number;
  11064. /**
  11065. * On double pick
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnDoublePickTrigger: number;
  11069. /**
  11070. * On pick up
  11071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11072. */
  11073. static readonly OnPickUpTrigger: number;
  11074. /**
  11075. * On pick out.
  11076. * This trigger will only be raised if you also declared a OnPickDown
  11077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11078. */
  11079. static readonly OnPickOutTrigger: number;
  11080. /**
  11081. * On long press
  11082. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11083. */
  11084. static readonly OnLongPressTrigger: number;
  11085. /**
  11086. * On pointer over
  11087. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11088. */
  11089. static readonly OnPointerOverTrigger: number;
  11090. /**
  11091. * On pointer out
  11092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11093. */
  11094. static readonly OnPointerOutTrigger: number;
  11095. /**
  11096. * On every frame
  11097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11098. */
  11099. static readonly OnEveryFrameTrigger: number;
  11100. /**
  11101. * On intersection enter
  11102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11103. */
  11104. static readonly OnIntersectionEnterTrigger: number;
  11105. /**
  11106. * On intersection exit
  11107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11108. */
  11109. static readonly OnIntersectionExitTrigger: number;
  11110. /**
  11111. * On key down
  11112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11113. */
  11114. static readonly OnKeyDownTrigger: number;
  11115. /**
  11116. * On key up
  11117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11118. */
  11119. static readonly OnKeyUpTrigger: number;
  11120. private _scene;
  11121. /**
  11122. * Creates a new action manager
  11123. * @param scene defines the hosting scene
  11124. */
  11125. constructor(scene: Scene);
  11126. /**
  11127. * Releases all associated resources
  11128. */
  11129. dispose(): void;
  11130. /**
  11131. * Gets hosting scene
  11132. * @returns the hosting scene
  11133. */
  11134. getScene(): Scene;
  11135. /**
  11136. * Does this action manager handles actions of any of the given triggers
  11137. * @param triggers defines the triggers to be tested
  11138. * @return a boolean indicating whether one (or more) of the triggers is handled
  11139. */
  11140. hasSpecificTriggers(triggers: number[]): boolean;
  11141. /**
  11142. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11143. * speed.
  11144. * @param triggerA defines the trigger to be tested
  11145. * @param triggerB defines the trigger to be tested
  11146. * @return a boolean indicating whether one (or more) of the triggers is handled
  11147. */
  11148. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11149. /**
  11150. * Does this action manager handles actions of a given trigger
  11151. * @param trigger defines the trigger to be tested
  11152. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11153. * @return whether the trigger is handled
  11154. */
  11155. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11156. /**
  11157. * Does this action manager has pointer triggers
  11158. */
  11159. readonly hasPointerTriggers: boolean;
  11160. /**
  11161. * Does this action manager has pick triggers
  11162. */
  11163. readonly hasPickTriggers: boolean;
  11164. /**
  11165. * Registers an action to this action manager
  11166. * @param action defines the action to be registered
  11167. * @return the action amended (prepared) after registration
  11168. */
  11169. registerAction(action: IAction): Nullable<IAction>;
  11170. /**
  11171. * Unregisters an action to this action manager
  11172. * @param action defines the action to be unregistered
  11173. * @return a boolean indicating whether the action has been unregistered
  11174. */
  11175. unregisterAction(action: IAction): Boolean;
  11176. /**
  11177. * Process a specific trigger
  11178. * @param trigger defines the trigger to process
  11179. * @param evt defines the event details to be processed
  11180. */
  11181. processTrigger(trigger: number, evt?: IActionEvent): void;
  11182. /** @hidden */
  11183. _getEffectiveTarget(target: any, propertyPath: string): any;
  11184. /** @hidden */
  11185. _getProperty(propertyPath: string): string;
  11186. /**
  11187. * Serialize this manager to a JSON object
  11188. * @param name defines the property name to store this manager
  11189. * @returns a JSON representation of this manager
  11190. */
  11191. serialize(name: string): any;
  11192. /**
  11193. * Creates a new ActionManager from a JSON data
  11194. * @param parsedActions defines the JSON data to read from
  11195. * @param object defines the hosting mesh
  11196. * @param scene defines the hosting scene
  11197. */
  11198. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11199. /**
  11200. * Get a trigger name by index
  11201. * @param trigger defines the trigger index
  11202. * @returns a trigger name
  11203. */
  11204. static GetTriggerName(trigger: number): string;
  11205. }
  11206. }
  11207. declare module "babylonjs/Culling/ray" {
  11208. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11209. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11211. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11212. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11213. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11214. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11215. import { Plane } from "babylonjs/Maths/math.plane";
  11216. /**
  11217. * Class representing a ray with position and direction
  11218. */
  11219. export class Ray {
  11220. /** origin point */
  11221. origin: Vector3;
  11222. /** direction */
  11223. direction: Vector3;
  11224. /** length of the ray */
  11225. length: number;
  11226. private static readonly TmpVector3;
  11227. private _tmpRay;
  11228. /**
  11229. * Creates a new ray
  11230. * @param origin origin point
  11231. * @param direction direction
  11232. * @param length length of the ray
  11233. */
  11234. constructor(
  11235. /** origin point */
  11236. origin: Vector3,
  11237. /** direction */
  11238. direction: Vector3,
  11239. /** length of the ray */
  11240. length?: number);
  11241. /**
  11242. * Checks if the ray intersects a box
  11243. * @param minimum bound of the box
  11244. * @param maximum bound of the box
  11245. * @param intersectionTreshold extra extend to be added to the box in all direction
  11246. * @returns if the box was hit
  11247. */
  11248. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11249. /**
  11250. * Checks if the ray intersects a box
  11251. * @param box the bounding box to check
  11252. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11253. * @returns if the box was hit
  11254. */
  11255. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11256. /**
  11257. * If the ray hits a sphere
  11258. * @param sphere the bounding sphere to check
  11259. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11260. * @returns true if it hits the sphere
  11261. */
  11262. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11263. /**
  11264. * If the ray hits a triange
  11265. * @param vertex0 triangle vertex
  11266. * @param vertex1 triangle vertex
  11267. * @param vertex2 triangle vertex
  11268. * @returns intersection information if hit
  11269. */
  11270. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11271. /**
  11272. * Checks if ray intersects a plane
  11273. * @param plane the plane to check
  11274. * @returns the distance away it was hit
  11275. */
  11276. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11277. /**
  11278. * Calculate the intercept of a ray on a given axis
  11279. * @param axis to check 'x' | 'y' | 'z'
  11280. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11281. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11282. */
  11283. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11284. /**
  11285. * Checks if ray intersects a mesh
  11286. * @param mesh the mesh to check
  11287. * @param fastCheck if only the bounding box should checked
  11288. * @returns picking info of the intersecton
  11289. */
  11290. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11291. /**
  11292. * Checks if ray intersects a mesh
  11293. * @param meshes the meshes to check
  11294. * @param fastCheck if only the bounding box should checked
  11295. * @param results array to store result in
  11296. * @returns Array of picking infos
  11297. */
  11298. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11299. private _comparePickingInfo;
  11300. private static smallnum;
  11301. private static rayl;
  11302. /**
  11303. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11304. * @param sega the first point of the segment to test the intersection against
  11305. * @param segb the second point of the segment to test the intersection against
  11306. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11307. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11308. */
  11309. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11310. /**
  11311. * Update the ray from viewport position
  11312. * @param x position
  11313. * @param y y position
  11314. * @param viewportWidth viewport width
  11315. * @param viewportHeight viewport height
  11316. * @param world world matrix
  11317. * @param view view matrix
  11318. * @param projection projection matrix
  11319. * @returns this ray updated
  11320. */
  11321. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11322. /**
  11323. * Creates a ray with origin and direction of 0,0,0
  11324. * @returns the new ray
  11325. */
  11326. static Zero(): Ray;
  11327. /**
  11328. * Creates a new ray from screen space and viewport
  11329. * @param x position
  11330. * @param y y position
  11331. * @param viewportWidth viewport width
  11332. * @param viewportHeight viewport height
  11333. * @param world world matrix
  11334. * @param view view matrix
  11335. * @param projection projection matrix
  11336. * @returns new ray
  11337. */
  11338. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11339. /**
  11340. * 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
  11341. * transformed to the given world matrix.
  11342. * @param origin The origin point
  11343. * @param end The end point
  11344. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11345. * @returns the new ray
  11346. */
  11347. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11348. /**
  11349. * Transforms a ray by a matrix
  11350. * @param ray ray to transform
  11351. * @param matrix matrix to apply
  11352. * @returns the resulting new ray
  11353. */
  11354. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11355. /**
  11356. * Transforms a ray by a matrix
  11357. * @param ray ray to transform
  11358. * @param matrix matrix to apply
  11359. * @param result ray to store result in
  11360. */
  11361. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11362. /**
  11363. * Unproject a ray from screen space to object space
  11364. * @param sourceX defines the screen space x coordinate to use
  11365. * @param sourceY defines the screen space y coordinate to use
  11366. * @param viewportWidth defines the current width of the viewport
  11367. * @param viewportHeight defines the current height of the viewport
  11368. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11369. * @param view defines the view matrix to use
  11370. * @param projection defines the projection matrix to use
  11371. */
  11372. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11373. }
  11374. /**
  11375. * Type used to define predicate used to select faces when a mesh intersection is detected
  11376. */
  11377. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11378. module "babylonjs/scene" {
  11379. interface Scene {
  11380. /** @hidden */
  11381. _tempPickingRay: Nullable<Ray>;
  11382. /** @hidden */
  11383. _cachedRayForTransform: Ray;
  11384. /** @hidden */
  11385. _pickWithRayInverseMatrix: Matrix;
  11386. /** @hidden */
  11387. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11388. /** @hidden */
  11389. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11390. }
  11391. }
  11392. }
  11393. declare module "babylonjs/sceneComponent" {
  11394. import { Scene } from "babylonjs/scene";
  11395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11396. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11397. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11398. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11399. import { Nullable } from "babylonjs/types";
  11400. import { Camera } from "babylonjs/Cameras/camera";
  11401. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11402. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11403. import { AbstractScene } from "babylonjs/abstractScene";
  11404. import { Mesh } from "babylonjs/Meshes/mesh";
  11405. /**
  11406. * Groups all the scene component constants in one place to ease maintenance.
  11407. * @hidden
  11408. */
  11409. export class SceneComponentConstants {
  11410. static readonly NAME_EFFECTLAYER: string;
  11411. static readonly NAME_LAYER: string;
  11412. static readonly NAME_LENSFLARESYSTEM: string;
  11413. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11414. static readonly NAME_PARTICLESYSTEM: string;
  11415. static readonly NAME_GAMEPAD: string;
  11416. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11417. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11418. static readonly NAME_DEPTHRENDERER: string;
  11419. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11420. static readonly NAME_SPRITE: string;
  11421. static readonly NAME_OUTLINERENDERER: string;
  11422. static readonly NAME_PROCEDURALTEXTURE: string;
  11423. static readonly NAME_SHADOWGENERATOR: string;
  11424. static readonly NAME_OCTREE: string;
  11425. static readonly NAME_PHYSICSENGINE: string;
  11426. static readonly NAME_AUDIO: string;
  11427. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11428. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11429. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11430. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11431. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11432. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11433. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11434. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11435. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11436. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11437. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11438. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11439. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11440. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11441. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11442. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11443. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11444. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11445. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11446. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11447. static readonly STEP_AFTERRENDER_AUDIO: number;
  11448. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11449. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11450. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11451. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11452. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11453. static readonly STEP_POINTERMOVE_SPRITE: number;
  11454. static readonly STEP_POINTERDOWN_SPRITE: number;
  11455. static readonly STEP_POINTERUP_SPRITE: number;
  11456. }
  11457. /**
  11458. * This represents a scene component.
  11459. *
  11460. * This is used to decouple the dependency the scene is having on the different workloads like
  11461. * layers, post processes...
  11462. */
  11463. export interface ISceneComponent {
  11464. /**
  11465. * The name of the component. Each component must have a unique name.
  11466. */
  11467. name: string;
  11468. /**
  11469. * The scene the component belongs to.
  11470. */
  11471. scene: Scene;
  11472. /**
  11473. * Register the component to one instance of a scene.
  11474. */
  11475. register(): void;
  11476. /**
  11477. * Rebuilds the elements related to this component in case of
  11478. * context lost for instance.
  11479. */
  11480. rebuild(): void;
  11481. /**
  11482. * Disposes the component and the associated ressources.
  11483. */
  11484. dispose(): void;
  11485. }
  11486. /**
  11487. * This represents a SERIALIZABLE scene component.
  11488. *
  11489. * This extends Scene Component to add Serialization methods on top.
  11490. */
  11491. export interface ISceneSerializableComponent extends ISceneComponent {
  11492. /**
  11493. * Adds all the elements from the container to the scene
  11494. * @param container the container holding the elements
  11495. */
  11496. addFromContainer(container: AbstractScene): void;
  11497. /**
  11498. * Removes all the elements in the container from the scene
  11499. * @param container contains the elements to remove
  11500. * @param dispose if the removed element should be disposed (default: false)
  11501. */
  11502. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11503. /**
  11504. * Serializes the component data to the specified json object
  11505. * @param serializationObject The object to serialize to
  11506. */
  11507. serialize(serializationObject: any): void;
  11508. }
  11509. /**
  11510. * Strong typing of a Mesh related stage step action
  11511. */
  11512. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11513. /**
  11514. * Strong typing of a Evaluate Sub Mesh related stage step action
  11515. */
  11516. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11517. /**
  11518. * Strong typing of a Active Mesh related stage step action
  11519. */
  11520. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11521. /**
  11522. * Strong typing of a Camera related stage step action
  11523. */
  11524. export type CameraStageAction = (camera: Camera) => void;
  11525. /**
  11526. * Strong typing of a Camera Frame buffer related stage step action
  11527. */
  11528. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11529. /**
  11530. * Strong typing of a Render Target related stage step action
  11531. */
  11532. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11533. /**
  11534. * Strong typing of a RenderingGroup related stage step action
  11535. */
  11536. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11537. /**
  11538. * Strong typing of a Mesh Render related stage step action
  11539. */
  11540. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11541. /**
  11542. * Strong typing of a simple stage step action
  11543. */
  11544. export type SimpleStageAction = () => void;
  11545. /**
  11546. * Strong typing of a render target action.
  11547. */
  11548. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11549. /**
  11550. * Strong typing of a pointer move action.
  11551. */
  11552. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11553. /**
  11554. * Strong typing of a pointer up/down action.
  11555. */
  11556. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11557. /**
  11558. * Representation of a stage in the scene (Basically a list of ordered steps)
  11559. * @hidden
  11560. */
  11561. export class Stage<T extends Function> extends Array<{
  11562. index: number;
  11563. component: ISceneComponent;
  11564. action: T;
  11565. }> {
  11566. /**
  11567. * Hide ctor from the rest of the world.
  11568. * @param items The items to add.
  11569. */
  11570. private constructor();
  11571. /**
  11572. * Creates a new Stage.
  11573. * @returns A new instance of a Stage
  11574. */
  11575. static Create<T extends Function>(): Stage<T>;
  11576. /**
  11577. * Registers a step in an ordered way in the targeted stage.
  11578. * @param index Defines the position to register the step in
  11579. * @param component Defines the component attached to the step
  11580. * @param action Defines the action to launch during the step
  11581. */
  11582. registerStep(index: number, component: ISceneComponent, action: T): void;
  11583. /**
  11584. * Clears all the steps from the stage.
  11585. */
  11586. clear(): void;
  11587. }
  11588. }
  11589. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11590. import { Nullable } from "babylonjs/types";
  11591. import { Observable } from "babylonjs/Misc/observable";
  11592. import { Scene } from "babylonjs/scene";
  11593. import { Sprite } from "babylonjs/Sprites/sprite";
  11594. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11595. import { Ray } from "babylonjs/Culling/ray";
  11596. import { Camera } from "babylonjs/Cameras/camera";
  11597. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11598. import { ISceneComponent } from "babylonjs/sceneComponent";
  11599. module "babylonjs/scene" {
  11600. interface Scene {
  11601. /** @hidden */
  11602. _pointerOverSprite: Nullable<Sprite>;
  11603. /** @hidden */
  11604. _pickedDownSprite: Nullable<Sprite>;
  11605. /** @hidden */
  11606. _tempSpritePickingRay: Nullable<Ray>;
  11607. /**
  11608. * All of the sprite managers added to this scene
  11609. * @see http://doc.babylonjs.com/babylon101/sprites
  11610. */
  11611. spriteManagers: Array<ISpriteManager>;
  11612. /**
  11613. * An event triggered when sprites rendering is about to start
  11614. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11615. */
  11616. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11617. /**
  11618. * An event triggered when sprites rendering is done
  11619. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11620. */
  11621. onAfterSpritesRenderingObservable: Observable<Scene>;
  11622. /** @hidden */
  11623. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11624. /** Launch a ray to try to pick a sprite in the scene
  11625. * @param x position on screen
  11626. * @param y position on screen
  11627. * @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
  11628. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11629. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11630. * @returns a PickingInfo
  11631. */
  11632. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11633. /** Use the given ray to pick a sprite in the scene
  11634. * @param ray The ray (in world space) to use to pick meshes
  11635. * @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
  11636. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11637. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11638. * @returns a PickingInfo
  11639. */
  11640. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11641. /** @hidden */
  11642. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11643. /** Launch a ray to try to pick sprites in the scene
  11644. * @param x position on screen
  11645. * @param y position on screen
  11646. * @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
  11647. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11648. * @returns a PickingInfo array
  11649. */
  11650. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11651. /** Use the given ray to pick sprites in the scene
  11652. * @param ray The ray (in world space) to use to pick meshes
  11653. * @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
  11654. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11655. * @returns a PickingInfo array
  11656. */
  11657. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11658. /**
  11659. * Force the sprite under the pointer
  11660. * @param sprite defines the sprite to use
  11661. */
  11662. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11663. /**
  11664. * Gets the sprite under the pointer
  11665. * @returns a Sprite or null if no sprite is under the pointer
  11666. */
  11667. getPointerOverSprite(): Nullable<Sprite>;
  11668. }
  11669. }
  11670. /**
  11671. * Defines the sprite scene component responsible to manage sprites
  11672. * in a given scene.
  11673. */
  11674. export class SpriteSceneComponent implements ISceneComponent {
  11675. /**
  11676. * The component name helpfull to identify the component in the list of scene components.
  11677. */
  11678. readonly name: string;
  11679. /**
  11680. * The scene the component belongs to.
  11681. */
  11682. scene: Scene;
  11683. /** @hidden */
  11684. private _spritePredicate;
  11685. /**
  11686. * Creates a new instance of the component for the given scene
  11687. * @param scene Defines the scene to register the component in
  11688. */
  11689. constructor(scene: Scene);
  11690. /**
  11691. * Registers the component in a given scene
  11692. */
  11693. register(): void;
  11694. /**
  11695. * Rebuilds the elements related to this component in case of
  11696. * context lost for instance.
  11697. */
  11698. rebuild(): void;
  11699. /**
  11700. * Disposes the component and the associated ressources.
  11701. */
  11702. dispose(): void;
  11703. private _pickSpriteButKeepRay;
  11704. private _pointerMove;
  11705. private _pointerDown;
  11706. private _pointerUp;
  11707. }
  11708. }
  11709. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11710. /** @hidden */
  11711. export var fogFragmentDeclaration: {
  11712. name: string;
  11713. shader: string;
  11714. };
  11715. }
  11716. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11717. /** @hidden */
  11718. export var fogFragment: {
  11719. name: string;
  11720. shader: string;
  11721. };
  11722. }
  11723. declare module "babylonjs/Shaders/sprites.fragment" {
  11724. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11725. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11726. /** @hidden */
  11727. export var spritesPixelShader: {
  11728. name: string;
  11729. shader: string;
  11730. };
  11731. }
  11732. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11733. /** @hidden */
  11734. export var fogVertexDeclaration: {
  11735. name: string;
  11736. shader: string;
  11737. };
  11738. }
  11739. declare module "babylonjs/Shaders/sprites.vertex" {
  11740. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11741. /** @hidden */
  11742. export var spritesVertexShader: {
  11743. name: string;
  11744. shader: string;
  11745. };
  11746. }
  11747. declare module "babylonjs/Sprites/spriteManager" {
  11748. import { IDisposable, Scene } from "babylonjs/scene";
  11749. import { Nullable } from "babylonjs/types";
  11750. import { Observable } from "babylonjs/Misc/observable";
  11751. import { Sprite } from "babylonjs/Sprites/sprite";
  11752. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11753. import { Camera } from "babylonjs/Cameras/camera";
  11754. import { Texture } from "babylonjs/Materials/Textures/texture";
  11755. import "babylonjs/Shaders/sprites.fragment";
  11756. import "babylonjs/Shaders/sprites.vertex";
  11757. import { Ray } from "babylonjs/Culling/ray";
  11758. /**
  11759. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11760. */
  11761. export interface ISpriteManager extends IDisposable {
  11762. /**
  11763. * Restricts the camera to viewing objects with the same layerMask.
  11764. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11765. */
  11766. layerMask: number;
  11767. /**
  11768. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11769. */
  11770. isPickable: boolean;
  11771. /**
  11772. * Specifies the rendering group id for this mesh (0 by default)
  11773. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11774. */
  11775. renderingGroupId: number;
  11776. /**
  11777. * Defines the list of sprites managed by the manager.
  11778. */
  11779. sprites: Array<Sprite>;
  11780. /**
  11781. * Tests the intersection of a sprite with a specific ray.
  11782. * @param ray The ray we are sending to test the collision
  11783. * @param camera The camera space we are sending rays in
  11784. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11785. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11786. * @returns picking info or null.
  11787. */
  11788. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11789. /**
  11790. * Intersects the sprites with a ray
  11791. * @param ray defines the ray to intersect with
  11792. * @param camera defines the current active camera
  11793. * @param predicate defines a predicate used to select candidate sprites
  11794. * @returns null if no hit or a PickingInfo array
  11795. */
  11796. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11797. /**
  11798. * Renders the list of sprites on screen.
  11799. */
  11800. render(): void;
  11801. }
  11802. /**
  11803. * Class used to manage multiple sprites on the same spritesheet
  11804. * @see http://doc.babylonjs.com/babylon101/sprites
  11805. */
  11806. export class SpriteManager implements ISpriteManager {
  11807. /** defines the manager's name */
  11808. name: string;
  11809. /** Gets the list of sprites */
  11810. sprites: Sprite[];
  11811. /** Gets or sets the rendering group id (0 by default) */
  11812. renderingGroupId: number;
  11813. /** Gets or sets camera layer mask */
  11814. layerMask: number;
  11815. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11816. fogEnabled: boolean;
  11817. /** Gets or sets a boolean indicating if the sprites are pickable */
  11818. isPickable: boolean;
  11819. /** Defines the default width of a cell in the spritesheet */
  11820. cellWidth: number;
  11821. /** Defines the default height of a cell in the spritesheet */
  11822. cellHeight: number;
  11823. /** Associative array from JSON sprite data file */
  11824. private _cellData;
  11825. /** Array of sprite names from JSON sprite data file */
  11826. private _spriteMap;
  11827. /** True when packed cell data from JSON file is ready*/
  11828. private _packedAndReady;
  11829. /**
  11830. * An event triggered when the manager is disposed.
  11831. */
  11832. onDisposeObservable: Observable<SpriteManager>;
  11833. private _onDisposeObserver;
  11834. /**
  11835. * Callback called when the manager is disposed
  11836. */
  11837. onDispose: () => void;
  11838. private _capacity;
  11839. private _fromPacked;
  11840. private _spriteTexture;
  11841. private _epsilon;
  11842. private _scene;
  11843. private _vertexData;
  11844. private _buffer;
  11845. private _vertexBuffers;
  11846. private _indexBuffer;
  11847. private _effectBase;
  11848. private _effectFog;
  11849. /**
  11850. * Gets or sets the spritesheet texture
  11851. */
  11852. texture: Texture;
  11853. /**
  11854. * Creates a new sprite manager
  11855. * @param name defines the manager's name
  11856. * @param imgUrl defines the sprite sheet url
  11857. * @param capacity defines the maximum allowed number of sprites
  11858. * @param cellSize defines the size of a sprite cell
  11859. * @param scene defines the hosting scene
  11860. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11861. * @param samplingMode defines the smapling mode to use with spritesheet
  11862. * @param fromPacked set to false; do not alter
  11863. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11864. */
  11865. constructor(
  11866. /** defines the manager's name */
  11867. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11868. private _makePacked;
  11869. private _appendSpriteVertex;
  11870. /**
  11871. * Intersects the sprites with a ray
  11872. * @param ray defines the ray to intersect with
  11873. * @param camera defines the current active camera
  11874. * @param predicate defines a predicate used to select candidate sprites
  11875. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11876. * @returns null if no hit or a PickingInfo
  11877. */
  11878. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11879. /**
  11880. * Intersects the sprites with a ray
  11881. * @param ray defines the ray to intersect with
  11882. * @param camera defines the current active camera
  11883. * @param predicate defines a predicate used to select candidate sprites
  11884. * @returns null if no hit or a PickingInfo array
  11885. */
  11886. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11887. /**
  11888. * Render all child sprites
  11889. */
  11890. render(): void;
  11891. /**
  11892. * Release associated resources
  11893. */
  11894. dispose(): void;
  11895. }
  11896. }
  11897. declare module "babylonjs/Sprites/sprite" {
  11898. import { Vector3 } from "babylonjs/Maths/math.vector";
  11899. import { Nullable } from "babylonjs/types";
  11900. import { ActionManager } from "babylonjs/Actions/actionManager";
  11901. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11902. import { Color4 } from "babylonjs/Maths/math.color";
  11903. /**
  11904. * Class used to represent a sprite
  11905. * @see http://doc.babylonjs.com/babylon101/sprites
  11906. */
  11907. export class Sprite {
  11908. /** defines the name */
  11909. name: string;
  11910. /** Gets or sets the current world position */
  11911. position: Vector3;
  11912. /** Gets or sets the main color */
  11913. color: Color4;
  11914. /** Gets or sets the width */
  11915. width: number;
  11916. /** Gets or sets the height */
  11917. height: number;
  11918. /** Gets or sets rotation angle */
  11919. angle: number;
  11920. /** Gets or sets the cell index in the sprite sheet */
  11921. cellIndex: number;
  11922. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11923. cellRef: string;
  11924. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11925. invertU: number;
  11926. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11927. invertV: number;
  11928. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11929. disposeWhenFinishedAnimating: boolean;
  11930. /** Gets the list of attached animations */
  11931. animations: Animation[];
  11932. /** Gets or sets a boolean indicating if the sprite can be picked */
  11933. isPickable: boolean;
  11934. /**
  11935. * Gets or sets the associated action manager
  11936. */
  11937. actionManager: Nullable<ActionManager>;
  11938. private _animationStarted;
  11939. private _loopAnimation;
  11940. private _fromIndex;
  11941. private _toIndex;
  11942. private _delay;
  11943. private _direction;
  11944. private _manager;
  11945. private _time;
  11946. private _onAnimationEnd;
  11947. /**
  11948. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11949. */
  11950. isVisible: boolean;
  11951. /**
  11952. * Gets or sets the sprite size
  11953. */
  11954. size: number;
  11955. /**
  11956. * Creates a new Sprite
  11957. * @param name defines the name
  11958. * @param manager defines the manager
  11959. */
  11960. constructor(
  11961. /** defines the name */
  11962. name: string, manager: ISpriteManager);
  11963. /**
  11964. * Starts an animation
  11965. * @param from defines the initial key
  11966. * @param to defines the end key
  11967. * @param loop defines if the animation must loop
  11968. * @param delay defines the start delay (in ms)
  11969. * @param onAnimationEnd defines a callback to call when animation ends
  11970. */
  11971. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11972. /** Stops current animation (if any) */
  11973. stopAnimation(): void;
  11974. /** @hidden */
  11975. _animate(deltaTime: number): void;
  11976. /** Release associated resources */
  11977. dispose(): void;
  11978. }
  11979. }
  11980. declare module "babylonjs/Collisions/pickingInfo" {
  11981. import { Nullable } from "babylonjs/types";
  11982. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11984. import { Sprite } from "babylonjs/Sprites/sprite";
  11985. import { Ray } from "babylonjs/Culling/ray";
  11986. /**
  11987. * Information about the result of picking within a scene
  11988. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11989. */
  11990. export class PickingInfo {
  11991. /** @hidden */
  11992. _pickingUnavailable: boolean;
  11993. /**
  11994. * If the pick collided with an object
  11995. */
  11996. hit: boolean;
  11997. /**
  11998. * Distance away where the pick collided
  11999. */
  12000. distance: number;
  12001. /**
  12002. * The location of pick collision
  12003. */
  12004. pickedPoint: Nullable<Vector3>;
  12005. /**
  12006. * The mesh corresponding the the pick collision
  12007. */
  12008. pickedMesh: Nullable<AbstractMesh>;
  12009. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12010. bu: number;
  12011. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12012. bv: number;
  12013. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12014. faceId: number;
  12015. /** Id of the the submesh that was picked */
  12016. subMeshId: number;
  12017. /** If a sprite was picked, this will be the sprite the pick collided with */
  12018. pickedSprite: Nullable<Sprite>;
  12019. /**
  12020. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12021. */
  12022. originMesh: Nullable<AbstractMesh>;
  12023. /**
  12024. * The ray that was used to perform the picking.
  12025. */
  12026. ray: Nullable<Ray>;
  12027. /**
  12028. * Gets the normal correspodning to the face the pick collided with
  12029. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12030. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12031. * @returns The normal correspodning to the face the pick collided with
  12032. */
  12033. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12034. /**
  12035. * Gets the texture coordinates of where the pick occured
  12036. * @returns the vector containing the coordnates of the texture
  12037. */
  12038. getTextureCoordinates(): Nullable<Vector2>;
  12039. }
  12040. }
  12041. declare module "babylonjs/Events/pointerEvents" {
  12042. import { Nullable } from "babylonjs/types";
  12043. import { Vector2 } from "babylonjs/Maths/math.vector";
  12044. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12045. import { Ray } from "babylonjs/Culling/ray";
  12046. /**
  12047. * Gather the list of pointer event types as constants.
  12048. */
  12049. export class PointerEventTypes {
  12050. /**
  12051. * 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.
  12052. */
  12053. static readonly POINTERDOWN: number;
  12054. /**
  12055. * The pointerup event is fired when a pointer is no longer active.
  12056. */
  12057. static readonly POINTERUP: number;
  12058. /**
  12059. * The pointermove event is fired when a pointer changes coordinates.
  12060. */
  12061. static readonly POINTERMOVE: number;
  12062. /**
  12063. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12064. */
  12065. static readonly POINTERWHEEL: number;
  12066. /**
  12067. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12068. */
  12069. static readonly POINTERPICK: number;
  12070. /**
  12071. * The pointertap event is fired when a the object has been touched and released without drag.
  12072. */
  12073. static readonly POINTERTAP: number;
  12074. /**
  12075. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12076. */
  12077. static readonly POINTERDOUBLETAP: number;
  12078. }
  12079. /**
  12080. * Base class of pointer info types.
  12081. */
  12082. export class PointerInfoBase {
  12083. /**
  12084. * Defines the type of event (PointerEventTypes)
  12085. */
  12086. type: number;
  12087. /**
  12088. * Defines the related dom event
  12089. */
  12090. event: PointerEvent | MouseWheelEvent;
  12091. /**
  12092. * Instantiates the base class of pointers info.
  12093. * @param type Defines the type of event (PointerEventTypes)
  12094. * @param event Defines the related dom event
  12095. */
  12096. constructor(
  12097. /**
  12098. * Defines the type of event (PointerEventTypes)
  12099. */
  12100. type: number,
  12101. /**
  12102. * Defines the related dom event
  12103. */
  12104. event: PointerEvent | MouseWheelEvent);
  12105. }
  12106. /**
  12107. * This class is used to store pointer related info for the onPrePointerObservable event.
  12108. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12109. */
  12110. export class PointerInfoPre extends PointerInfoBase {
  12111. /**
  12112. * Ray from a pointer if availible (eg. 6dof controller)
  12113. */
  12114. ray: Nullable<Ray>;
  12115. /**
  12116. * Defines the local position of the pointer on the canvas.
  12117. */
  12118. localPosition: Vector2;
  12119. /**
  12120. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12121. */
  12122. skipOnPointerObservable: boolean;
  12123. /**
  12124. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12125. * @param type Defines the type of event (PointerEventTypes)
  12126. * @param event Defines the related dom event
  12127. * @param localX Defines the local x coordinates of the pointer when the event occured
  12128. * @param localY Defines the local y coordinates of the pointer when the event occured
  12129. */
  12130. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12131. }
  12132. /**
  12133. * This type contains all the data related to a pointer event in Babylon.js.
  12134. * 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.
  12135. */
  12136. export class PointerInfo extends PointerInfoBase {
  12137. /**
  12138. * Defines the picking info associated to the info (if any)\
  12139. */
  12140. pickInfo: Nullable<PickingInfo>;
  12141. /**
  12142. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12143. * @param type Defines the type of event (PointerEventTypes)
  12144. * @param event Defines the related dom event
  12145. * @param pickInfo Defines the picking info associated to the info (if any)\
  12146. */
  12147. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12148. /**
  12149. * Defines the picking info associated to the info (if any)\
  12150. */
  12151. pickInfo: Nullable<PickingInfo>);
  12152. }
  12153. /**
  12154. * Data relating to a touch event on the screen.
  12155. */
  12156. export interface PointerTouch {
  12157. /**
  12158. * X coordinate of touch.
  12159. */
  12160. x: number;
  12161. /**
  12162. * Y coordinate of touch.
  12163. */
  12164. y: number;
  12165. /**
  12166. * Id of touch. Unique for each finger.
  12167. */
  12168. pointerId: number;
  12169. /**
  12170. * Event type passed from DOM.
  12171. */
  12172. type: any;
  12173. }
  12174. }
  12175. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12176. import { Observable } from "babylonjs/Misc/observable";
  12177. import { Nullable } from "babylonjs/types";
  12178. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12179. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12180. /**
  12181. * Manage the mouse inputs to control the movement of a free camera.
  12182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12183. */
  12184. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12185. /**
  12186. * Define if touch is enabled in the mouse input
  12187. */
  12188. touchEnabled: boolean;
  12189. /**
  12190. * Defines the camera the input is attached to.
  12191. */
  12192. camera: FreeCamera;
  12193. /**
  12194. * Defines the buttons associated with the input to handle camera move.
  12195. */
  12196. buttons: number[];
  12197. /**
  12198. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12199. */
  12200. angularSensibility: number;
  12201. private _pointerInput;
  12202. private _onMouseMove;
  12203. private _observer;
  12204. private previousPosition;
  12205. /**
  12206. * Observable for when a pointer move event occurs containing the move offset
  12207. */
  12208. onPointerMovedObservable: Observable<{
  12209. offsetX: number;
  12210. offsetY: number;
  12211. }>;
  12212. /**
  12213. * @hidden
  12214. * If the camera should be rotated automatically based on pointer movement
  12215. */
  12216. _allowCameraRotation: boolean;
  12217. /**
  12218. * Manage the mouse inputs to control the movement of a free camera.
  12219. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12220. * @param touchEnabled Defines if touch is enabled or not
  12221. */
  12222. constructor(
  12223. /**
  12224. * Define if touch is enabled in the mouse input
  12225. */
  12226. touchEnabled?: boolean);
  12227. /**
  12228. * Attach the input controls to a specific dom element to get the input from.
  12229. * @param element Defines the element the controls should be listened from
  12230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12231. */
  12232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12233. /**
  12234. * Called on JS contextmenu event.
  12235. * Override this method to provide functionality.
  12236. */
  12237. protected onContextMenu(evt: PointerEvent): void;
  12238. /**
  12239. * Detach the current controls from the specified dom element.
  12240. * @param element Defines the element to stop listening the inputs from
  12241. */
  12242. detachControl(element: Nullable<HTMLElement>): void;
  12243. /**
  12244. * Gets the class name of the current intput.
  12245. * @returns the class name
  12246. */
  12247. getClassName(): string;
  12248. /**
  12249. * Get the friendly name associated with the input class.
  12250. * @returns the input friendly name
  12251. */
  12252. getSimpleName(): string;
  12253. }
  12254. }
  12255. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12256. import { Nullable } from "babylonjs/types";
  12257. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12258. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12259. /**
  12260. * Manage the touch inputs to control the movement of a free camera.
  12261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12262. */
  12263. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12264. /**
  12265. * Defines the camera the input is attached to.
  12266. */
  12267. camera: FreeCamera;
  12268. /**
  12269. * Defines the touch sensibility for rotation.
  12270. * The higher the faster.
  12271. */
  12272. touchAngularSensibility: number;
  12273. /**
  12274. * Defines the touch sensibility for move.
  12275. * The higher the faster.
  12276. */
  12277. touchMoveSensibility: number;
  12278. private _offsetX;
  12279. private _offsetY;
  12280. private _pointerPressed;
  12281. private _pointerInput;
  12282. private _observer;
  12283. private _onLostFocus;
  12284. /**
  12285. * Attach the input controls to a specific dom element to get the input from.
  12286. * @param element Defines the element the controls should be listened from
  12287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12288. */
  12289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12290. /**
  12291. * Detach the current controls from the specified dom element.
  12292. * @param element Defines the element to stop listening the inputs from
  12293. */
  12294. detachControl(element: Nullable<HTMLElement>): void;
  12295. /**
  12296. * Update the current camera state depending on the inputs that have been used this frame.
  12297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12298. */
  12299. checkInputs(): void;
  12300. /**
  12301. * Gets the class name of the current intput.
  12302. * @returns the class name
  12303. */
  12304. getClassName(): string;
  12305. /**
  12306. * Get the friendly name associated with the input class.
  12307. * @returns the input friendly name
  12308. */
  12309. getSimpleName(): string;
  12310. }
  12311. }
  12312. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12313. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12314. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12315. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12316. import { Nullable } from "babylonjs/types";
  12317. /**
  12318. * Default Inputs manager for the FreeCamera.
  12319. * It groups all the default supported inputs for ease of use.
  12320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12321. */
  12322. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12323. /**
  12324. * @hidden
  12325. */
  12326. _mouseInput: Nullable<FreeCameraMouseInput>;
  12327. /**
  12328. * Instantiates a new FreeCameraInputsManager.
  12329. * @param camera Defines the camera the inputs belong to
  12330. */
  12331. constructor(camera: FreeCamera);
  12332. /**
  12333. * Add keyboard input support to the input manager.
  12334. * @returns the current input manager
  12335. */
  12336. addKeyboard(): FreeCameraInputsManager;
  12337. /**
  12338. * Add mouse input support to the input manager.
  12339. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12340. * @returns the current input manager
  12341. */
  12342. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12343. /**
  12344. * Removes the mouse input support from the manager
  12345. * @returns the current input manager
  12346. */
  12347. removeMouse(): FreeCameraInputsManager;
  12348. /**
  12349. * Add touch input support to the input manager.
  12350. * @returns the current input manager
  12351. */
  12352. addTouch(): FreeCameraInputsManager;
  12353. /**
  12354. * Remove all attached input methods from a camera
  12355. */
  12356. clear(): void;
  12357. }
  12358. }
  12359. declare module "babylonjs/Cameras/freeCamera" {
  12360. import { Vector3 } from "babylonjs/Maths/math.vector";
  12361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12362. import { Scene } from "babylonjs/scene";
  12363. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12364. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12365. /**
  12366. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12367. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12368. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12369. */
  12370. export class FreeCamera extends TargetCamera {
  12371. /**
  12372. * Define the collision ellipsoid of the camera.
  12373. * This is helpful to simulate a camera body like the player body around the camera
  12374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12375. */
  12376. ellipsoid: Vector3;
  12377. /**
  12378. * Define an offset for the position of the ellipsoid around the camera.
  12379. * This can be helpful to determine the center of the body near the gravity center of the body
  12380. * instead of its head.
  12381. */
  12382. ellipsoidOffset: Vector3;
  12383. /**
  12384. * Enable or disable collisions of the camera with the rest of the scene objects.
  12385. */
  12386. checkCollisions: boolean;
  12387. /**
  12388. * Enable or disable gravity on the camera.
  12389. */
  12390. applyGravity: boolean;
  12391. /**
  12392. * Define the input manager associated to the camera.
  12393. */
  12394. inputs: FreeCameraInputsManager;
  12395. /**
  12396. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12397. * Higher values reduce sensitivity.
  12398. */
  12399. /**
  12400. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12401. * Higher values reduce sensitivity.
  12402. */
  12403. angularSensibility: number;
  12404. /**
  12405. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12406. */
  12407. keysUp: number[];
  12408. /**
  12409. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12410. */
  12411. keysDown: number[];
  12412. /**
  12413. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12414. */
  12415. keysLeft: number[];
  12416. /**
  12417. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12418. */
  12419. keysRight: number[];
  12420. /**
  12421. * Event raised when the camera collide with a mesh in the scene.
  12422. */
  12423. onCollide: (collidedMesh: AbstractMesh) => void;
  12424. private _collider;
  12425. private _needMoveForGravity;
  12426. private _oldPosition;
  12427. private _diffPosition;
  12428. private _newPosition;
  12429. /** @hidden */
  12430. _localDirection: Vector3;
  12431. /** @hidden */
  12432. _transformedDirection: Vector3;
  12433. /**
  12434. * Instantiates a Free Camera.
  12435. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12436. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12437. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12438. * @param name Define the name of the camera in the scene
  12439. * @param position Define the start position of the camera in the scene
  12440. * @param scene Define the scene the camera belongs to
  12441. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12442. */
  12443. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12444. /**
  12445. * Attached controls to the current camera.
  12446. * @param element Defines the element the controls should be listened from
  12447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12448. */
  12449. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12450. /**
  12451. * Detach the current controls from the camera.
  12452. * The camera will stop reacting to inputs.
  12453. * @param element Defines the element to stop listening the inputs from
  12454. */
  12455. detachControl(element: HTMLElement): void;
  12456. private _collisionMask;
  12457. /**
  12458. * Define a collision mask to limit the list of object the camera can collide with
  12459. */
  12460. collisionMask: number;
  12461. /** @hidden */
  12462. _collideWithWorld(displacement: Vector3): void;
  12463. private _onCollisionPositionChange;
  12464. /** @hidden */
  12465. _checkInputs(): void;
  12466. /** @hidden */
  12467. _decideIfNeedsToMove(): boolean;
  12468. /** @hidden */
  12469. _updatePosition(): void;
  12470. /**
  12471. * Destroy the camera and release the current resources hold by it.
  12472. */
  12473. dispose(): void;
  12474. /**
  12475. * Gets the current object class name.
  12476. * @return the class name
  12477. */
  12478. getClassName(): string;
  12479. }
  12480. }
  12481. declare module "babylonjs/Gamepads/gamepad" {
  12482. import { Observable } from "babylonjs/Misc/observable";
  12483. /**
  12484. * Represents a gamepad control stick position
  12485. */
  12486. export class StickValues {
  12487. /**
  12488. * The x component of the control stick
  12489. */
  12490. x: number;
  12491. /**
  12492. * The y component of the control stick
  12493. */
  12494. y: number;
  12495. /**
  12496. * Initializes the gamepad x and y control stick values
  12497. * @param x The x component of the gamepad control stick value
  12498. * @param y The y component of the gamepad control stick value
  12499. */
  12500. constructor(
  12501. /**
  12502. * The x component of the control stick
  12503. */
  12504. x: number,
  12505. /**
  12506. * The y component of the control stick
  12507. */
  12508. y: number);
  12509. }
  12510. /**
  12511. * An interface which manages callbacks for gamepad button changes
  12512. */
  12513. export interface GamepadButtonChanges {
  12514. /**
  12515. * Called when a gamepad has been changed
  12516. */
  12517. changed: boolean;
  12518. /**
  12519. * Called when a gamepad press event has been triggered
  12520. */
  12521. pressChanged: boolean;
  12522. /**
  12523. * Called when a touch event has been triggered
  12524. */
  12525. touchChanged: boolean;
  12526. /**
  12527. * Called when a value has changed
  12528. */
  12529. valueChanged: boolean;
  12530. }
  12531. /**
  12532. * Represents a gamepad
  12533. */
  12534. export class Gamepad {
  12535. /**
  12536. * The id of the gamepad
  12537. */
  12538. id: string;
  12539. /**
  12540. * The index of the gamepad
  12541. */
  12542. index: number;
  12543. /**
  12544. * The browser gamepad
  12545. */
  12546. browserGamepad: any;
  12547. /**
  12548. * Specifies what type of gamepad this represents
  12549. */
  12550. type: number;
  12551. private _leftStick;
  12552. private _rightStick;
  12553. /** @hidden */
  12554. _isConnected: boolean;
  12555. private _leftStickAxisX;
  12556. private _leftStickAxisY;
  12557. private _rightStickAxisX;
  12558. private _rightStickAxisY;
  12559. /**
  12560. * Triggered when the left control stick has been changed
  12561. */
  12562. private _onleftstickchanged;
  12563. /**
  12564. * Triggered when the right control stick has been changed
  12565. */
  12566. private _onrightstickchanged;
  12567. /**
  12568. * Represents a gamepad controller
  12569. */
  12570. static GAMEPAD: number;
  12571. /**
  12572. * Represents a generic controller
  12573. */
  12574. static GENERIC: number;
  12575. /**
  12576. * Represents an XBox controller
  12577. */
  12578. static XBOX: number;
  12579. /**
  12580. * Represents a pose-enabled controller
  12581. */
  12582. static POSE_ENABLED: number;
  12583. /**
  12584. * Represents an Dual Shock controller
  12585. */
  12586. static DUALSHOCK: number;
  12587. /**
  12588. * Specifies whether the left control stick should be Y-inverted
  12589. */
  12590. protected _invertLeftStickY: boolean;
  12591. /**
  12592. * Specifies if the gamepad has been connected
  12593. */
  12594. readonly isConnected: boolean;
  12595. /**
  12596. * Initializes the gamepad
  12597. * @param id The id of the gamepad
  12598. * @param index The index of the gamepad
  12599. * @param browserGamepad The browser gamepad
  12600. * @param leftStickX The x component of the left joystick
  12601. * @param leftStickY The y component of the left joystick
  12602. * @param rightStickX The x component of the right joystick
  12603. * @param rightStickY The y component of the right joystick
  12604. */
  12605. constructor(
  12606. /**
  12607. * The id of the gamepad
  12608. */
  12609. id: string,
  12610. /**
  12611. * The index of the gamepad
  12612. */
  12613. index: number,
  12614. /**
  12615. * The browser gamepad
  12616. */
  12617. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12618. /**
  12619. * Callback triggered when the left joystick has changed
  12620. * @param callback
  12621. */
  12622. onleftstickchanged(callback: (values: StickValues) => void): void;
  12623. /**
  12624. * Callback triggered when the right joystick has changed
  12625. * @param callback
  12626. */
  12627. onrightstickchanged(callback: (values: StickValues) => void): void;
  12628. /**
  12629. * Gets the left joystick
  12630. */
  12631. /**
  12632. * Sets the left joystick values
  12633. */
  12634. leftStick: StickValues;
  12635. /**
  12636. * Gets the right joystick
  12637. */
  12638. /**
  12639. * Sets the right joystick value
  12640. */
  12641. rightStick: StickValues;
  12642. /**
  12643. * Updates the gamepad joystick positions
  12644. */
  12645. update(): void;
  12646. /**
  12647. * Disposes the gamepad
  12648. */
  12649. dispose(): void;
  12650. }
  12651. /**
  12652. * Represents a generic gamepad
  12653. */
  12654. export class GenericPad extends Gamepad {
  12655. private _buttons;
  12656. private _onbuttondown;
  12657. private _onbuttonup;
  12658. /**
  12659. * Observable triggered when a button has been pressed
  12660. */
  12661. onButtonDownObservable: Observable<number>;
  12662. /**
  12663. * Observable triggered when a button has been released
  12664. */
  12665. onButtonUpObservable: Observable<number>;
  12666. /**
  12667. * Callback triggered when a button has been pressed
  12668. * @param callback Called when a button has been pressed
  12669. */
  12670. onbuttondown(callback: (buttonPressed: number) => void): void;
  12671. /**
  12672. * Callback triggered when a button has been released
  12673. * @param callback Called when a button has been released
  12674. */
  12675. onbuttonup(callback: (buttonReleased: number) => void): void;
  12676. /**
  12677. * Initializes the generic gamepad
  12678. * @param id The id of the generic gamepad
  12679. * @param index The index of the generic gamepad
  12680. * @param browserGamepad The browser gamepad
  12681. */
  12682. constructor(id: string, index: number, browserGamepad: any);
  12683. private _setButtonValue;
  12684. /**
  12685. * Updates the generic gamepad
  12686. */
  12687. update(): void;
  12688. /**
  12689. * Disposes the generic gamepad
  12690. */
  12691. dispose(): void;
  12692. }
  12693. }
  12694. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12695. import { Nullable } from "babylonjs/types";
  12696. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12697. import { Scene } from "babylonjs/scene";
  12698. module "babylonjs/Engines/engine" {
  12699. interface Engine {
  12700. /**
  12701. * Creates a raw texture
  12702. * @param data defines the data to store in the texture
  12703. * @param width defines the width of the texture
  12704. * @param height defines the height of the texture
  12705. * @param format defines the format of the data
  12706. * @param generateMipMaps defines if the engine should generate the mip levels
  12707. * @param invertY defines if data must be stored with Y axis inverted
  12708. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12709. * @param compression defines the compression used (null by default)
  12710. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12711. * @returns the raw texture inside an InternalTexture
  12712. */
  12713. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12714. /**
  12715. * Update a raw texture
  12716. * @param texture defines the texture to update
  12717. * @param data defines the data to store in the texture
  12718. * @param format defines the format of the data
  12719. * @param invertY defines if data must be stored with Y axis inverted
  12720. */
  12721. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12722. /**
  12723. * Update a raw texture
  12724. * @param texture defines the texture to update
  12725. * @param data defines the data to store in the texture
  12726. * @param format defines the format of the data
  12727. * @param invertY defines if data must be stored with Y axis inverted
  12728. * @param compression defines the compression used (null by default)
  12729. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12730. */
  12731. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12732. /**
  12733. * Creates a new raw cube texture
  12734. * @param data defines the array of data to use to create each face
  12735. * @param size defines the size of the textures
  12736. * @param format defines the format of the data
  12737. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12738. * @param generateMipMaps defines if the engine should generate the mip levels
  12739. * @param invertY defines if data must be stored with Y axis inverted
  12740. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12741. * @param compression defines the compression used (null by default)
  12742. * @returns the cube texture as an InternalTexture
  12743. */
  12744. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12745. /**
  12746. * Update a raw cube texture
  12747. * @param texture defines the texture to udpdate
  12748. * @param data defines the data to store
  12749. * @param format defines the data format
  12750. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12751. * @param invertY defines if data must be stored with Y axis inverted
  12752. */
  12753. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12754. /**
  12755. * Update a raw cube texture
  12756. * @param texture defines the texture to udpdate
  12757. * @param data defines the data to store
  12758. * @param format defines the data format
  12759. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12760. * @param invertY defines if data must be stored with Y axis inverted
  12761. * @param compression defines the compression used (null by default)
  12762. */
  12763. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12764. /**
  12765. * Update a raw cube texture
  12766. * @param texture defines the texture to udpdate
  12767. * @param data defines the data to store
  12768. * @param format defines the data format
  12769. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12770. * @param invertY defines if data must be stored with Y axis inverted
  12771. * @param compression defines the compression used (null by default)
  12772. * @param level defines which level of the texture to update
  12773. */
  12774. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12775. /**
  12776. * Creates a new raw cube texture from a specified url
  12777. * @param url defines the url where the data is located
  12778. * @param scene defines the current scene
  12779. * @param size defines the size of the textures
  12780. * @param format defines the format of the data
  12781. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12782. * @param noMipmap defines if the engine should avoid generating the mip levels
  12783. * @param callback defines a callback used to extract texture data from loaded data
  12784. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12785. * @param onLoad defines a callback called when texture is loaded
  12786. * @param onError defines a callback called if there is an error
  12787. * @returns the cube texture as an InternalTexture
  12788. */
  12789. 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;
  12790. /**
  12791. * Creates a new raw cube texture from a specified url
  12792. * @param url defines the url where the data is located
  12793. * @param scene defines the current scene
  12794. * @param size defines the size of the textures
  12795. * @param format defines the format of the data
  12796. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12797. * @param noMipmap defines if the engine should avoid generating the mip levels
  12798. * @param callback defines a callback used to extract texture data from loaded data
  12799. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12800. * @param onLoad defines a callback called when texture is loaded
  12801. * @param onError defines a callback called if there is an error
  12802. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12803. * @param invertY defines if data must be stored with Y axis inverted
  12804. * @returns the cube texture as an InternalTexture
  12805. */
  12806. 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;
  12807. /**
  12808. * Creates a new raw 3D texture
  12809. * @param data defines the data used to create the texture
  12810. * @param width defines the width of the texture
  12811. * @param height defines the height of the texture
  12812. * @param depth defines the depth of the texture
  12813. * @param format defines the format of the texture
  12814. * @param generateMipMaps defines if the engine must generate mip levels
  12815. * @param invertY defines if data must be stored with Y axis inverted
  12816. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12817. * @param compression defines the compressed used (can be null)
  12818. * @param textureType defines the compressed used (can be null)
  12819. * @returns a new raw 3D texture (stored in an InternalTexture)
  12820. */
  12821. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12822. /**
  12823. * Update a raw 3D texture
  12824. * @param texture defines the texture to update
  12825. * @param data defines the data to store
  12826. * @param format defines the data format
  12827. * @param invertY defines if data must be stored with Y axis inverted
  12828. */
  12829. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12830. /**
  12831. * Update a raw 3D texture
  12832. * @param texture defines the texture to update
  12833. * @param data defines the data to store
  12834. * @param format defines the data format
  12835. * @param invertY defines if data must be stored with Y axis inverted
  12836. * @param compression defines the used compression (can be null)
  12837. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12838. */
  12839. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12840. /**
  12841. * Creates a new raw 2D array texture
  12842. * @param data defines the data used to create the texture
  12843. * @param width defines the width of the texture
  12844. * @param height defines the height of the texture
  12845. * @param depth defines the number of layers of the texture
  12846. * @param format defines the format of the texture
  12847. * @param generateMipMaps defines if the engine must generate mip levels
  12848. * @param invertY defines if data must be stored with Y axis inverted
  12849. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12850. * @param compression defines the compressed used (can be null)
  12851. * @param textureType defines the compressed used (can be null)
  12852. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12853. */
  12854. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12855. /**
  12856. * Update a raw 2D array texture
  12857. * @param texture defines the texture to update
  12858. * @param data defines the data to store
  12859. * @param format defines the data format
  12860. * @param invertY defines if data must be stored with Y axis inverted
  12861. */
  12862. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12863. /**
  12864. * Update a raw 2D array texture
  12865. * @param texture defines the texture to update
  12866. * @param data defines the data to store
  12867. * @param format defines the data format
  12868. * @param invertY defines if data must be stored with Y axis inverted
  12869. * @param compression defines the used compression (can be null)
  12870. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12871. */
  12872. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12873. }
  12874. }
  12875. }
  12876. declare module "babylonjs/Materials/Textures/rawTexture" {
  12877. import { Scene } from "babylonjs/scene";
  12878. import { Texture } from "babylonjs/Materials/Textures/texture";
  12879. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12880. /**
  12881. * Raw texture can help creating a texture directly from an array of data.
  12882. * This can be super useful if you either get the data from an uncompressed source or
  12883. * if you wish to create your texture pixel by pixel.
  12884. */
  12885. export class RawTexture extends Texture {
  12886. /**
  12887. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12888. */
  12889. format: number;
  12890. private _engine;
  12891. /**
  12892. * Instantiates a new RawTexture.
  12893. * Raw texture can help creating a texture directly from an array of data.
  12894. * This can be super useful if you either get the data from an uncompressed source or
  12895. * if you wish to create your texture pixel by pixel.
  12896. * @param data define the array of data to use to create the texture
  12897. * @param width define the width of the texture
  12898. * @param height define the height of the texture
  12899. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12900. * @param scene define the scene the texture belongs to
  12901. * @param generateMipMaps define whether mip maps should be generated or not
  12902. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12903. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12904. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12905. */
  12906. constructor(data: ArrayBufferView, width: number, height: number,
  12907. /**
  12908. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12909. */
  12910. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12911. /**
  12912. * Updates the texture underlying data.
  12913. * @param data Define the new data of the texture
  12914. */
  12915. update(data: ArrayBufferView): void;
  12916. /**
  12917. * Creates a luminance texture from some data.
  12918. * @param data Define the texture data
  12919. * @param width Define the width of the texture
  12920. * @param height Define the height of the texture
  12921. * @param scene Define the scene the texture belongs to
  12922. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12923. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12924. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12925. * @returns the luminance texture
  12926. */
  12927. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12928. /**
  12929. * Creates a luminance alpha texture from some data.
  12930. * @param data Define the texture data
  12931. * @param width Define the width of the texture
  12932. * @param height Define the height of the texture
  12933. * @param scene Define the scene the texture belongs to
  12934. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12935. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12936. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12937. * @returns the luminance alpha texture
  12938. */
  12939. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12940. /**
  12941. * Creates an alpha texture from some data.
  12942. * @param data Define the texture data
  12943. * @param width Define the width of the texture
  12944. * @param height Define the height of the texture
  12945. * @param scene Define the scene the texture belongs to
  12946. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12947. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12948. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12949. * @returns the alpha texture
  12950. */
  12951. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12952. /**
  12953. * Creates a RGB texture from some data.
  12954. * @param data Define the texture data
  12955. * @param width Define the width of the texture
  12956. * @param height Define the height of the texture
  12957. * @param scene Define the scene the texture belongs to
  12958. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12961. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12962. * @returns the RGB alpha texture
  12963. */
  12964. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12965. /**
  12966. * Creates a RGBA texture from some data.
  12967. * @param data Define the texture data
  12968. * @param width Define the width of the texture
  12969. * @param height Define the height of the texture
  12970. * @param scene Define the scene the texture belongs to
  12971. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12972. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12973. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12974. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12975. * @returns the RGBA texture
  12976. */
  12977. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12978. /**
  12979. * Creates a R texture from some data.
  12980. * @param data Define the texture data
  12981. * @param width Define the width of the texture
  12982. * @param height Define the height of the texture
  12983. * @param scene Define the scene the texture belongs to
  12984. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12985. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12986. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12987. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12988. * @returns the R texture
  12989. */
  12990. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12991. }
  12992. }
  12993. declare module "babylonjs/Maths/math.size" {
  12994. /**
  12995. * Interface for the size containing width and height
  12996. */
  12997. export interface ISize {
  12998. /**
  12999. * Width
  13000. */
  13001. width: number;
  13002. /**
  13003. * Heighht
  13004. */
  13005. height: number;
  13006. }
  13007. /**
  13008. * Size containing widht and height
  13009. */
  13010. export class Size implements ISize {
  13011. /**
  13012. * Width
  13013. */
  13014. width: number;
  13015. /**
  13016. * Height
  13017. */
  13018. height: number;
  13019. /**
  13020. * Creates a Size object from the given width and height (floats).
  13021. * @param width width of the new size
  13022. * @param height height of the new size
  13023. */
  13024. constructor(width: number, height: number);
  13025. /**
  13026. * Returns a string with the Size width and height
  13027. * @returns a string with the Size width and height
  13028. */
  13029. toString(): string;
  13030. /**
  13031. * "Size"
  13032. * @returns the string "Size"
  13033. */
  13034. getClassName(): string;
  13035. /**
  13036. * Returns the Size hash code.
  13037. * @returns a hash code for a unique width and height
  13038. */
  13039. getHashCode(): number;
  13040. /**
  13041. * Updates the current size from the given one.
  13042. * @param src the given size
  13043. */
  13044. copyFrom(src: Size): void;
  13045. /**
  13046. * Updates in place the current Size from the given floats.
  13047. * @param width width of the new size
  13048. * @param height height of the new size
  13049. * @returns the updated Size.
  13050. */
  13051. copyFromFloats(width: number, height: number): Size;
  13052. /**
  13053. * Updates in place the current Size from the given floats.
  13054. * @param width width to set
  13055. * @param height height to set
  13056. * @returns the updated Size.
  13057. */
  13058. set(width: number, height: number): Size;
  13059. /**
  13060. * Multiplies the width and height by numbers
  13061. * @param w factor to multiple the width by
  13062. * @param h factor to multiple the height by
  13063. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13064. */
  13065. multiplyByFloats(w: number, h: number): Size;
  13066. /**
  13067. * Clones the size
  13068. * @returns a new Size copied from the given one.
  13069. */
  13070. clone(): Size;
  13071. /**
  13072. * True if the current Size and the given one width and height are strictly equal.
  13073. * @param other the other size to compare against
  13074. * @returns True if the current Size and the given one width and height are strictly equal.
  13075. */
  13076. equals(other: Size): boolean;
  13077. /**
  13078. * The surface of the Size : width * height (float).
  13079. */
  13080. readonly surface: number;
  13081. /**
  13082. * Create a new size of zero
  13083. * @returns a new Size set to (0.0, 0.0)
  13084. */
  13085. static Zero(): Size;
  13086. /**
  13087. * Sums the width and height of two sizes
  13088. * @param otherSize size to add to this size
  13089. * @returns a new Size set as the addition result of the current Size and the given one.
  13090. */
  13091. add(otherSize: Size): Size;
  13092. /**
  13093. * Subtracts the width and height of two
  13094. * @param otherSize size to subtract to this size
  13095. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13096. */
  13097. subtract(otherSize: Size): Size;
  13098. /**
  13099. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13100. * @param start starting size to lerp between
  13101. * @param end end size to lerp between
  13102. * @param amount amount to lerp between the start and end values
  13103. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13104. */
  13105. static Lerp(start: Size, end: Size, amount: number): Size;
  13106. }
  13107. }
  13108. declare module "babylonjs/Animations/runtimeAnimation" {
  13109. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13110. import { Animatable } from "babylonjs/Animations/animatable";
  13111. import { Scene } from "babylonjs/scene";
  13112. /**
  13113. * Defines a runtime animation
  13114. */
  13115. export class RuntimeAnimation {
  13116. private _events;
  13117. /**
  13118. * The current frame of the runtime animation
  13119. */
  13120. private _currentFrame;
  13121. /**
  13122. * The animation used by the runtime animation
  13123. */
  13124. private _animation;
  13125. /**
  13126. * The target of the runtime animation
  13127. */
  13128. private _target;
  13129. /**
  13130. * The initiating animatable
  13131. */
  13132. private _host;
  13133. /**
  13134. * The original value of the runtime animation
  13135. */
  13136. private _originalValue;
  13137. /**
  13138. * The original blend value of the runtime animation
  13139. */
  13140. private _originalBlendValue;
  13141. /**
  13142. * The offsets cache of the runtime animation
  13143. */
  13144. private _offsetsCache;
  13145. /**
  13146. * The high limits cache of the runtime animation
  13147. */
  13148. private _highLimitsCache;
  13149. /**
  13150. * Specifies if the runtime animation has been stopped
  13151. */
  13152. private _stopped;
  13153. /**
  13154. * The blending factor of the runtime animation
  13155. */
  13156. private _blendingFactor;
  13157. /**
  13158. * The BabylonJS scene
  13159. */
  13160. private _scene;
  13161. /**
  13162. * The current value of the runtime animation
  13163. */
  13164. private _currentValue;
  13165. /** @hidden */
  13166. _animationState: _IAnimationState;
  13167. /**
  13168. * The active target of the runtime animation
  13169. */
  13170. private _activeTargets;
  13171. private _currentActiveTarget;
  13172. private _directTarget;
  13173. /**
  13174. * The target path of the runtime animation
  13175. */
  13176. private _targetPath;
  13177. /**
  13178. * The weight of the runtime animation
  13179. */
  13180. private _weight;
  13181. /**
  13182. * The ratio offset of the runtime animation
  13183. */
  13184. private _ratioOffset;
  13185. /**
  13186. * The previous delay of the runtime animation
  13187. */
  13188. private _previousDelay;
  13189. /**
  13190. * The previous ratio of the runtime animation
  13191. */
  13192. private _previousRatio;
  13193. private _enableBlending;
  13194. private _keys;
  13195. private _minFrame;
  13196. private _maxFrame;
  13197. private _minValue;
  13198. private _maxValue;
  13199. private _targetIsArray;
  13200. /**
  13201. * Gets the current frame of the runtime animation
  13202. */
  13203. readonly currentFrame: number;
  13204. /**
  13205. * Gets the weight of the runtime animation
  13206. */
  13207. readonly weight: number;
  13208. /**
  13209. * Gets the current value of the runtime animation
  13210. */
  13211. readonly currentValue: any;
  13212. /**
  13213. * Gets the target path of the runtime animation
  13214. */
  13215. readonly targetPath: string;
  13216. /**
  13217. * Gets the actual target of the runtime animation
  13218. */
  13219. readonly target: any;
  13220. /** @hidden */
  13221. _onLoop: () => void;
  13222. /**
  13223. * Create a new RuntimeAnimation object
  13224. * @param target defines the target of the animation
  13225. * @param animation defines the source animation object
  13226. * @param scene defines the hosting scene
  13227. * @param host defines the initiating Animatable
  13228. */
  13229. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13230. private _preparePath;
  13231. /**
  13232. * Gets the animation from the runtime animation
  13233. */
  13234. readonly animation: Animation;
  13235. /**
  13236. * Resets the runtime animation to the beginning
  13237. * @param restoreOriginal defines whether to restore the target property to the original value
  13238. */
  13239. reset(restoreOriginal?: boolean): void;
  13240. /**
  13241. * Specifies if the runtime animation is stopped
  13242. * @returns Boolean specifying if the runtime animation is stopped
  13243. */
  13244. isStopped(): boolean;
  13245. /**
  13246. * Disposes of the runtime animation
  13247. */
  13248. dispose(): void;
  13249. /**
  13250. * Apply the interpolated value to the target
  13251. * @param currentValue defines the value computed by the animation
  13252. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13253. */
  13254. setValue(currentValue: any, weight: number): void;
  13255. private _getOriginalValues;
  13256. private _setValue;
  13257. /**
  13258. * Gets the loop pmode of the runtime animation
  13259. * @returns Loop Mode
  13260. */
  13261. private _getCorrectLoopMode;
  13262. /**
  13263. * Move the current animation to a given frame
  13264. * @param frame defines the frame to move to
  13265. */
  13266. goToFrame(frame: number): void;
  13267. /**
  13268. * @hidden Internal use only
  13269. */
  13270. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13271. /**
  13272. * Execute the current animation
  13273. * @param delay defines the delay to add to the current frame
  13274. * @param from defines the lower bound of the animation range
  13275. * @param to defines the upper bound of the animation range
  13276. * @param loop defines if the current animation must loop
  13277. * @param speedRatio defines the current speed ratio
  13278. * @param weight defines the weight of the animation (default is -1 so no weight)
  13279. * @param onLoop optional callback called when animation loops
  13280. * @returns a boolean indicating if the animation is running
  13281. */
  13282. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13283. }
  13284. }
  13285. declare module "babylonjs/Animations/animatable" {
  13286. import { Animation } from "babylonjs/Animations/animation";
  13287. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13288. import { Nullable } from "babylonjs/types";
  13289. import { Observable } from "babylonjs/Misc/observable";
  13290. import { Scene } from "babylonjs/scene";
  13291. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13292. import { Node } from "babylonjs/node";
  13293. /**
  13294. * Class used to store an actual running animation
  13295. */
  13296. export class Animatable {
  13297. /** defines the target object */
  13298. target: any;
  13299. /** defines the starting frame number (default is 0) */
  13300. fromFrame: number;
  13301. /** defines the ending frame number (default is 100) */
  13302. toFrame: number;
  13303. /** defines if the animation must loop (default is false) */
  13304. loopAnimation: boolean;
  13305. /** defines a callback to call when animation ends if it is not looping */
  13306. onAnimationEnd?: (() => void) | null | undefined;
  13307. /** defines a callback to call when animation loops */
  13308. onAnimationLoop?: (() => void) | null | undefined;
  13309. private _localDelayOffset;
  13310. private _pausedDelay;
  13311. private _runtimeAnimations;
  13312. private _paused;
  13313. private _scene;
  13314. private _speedRatio;
  13315. private _weight;
  13316. private _syncRoot;
  13317. /**
  13318. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13319. * This will only apply for non looping animation (default is true)
  13320. */
  13321. disposeOnEnd: boolean;
  13322. /**
  13323. * Gets a boolean indicating if the animation has started
  13324. */
  13325. animationStarted: boolean;
  13326. /**
  13327. * Observer raised when the animation ends
  13328. */
  13329. onAnimationEndObservable: Observable<Animatable>;
  13330. /**
  13331. * Observer raised when the animation loops
  13332. */
  13333. onAnimationLoopObservable: Observable<Animatable>;
  13334. /**
  13335. * Gets the root Animatable used to synchronize and normalize animations
  13336. */
  13337. readonly syncRoot: Nullable<Animatable>;
  13338. /**
  13339. * Gets the current frame of the first RuntimeAnimation
  13340. * Used to synchronize Animatables
  13341. */
  13342. readonly masterFrame: number;
  13343. /**
  13344. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13345. */
  13346. weight: number;
  13347. /**
  13348. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13349. */
  13350. speedRatio: number;
  13351. /**
  13352. * Creates a new Animatable
  13353. * @param scene defines the hosting scene
  13354. * @param target defines the target object
  13355. * @param fromFrame defines the starting frame number (default is 0)
  13356. * @param toFrame defines the ending frame number (default is 100)
  13357. * @param loopAnimation defines if the animation must loop (default is false)
  13358. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13359. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13360. * @param animations defines a group of animation to add to the new Animatable
  13361. * @param onAnimationLoop defines a callback to call when animation loops
  13362. */
  13363. constructor(scene: Scene,
  13364. /** defines the target object */
  13365. target: any,
  13366. /** defines the starting frame number (default is 0) */
  13367. fromFrame?: number,
  13368. /** defines the ending frame number (default is 100) */
  13369. toFrame?: number,
  13370. /** defines if the animation must loop (default is false) */
  13371. loopAnimation?: boolean, speedRatio?: number,
  13372. /** defines a callback to call when animation ends if it is not looping */
  13373. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13374. /** defines a callback to call when animation loops */
  13375. onAnimationLoop?: (() => void) | null | undefined);
  13376. /**
  13377. * Synchronize and normalize current Animatable with a source Animatable
  13378. * This is useful when using animation weights and when animations are not of the same length
  13379. * @param root defines the root Animatable to synchronize with
  13380. * @returns the current Animatable
  13381. */
  13382. syncWith(root: Animatable): Animatable;
  13383. /**
  13384. * Gets the list of runtime animations
  13385. * @returns an array of RuntimeAnimation
  13386. */
  13387. getAnimations(): RuntimeAnimation[];
  13388. /**
  13389. * Adds more animations to the current animatable
  13390. * @param target defines the target of the animations
  13391. * @param animations defines the new animations to add
  13392. */
  13393. appendAnimations(target: any, animations: Animation[]): void;
  13394. /**
  13395. * Gets the source animation for a specific property
  13396. * @param property defines the propertyu to look for
  13397. * @returns null or the source animation for the given property
  13398. */
  13399. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13400. /**
  13401. * Gets the runtime animation for a specific property
  13402. * @param property defines the propertyu to look for
  13403. * @returns null or the runtime animation for the given property
  13404. */
  13405. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13406. /**
  13407. * Resets the animatable to its original state
  13408. */
  13409. reset(): void;
  13410. /**
  13411. * Allows the animatable to blend with current running animations
  13412. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13413. * @param blendingSpeed defines the blending speed to use
  13414. */
  13415. enableBlending(blendingSpeed: number): void;
  13416. /**
  13417. * Disable animation blending
  13418. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13419. */
  13420. disableBlending(): void;
  13421. /**
  13422. * Jump directly to a given frame
  13423. * @param frame defines the frame to jump to
  13424. */
  13425. goToFrame(frame: number): void;
  13426. /**
  13427. * Pause the animation
  13428. */
  13429. pause(): void;
  13430. /**
  13431. * Restart the animation
  13432. */
  13433. restart(): void;
  13434. private _raiseOnAnimationEnd;
  13435. /**
  13436. * Stop and delete the current animation
  13437. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13438. * @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)
  13439. */
  13440. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13441. /**
  13442. * Wait asynchronously for the animation to end
  13443. * @returns a promise which will be fullfilled when the animation ends
  13444. */
  13445. waitAsync(): Promise<Animatable>;
  13446. /** @hidden */
  13447. _animate(delay: number): boolean;
  13448. }
  13449. module "babylonjs/scene" {
  13450. interface Scene {
  13451. /** @hidden */
  13452. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13453. /** @hidden */
  13454. _processLateAnimationBindingsForMatrices(holder: {
  13455. totalWeight: number;
  13456. animations: RuntimeAnimation[];
  13457. originalValue: Matrix;
  13458. }): any;
  13459. /** @hidden */
  13460. _processLateAnimationBindingsForQuaternions(holder: {
  13461. totalWeight: number;
  13462. animations: RuntimeAnimation[];
  13463. originalValue: Quaternion;
  13464. }, refQuaternion: Quaternion): Quaternion;
  13465. /** @hidden */
  13466. _processLateAnimationBindings(): void;
  13467. /**
  13468. * Will start the animation sequence of a given target
  13469. * @param target defines the target
  13470. * @param from defines from which frame should animation start
  13471. * @param to defines until which frame should animation run.
  13472. * @param weight defines the weight to apply to the animation (1.0 by default)
  13473. * @param loop defines if the animation loops
  13474. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13475. * @param onAnimationEnd defines the function to be executed when the animation ends
  13476. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13477. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13478. * @param onAnimationLoop defines the callback to call when an animation loops
  13479. * @returns the animatable object created for this animation
  13480. */
  13481. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13482. /**
  13483. * Will start the animation sequence of a given target
  13484. * @param target defines the target
  13485. * @param from defines from which frame should animation start
  13486. * @param to defines until which frame should animation run.
  13487. * @param loop defines if the animation loops
  13488. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13489. * @param onAnimationEnd defines the function to be executed when the animation ends
  13490. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13491. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13492. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13493. * @param onAnimationLoop defines the callback to call when an animation loops
  13494. * @returns the animatable object created for this animation
  13495. */
  13496. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13497. /**
  13498. * Will start the animation sequence of a given target and its hierarchy
  13499. * @param target defines the target
  13500. * @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.
  13501. * @param from defines from which frame should animation start
  13502. * @param to defines until which frame should animation run.
  13503. * @param loop defines if the animation loops
  13504. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13505. * @param onAnimationEnd defines the function to be executed when the animation ends
  13506. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13507. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13508. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13509. * @param onAnimationLoop defines the callback to call when an animation loops
  13510. * @returns the list of created animatables
  13511. */
  13512. 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[];
  13513. /**
  13514. * Begin a new animation on a given node
  13515. * @param target defines the target where the animation will take place
  13516. * @param animations defines the list of animations to start
  13517. * @param from defines the initial value
  13518. * @param to defines the final value
  13519. * @param loop defines if you want animation to loop (off by default)
  13520. * @param speedRatio defines the speed ratio to apply to all animations
  13521. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13522. * @param onAnimationLoop defines the callback to call when an animation loops
  13523. * @returns the list of created animatables
  13524. */
  13525. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13526. /**
  13527. * Begin a new animation on a given node and its hierarchy
  13528. * @param target defines the root node where the animation will take place
  13529. * @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.
  13530. * @param animations defines the list of animations to start
  13531. * @param from defines the initial value
  13532. * @param to defines the final value
  13533. * @param loop defines if you want animation to loop (off by default)
  13534. * @param speedRatio defines the speed ratio to apply to all animations
  13535. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13536. * @param onAnimationLoop defines the callback to call when an animation loops
  13537. * @returns the list of animatables created for all nodes
  13538. */
  13539. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13540. /**
  13541. * Gets the animatable associated with a specific target
  13542. * @param target defines the target of the animatable
  13543. * @returns the required animatable if found
  13544. */
  13545. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13546. /**
  13547. * Gets all animatables associated with a given target
  13548. * @param target defines the target to look animatables for
  13549. * @returns an array of Animatables
  13550. */
  13551. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13552. /**
  13553. * Stops and removes all animations that have been applied to the scene
  13554. */
  13555. stopAllAnimations(): void;
  13556. /**
  13557. * Gets the current delta time used by animation engine
  13558. */
  13559. deltaTime: number;
  13560. }
  13561. }
  13562. module "babylonjs/Bones/bone" {
  13563. interface Bone {
  13564. /**
  13565. * Copy an animation range from another bone
  13566. * @param source defines the source bone
  13567. * @param rangeName defines the range name to copy
  13568. * @param frameOffset defines the frame offset
  13569. * @param rescaleAsRequired defines if rescaling must be applied if required
  13570. * @param skelDimensionsRatio defines the scaling ratio
  13571. * @returns true if operation was successful
  13572. */
  13573. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13574. }
  13575. }
  13576. }
  13577. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13578. /**
  13579. * Class used to override all child animations of a given target
  13580. */
  13581. export class AnimationPropertiesOverride {
  13582. /**
  13583. * Gets or sets a value indicating if animation blending must be used
  13584. */
  13585. enableBlending: boolean;
  13586. /**
  13587. * Gets or sets the blending speed to use when enableBlending is true
  13588. */
  13589. blendingSpeed: number;
  13590. /**
  13591. * Gets or sets the default loop mode to use
  13592. */
  13593. loopMode: number;
  13594. }
  13595. }
  13596. declare module "babylonjs/Bones/skeleton" {
  13597. import { Bone } from "babylonjs/Bones/bone";
  13598. import { Observable } from "babylonjs/Misc/observable";
  13599. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13600. import { Scene } from "babylonjs/scene";
  13601. import { Nullable } from "babylonjs/types";
  13602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13603. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13604. import { Animatable } from "babylonjs/Animations/animatable";
  13605. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13606. import { Animation } from "babylonjs/Animations/animation";
  13607. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13608. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13609. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13610. /**
  13611. * Class used to handle skinning animations
  13612. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13613. */
  13614. export class Skeleton implements IAnimatable {
  13615. /** defines the skeleton name */
  13616. name: string;
  13617. /** defines the skeleton Id */
  13618. id: string;
  13619. /**
  13620. * Defines the list of child bones
  13621. */
  13622. bones: Bone[];
  13623. /**
  13624. * Defines an estimate of the dimension of the skeleton at rest
  13625. */
  13626. dimensionsAtRest: Vector3;
  13627. /**
  13628. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13629. */
  13630. needInitialSkinMatrix: boolean;
  13631. /**
  13632. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13633. */
  13634. overrideMesh: Nullable<AbstractMesh>;
  13635. /**
  13636. * Gets the list of animations attached to this skeleton
  13637. */
  13638. animations: Array<Animation>;
  13639. private _scene;
  13640. private _isDirty;
  13641. private _transformMatrices;
  13642. private _transformMatrixTexture;
  13643. private _meshesWithPoseMatrix;
  13644. private _animatables;
  13645. private _identity;
  13646. private _synchronizedWithMesh;
  13647. private _ranges;
  13648. private _lastAbsoluteTransformsUpdateId;
  13649. private _canUseTextureForBones;
  13650. private _uniqueId;
  13651. /** @hidden */
  13652. _numBonesWithLinkedTransformNode: number;
  13653. /** @hidden */
  13654. _hasWaitingData: Nullable<boolean>;
  13655. /**
  13656. * Specifies if the skeleton should be serialized
  13657. */
  13658. doNotSerialize: boolean;
  13659. private _useTextureToStoreBoneMatrices;
  13660. /**
  13661. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13662. * Please note that this option is not available if the hardware does not support it
  13663. */
  13664. useTextureToStoreBoneMatrices: boolean;
  13665. private _animationPropertiesOverride;
  13666. /**
  13667. * Gets or sets the animation properties override
  13668. */
  13669. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13670. /**
  13671. * List of inspectable custom properties (used by the Inspector)
  13672. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13673. */
  13674. inspectableCustomProperties: IInspectable[];
  13675. /**
  13676. * An observable triggered before computing the skeleton's matrices
  13677. */
  13678. onBeforeComputeObservable: Observable<Skeleton>;
  13679. /**
  13680. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13681. */
  13682. readonly isUsingTextureForMatrices: boolean;
  13683. /**
  13684. * Gets the unique ID of this skeleton
  13685. */
  13686. readonly uniqueId: number;
  13687. /**
  13688. * Creates a new skeleton
  13689. * @param name defines the skeleton name
  13690. * @param id defines the skeleton Id
  13691. * @param scene defines the hosting scene
  13692. */
  13693. constructor(
  13694. /** defines the skeleton name */
  13695. name: string,
  13696. /** defines the skeleton Id */
  13697. id: string, scene: Scene);
  13698. /**
  13699. * Gets the current object class name.
  13700. * @return the class name
  13701. */
  13702. getClassName(): string;
  13703. /**
  13704. * Returns an array containing the root bones
  13705. * @returns an array containing the root bones
  13706. */
  13707. getChildren(): Array<Bone>;
  13708. /**
  13709. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13710. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13711. * @returns a Float32Array containing matrices data
  13712. */
  13713. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13714. /**
  13715. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13716. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13717. * @returns a raw texture containing the data
  13718. */
  13719. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13720. /**
  13721. * Gets the current hosting scene
  13722. * @returns a scene object
  13723. */
  13724. getScene(): Scene;
  13725. /**
  13726. * Gets a string representing the current skeleton data
  13727. * @param fullDetails defines a boolean indicating if we want a verbose version
  13728. * @returns a string representing the current skeleton data
  13729. */
  13730. toString(fullDetails?: boolean): string;
  13731. /**
  13732. * Get bone's index searching by name
  13733. * @param name defines bone's name to search for
  13734. * @return the indice of the bone. Returns -1 if not found
  13735. */
  13736. getBoneIndexByName(name: string): number;
  13737. /**
  13738. * Creater a new animation range
  13739. * @param name defines the name of the range
  13740. * @param from defines the start key
  13741. * @param to defines the end key
  13742. */
  13743. createAnimationRange(name: string, from: number, to: number): void;
  13744. /**
  13745. * Delete a specific animation range
  13746. * @param name defines the name of the range
  13747. * @param deleteFrames defines if frames must be removed as well
  13748. */
  13749. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13750. /**
  13751. * Gets a specific animation range
  13752. * @param name defines the name of the range to look for
  13753. * @returns the requested animation range or null if not found
  13754. */
  13755. getAnimationRange(name: string): Nullable<AnimationRange>;
  13756. /**
  13757. * Gets the list of all animation ranges defined on this skeleton
  13758. * @returns an array
  13759. */
  13760. getAnimationRanges(): Nullable<AnimationRange>[];
  13761. /**
  13762. * Copy animation range from a source skeleton.
  13763. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13764. * @param source defines the source skeleton
  13765. * @param name defines the name of the range to copy
  13766. * @param rescaleAsRequired defines if rescaling must be applied if required
  13767. * @returns true if operation was successful
  13768. */
  13769. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13770. /**
  13771. * Forces the skeleton to go to rest pose
  13772. */
  13773. returnToRest(): void;
  13774. private _getHighestAnimationFrame;
  13775. /**
  13776. * Begin a specific animation range
  13777. * @param name defines the name of the range to start
  13778. * @param loop defines if looping must be turned on (false by default)
  13779. * @param speedRatio defines the speed ratio to apply (1 by default)
  13780. * @param onAnimationEnd defines a callback which will be called when animation will end
  13781. * @returns a new animatable
  13782. */
  13783. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13784. /** @hidden */
  13785. _markAsDirty(): void;
  13786. /** @hidden */
  13787. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13788. /** @hidden */
  13789. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13790. private _computeTransformMatrices;
  13791. /**
  13792. * Build all resources required to render a skeleton
  13793. */
  13794. prepare(): void;
  13795. /**
  13796. * Gets the list of animatables currently running for this skeleton
  13797. * @returns an array of animatables
  13798. */
  13799. getAnimatables(): IAnimatable[];
  13800. /**
  13801. * Clone the current skeleton
  13802. * @param name defines the name of the new skeleton
  13803. * @param id defines the id of the new skeleton
  13804. * @returns the new skeleton
  13805. */
  13806. clone(name: string, id?: string): Skeleton;
  13807. /**
  13808. * Enable animation blending for this skeleton
  13809. * @param blendingSpeed defines the blending speed to apply
  13810. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13811. */
  13812. enableBlending(blendingSpeed?: number): void;
  13813. /**
  13814. * Releases all resources associated with the current skeleton
  13815. */
  13816. dispose(): void;
  13817. /**
  13818. * Serialize the skeleton in a JSON object
  13819. * @returns a JSON object
  13820. */
  13821. serialize(): any;
  13822. /**
  13823. * Creates a new skeleton from serialized data
  13824. * @param parsedSkeleton defines the serialized data
  13825. * @param scene defines the hosting scene
  13826. * @returns a new skeleton
  13827. */
  13828. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13829. /**
  13830. * Compute all node absolute transforms
  13831. * @param forceUpdate defines if computation must be done even if cache is up to date
  13832. */
  13833. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13834. /**
  13835. * Gets the root pose matrix
  13836. * @returns a matrix
  13837. */
  13838. getPoseMatrix(): Nullable<Matrix>;
  13839. /**
  13840. * Sorts bones per internal index
  13841. */
  13842. sortBones(): void;
  13843. private _sortBones;
  13844. }
  13845. }
  13846. declare module "babylonjs/Bones/bone" {
  13847. import { Skeleton } from "babylonjs/Bones/skeleton";
  13848. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13849. import { Nullable } from "babylonjs/types";
  13850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13851. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13852. import { Node } from "babylonjs/node";
  13853. import { Space } from "babylonjs/Maths/math.axis";
  13854. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13855. /**
  13856. * Class used to store bone information
  13857. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13858. */
  13859. export class Bone extends Node {
  13860. /**
  13861. * defines the bone name
  13862. */
  13863. name: string;
  13864. private static _tmpVecs;
  13865. private static _tmpQuat;
  13866. private static _tmpMats;
  13867. /**
  13868. * Gets the list of child bones
  13869. */
  13870. children: Bone[];
  13871. /** Gets the animations associated with this bone */
  13872. animations: import("babylonjs/Animations/animation").Animation[];
  13873. /**
  13874. * Gets or sets bone length
  13875. */
  13876. length: number;
  13877. /**
  13878. * @hidden Internal only
  13879. * Set this value to map this bone to a different index in the transform matrices
  13880. * Set this value to -1 to exclude the bone from the transform matrices
  13881. */
  13882. _index: Nullable<number>;
  13883. private _skeleton;
  13884. private _localMatrix;
  13885. private _restPose;
  13886. private _baseMatrix;
  13887. private _absoluteTransform;
  13888. private _invertedAbsoluteTransform;
  13889. private _parent;
  13890. private _scalingDeterminant;
  13891. private _worldTransform;
  13892. private _localScaling;
  13893. private _localRotation;
  13894. private _localPosition;
  13895. private _needToDecompose;
  13896. private _needToCompose;
  13897. /** @hidden */
  13898. _linkedTransformNode: Nullable<TransformNode>;
  13899. /** @hidden */
  13900. _waitingTransformNodeId: Nullable<string>;
  13901. /** @hidden */
  13902. /** @hidden */
  13903. _matrix: Matrix;
  13904. /**
  13905. * Create a new bone
  13906. * @param name defines the bone name
  13907. * @param skeleton defines the parent skeleton
  13908. * @param parentBone defines the parent (can be null if the bone is the root)
  13909. * @param localMatrix defines the local matrix
  13910. * @param restPose defines the rest pose matrix
  13911. * @param baseMatrix defines the base matrix
  13912. * @param index defines index of the bone in the hiearchy
  13913. */
  13914. constructor(
  13915. /**
  13916. * defines the bone name
  13917. */
  13918. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13919. /**
  13920. * Gets the current object class name.
  13921. * @return the class name
  13922. */
  13923. getClassName(): string;
  13924. /**
  13925. * Gets the parent skeleton
  13926. * @returns a skeleton
  13927. */
  13928. getSkeleton(): Skeleton;
  13929. /**
  13930. * Gets parent bone
  13931. * @returns a bone or null if the bone is the root of the bone hierarchy
  13932. */
  13933. getParent(): Nullable<Bone>;
  13934. /**
  13935. * Returns an array containing the root bones
  13936. * @returns an array containing the root bones
  13937. */
  13938. getChildren(): Array<Bone>;
  13939. /**
  13940. * Gets the node index in matrix array generated for rendering
  13941. * @returns the node index
  13942. */
  13943. getIndex(): number;
  13944. /**
  13945. * Sets the parent bone
  13946. * @param parent defines the parent (can be null if the bone is the root)
  13947. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13948. */
  13949. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13950. /**
  13951. * Gets the local matrix
  13952. * @returns a matrix
  13953. */
  13954. getLocalMatrix(): Matrix;
  13955. /**
  13956. * Gets the base matrix (initial matrix which remains unchanged)
  13957. * @returns a matrix
  13958. */
  13959. getBaseMatrix(): Matrix;
  13960. /**
  13961. * Gets the rest pose matrix
  13962. * @returns a matrix
  13963. */
  13964. getRestPose(): Matrix;
  13965. /**
  13966. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13967. */
  13968. getWorldMatrix(): Matrix;
  13969. /**
  13970. * Sets the local matrix to rest pose matrix
  13971. */
  13972. returnToRest(): void;
  13973. /**
  13974. * Gets the inverse of the absolute transform matrix.
  13975. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13976. * @returns a matrix
  13977. */
  13978. getInvertedAbsoluteTransform(): Matrix;
  13979. /**
  13980. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13981. * @returns a matrix
  13982. */
  13983. getAbsoluteTransform(): Matrix;
  13984. /**
  13985. * Links with the given transform node.
  13986. * The local matrix of this bone is copied from the transform node every frame.
  13987. * @param transformNode defines the transform node to link to
  13988. */
  13989. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13990. /**
  13991. * Gets the node used to drive the bone's transformation
  13992. * @returns a transform node or null
  13993. */
  13994. getTransformNode(): Nullable<TransformNode>;
  13995. /** Gets or sets current position (in local space) */
  13996. position: Vector3;
  13997. /** Gets or sets current rotation (in local space) */
  13998. rotation: Vector3;
  13999. /** Gets or sets current rotation quaternion (in local space) */
  14000. rotationQuaternion: Quaternion;
  14001. /** Gets or sets current scaling (in local space) */
  14002. scaling: Vector3;
  14003. /**
  14004. * Gets the animation properties override
  14005. */
  14006. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  14007. private _decompose;
  14008. private _compose;
  14009. /**
  14010. * Update the base and local matrices
  14011. * @param matrix defines the new base or local matrix
  14012. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14013. * @param updateLocalMatrix defines if the local matrix should be updated
  14014. */
  14015. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14016. /** @hidden */
  14017. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14018. /**
  14019. * Flag the bone as dirty (Forcing it to update everything)
  14020. */
  14021. markAsDirty(): void;
  14022. /** @hidden */
  14023. _markAsDirtyAndCompose(): void;
  14024. private _markAsDirtyAndDecompose;
  14025. /**
  14026. * Translate the bone in local or world space
  14027. * @param vec The amount to translate the bone
  14028. * @param space The space that the translation is in
  14029. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14030. */
  14031. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14032. /**
  14033. * Set the postion of the bone in local or world space
  14034. * @param position The position to set the bone
  14035. * @param space The space that the position is in
  14036. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14037. */
  14038. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14039. /**
  14040. * Set the absolute position of the bone (world space)
  14041. * @param position The position to set the bone
  14042. * @param mesh The mesh that this bone is attached to
  14043. */
  14044. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14045. /**
  14046. * Scale the bone on the x, y and z axes (in local space)
  14047. * @param x The amount to scale the bone on the x axis
  14048. * @param y The amount to scale the bone on the y axis
  14049. * @param z The amount to scale the bone on the z axis
  14050. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14051. */
  14052. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14053. /**
  14054. * Set the bone scaling in local space
  14055. * @param scale defines the scaling vector
  14056. */
  14057. setScale(scale: Vector3): void;
  14058. /**
  14059. * Gets the current scaling in local space
  14060. * @returns the current scaling vector
  14061. */
  14062. getScale(): Vector3;
  14063. /**
  14064. * Gets the current scaling in local space and stores it in a target vector
  14065. * @param result defines the target vector
  14066. */
  14067. getScaleToRef(result: Vector3): void;
  14068. /**
  14069. * Set the yaw, pitch, and roll of the bone in local or world space
  14070. * @param yaw The rotation of the bone on the y axis
  14071. * @param pitch The rotation of the bone on the x axis
  14072. * @param roll The rotation of the bone on the z axis
  14073. * @param space The space that the axes of rotation are in
  14074. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14075. */
  14076. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14077. /**
  14078. * Add a rotation to the bone on an axis in local or world space
  14079. * @param axis The axis to rotate the bone on
  14080. * @param amount The amount to rotate the bone
  14081. * @param space The space that the axis is in
  14082. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14083. */
  14084. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14085. /**
  14086. * Set the rotation of the bone to a particular axis angle in local or world space
  14087. * @param axis The axis to rotate the bone on
  14088. * @param angle The angle that the bone should be rotated to
  14089. * @param space The space that the axis is in
  14090. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14091. */
  14092. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14093. /**
  14094. * Set the euler rotation of the bone in local of world space
  14095. * @param rotation The euler rotation that the bone should be set to
  14096. * @param space The space that the rotation is in
  14097. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14098. */
  14099. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14100. /**
  14101. * Set the quaternion rotation of the bone in local of world space
  14102. * @param quat The quaternion rotation that the bone should be set to
  14103. * @param space The space that the rotation is in
  14104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14105. */
  14106. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14107. /**
  14108. * Set the rotation matrix of the bone in local of world space
  14109. * @param rotMat The rotation matrix that the bone should be set to
  14110. * @param space The space that the rotation is in
  14111. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14112. */
  14113. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14114. private _rotateWithMatrix;
  14115. private _getNegativeRotationToRef;
  14116. /**
  14117. * Get the position of the bone in local or world space
  14118. * @param space The space that the returned position is in
  14119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14120. * @returns The position of the bone
  14121. */
  14122. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14123. /**
  14124. * Copy the position of the bone to a vector3 in local or world space
  14125. * @param space The space that the returned position is in
  14126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14127. * @param result The vector3 to copy the position to
  14128. */
  14129. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14130. /**
  14131. * Get the absolute position of the bone (world space)
  14132. * @param mesh The mesh that this bone is attached to
  14133. * @returns The absolute position of the bone
  14134. */
  14135. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14136. /**
  14137. * Copy the absolute position of the bone (world space) to the result param
  14138. * @param mesh The mesh that this bone is attached to
  14139. * @param result The vector3 to copy the absolute position to
  14140. */
  14141. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14142. /**
  14143. * Compute the absolute transforms of this bone and its children
  14144. */
  14145. computeAbsoluteTransforms(): void;
  14146. /**
  14147. * Get the world direction from an axis that is in the local space of the bone
  14148. * @param localAxis The local direction that is used to compute the world direction
  14149. * @param mesh The mesh that this bone is attached to
  14150. * @returns The world direction
  14151. */
  14152. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14153. /**
  14154. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14155. * @param localAxis The local direction that is used to compute the world direction
  14156. * @param mesh The mesh that this bone is attached to
  14157. * @param result The vector3 that the world direction will be copied to
  14158. */
  14159. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14160. /**
  14161. * Get the euler rotation of the bone in local or world space
  14162. * @param space The space that the rotation should be in
  14163. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14164. * @returns The euler rotation
  14165. */
  14166. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14167. /**
  14168. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14169. * @param space The space that the rotation should be in
  14170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14171. * @param result The vector3 that the rotation should be copied to
  14172. */
  14173. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14174. /**
  14175. * Get the quaternion rotation of the bone in either local or world space
  14176. * @param space The space that the rotation should be in
  14177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14178. * @returns The quaternion rotation
  14179. */
  14180. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14181. /**
  14182. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14183. * @param space The space that the rotation should be in
  14184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14185. * @param result The quaternion that the rotation should be copied to
  14186. */
  14187. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14188. /**
  14189. * Get the rotation matrix of the bone in local or world space
  14190. * @param space The space that the rotation should be in
  14191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14192. * @returns The rotation matrix
  14193. */
  14194. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14195. /**
  14196. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14197. * @param space The space that the rotation should be in
  14198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14199. * @param result The quaternion that the rotation should be copied to
  14200. */
  14201. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14202. /**
  14203. * Get the world position of a point that is in the local space of the bone
  14204. * @param position The local position
  14205. * @param mesh The mesh that this bone is attached to
  14206. * @returns The world position
  14207. */
  14208. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14209. /**
  14210. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14211. * @param position The local position
  14212. * @param mesh The mesh that this bone is attached to
  14213. * @param result The vector3 that the world position should be copied to
  14214. */
  14215. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14216. /**
  14217. * Get the local position of a point that is in world space
  14218. * @param position The world position
  14219. * @param mesh The mesh that this bone is attached to
  14220. * @returns The local position
  14221. */
  14222. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14223. /**
  14224. * Get the local position of a point that is in world space and copy it to the result param
  14225. * @param position The world position
  14226. * @param mesh The mesh that this bone is attached to
  14227. * @param result The vector3 that the local position should be copied to
  14228. */
  14229. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14230. }
  14231. }
  14232. declare module "babylonjs/Meshes/transformNode" {
  14233. import { DeepImmutable } from "babylonjs/types";
  14234. import { Observable } from "babylonjs/Misc/observable";
  14235. import { Nullable } from "babylonjs/types";
  14236. import { Camera } from "babylonjs/Cameras/camera";
  14237. import { Scene } from "babylonjs/scene";
  14238. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14239. import { Node } from "babylonjs/node";
  14240. import { Bone } from "babylonjs/Bones/bone";
  14241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14242. import { Space } from "babylonjs/Maths/math.axis";
  14243. /**
  14244. * 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.
  14245. * @see https://doc.babylonjs.com/how_to/transformnode
  14246. */
  14247. export class TransformNode extends Node {
  14248. /**
  14249. * Object will not rotate to face the camera
  14250. */
  14251. static BILLBOARDMODE_NONE: number;
  14252. /**
  14253. * Object will rotate to face the camera but only on the x axis
  14254. */
  14255. static BILLBOARDMODE_X: number;
  14256. /**
  14257. * Object will rotate to face the camera but only on the y axis
  14258. */
  14259. static BILLBOARDMODE_Y: number;
  14260. /**
  14261. * Object will rotate to face the camera but only on the z axis
  14262. */
  14263. static BILLBOARDMODE_Z: number;
  14264. /**
  14265. * Object will rotate to face the camera
  14266. */
  14267. static BILLBOARDMODE_ALL: number;
  14268. /**
  14269. * Object will rotate to face the camera's position instead of orientation
  14270. */
  14271. static BILLBOARDMODE_USE_POSITION: number;
  14272. private _forward;
  14273. private _forwardInverted;
  14274. private _up;
  14275. private _right;
  14276. private _rightInverted;
  14277. private _position;
  14278. private _rotation;
  14279. private _rotationQuaternion;
  14280. protected _scaling: Vector3;
  14281. protected _isDirty: boolean;
  14282. private _transformToBoneReferal;
  14283. private _isAbsoluteSynced;
  14284. private _billboardMode;
  14285. /**
  14286. * Gets or sets the billboard mode. Default is 0.
  14287. *
  14288. * | Value | Type | Description |
  14289. * | --- | --- | --- |
  14290. * | 0 | BILLBOARDMODE_NONE | |
  14291. * | 1 | BILLBOARDMODE_X | |
  14292. * | 2 | BILLBOARDMODE_Y | |
  14293. * | 4 | BILLBOARDMODE_Z | |
  14294. * | 7 | BILLBOARDMODE_ALL | |
  14295. *
  14296. */
  14297. billboardMode: number;
  14298. private _preserveParentRotationForBillboard;
  14299. /**
  14300. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14301. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14302. */
  14303. preserveParentRotationForBillboard: boolean;
  14304. /**
  14305. * 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
  14306. */
  14307. scalingDeterminant: number;
  14308. private _infiniteDistance;
  14309. /**
  14310. * Gets or sets the distance of the object to max, often used by skybox
  14311. */
  14312. infiniteDistance: boolean;
  14313. /**
  14314. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14315. * By default the system will update normals to compensate
  14316. */
  14317. ignoreNonUniformScaling: boolean;
  14318. /**
  14319. * 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
  14320. */
  14321. reIntegrateRotationIntoRotationQuaternion: boolean;
  14322. /** @hidden */
  14323. _poseMatrix: Nullable<Matrix>;
  14324. /** @hidden */
  14325. _localMatrix: Matrix;
  14326. private _usePivotMatrix;
  14327. private _absolutePosition;
  14328. private _absoluteScaling;
  14329. private _absoluteRotationQuaternion;
  14330. private _pivotMatrix;
  14331. private _pivotMatrixInverse;
  14332. protected _postMultiplyPivotMatrix: boolean;
  14333. protected _isWorldMatrixFrozen: boolean;
  14334. /** @hidden */
  14335. _indexInSceneTransformNodesArray: number;
  14336. /**
  14337. * An event triggered after the world matrix is updated
  14338. */
  14339. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14340. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14341. /**
  14342. * Gets a string identifying the name of the class
  14343. * @returns "TransformNode" string
  14344. */
  14345. getClassName(): string;
  14346. /**
  14347. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14348. */
  14349. position: Vector3;
  14350. /**
  14351. * 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)).
  14352. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14353. */
  14354. rotation: Vector3;
  14355. /**
  14356. * 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)).
  14357. */
  14358. scaling: Vector3;
  14359. /**
  14360. * 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).
  14361. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14362. */
  14363. rotationQuaternion: Nullable<Quaternion>;
  14364. /**
  14365. * The forward direction of that transform in world space.
  14366. */
  14367. readonly forward: Vector3;
  14368. /**
  14369. * The up direction of that transform in world space.
  14370. */
  14371. readonly up: Vector3;
  14372. /**
  14373. * The right direction of that transform in world space.
  14374. */
  14375. readonly right: Vector3;
  14376. /**
  14377. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14378. * @param matrix the matrix to copy the pose from
  14379. * @returns this TransformNode.
  14380. */
  14381. updatePoseMatrix(matrix: Matrix): TransformNode;
  14382. /**
  14383. * Returns the mesh Pose matrix.
  14384. * @returns the pose matrix
  14385. */
  14386. getPoseMatrix(): Matrix;
  14387. /** @hidden */
  14388. _isSynchronized(): boolean;
  14389. /** @hidden */
  14390. _initCache(): void;
  14391. /**
  14392. * Flag the transform node as dirty (Forcing it to update everything)
  14393. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14394. * @returns this transform node
  14395. */
  14396. markAsDirty(property: string): TransformNode;
  14397. /**
  14398. * Returns the current mesh absolute position.
  14399. * Returns a Vector3.
  14400. */
  14401. readonly absolutePosition: Vector3;
  14402. /**
  14403. * Returns the current mesh absolute scaling.
  14404. * Returns a Vector3.
  14405. */
  14406. readonly absoluteScaling: Vector3;
  14407. /**
  14408. * Returns the current mesh absolute rotation.
  14409. * Returns a Quaternion.
  14410. */
  14411. readonly absoluteRotationQuaternion: Quaternion;
  14412. /**
  14413. * Sets a new matrix to apply before all other transformation
  14414. * @param matrix defines the transform matrix
  14415. * @returns the current TransformNode
  14416. */
  14417. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14418. /**
  14419. * Sets a new pivot matrix to the current node
  14420. * @param matrix defines the new pivot matrix to use
  14421. * @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
  14422. * @returns the current TransformNode
  14423. */
  14424. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14425. /**
  14426. * Returns the mesh pivot matrix.
  14427. * Default : Identity.
  14428. * @returns the matrix
  14429. */
  14430. getPivotMatrix(): Matrix;
  14431. /**
  14432. * Instantiate (when possible) or clone that node with its hierarchy
  14433. * @param newParent defines the new parent to use for the instance (or clone)
  14434. * @param options defines options to configure how copy is done
  14435. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14436. * @returns an instance (or a clone) of the current node with its hiearchy
  14437. */
  14438. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14439. doNotInstantiate: boolean;
  14440. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14441. /**
  14442. * Prevents the World matrix to be computed any longer
  14443. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14444. * @returns the TransformNode.
  14445. */
  14446. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14447. /**
  14448. * Allows back the World matrix computation.
  14449. * @returns the TransformNode.
  14450. */
  14451. unfreezeWorldMatrix(): this;
  14452. /**
  14453. * True if the World matrix has been frozen.
  14454. */
  14455. readonly isWorldMatrixFrozen: boolean;
  14456. /**
  14457. * Retuns the mesh absolute position in the World.
  14458. * @returns a Vector3.
  14459. */
  14460. getAbsolutePosition(): Vector3;
  14461. /**
  14462. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14463. * @param absolutePosition the absolute position to set
  14464. * @returns the TransformNode.
  14465. */
  14466. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14467. /**
  14468. * Sets the mesh position in its local space.
  14469. * @param vector3 the position to set in localspace
  14470. * @returns the TransformNode.
  14471. */
  14472. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14473. /**
  14474. * Returns the mesh position in the local space from the current World matrix values.
  14475. * @returns a new Vector3.
  14476. */
  14477. getPositionExpressedInLocalSpace(): Vector3;
  14478. /**
  14479. * Translates the mesh along the passed Vector3 in its local space.
  14480. * @param vector3 the distance to translate in localspace
  14481. * @returns the TransformNode.
  14482. */
  14483. locallyTranslate(vector3: Vector3): TransformNode;
  14484. private static _lookAtVectorCache;
  14485. /**
  14486. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14487. * @param targetPoint the position (must be in same space as current mesh) to look at
  14488. * @param yawCor optional yaw (y-axis) correction in radians
  14489. * @param pitchCor optional pitch (x-axis) correction in radians
  14490. * @param rollCor optional roll (z-axis) correction in radians
  14491. * @param space the choosen space of the target
  14492. * @returns the TransformNode.
  14493. */
  14494. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14495. /**
  14496. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14497. * This Vector3 is expressed in the World space.
  14498. * @param localAxis axis to rotate
  14499. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14500. */
  14501. getDirection(localAxis: Vector3): Vector3;
  14502. /**
  14503. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14504. * localAxis is expressed in the mesh local space.
  14505. * result is computed in the Wordl space from the mesh World matrix.
  14506. * @param localAxis axis to rotate
  14507. * @param result the resulting transformnode
  14508. * @returns this TransformNode.
  14509. */
  14510. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14511. /**
  14512. * Sets this transform node rotation to the given local axis.
  14513. * @param localAxis the axis in local space
  14514. * @param yawCor optional yaw (y-axis) correction in radians
  14515. * @param pitchCor optional pitch (x-axis) correction in radians
  14516. * @param rollCor optional roll (z-axis) correction in radians
  14517. * @returns this TransformNode
  14518. */
  14519. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14520. /**
  14521. * Sets a new pivot point to the current node
  14522. * @param point defines the new pivot point to use
  14523. * @param space defines if the point is in world or local space (local by default)
  14524. * @returns the current TransformNode
  14525. */
  14526. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14527. /**
  14528. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14529. * @returns the pivot point
  14530. */
  14531. getPivotPoint(): Vector3;
  14532. /**
  14533. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14534. * @param result the vector3 to store the result
  14535. * @returns this TransformNode.
  14536. */
  14537. getPivotPointToRef(result: Vector3): TransformNode;
  14538. /**
  14539. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14540. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14541. */
  14542. getAbsolutePivotPoint(): Vector3;
  14543. /**
  14544. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14545. * @param result vector3 to store the result
  14546. * @returns this TransformNode.
  14547. */
  14548. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14549. /**
  14550. * Defines the passed node as the parent of the current node.
  14551. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14552. * @see https://doc.babylonjs.com/how_to/parenting
  14553. * @param node the node ot set as the parent
  14554. * @returns this TransformNode.
  14555. */
  14556. setParent(node: Nullable<Node>): TransformNode;
  14557. private _nonUniformScaling;
  14558. /**
  14559. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14560. */
  14561. readonly nonUniformScaling: boolean;
  14562. /** @hidden */
  14563. _updateNonUniformScalingState(value: boolean): boolean;
  14564. /**
  14565. * Attach the current TransformNode to another TransformNode associated with a bone
  14566. * @param bone Bone affecting the TransformNode
  14567. * @param affectedTransformNode TransformNode associated with the bone
  14568. * @returns this object
  14569. */
  14570. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14571. /**
  14572. * Detach the transform node if its associated with a bone
  14573. * @returns this object
  14574. */
  14575. detachFromBone(): TransformNode;
  14576. private static _rotationAxisCache;
  14577. /**
  14578. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14579. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14580. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14581. * The passed axis is also normalized.
  14582. * @param axis the axis to rotate around
  14583. * @param amount the amount to rotate in radians
  14584. * @param space Space to rotate in (Default: local)
  14585. * @returns the TransformNode.
  14586. */
  14587. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14588. /**
  14589. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14590. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14591. * The passed axis is also normalized. .
  14592. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14593. * @param point the point to rotate around
  14594. * @param axis the axis to rotate around
  14595. * @param amount the amount to rotate in radians
  14596. * @returns the TransformNode
  14597. */
  14598. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14599. /**
  14600. * Translates the mesh along the axis vector for the passed distance in the given space.
  14601. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14602. * @param axis the axis to translate in
  14603. * @param distance the distance to translate
  14604. * @param space Space to rotate in (Default: local)
  14605. * @returns the TransformNode.
  14606. */
  14607. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14608. /**
  14609. * Adds a rotation step to the mesh current rotation.
  14610. * x, y, z are Euler angles expressed in radians.
  14611. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14612. * This means this rotation is made in the mesh local space only.
  14613. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14614. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14615. * ```javascript
  14616. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14617. * ```
  14618. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14619. * 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.
  14620. * @param x Rotation to add
  14621. * @param y Rotation to add
  14622. * @param z Rotation to add
  14623. * @returns the TransformNode.
  14624. */
  14625. addRotation(x: number, y: number, z: number): TransformNode;
  14626. /**
  14627. * @hidden
  14628. */
  14629. protected _getEffectiveParent(): Nullable<Node>;
  14630. /**
  14631. * Computes the world matrix of the node
  14632. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14633. * @returns the world matrix
  14634. */
  14635. computeWorldMatrix(force?: boolean): Matrix;
  14636. protected _afterComputeWorldMatrix(): void;
  14637. /**
  14638. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14639. * @param func callback function to add
  14640. *
  14641. * @returns the TransformNode.
  14642. */
  14643. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14644. /**
  14645. * Removes a registered callback function.
  14646. * @param func callback function to remove
  14647. * @returns the TransformNode.
  14648. */
  14649. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14650. /**
  14651. * Gets the position of the current mesh in camera space
  14652. * @param camera defines the camera to use
  14653. * @returns a position
  14654. */
  14655. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14656. /**
  14657. * Returns the distance from the mesh to the active camera
  14658. * @param camera defines the camera to use
  14659. * @returns the distance
  14660. */
  14661. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14662. /**
  14663. * Clone the current transform node
  14664. * @param name Name of the new clone
  14665. * @param newParent New parent for the clone
  14666. * @param doNotCloneChildren Do not clone children hierarchy
  14667. * @returns the new transform node
  14668. */
  14669. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14670. /**
  14671. * Serializes the objects information.
  14672. * @param currentSerializationObject defines the object to serialize in
  14673. * @returns the serialized object
  14674. */
  14675. serialize(currentSerializationObject?: any): any;
  14676. /**
  14677. * Returns a new TransformNode object parsed from the source provided.
  14678. * @param parsedTransformNode is the source.
  14679. * @param scene the scne the object belongs to
  14680. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14681. * @returns a new TransformNode object parsed from the source provided.
  14682. */
  14683. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14684. /**
  14685. * Get all child-transformNodes of this node
  14686. * @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
  14687. * @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
  14688. * @returns an array of TransformNode
  14689. */
  14690. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14691. /**
  14692. * Releases resources associated with this transform node.
  14693. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14694. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14695. */
  14696. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14697. /**
  14698. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14699. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14700. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14701. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14702. * @returns the current mesh
  14703. */
  14704. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14705. private _syncAbsoluteScalingAndRotation;
  14706. }
  14707. }
  14708. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14709. import { Observable } from "babylonjs/Misc/observable";
  14710. import { Nullable } from "babylonjs/types";
  14711. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14712. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14714. import { Ray } from "babylonjs/Culling/ray";
  14715. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14716. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14717. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14718. /**
  14719. * Defines the types of pose enabled controllers that are supported
  14720. */
  14721. export enum PoseEnabledControllerType {
  14722. /**
  14723. * HTC Vive
  14724. */
  14725. VIVE = 0,
  14726. /**
  14727. * Oculus Rift
  14728. */
  14729. OCULUS = 1,
  14730. /**
  14731. * Windows mixed reality
  14732. */
  14733. WINDOWS = 2,
  14734. /**
  14735. * Samsung gear VR
  14736. */
  14737. GEAR_VR = 3,
  14738. /**
  14739. * Google Daydream
  14740. */
  14741. DAYDREAM = 4,
  14742. /**
  14743. * Generic
  14744. */
  14745. GENERIC = 5
  14746. }
  14747. /**
  14748. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14749. */
  14750. export interface MutableGamepadButton {
  14751. /**
  14752. * Value of the button/trigger
  14753. */
  14754. value: number;
  14755. /**
  14756. * If the button/trigger is currently touched
  14757. */
  14758. touched: boolean;
  14759. /**
  14760. * If the button/trigger is currently pressed
  14761. */
  14762. pressed: boolean;
  14763. }
  14764. /**
  14765. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14766. * @hidden
  14767. */
  14768. export interface ExtendedGamepadButton extends GamepadButton {
  14769. /**
  14770. * If the button/trigger is currently pressed
  14771. */
  14772. readonly pressed: boolean;
  14773. /**
  14774. * If the button/trigger is currently touched
  14775. */
  14776. readonly touched: boolean;
  14777. /**
  14778. * Value of the button/trigger
  14779. */
  14780. readonly value: number;
  14781. }
  14782. /** @hidden */
  14783. export interface _GamePadFactory {
  14784. /**
  14785. * Returns wether or not the current gamepad can be created for this type of controller.
  14786. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14787. * @returns true if it can be created, otherwise false
  14788. */
  14789. canCreate(gamepadInfo: any): boolean;
  14790. /**
  14791. * Creates a new instance of the Gamepad.
  14792. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14793. * @returns the new gamepad instance
  14794. */
  14795. create(gamepadInfo: any): Gamepad;
  14796. }
  14797. /**
  14798. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14799. */
  14800. export class PoseEnabledControllerHelper {
  14801. /** @hidden */
  14802. static _ControllerFactories: _GamePadFactory[];
  14803. /** @hidden */
  14804. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14805. /**
  14806. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14807. * @param vrGamepad the gamepad to initialized
  14808. * @returns a vr controller of the type the gamepad identified as
  14809. */
  14810. static InitiateController(vrGamepad: any): Gamepad;
  14811. }
  14812. /**
  14813. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14814. */
  14815. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14816. /**
  14817. * If the controller is used in a webXR session
  14818. */
  14819. isXR: boolean;
  14820. private _deviceRoomPosition;
  14821. private _deviceRoomRotationQuaternion;
  14822. /**
  14823. * The device position in babylon space
  14824. */
  14825. devicePosition: Vector3;
  14826. /**
  14827. * The device rotation in babylon space
  14828. */
  14829. deviceRotationQuaternion: Quaternion;
  14830. /**
  14831. * The scale factor of the device in babylon space
  14832. */
  14833. deviceScaleFactor: number;
  14834. /**
  14835. * (Likely devicePosition should be used instead) The device position in its room space
  14836. */
  14837. position: Vector3;
  14838. /**
  14839. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14840. */
  14841. rotationQuaternion: Quaternion;
  14842. /**
  14843. * The type of controller (Eg. Windows mixed reality)
  14844. */
  14845. controllerType: PoseEnabledControllerType;
  14846. protected _calculatedPosition: Vector3;
  14847. private _calculatedRotation;
  14848. /**
  14849. * The raw pose from the device
  14850. */
  14851. rawPose: DevicePose;
  14852. private _trackPosition;
  14853. private _maxRotationDistFromHeadset;
  14854. private _draggedRoomRotation;
  14855. /**
  14856. * @hidden
  14857. */
  14858. _disableTrackPosition(fixedPosition: Vector3): void;
  14859. /**
  14860. * Internal, the mesh attached to the controller
  14861. * @hidden
  14862. */
  14863. _mesh: Nullable<AbstractMesh>;
  14864. private _poseControlledCamera;
  14865. private _leftHandSystemQuaternion;
  14866. /**
  14867. * Internal, matrix used to convert room space to babylon space
  14868. * @hidden
  14869. */
  14870. _deviceToWorld: Matrix;
  14871. /**
  14872. * Node to be used when casting a ray from the controller
  14873. * @hidden
  14874. */
  14875. _pointingPoseNode: Nullable<TransformNode>;
  14876. /**
  14877. * Name of the child mesh that can be used to cast a ray from the controller
  14878. */
  14879. static readonly POINTING_POSE: string;
  14880. /**
  14881. * Creates a new PoseEnabledController from a gamepad
  14882. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14883. */
  14884. constructor(browserGamepad: any);
  14885. private _workingMatrix;
  14886. /**
  14887. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14888. */
  14889. update(): void;
  14890. /**
  14891. * Updates only the pose device and mesh without doing any button event checking
  14892. */
  14893. protected _updatePoseAndMesh(): void;
  14894. /**
  14895. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14896. * @param poseData raw pose fromthe device
  14897. */
  14898. updateFromDevice(poseData: DevicePose): void;
  14899. /**
  14900. * @hidden
  14901. */
  14902. _meshAttachedObservable: Observable<AbstractMesh>;
  14903. /**
  14904. * Attaches a mesh to the controller
  14905. * @param mesh the mesh to be attached
  14906. */
  14907. attachToMesh(mesh: AbstractMesh): void;
  14908. /**
  14909. * Attaches the controllers mesh to a camera
  14910. * @param camera the camera the mesh should be attached to
  14911. */
  14912. attachToPoseControlledCamera(camera: TargetCamera): void;
  14913. /**
  14914. * Disposes of the controller
  14915. */
  14916. dispose(): void;
  14917. /**
  14918. * The mesh that is attached to the controller
  14919. */
  14920. readonly mesh: Nullable<AbstractMesh>;
  14921. /**
  14922. * Gets the ray of the controller in the direction the controller is pointing
  14923. * @param length the length the resulting ray should be
  14924. * @returns a ray in the direction the controller is pointing
  14925. */
  14926. getForwardRay(length?: number): Ray;
  14927. }
  14928. }
  14929. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14930. import { Observable } from "babylonjs/Misc/observable";
  14931. import { Scene } from "babylonjs/scene";
  14932. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14933. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14934. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14935. import { Nullable } from "babylonjs/types";
  14936. /**
  14937. * Defines the WebVRController object that represents controllers tracked in 3D space
  14938. */
  14939. export abstract class WebVRController extends PoseEnabledController {
  14940. /**
  14941. * Internal, the default controller model for the controller
  14942. */
  14943. protected _defaultModel: Nullable<AbstractMesh>;
  14944. /**
  14945. * Fired when the trigger state has changed
  14946. */
  14947. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14948. /**
  14949. * Fired when the main button state has changed
  14950. */
  14951. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14952. /**
  14953. * Fired when the secondary button state has changed
  14954. */
  14955. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14956. /**
  14957. * Fired when the pad state has changed
  14958. */
  14959. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14960. /**
  14961. * Fired when controllers stick values have changed
  14962. */
  14963. onPadValuesChangedObservable: Observable<StickValues>;
  14964. /**
  14965. * Array of button availible on the controller
  14966. */
  14967. protected _buttons: Array<MutableGamepadButton>;
  14968. private _onButtonStateChange;
  14969. /**
  14970. * Fired when a controller button's state has changed
  14971. * @param callback the callback containing the button that was modified
  14972. */
  14973. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14974. /**
  14975. * X and Y axis corresponding to the controllers joystick
  14976. */
  14977. pad: StickValues;
  14978. /**
  14979. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14980. */
  14981. hand: string;
  14982. /**
  14983. * The default controller model for the controller
  14984. */
  14985. readonly defaultModel: Nullable<AbstractMesh>;
  14986. /**
  14987. * Creates a new WebVRController from a gamepad
  14988. * @param vrGamepad the gamepad that the WebVRController should be created from
  14989. */
  14990. constructor(vrGamepad: any);
  14991. /**
  14992. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14993. */
  14994. update(): void;
  14995. /**
  14996. * Function to be called when a button is modified
  14997. */
  14998. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14999. /**
  15000. * Loads a mesh and attaches it to the controller
  15001. * @param scene the scene the mesh should be added to
  15002. * @param meshLoaded callback for when the mesh has been loaded
  15003. */
  15004. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15005. private _setButtonValue;
  15006. private _changes;
  15007. private _checkChanges;
  15008. /**
  15009. * Disposes of th webVRCOntroller
  15010. */
  15011. dispose(): void;
  15012. }
  15013. }
  15014. declare module "babylonjs/Lights/hemisphericLight" {
  15015. import { Nullable } from "babylonjs/types";
  15016. import { Scene } from "babylonjs/scene";
  15017. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15018. import { Color3 } from "babylonjs/Maths/math.color";
  15019. import { Effect } from "babylonjs/Materials/effect";
  15020. import { Light } from "babylonjs/Lights/light";
  15021. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15022. /**
  15023. * The HemisphericLight simulates the ambient environment light,
  15024. * so the passed direction is the light reflection direction, not the incoming direction.
  15025. */
  15026. export class HemisphericLight extends Light {
  15027. /**
  15028. * The groundColor is the light in the opposite direction to the one specified during creation.
  15029. * 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.
  15030. */
  15031. groundColor: Color3;
  15032. /**
  15033. * The light reflection direction, not the incoming direction.
  15034. */
  15035. direction: Vector3;
  15036. /**
  15037. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15038. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15039. * The HemisphericLight can't cast shadows.
  15040. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15041. * @param name The friendly name of the light
  15042. * @param direction The direction of the light reflection
  15043. * @param scene The scene the light belongs to
  15044. */
  15045. constructor(name: string, direction: Vector3, scene: Scene);
  15046. protected _buildUniformLayout(): void;
  15047. /**
  15048. * Returns the string "HemisphericLight".
  15049. * @return The class name
  15050. */
  15051. getClassName(): string;
  15052. /**
  15053. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15054. * Returns the updated direction.
  15055. * @param target The target the direction should point to
  15056. * @return The computed direction
  15057. */
  15058. setDirectionToTarget(target: Vector3): Vector3;
  15059. /**
  15060. * Returns the shadow generator associated to the light.
  15061. * @returns Always null for hemispheric lights because it does not support shadows.
  15062. */
  15063. getShadowGenerator(): Nullable<IShadowGenerator>;
  15064. /**
  15065. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15066. * @param effect The effect to update
  15067. * @param lightIndex The index of the light in the effect to update
  15068. * @returns The hemispheric light
  15069. */
  15070. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15071. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15072. /**
  15073. * Computes the world matrix of the node
  15074. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15075. * @param useWasUpdatedFlag defines a reserved property
  15076. * @returns the world matrix
  15077. */
  15078. computeWorldMatrix(): Matrix;
  15079. /**
  15080. * Returns the integer 3.
  15081. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15082. */
  15083. getTypeID(): number;
  15084. /**
  15085. * Prepares the list of defines specific to the light type.
  15086. * @param defines the list of defines
  15087. * @param lightIndex defines the index of the light for the effect
  15088. */
  15089. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15090. }
  15091. }
  15092. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15093. /** @hidden */
  15094. export var vrMultiviewToSingleviewPixelShader: {
  15095. name: string;
  15096. shader: string;
  15097. };
  15098. }
  15099. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15100. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15101. import { Scene } from "babylonjs/scene";
  15102. /**
  15103. * Renders to multiple views with a single draw call
  15104. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15105. */
  15106. export class MultiviewRenderTarget extends RenderTargetTexture {
  15107. /**
  15108. * Creates a multiview render target
  15109. * @param scene scene used with the render target
  15110. * @param size the size of the render target (used for each view)
  15111. */
  15112. constructor(scene: Scene, size?: number | {
  15113. width: number;
  15114. height: number;
  15115. } | {
  15116. ratio: number;
  15117. });
  15118. /**
  15119. * @hidden
  15120. * @param faceIndex the face index, if its a cube texture
  15121. */
  15122. _bindFrameBuffer(faceIndex?: number): void;
  15123. /**
  15124. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15125. * @returns the view count
  15126. */
  15127. getViewCount(): number;
  15128. }
  15129. }
  15130. declare module "babylonjs/Maths/math.frustum" {
  15131. import { Matrix } from "babylonjs/Maths/math.vector";
  15132. import { DeepImmutable } from "babylonjs/types";
  15133. import { Plane } from "babylonjs/Maths/math.plane";
  15134. /**
  15135. * Represents a camera frustum
  15136. */
  15137. export class Frustum {
  15138. /**
  15139. * Gets the planes representing the frustum
  15140. * @param transform matrix to be applied to the returned planes
  15141. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15142. */
  15143. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15144. /**
  15145. * Gets the near frustum plane transformed by the transform matrix
  15146. * @param transform transformation matrix to be applied to the resulting frustum plane
  15147. * @param frustumPlane the resuling frustum plane
  15148. */
  15149. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15150. /**
  15151. * Gets the far frustum plane transformed by the transform matrix
  15152. * @param transform transformation matrix to be applied to the resulting frustum plane
  15153. * @param frustumPlane the resuling frustum plane
  15154. */
  15155. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15156. /**
  15157. * Gets the left frustum plane transformed by the transform matrix
  15158. * @param transform transformation matrix to be applied to the resulting frustum plane
  15159. * @param frustumPlane the resuling frustum plane
  15160. */
  15161. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15162. /**
  15163. * Gets the right frustum plane transformed by the transform matrix
  15164. * @param transform transformation matrix to be applied to the resulting frustum plane
  15165. * @param frustumPlane the resuling frustum plane
  15166. */
  15167. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15168. /**
  15169. * Gets the top frustum plane transformed by the transform matrix
  15170. * @param transform transformation matrix to be applied to the resulting frustum plane
  15171. * @param frustumPlane the resuling frustum plane
  15172. */
  15173. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15174. /**
  15175. * Gets the bottom frustum plane transformed by the transform matrix
  15176. * @param transform transformation matrix to be applied to the resulting frustum plane
  15177. * @param frustumPlane the resuling frustum plane
  15178. */
  15179. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15180. /**
  15181. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15182. * @param transform transformation matrix to be applied to the resulting frustum planes
  15183. * @param frustumPlanes the resuling frustum planes
  15184. */
  15185. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15186. }
  15187. }
  15188. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15189. import { Camera } from "babylonjs/Cameras/camera";
  15190. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15191. import { Nullable } from "babylonjs/types";
  15192. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15193. import { Matrix } from "babylonjs/Maths/math.vector";
  15194. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15195. module "babylonjs/Engines/engine" {
  15196. interface Engine {
  15197. /**
  15198. * Creates a new multiview render target
  15199. * @param width defines the width of the texture
  15200. * @param height defines the height of the texture
  15201. * @returns the created multiview texture
  15202. */
  15203. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15204. /**
  15205. * Binds a multiview framebuffer to be drawn to
  15206. * @param multiviewTexture texture to bind
  15207. */
  15208. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15209. }
  15210. }
  15211. module "babylonjs/Cameras/camera" {
  15212. interface Camera {
  15213. /**
  15214. * @hidden
  15215. * 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)
  15216. */
  15217. _useMultiviewToSingleView: boolean;
  15218. /**
  15219. * @hidden
  15220. * 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)
  15221. */
  15222. _multiviewTexture: Nullable<RenderTargetTexture>;
  15223. /**
  15224. * @hidden
  15225. * ensures the multiview texture of the camera exists and has the specified width/height
  15226. * @param width height to set on the multiview texture
  15227. * @param height width to set on the multiview texture
  15228. */
  15229. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15230. }
  15231. }
  15232. module "babylonjs/scene" {
  15233. interface Scene {
  15234. /** @hidden */
  15235. _transformMatrixR: Matrix;
  15236. /** @hidden */
  15237. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15238. /** @hidden */
  15239. _createMultiviewUbo(): void;
  15240. /** @hidden */
  15241. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15242. /** @hidden */
  15243. _renderMultiviewToSingleView(camera: Camera): void;
  15244. }
  15245. }
  15246. }
  15247. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15248. import { Camera } from "babylonjs/Cameras/camera";
  15249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15250. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15251. import "babylonjs/Engines/Extensions/engine.multiview";
  15252. /**
  15253. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15254. * This will not be used for webXR as it supports displaying texture arrays directly
  15255. */
  15256. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15257. /**
  15258. * Initializes a VRMultiviewToSingleview
  15259. * @param name name of the post process
  15260. * @param camera camera to be applied to
  15261. * @param scaleFactor scaling factor to the size of the output texture
  15262. */
  15263. constructor(name: string, camera: Camera, scaleFactor: number);
  15264. }
  15265. }
  15266. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15267. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15268. import { Nullable } from "babylonjs/types";
  15269. import { Size } from "babylonjs/Maths/math.size";
  15270. import { Observable } from "babylonjs/Misc/observable";
  15271. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15272. /**
  15273. * Interface used to define additional presentation attributes
  15274. */
  15275. export interface IVRPresentationAttributes {
  15276. /**
  15277. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15278. */
  15279. highRefreshRate: boolean;
  15280. /**
  15281. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15282. */
  15283. foveationLevel: number;
  15284. }
  15285. module "babylonjs/Engines/engine" {
  15286. interface Engine {
  15287. /** @hidden */
  15288. _vrDisplay: any;
  15289. /** @hidden */
  15290. _vrSupported: boolean;
  15291. /** @hidden */
  15292. _oldSize: Size;
  15293. /** @hidden */
  15294. _oldHardwareScaleFactor: number;
  15295. /** @hidden */
  15296. _vrExclusivePointerMode: boolean;
  15297. /** @hidden */
  15298. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15299. /** @hidden */
  15300. _onVRDisplayPointerRestricted: () => void;
  15301. /** @hidden */
  15302. _onVRDisplayPointerUnrestricted: () => void;
  15303. /** @hidden */
  15304. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15305. /** @hidden */
  15306. _onVrDisplayDisconnect: Nullable<() => void>;
  15307. /** @hidden */
  15308. _onVrDisplayPresentChange: Nullable<() => void>;
  15309. /**
  15310. * Observable signaled when VR display mode changes
  15311. */
  15312. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15313. /**
  15314. * Observable signaled when VR request present is complete
  15315. */
  15316. onVRRequestPresentComplete: Observable<boolean>;
  15317. /**
  15318. * Observable signaled when VR request present starts
  15319. */
  15320. onVRRequestPresentStart: Observable<Engine>;
  15321. /**
  15322. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15323. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15324. */
  15325. isInVRExclusivePointerMode: boolean;
  15326. /**
  15327. * Gets a boolean indicating if a webVR device was detected
  15328. * @returns true if a webVR device was detected
  15329. */
  15330. isVRDevicePresent(): boolean;
  15331. /**
  15332. * Gets the current webVR device
  15333. * @returns the current webVR device (or null)
  15334. */
  15335. getVRDevice(): any;
  15336. /**
  15337. * Initializes a webVR display and starts listening to display change events
  15338. * The onVRDisplayChangedObservable will be notified upon these changes
  15339. * @returns A promise containing a VRDisplay and if vr is supported
  15340. */
  15341. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15342. /** @hidden */
  15343. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15344. /**
  15345. * Gets or sets the presentation attributes used to configure VR rendering
  15346. */
  15347. vrPresentationAttributes?: IVRPresentationAttributes;
  15348. /**
  15349. * Call this function to switch to webVR mode
  15350. * Will do nothing if webVR is not supported or if there is no webVR device
  15351. * @param options the webvr options provided to the camera. mainly used for multiview
  15352. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15353. */
  15354. enableVR(options: WebVROptions): void;
  15355. /** @hidden */
  15356. _onVRFullScreenTriggered(): void;
  15357. }
  15358. }
  15359. }
  15360. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15361. import { Nullable } from "babylonjs/types";
  15362. import { Observable } from "babylonjs/Misc/observable";
  15363. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15364. import { Scene } from "babylonjs/scene";
  15365. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15366. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15367. import { Node } from "babylonjs/node";
  15368. import { Ray } from "babylonjs/Culling/ray";
  15369. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15370. import "babylonjs/Engines/Extensions/engine.webVR";
  15371. /**
  15372. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15373. * IMPORTANT!! The data is right-hand data.
  15374. * @export
  15375. * @interface DevicePose
  15376. */
  15377. export interface DevicePose {
  15378. /**
  15379. * The position of the device, values in array are [x,y,z].
  15380. */
  15381. readonly position: Nullable<Float32Array>;
  15382. /**
  15383. * The linearVelocity of the device, values in array are [x,y,z].
  15384. */
  15385. readonly linearVelocity: Nullable<Float32Array>;
  15386. /**
  15387. * The linearAcceleration of the device, values in array are [x,y,z].
  15388. */
  15389. readonly linearAcceleration: Nullable<Float32Array>;
  15390. /**
  15391. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15392. */
  15393. readonly orientation: Nullable<Float32Array>;
  15394. /**
  15395. * The angularVelocity of the device, values in array are [x,y,z].
  15396. */
  15397. readonly angularVelocity: Nullable<Float32Array>;
  15398. /**
  15399. * The angularAcceleration of the device, values in array are [x,y,z].
  15400. */
  15401. readonly angularAcceleration: Nullable<Float32Array>;
  15402. }
  15403. /**
  15404. * Interface representing a pose controlled object in Babylon.
  15405. * A pose controlled object has both regular pose values as well as pose values
  15406. * from an external device such as a VR head mounted display
  15407. */
  15408. export interface PoseControlled {
  15409. /**
  15410. * The position of the object in babylon space.
  15411. */
  15412. position: Vector3;
  15413. /**
  15414. * The rotation quaternion of the object in babylon space.
  15415. */
  15416. rotationQuaternion: Quaternion;
  15417. /**
  15418. * The position of the device in babylon space.
  15419. */
  15420. devicePosition?: Vector3;
  15421. /**
  15422. * The rotation quaternion of the device in babylon space.
  15423. */
  15424. deviceRotationQuaternion: Quaternion;
  15425. /**
  15426. * The raw pose coming from the device.
  15427. */
  15428. rawPose: Nullable<DevicePose>;
  15429. /**
  15430. * The scale of the device to be used when translating from device space to babylon space.
  15431. */
  15432. deviceScaleFactor: number;
  15433. /**
  15434. * Updates the poseControlled values based on the input device pose.
  15435. * @param poseData the pose data to update the object with
  15436. */
  15437. updateFromDevice(poseData: DevicePose): void;
  15438. }
  15439. /**
  15440. * Set of options to customize the webVRCamera
  15441. */
  15442. export interface WebVROptions {
  15443. /**
  15444. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15445. */
  15446. trackPosition?: boolean;
  15447. /**
  15448. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15449. */
  15450. positionScale?: number;
  15451. /**
  15452. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15453. */
  15454. displayName?: string;
  15455. /**
  15456. * Should the native controller meshes be initialized. (default: true)
  15457. */
  15458. controllerMeshes?: boolean;
  15459. /**
  15460. * Creating a default HemiLight only on controllers. (default: true)
  15461. */
  15462. defaultLightingOnControllers?: boolean;
  15463. /**
  15464. * If you don't want to use the default VR button of the helper. (default: false)
  15465. */
  15466. useCustomVRButton?: boolean;
  15467. /**
  15468. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15469. */
  15470. customVRButton?: HTMLButtonElement;
  15471. /**
  15472. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15473. */
  15474. rayLength?: number;
  15475. /**
  15476. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15477. */
  15478. defaultHeight?: number;
  15479. /**
  15480. * If multiview should be used if availible (default: false)
  15481. */
  15482. useMultiview?: boolean;
  15483. }
  15484. /**
  15485. * This represents a WebVR camera.
  15486. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15487. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15488. */
  15489. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15490. private webVROptions;
  15491. /**
  15492. * @hidden
  15493. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15494. */
  15495. _vrDevice: any;
  15496. /**
  15497. * The rawPose of the vrDevice.
  15498. */
  15499. rawPose: Nullable<DevicePose>;
  15500. private _onVREnabled;
  15501. private _specsVersion;
  15502. private _attached;
  15503. private _frameData;
  15504. protected _descendants: Array<Node>;
  15505. private _deviceRoomPosition;
  15506. /** @hidden */
  15507. _deviceRoomRotationQuaternion: Quaternion;
  15508. private _standingMatrix;
  15509. /**
  15510. * Represents device position in babylon space.
  15511. */
  15512. devicePosition: Vector3;
  15513. /**
  15514. * Represents device rotation in babylon space.
  15515. */
  15516. deviceRotationQuaternion: Quaternion;
  15517. /**
  15518. * The scale of the device to be used when translating from device space to babylon space.
  15519. */
  15520. deviceScaleFactor: number;
  15521. private _deviceToWorld;
  15522. private _worldToDevice;
  15523. /**
  15524. * References to the webVR controllers for the vrDevice.
  15525. */
  15526. controllers: Array<WebVRController>;
  15527. /**
  15528. * Emits an event when a controller is attached.
  15529. */
  15530. onControllersAttachedObservable: Observable<WebVRController[]>;
  15531. /**
  15532. * Emits an event when a controller's mesh has been loaded;
  15533. */
  15534. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15535. /**
  15536. * Emits an event when the HMD's pose has been updated.
  15537. */
  15538. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15539. private _poseSet;
  15540. /**
  15541. * If the rig cameras be used as parent instead of this camera.
  15542. */
  15543. rigParenting: boolean;
  15544. private _lightOnControllers;
  15545. private _defaultHeight?;
  15546. /**
  15547. * Instantiates a WebVRFreeCamera.
  15548. * @param name The name of the WebVRFreeCamera
  15549. * @param position The starting anchor position for the camera
  15550. * @param scene The scene the camera belongs to
  15551. * @param webVROptions a set of customizable options for the webVRCamera
  15552. */
  15553. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15554. /**
  15555. * Gets the device distance from the ground in meters.
  15556. * @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.
  15557. */
  15558. deviceDistanceToRoomGround(): number;
  15559. /**
  15560. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15561. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15562. */
  15563. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15564. /**
  15565. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15566. * @returns A promise with a boolean set to if the standing matrix is supported.
  15567. */
  15568. useStandingMatrixAsync(): Promise<boolean>;
  15569. /**
  15570. * Disposes the camera
  15571. */
  15572. dispose(): void;
  15573. /**
  15574. * Gets a vrController by name.
  15575. * @param name The name of the controller to retreive
  15576. * @returns the controller matching the name specified or null if not found
  15577. */
  15578. getControllerByName(name: string): Nullable<WebVRController>;
  15579. private _leftController;
  15580. /**
  15581. * The controller corresponding to the users left hand.
  15582. */
  15583. readonly leftController: Nullable<WebVRController>;
  15584. private _rightController;
  15585. /**
  15586. * The controller corresponding to the users right hand.
  15587. */
  15588. readonly rightController: Nullable<WebVRController>;
  15589. /**
  15590. * Casts a ray forward from the vrCamera's gaze.
  15591. * @param length Length of the ray (default: 100)
  15592. * @returns the ray corresponding to the gaze
  15593. */
  15594. getForwardRay(length?: number): Ray;
  15595. /**
  15596. * @hidden
  15597. * Updates the camera based on device's frame data
  15598. */
  15599. _checkInputs(): void;
  15600. /**
  15601. * Updates the poseControlled values based on the input device pose.
  15602. * @param poseData Pose coming from the device
  15603. */
  15604. updateFromDevice(poseData: DevicePose): void;
  15605. private _htmlElementAttached;
  15606. private _detachIfAttached;
  15607. /**
  15608. * WebVR's attach control will start broadcasting frames to the device.
  15609. * Note that in certain browsers (chrome for example) this function must be called
  15610. * within a user-interaction callback. Example:
  15611. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15612. *
  15613. * @param element html element to attach the vrDevice to
  15614. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15615. */
  15616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15617. /**
  15618. * Detaches the camera from the html element and disables VR
  15619. *
  15620. * @param element html element to detach from
  15621. */
  15622. detachControl(element: HTMLElement): void;
  15623. /**
  15624. * @returns the name of this class
  15625. */
  15626. getClassName(): string;
  15627. /**
  15628. * Calls resetPose on the vrDisplay
  15629. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15630. */
  15631. resetToCurrentRotation(): void;
  15632. /**
  15633. * @hidden
  15634. * Updates the rig cameras (left and right eye)
  15635. */
  15636. _updateRigCameras(): void;
  15637. private _workingVector;
  15638. private _oneVector;
  15639. private _workingMatrix;
  15640. private updateCacheCalled;
  15641. private _correctPositionIfNotTrackPosition;
  15642. /**
  15643. * @hidden
  15644. * Updates the cached values of the camera
  15645. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15646. */
  15647. _updateCache(ignoreParentClass?: boolean): void;
  15648. /**
  15649. * @hidden
  15650. * Get current device position in babylon world
  15651. */
  15652. _computeDevicePosition(): void;
  15653. /**
  15654. * Updates the current device position and rotation in the babylon world
  15655. */
  15656. update(): void;
  15657. /**
  15658. * @hidden
  15659. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15660. * @returns an identity matrix
  15661. */
  15662. _getViewMatrix(): Matrix;
  15663. private _tmpMatrix;
  15664. /**
  15665. * This function is called by the two RIG cameras.
  15666. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15667. * @hidden
  15668. */
  15669. _getWebVRViewMatrix(): Matrix;
  15670. /** @hidden */
  15671. _getWebVRProjectionMatrix(): Matrix;
  15672. private _onGamepadConnectedObserver;
  15673. private _onGamepadDisconnectedObserver;
  15674. private _updateCacheWhenTrackingDisabledObserver;
  15675. /**
  15676. * Initializes the controllers and their meshes
  15677. */
  15678. initControllers(): void;
  15679. }
  15680. }
  15681. declare module "babylonjs/PostProcesses/postProcess" {
  15682. import { Nullable } from "babylonjs/types";
  15683. import { SmartArray } from "babylonjs/Misc/smartArray";
  15684. import { Observable } from "babylonjs/Misc/observable";
  15685. import { Vector2 } from "babylonjs/Maths/math.vector";
  15686. import { Camera } from "babylonjs/Cameras/camera";
  15687. import { Effect } from "babylonjs/Materials/effect";
  15688. import "babylonjs/Shaders/postprocess.vertex";
  15689. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15690. import { Engine } from "babylonjs/Engines/engine";
  15691. import { Color4 } from "babylonjs/Maths/math.color";
  15692. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15693. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15694. /**
  15695. * Size options for a post process
  15696. */
  15697. export type PostProcessOptions = {
  15698. width: number;
  15699. height: number;
  15700. };
  15701. /**
  15702. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15703. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15704. */
  15705. export class PostProcess {
  15706. /** Name of the PostProcess. */
  15707. name: string;
  15708. /**
  15709. * Gets or sets the unique id of the post process
  15710. */
  15711. uniqueId: number;
  15712. /**
  15713. * Width of the texture to apply the post process on
  15714. */
  15715. width: number;
  15716. /**
  15717. * Height of the texture to apply the post process on
  15718. */
  15719. height: number;
  15720. /**
  15721. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15722. * @hidden
  15723. */
  15724. _outputTexture: Nullable<InternalTexture>;
  15725. /**
  15726. * Sampling mode used by the shader
  15727. * See https://doc.babylonjs.com/classes/3.1/texture
  15728. */
  15729. renderTargetSamplingMode: number;
  15730. /**
  15731. * Clear color to use when screen clearing
  15732. */
  15733. clearColor: Color4;
  15734. /**
  15735. * If the buffer needs to be cleared before applying the post process. (default: true)
  15736. * Should be set to false if shader will overwrite all previous pixels.
  15737. */
  15738. autoClear: boolean;
  15739. /**
  15740. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15741. */
  15742. alphaMode: number;
  15743. /**
  15744. * Sets the setAlphaBlendConstants of the babylon engine
  15745. */
  15746. alphaConstants: Color4;
  15747. /**
  15748. * Animations to be used for the post processing
  15749. */
  15750. animations: import("babylonjs/Animations/animation").Animation[];
  15751. /**
  15752. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15753. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15754. */
  15755. enablePixelPerfectMode: boolean;
  15756. /**
  15757. * Force the postprocess to be applied without taking in account viewport
  15758. */
  15759. forceFullscreenViewport: boolean;
  15760. /**
  15761. * List of inspectable custom properties (used by the Inspector)
  15762. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15763. */
  15764. inspectableCustomProperties: IInspectable[];
  15765. /**
  15766. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15767. *
  15768. * | Value | Type | Description |
  15769. * | ----- | ----------------------------------- | ----------- |
  15770. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15771. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15772. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15773. *
  15774. */
  15775. scaleMode: number;
  15776. /**
  15777. * Force textures to be a power of two (default: false)
  15778. */
  15779. alwaysForcePOT: boolean;
  15780. private _samples;
  15781. /**
  15782. * Number of sample textures (default: 1)
  15783. */
  15784. samples: number;
  15785. /**
  15786. * Modify the scale of the post process to be the same as the viewport (default: false)
  15787. */
  15788. adaptScaleToCurrentViewport: boolean;
  15789. private _camera;
  15790. private _scene;
  15791. private _engine;
  15792. private _options;
  15793. private _reusable;
  15794. private _textureType;
  15795. /**
  15796. * Smart array of input and output textures for the post process.
  15797. * @hidden
  15798. */
  15799. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15800. /**
  15801. * The index in _textures that corresponds to the output texture.
  15802. * @hidden
  15803. */
  15804. _currentRenderTextureInd: number;
  15805. private _effect;
  15806. private _samplers;
  15807. private _fragmentUrl;
  15808. private _vertexUrl;
  15809. private _parameters;
  15810. private _scaleRatio;
  15811. protected _indexParameters: any;
  15812. private _shareOutputWithPostProcess;
  15813. private _texelSize;
  15814. private _forcedOutputTexture;
  15815. /**
  15816. * Returns the fragment url or shader name used in the post process.
  15817. * @returns the fragment url or name in the shader store.
  15818. */
  15819. getEffectName(): string;
  15820. /**
  15821. * An event triggered when the postprocess is activated.
  15822. */
  15823. onActivateObservable: Observable<Camera>;
  15824. private _onActivateObserver;
  15825. /**
  15826. * A function that is added to the onActivateObservable
  15827. */
  15828. onActivate: Nullable<(camera: Camera) => void>;
  15829. /**
  15830. * An event triggered when the postprocess changes its size.
  15831. */
  15832. onSizeChangedObservable: Observable<PostProcess>;
  15833. private _onSizeChangedObserver;
  15834. /**
  15835. * A function that is added to the onSizeChangedObservable
  15836. */
  15837. onSizeChanged: (postProcess: PostProcess) => void;
  15838. /**
  15839. * An event triggered when the postprocess applies its effect.
  15840. */
  15841. onApplyObservable: Observable<Effect>;
  15842. private _onApplyObserver;
  15843. /**
  15844. * A function that is added to the onApplyObservable
  15845. */
  15846. onApply: (effect: Effect) => void;
  15847. /**
  15848. * An event triggered before rendering the postprocess
  15849. */
  15850. onBeforeRenderObservable: Observable<Effect>;
  15851. private _onBeforeRenderObserver;
  15852. /**
  15853. * A function that is added to the onBeforeRenderObservable
  15854. */
  15855. onBeforeRender: (effect: Effect) => void;
  15856. /**
  15857. * An event triggered after rendering the postprocess
  15858. */
  15859. onAfterRenderObservable: Observable<Effect>;
  15860. private _onAfterRenderObserver;
  15861. /**
  15862. * A function that is added to the onAfterRenderObservable
  15863. */
  15864. onAfterRender: (efect: Effect) => void;
  15865. /**
  15866. * 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
  15867. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15868. */
  15869. inputTexture: InternalTexture;
  15870. /**
  15871. * Gets the camera which post process is applied to.
  15872. * @returns The camera the post process is applied to.
  15873. */
  15874. getCamera(): Camera;
  15875. /**
  15876. * Gets the texel size of the postprocess.
  15877. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15878. */
  15879. readonly texelSize: Vector2;
  15880. /**
  15881. * Creates a new instance PostProcess
  15882. * @param name The name of the PostProcess.
  15883. * @param fragmentUrl The url of the fragment shader to be used.
  15884. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15885. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15886. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15887. * @param camera The camera to apply the render pass to.
  15888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15889. * @param engine The engine which the post process will be applied. (default: current engine)
  15890. * @param reusable If the post process can be reused on the same frame. (default: false)
  15891. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15892. * @param textureType Type of textures used when performing the post process. (default: 0)
  15893. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15894. * @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
  15895. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15896. */
  15897. constructor(
  15898. /** Name of the PostProcess. */
  15899. 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);
  15900. /**
  15901. * Gets a string idenfifying the name of the class
  15902. * @returns "PostProcess" string
  15903. */
  15904. getClassName(): string;
  15905. /**
  15906. * Gets the engine which this post process belongs to.
  15907. * @returns The engine the post process was enabled with.
  15908. */
  15909. getEngine(): Engine;
  15910. /**
  15911. * The effect that is created when initializing the post process.
  15912. * @returns The created effect corresponding the the postprocess.
  15913. */
  15914. getEffect(): Effect;
  15915. /**
  15916. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15917. * @param postProcess The post process to share the output with.
  15918. * @returns This post process.
  15919. */
  15920. shareOutputWith(postProcess: PostProcess): PostProcess;
  15921. /**
  15922. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15923. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15924. */
  15925. useOwnOutput(): void;
  15926. /**
  15927. * Updates the effect with the current post process compile time values and recompiles the shader.
  15928. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15929. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15930. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15931. * @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
  15932. * @param onCompiled Called when the shader has been compiled.
  15933. * @param onError Called if there is an error when compiling a shader.
  15934. */
  15935. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15936. /**
  15937. * The post process is reusable if it can be used multiple times within one frame.
  15938. * @returns If the post process is reusable
  15939. */
  15940. isReusable(): boolean;
  15941. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15942. markTextureDirty(): void;
  15943. /**
  15944. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15945. * 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.
  15946. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15947. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15948. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15949. * @returns The target texture that was bound to be written to.
  15950. */
  15951. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15952. /**
  15953. * If the post process is supported.
  15954. */
  15955. readonly isSupported: boolean;
  15956. /**
  15957. * The aspect ratio of the output texture.
  15958. */
  15959. readonly aspectRatio: number;
  15960. /**
  15961. * Get a value indicating if the post-process is ready to be used
  15962. * @returns true if the post-process is ready (shader is compiled)
  15963. */
  15964. isReady(): boolean;
  15965. /**
  15966. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15967. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15968. */
  15969. apply(): Nullable<Effect>;
  15970. private _disposeTextures;
  15971. /**
  15972. * Disposes the post process.
  15973. * @param camera The camera to dispose the post process on.
  15974. */
  15975. dispose(camera?: Camera): void;
  15976. }
  15977. }
  15978. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15979. /** @hidden */
  15980. export var kernelBlurVaryingDeclaration: {
  15981. name: string;
  15982. shader: string;
  15983. };
  15984. }
  15985. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15986. /** @hidden */
  15987. export var kernelBlurFragment: {
  15988. name: string;
  15989. shader: string;
  15990. };
  15991. }
  15992. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15993. /** @hidden */
  15994. export var kernelBlurFragment2: {
  15995. name: string;
  15996. shader: string;
  15997. };
  15998. }
  15999. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16000. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16001. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16002. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16003. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16004. /** @hidden */
  16005. export var kernelBlurPixelShader: {
  16006. name: string;
  16007. shader: string;
  16008. };
  16009. }
  16010. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16011. /** @hidden */
  16012. export var kernelBlurVertex: {
  16013. name: string;
  16014. shader: string;
  16015. };
  16016. }
  16017. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16018. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16019. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16020. /** @hidden */
  16021. export var kernelBlurVertexShader: {
  16022. name: string;
  16023. shader: string;
  16024. };
  16025. }
  16026. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16027. import { Vector2 } from "babylonjs/Maths/math.vector";
  16028. import { Nullable } from "babylonjs/types";
  16029. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16030. import { Camera } from "babylonjs/Cameras/camera";
  16031. import { Effect } from "babylonjs/Materials/effect";
  16032. import { Engine } from "babylonjs/Engines/engine";
  16033. import "babylonjs/Shaders/kernelBlur.fragment";
  16034. import "babylonjs/Shaders/kernelBlur.vertex";
  16035. /**
  16036. * The Blur Post Process which blurs an image based on a kernel and direction.
  16037. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16038. */
  16039. export class BlurPostProcess extends PostProcess {
  16040. /** The direction in which to blur the image. */
  16041. direction: Vector2;
  16042. private blockCompilation;
  16043. protected _kernel: number;
  16044. protected _idealKernel: number;
  16045. protected _packedFloat: boolean;
  16046. private _staticDefines;
  16047. /**
  16048. * Sets the length in pixels of the blur sample region
  16049. */
  16050. /**
  16051. * Gets the length in pixels of the blur sample region
  16052. */
  16053. kernel: number;
  16054. /**
  16055. * Sets wether or not the blur needs to unpack/repack floats
  16056. */
  16057. /**
  16058. * Gets wether or not the blur is unpacking/repacking floats
  16059. */
  16060. packedFloat: boolean;
  16061. /**
  16062. * Creates a new instance BlurPostProcess
  16063. * @param name The name of the effect.
  16064. * @param direction The direction in which to blur the image.
  16065. * @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.
  16066. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16067. * @param camera The camera to apply the render pass to.
  16068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16069. * @param engine The engine which the post process will be applied. (default: current engine)
  16070. * @param reusable If the post process can be reused on the same frame. (default: false)
  16071. * @param textureType Type of textures used when performing the post process. (default: 0)
  16072. * @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)
  16073. */
  16074. constructor(name: string,
  16075. /** The direction in which to blur the image. */
  16076. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16077. /**
  16078. * Updates the effect with the current post process compile time values and recompiles the shader.
  16079. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16080. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16081. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16082. * @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
  16083. * @param onCompiled Called when the shader has been compiled.
  16084. * @param onError Called if there is an error when compiling a shader.
  16085. */
  16086. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16087. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16088. /**
  16089. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16090. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16091. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16092. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16093. * The gaps between physical kernels are compensated for in the weighting of the samples
  16094. * @param idealKernel Ideal blur kernel.
  16095. * @return Nearest best kernel.
  16096. */
  16097. protected _nearestBestKernel(idealKernel: number): number;
  16098. /**
  16099. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16100. * @param x The point on the Gaussian distribution to sample.
  16101. * @return the value of the Gaussian function at x.
  16102. */
  16103. protected _gaussianWeight(x: number): number;
  16104. /**
  16105. * Generates a string that can be used as a floating point number in GLSL.
  16106. * @param x Value to print.
  16107. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16108. * @return GLSL float string.
  16109. */
  16110. protected _glslFloat(x: number, decimalFigures?: number): string;
  16111. }
  16112. }
  16113. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16114. import { Scene } from "babylonjs/scene";
  16115. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16116. import { Plane } from "babylonjs/Maths/math.plane";
  16117. /**
  16118. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16119. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16120. * You can then easily use it as a reflectionTexture on a flat surface.
  16121. * In case the surface is not a plane, please consider relying on reflection probes.
  16122. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16123. */
  16124. export class MirrorTexture extends RenderTargetTexture {
  16125. private scene;
  16126. /**
  16127. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16128. * 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.
  16129. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16130. */
  16131. mirrorPlane: Plane;
  16132. /**
  16133. * Define the blur ratio used to blur the reflection if needed.
  16134. */
  16135. blurRatio: number;
  16136. /**
  16137. * Define the adaptive blur kernel used to blur the reflection if needed.
  16138. * This will autocompute the closest best match for the `blurKernel`
  16139. */
  16140. adaptiveBlurKernel: number;
  16141. /**
  16142. * Define the blur kernel used to blur the reflection if needed.
  16143. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16144. */
  16145. blurKernel: number;
  16146. /**
  16147. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16148. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16149. */
  16150. blurKernelX: number;
  16151. /**
  16152. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16153. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16154. */
  16155. blurKernelY: number;
  16156. private _autoComputeBlurKernel;
  16157. protected _onRatioRescale(): void;
  16158. private _updateGammaSpace;
  16159. private _imageProcessingConfigChangeObserver;
  16160. private _transformMatrix;
  16161. private _mirrorMatrix;
  16162. private _savedViewMatrix;
  16163. private _blurX;
  16164. private _blurY;
  16165. private _adaptiveBlurKernel;
  16166. private _blurKernelX;
  16167. private _blurKernelY;
  16168. private _blurRatio;
  16169. /**
  16170. * Instantiates a Mirror Texture.
  16171. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16172. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16173. * You can then easily use it as a reflectionTexture on a flat surface.
  16174. * In case the surface is not a plane, please consider relying on reflection probes.
  16175. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16176. * @param name
  16177. * @param size
  16178. * @param scene
  16179. * @param generateMipMaps
  16180. * @param type
  16181. * @param samplingMode
  16182. * @param generateDepthBuffer
  16183. */
  16184. constructor(name: string, size: number | {
  16185. width: number;
  16186. height: number;
  16187. } | {
  16188. ratio: number;
  16189. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16190. private _preparePostProcesses;
  16191. /**
  16192. * Clone the mirror texture.
  16193. * @returns the cloned texture
  16194. */
  16195. clone(): MirrorTexture;
  16196. /**
  16197. * Serialize the texture to a JSON representation you could use in Parse later on
  16198. * @returns the serialized JSON representation
  16199. */
  16200. serialize(): any;
  16201. /**
  16202. * Dispose the texture and release its associated resources.
  16203. */
  16204. dispose(): void;
  16205. }
  16206. }
  16207. declare module "babylonjs/Materials/Textures/texture" {
  16208. import { Observable } from "babylonjs/Misc/observable";
  16209. import { Nullable } from "babylonjs/types";
  16210. import { Matrix } from "babylonjs/Maths/math.vector";
  16211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16212. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16213. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16214. import { Scene } from "babylonjs/scene";
  16215. /**
  16216. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16217. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16218. */
  16219. export class Texture extends BaseTexture {
  16220. /**
  16221. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16222. */
  16223. static SerializeBuffers: boolean;
  16224. /** @hidden */
  16225. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16226. /** @hidden */
  16227. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16228. /** @hidden */
  16229. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16230. /** nearest is mag = nearest and min = nearest and mip = linear */
  16231. static readonly NEAREST_SAMPLINGMODE: number;
  16232. /** nearest is mag = nearest and min = nearest and mip = linear */
  16233. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16234. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16235. static readonly BILINEAR_SAMPLINGMODE: number;
  16236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16237. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16238. /** Trilinear is mag = linear and min = linear and mip = linear */
  16239. static readonly TRILINEAR_SAMPLINGMODE: number;
  16240. /** Trilinear is mag = linear and min = linear and mip = linear */
  16241. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16242. /** mag = nearest and min = nearest and mip = nearest */
  16243. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16244. /** mag = nearest and min = linear and mip = nearest */
  16245. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16246. /** mag = nearest and min = linear and mip = linear */
  16247. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16248. /** mag = nearest and min = linear and mip = none */
  16249. static readonly NEAREST_LINEAR: number;
  16250. /** mag = nearest and min = nearest and mip = none */
  16251. static readonly NEAREST_NEAREST: number;
  16252. /** mag = linear and min = nearest and mip = nearest */
  16253. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16254. /** mag = linear and min = nearest and mip = linear */
  16255. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16256. /** mag = linear and min = linear and mip = none */
  16257. static readonly LINEAR_LINEAR: number;
  16258. /** mag = linear and min = nearest and mip = none */
  16259. static readonly LINEAR_NEAREST: number;
  16260. /** Explicit coordinates mode */
  16261. static readonly EXPLICIT_MODE: number;
  16262. /** Spherical coordinates mode */
  16263. static readonly SPHERICAL_MODE: number;
  16264. /** Planar coordinates mode */
  16265. static readonly PLANAR_MODE: number;
  16266. /** Cubic coordinates mode */
  16267. static readonly CUBIC_MODE: number;
  16268. /** Projection coordinates mode */
  16269. static readonly PROJECTION_MODE: number;
  16270. /** Inverse Cubic coordinates mode */
  16271. static readonly SKYBOX_MODE: number;
  16272. /** Inverse Cubic coordinates mode */
  16273. static readonly INVCUBIC_MODE: number;
  16274. /** Equirectangular coordinates mode */
  16275. static readonly EQUIRECTANGULAR_MODE: number;
  16276. /** Equirectangular Fixed coordinates mode */
  16277. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16278. /** Equirectangular Fixed Mirrored coordinates mode */
  16279. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16280. /** Texture is not repeating outside of 0..1 UVs */
  16281. static readonly CLAMP_ADDRESSMODE: number;
  16282. /** Texture is repeating outside of 0..1 UVs */
  16283. static readonly WRAP_ADDRESSMODE: number;
  16284. /** Texture is repeating and mirrored */
  16285. static readonly MIRROR_ADDRESSMODE: number;
  16286. /**
  16287. * 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
  16288. */
  16289. static UseSerializedUrlIfAny: boolean;
  16290. /**
  16291. * Define the url of the texture.
  16292. */
  16293. url: Nullable<string>;
  16294. /**
  16295. * Define an offset on the texture to offset the u coordinates of the UVs
  16296. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16297. */
  16298. uOffset: number;
  16299. /**
  16300. * Define an offset on the texture to offset the v coordinates of the UVs
  16301. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16302. */
  16303. vOffset: number;
  16304. /**
  16305. * Define an offset on the texture to scale the u coordinates of the UVs
  16306. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16307. */
  16308. uScale: number;
  16309. /**
  16310. * Define an offset on the texture to scale the v coordinates of the UVs
  16311. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16312. */
  16313. vScale: number;
  16314. /**
  16315. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16316. * @see http://doc.babylonjs.com/how_to/more_materials
  16317. */
  16318. uAng: number;
  16319. /**
  16320. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16321. * @see http://doc.babylonjs.com/how_to/more_materials
  16322. */
  16323. vAng: number;
  16324. /**
  16325. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16326. * @see http://doc.babylonjs.com/how_to/more_materials
  16327. */
  16328. wAng: number;
  16329. /**
  16330. * Defines the center of rotation (U)
  16331. */
  16332. uRotationCenter: number;
  16333. /**
  16334. * Defines the center of rotation (V)
  16335. */
  16336. vRotationCenter: number;
  16337. /**
  16338. * Defines the center of rotation (W)
  16339. */
  16340. wRotationCenter: number;
  16341. /**
  16342. * Are mip maps generated for this texture or not.
  16343. */
  16344. readonly noMipmap: boolean;
  16345. /**
  16346. * List of inspectable custom properties (used by the Inspector)
  16347. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16348. */
  16349. inspectableCustomProperties: Nullable<IInspectable[]>;
  16350. private _noMipmap;
  16351. /** @hidden */
  16352. _invertY: boolean;
  16353. private _rowGenerationMatrix;
  16354. private _cachedTextureMatrix;
  16355. private _projectionModeMatrix;
  16356. private _t0;
  16357. private _t1;
  16358. private _t2;
  16359. private _cachedUOffset;
  16360. private _cachedVOffset;
  16361. private _cachedUScale;
  16362. private _cachedVScale;
  16363. private _cachedUAng;
  16364. private _cachedVAng;
  16365. private _cachedWAng;
  16366. private _cachedProjectionMatrixId;
  16367. private _cachedCoordinatesMode;
  16368. /** @hidden */
  16369. protected _initialSamplingMode: number;
  16370. /** @hidden */
  16371. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16372. private _deleteBuffer;
  16373. protected _format: Nullable<number>;
  16374. private _delayedOnLoad;
  16375. private _delayedOnError;
  16376. private _mimeType?;
  16377. /**
  16378. * Observable triggered once the texture has been loaded.
  16379. */
  16380. onLoadObservable: Observable<Texture>;
  16381. protected _isBlocking: boolean;
  16382. /**
  16383. * Is the texture preventing material to render while loading.
  16384. * If false, a default texture will be used instead of the loading one during the preparation step.
  16385. */
  16386. isBlocking: boolean;
  16387. /**
  16388. * Get the current sampling mode associated with the texture.
  16389. */
  16390. readonly samplingMode: number;
  16391. /**
  16392. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16393. */
  16394. readonly invertY: boolean;
  16395. /**
  16396. * Instantiates a new texture.
  16397. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16398. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16399. * @param url defines the url of the picture to load as a texture
  16400. * @param scene defines the scene or engine the texture will belong to
  16401. * @param noMipmap defines if the texture will require mip maps or not
  16402. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16403. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16404. * @param onLoad defines a callback triggered when the texture has been loaded
  16405. * @param onError defines a callback triggered when an error occurred during the loading session
  16406. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16407. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16408. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16409. * @param mimeType defines an optional mime type information
  16410. */
  16411. 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);
  16412. /**
  16413. * Update the url (and optional buffer) of this texture if url was null during construction.
  16414. * @param url the url of the texture
  16415. * @param buffer the buffer of the texture (defaults to null)
  16416. * @param onLoad callback called when the texture is loaded (defaults to null)
  16417. */
  16418. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16419. /**
  16420. * Finish the loading sequence of a texture flagged as delayed load.
  16421. * @hidden
  16422. */
  16423. delayLoad(): void;
  16424. private _prepareRowForTextureGeneration;
  16425. /**
  16426. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16427. * @returns the transform matrix of the texture.
  16428. */
  16429. getTextureMatrix(): Matrix;
  16430. /**
  16431. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16432. * @returns The reflection texture transform
  16433. */
  16434. getReflectionTextureMatrix(): Matrix;
  16435. /**
  16436. * Clones the texture.
  16437. * @returns the cloned texture
  16438. */
  16439. clone(): Texture;
  16440. /**
  16441. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16442. * @returns The JSON representation of the texture
  16443. */
  16444. serialize(): any;
  16445. /**
  16446. * Get the current class name of the texture useful for serialization or dynamic coding.
  16447. * @returns "Texture"
  16448. */
  16449. getClassName(): string;
  16450. /**
  16451. * Dispose the texture and release its associated resources.
  16452. */
  16453. dispose(): void;
  16454. /**
  16455. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16456. * @param parsedTexture Define the JSON representation of the texture
  16457. * @param scene Define the scene the parsed texture should be instantiated in
  16458. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16459. * @returns The parsed texture if successful
  16460. */
  16461. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16462. /**
  16463. * Creates a texture from its base 64 representation.
  16464. * @param data Define the base64 payload without the data: prefix
  16465. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16466. * @param scene Define the scene the texture should belong to
  16467. * @param noMipmap Forces the texture to not create mip map information if true
  16468. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16469. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16470. * @param onLoad define a callback triggered when the texture has been loaded
  16471. * @param onError define a callback triggered when an error occurred during the loading session
  16472. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16473. * @returns the created texture
  16474. */
  16475. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16476. /**
  16477. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16478. * @param data Define the base64 payload without the data: prefix
  16479. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16480. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16481. * @param scene Define the scene the texture should belong to
  16482. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16483. * @param noMipmap Forces the texture to not create mip map information if true
  16484. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16485. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16486. * @param onLoad define a callback triggered when the texture has been loaded
  16487. * @param onError define a callback triggered when an error occurred during the loading session
  16488. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16489. * @returns the created texture
  16490. */
  16491. 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;
  16492. }
  16493. }
  16494. declare module "babylonjs/PostProcesses/postProcessManager" {
  16495. import { Nullable } from "babylonjs/types";
  16496. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16497. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16498. import { Scene } from "babylonjs/scene";
  16499. /**
  16500. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16501. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16502. */
  16503. export class PostProcessManager {
  16504. private _scene;
  16505. private _indexBuffer;
  16506. private _vertexBuffers;
  16507. /**
  16508. * Creates a new instance PostProcess
  16509. * @param scene The scene that the post process is associated with.
  16510. */
  16511. constructor(scene: Scene);
  16512. private _prepareBuffers;
  16513. private _buildIndexBuffer;
  16514. /**
  16515. * Rebuilds the vertex buffers of the manager.
  16516. * @hidden
  16517. */
  16518. _rebuild(): void;
  16519. /**
  16520. * Prepares a frame to be run through a post process.
  16521. * @param sourceTexture The input texture to the post procesess. (default: null)
  16522. * @param postProcesses An array of post processes to be run. (default: null)
  16523. * @returns True if the post processes were able to be run.
  16524. * @hidden
  16525. */
  16526. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16527. /**
  16528. * Manually render a set of post processes to a texture.
  16529. * @param postProcesses An array of post processes to be run.
  16530. * @param targetTexture The target texture to render to.
  16531. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16532. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16533. * @param lodLevel defines which lod of the texture to render to
  16534. */
  16535. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16536. /**
  16537. * Finalize the result of the output of the postprocesses.
  16538. * @param doNotPresent If true the result will not be displayed to the screen.
  16539. * @param targetTexture The target texture to render to.
  16540. * @param faceIndex The index of the face to bind the target texture to.
  16541. * @param postProcesses The array of post processes to render.
  16542. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16543. * @hidden
  16544. */
  16545. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16546. /**
  16547. * Disposes of the post process manager.
  16548. */
  16549. dispose(): void;
  16550. }
  16551. }
  16552. declare module "babylonjs/Misc/gradients" {
  16553. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16554. /** Interface used by value gradients (color, factor, ...) */
  16555. export interface IValueGradient {
  16556. /**
  16557. * Gets or sets the gradient value (between 0 and 1)
  16558. */
  16559. gradient: number;
  16560. }
  16561. /** Class used to store color4 gradient */
  16562. export class ColorGradient implements IValueGradient {
  16563. /**
  16564. * Gets or sets the gradient value (between 0 and 1)
  16565. */
  16566. gradient: number;
  16567. /**
  16568. * Gets or sets first associated color
  16569. */
  16570. color1: Color4;
  16571. /**
  16572. * Gets or sets second associated color
  16573. */
  16574. color2?: Color4;
  16575. /**
  16576. * Will get a color picked randomly between color1 and color2.
  16577. * If color2 is undefined then color1 will be used
  16578. * @param result defines the target Color4 to store the result in
  16579. */
  16580. getColorToRef(result: Color4): void;
  16581. }
  16582. /** Class used to store color 3 gradient */
  16583. export class Color3Gradient implements IValueGradient {
  16584. /**
  16585. * Gets or sets the gradient value (between 0 and 1)
  16586. */
  16587. gradient: number;
  16588. /**
  16589. * Gets or sets the associated color
  16590. */
  16591. color: Color3;
  16592. }
  16593. /** Class used to store factor gradient */
  16594. export class FactorGradient implements IValueGradient {
  16595. /**
  16596. * Gets or sets the gradient value (between 0 and 1)
  16597. */
  16598. gradient: number;
  16599. /**
  16600. * Gets or sets first associated factor
  16601. */
  16602. factor1: number;
  16603. /**
  16604. * Gets or sets second associated factor
  16605. */
  16606. factor2?: number;
  16607. /**
  16608. * Will get a number picked randomly between factor1 and factor2.
  16609. * If factor2 is undefined then factor1 will be used
  16610. * @returns the picked number
  16611. */
  16612. getFactor(): number;
  16613. }
  16614. /**
  16615. * Helper used to simplify some generic gradient tasks
  16616. */
  16617. export class GradientHelper {
  16618. /**
  16619. * Gets the current gradient from an array of IValueGradient
  16620. * @param ratio defines the current ratio to get
  16621. * @param gradients defines the array of IValueGradient
  16622. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16623. */
  16624. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16625. }
  16626. }
  16627. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16628. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16629. import { Nullable } from "babylonjs/types";
  16630. module "babylonjs/Engines/thinEngine" {
  16631. interface ThinEngine {
  16632. /**
  16633. * Creates a dynamic texture
  16634. * @param width defines the width of the texture
  16635. * @param height defines the height of the texture
  16636. * @param generateMipMaps defines if the engine should generate the mip levels
  16637. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16638. * @returns the dynamic texture inside an InternalTexture
  16639. */
  16640. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16641. /**
  16642. * Update the content of a dynamic texture
  16643. * @param texture defines the texture to update
  16644. * @param canvas defines the canvas containing the source
  16645. * @param invertY defines if data must be stored with Y axis inverted
  16646. * @param premulAlpha defines if alpha is stored as premultiplied
  16647. * @param format defines the format of the data
  16648. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16649. */
  16650. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16651. }
  16652. }
  16653. }
  16654. declare module "babylonjs/Misc/canvasGenerator" {
  16655. /**
  16656. * Helper class used to generate a canvas to manipulate images
  16657. */
  16658. export class CanvasGenerator {
  16659. /**
  16660. * Create a new canvas (or offscreen canvas depending on the context)
  16661. * @param width defines the expected width
  16662. * @param height defines the expected height
  16663. * @return a new canvas or offscreen canvas
  16664. */
  16665. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16666. }
  16667. }
  16668. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16669. import { Scene } from "babylonjs/scene";
  16670. import { Texture } from "babylonjs/Materials/Textures/texture";
  16671. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16672. /**
  16673. * A class extending Texture allowing drawing on a texture
  16674. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16675. */
  16676. export class DynamicTexture extends Texture {
  16677. private _generateMipMaps;
  16678. private _canvas;
  16679. private _context;
  16680. private _engine;
  16681. /**
  16682. * Creates a DynamicTexture
  16683. * @param name defines the name of the texture
  16684. * @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
  16685. * @param scene defines the scene where you want the texture
  16686. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16687. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16688. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16689. */
  16690. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16691. /**
  16692. * Get the current class name of the texture useful for serialization or dynamic coding.
  16693. * @returns "DynamicTexture"
  16694. */
  16695. getClassName(): string;
  16696. /**
  16697. * Gets the current state of canRescale
  16698. */
  16699. readonly canRescale: boolean;
  16700. private _recreate;
  16701. /**
  16702. * Scales the texture
  16703. * @param ratio the scale factor to apply to both width and height
  16704. */
  16705. scale(ratio: number): void;
  16706. /**
  16707. * Resizes the texture
  16708. * @param width the new width
  16709. * @param height the new height
  16710. */
  16711. scaleTo(width: number, height: number): void;
  16712. /**
  16713. * Gets the context of the canvas used by the texture
  16714. * @returns the canvas context of the dynamic texture
  16715. */
  16716. getContext(): CanvasRenderingContext2D;
  16717. /**
  16718. * Clears the texture
  16719. */
  16720. clear(): void;
  16721. /**
  16722. * Updates the texture
  16723. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16724. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16725. */
  16726. update(invertY?: boolean, premulAlpha?: boolean): void;
  16727. /**
  16728. * Draws text onto the texture
  16729. * @param text defines the text to be drawn
  16730. * @param x defines the placement of the text from the left
  16731. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16732. * @param font defines the font to be used with font-style, font-size, font-name
  16733. * @param color defines the color used for the text
  16734. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16735. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16736. * @param update defines whether texture is immediately update (default is true)
  16737. */
  16738. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16739. /**
  16740. * Clones the texture
  16741. * @returns the clone of the texture.
  16742. */
  16743. clone(): DynamicTexture;
  16744. /**
  16745. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16746. * @returns a serialized dynamic texture object
  16747. */
  16748. serialize(): any;
  16749. /** @hidden */
  16750. _rebuild(): void;
  16751. }
  16752. }
  16753. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16754. import { Scene } from "babylonjs/scene";
  16755. import { ISceneComponent } from "babylonjs/sceneComponent";
  16756. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16757. module "babylonjs/abstractScene" {
  16758. interface AbstractScene {
  16759. /**
  16760. * The list of procedural textures added to the scene
  16761. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16762. */
  16763. proceduralTextures: Array<ProceduralTexture>;
  16764. }
  16765. }
  16766. /**
  16767. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16768. * in a given scene.
  16769. */
  16770. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16771. /**
  16772. * The component name helpfull to identify the component in the list of scene components.
  16773. */
  16774. readonly name: string;
  16775. /**
  16776. * The scene the component belongs to.
  16777. */
  16778. scene: Scene;
  16779. /**
  16780. * Creates a new instance of the component for the given scene
  16781. * @param scene Defines the scene to register the component in
  16782. */
  16783. constructor(scene: Scene);
  16784. /**
  16785. * Registers the component in a given scene
  16786. */
  16787. register(): void;
  16788. /**
  16789. * Rebuilds the elements related to this component in case of
  16790. * context lost for instance.
  16791. */
  16792. rebuild(): void;
  16793. /**
  16794. * Disposes the component and the associated ressources.
  16795. */
  16796. dispose(): void;
  16797. private _beforeClear;
  16798. }
  16799. }
  16800. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16801. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16802. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16803. module "babylonjs/Engines/thinEngine" {
  16804. interface ThinEngine {
  16805. /**
  16806. * Creates a new render target cube texture
  16807. * @param size defines the size of the texture
  16808. * @param options defines the options used to create the texture
  16809. * @returns a new render target cube texture stored in an InternalTexture
  16810. */
  16811. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16812. }
  16813. }
  16814. }
  16815. declare module "babylonjs/Shaders/procedural.vertex" {
  16816. /** @hidden */
  16817. export var proceduralVertexShader: {
  16818. name: string;
  16819. shader: string;
  16820. };
  16821. }
  16822. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16823. import { Observable } from "babylonjs/Misc/observable";
  16824. import { Nullable } from "babylonjs/types";
  16825. import { Scene } from "babylonjs/scene";
  16826. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16827. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16828. import { Effect } from "babylonjs/Materials/effect";
  16829. import { Texture } from "babylonjs/Materials/Textures/texture";
  16830. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16831. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16832. import "babylonjs/Shaders/procedural.vertex";
  16833. /**
  16834. * 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.
  16835. * This is the base class of any Procedural texture and contains most of the shareable code.
  16836. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16837. */
  16838. export class ProceduralTexture extends Texture {
  16839. isCube: boolean;
  16840. /**
  16841. * Define if the texture is enabled or not (disabled texture will not render)
  16842. */
  16843. isEnabled: boolean;
  16844. /**
  16845. * Define if the texture must be cleared before rendering (default is true)
  16846. */
  16847. autoClear: boolean;
  16848. /**
  16849. * Callback called when the texture is generated
  16850. */
  16851. onGenerated: () => void;
  16852. /**
  16853. * Event raised when the texture is generated
  16854. */
  16855. onGeneratedObservable: Observable<ProceduralTexture>;
  16856. /** @hidden */
  16857. _generateMipMaps: boolean;
  16858. /** @hidden **/
  16859. _effect: Effect;
  16860. /** @hidden */
  16861. _textures: {
  16862. [key: string]: Texture;
  16863. };
  16864. private _size;
  16865. private _currentRefreshId;
  16866. private _refreshRate;
  16867. private _vertexBuffers;
  16868. private _indexBuffer;
  16869. private _uniforms;
  16870. private _samplers;
  16871. private _fragment;
  16872. private _floats;
  16873. private _ints;
  16874. private _floatsArrays;
  16875. private _colors3;
  16876. private _colors4;
  16877. private _vectors2;
  16878. private _vectors3;
  16879. private _matrices;
  16880. private _fallbackTexture;
  16881. private _fallbackTextureUsed;
  16882. private _engine;
  16883. private _cachedDefines;
  16884. private _contentUpdateId;
  16885. private _contentData;
  16886. /**
  16887. * Instantiates a new procedural texture.
  16888. * 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.
  16889. * This is the base class of any Procedural texture and contains most of the shareable code.
  16890. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16891. * @param name Define the name of the texture
  16892. * @param size Define the size of the texture to create
  16893. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16894. * @param scene Define the scene the texture belongs to
  16895. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16896. * @param generateMipMaps Define if the texture should creates mip maps or not
  16897. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16898. */
  16899. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16900. /**
  16901. * The effect that is created when initializing the post process.
  16902. * @returns The created effect corresponding the the postprocess.
  16903. */
  16904. getEffect(): Effect;
  16905. /**
  16906. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16907. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16908. */
  16909. getContent(): Nullable<ArrayBufferView>;
  16910. private _createIndexBuffer;
  16911. /** @hidden */
  16912. _rebuild(): void;
  16913. /**
  16914. * Resets the texture in order to recreate its associated resources.
  16915. * This can be called in case of context loss
  16916. */
  16917. reset(): void;
  16918. protected _getDefines(): string;
  16919. /**
  16920. * Is the texture ready to be used ? (rendered at least once)
  16921. * @returns true if ready, otherwise, false.
  16922. */
  16923. isReady(): boolean;
  16924. /**
  16925. * Resets the refresh counter of the texture and start bak from scratch.
  16926. * Could be useful to regenerate the texture if it is setup to render only once.
  16927. */
  16928. resetRefreshCounter(): void;
  16929. /**
  16930. * Set the fragment shader to use in order to render the texture.
  16931. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16932. */
  16933. setFragment(fragment: any): void;
  16934. /**
  16935. * Define the refresh rate of the texture or the rendering frequency.
  16936. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16937. */
  16938. refreshRate: number;
  16939. /** @hidden */
  16940. _shouldRender(): boolean;
  16941. /**
  16942. * Get the size the texture is rendering at.
  16943. * @returns the size (texture is always squared)
  16944. */
  16945. getRenderSize(): number;
  16946. /**
  16947. * Resize the texture to new value.
  16948. * @param size Define the new size the texture should have
  16949. * @param generateMipMaps Define whether the new texture should create mip maps
  16950. */
  16951. resize(size: number, generateMipMaps: boolean): void;
  16952. private _checkUniform;
  16953. /**
  16954. * Set a texture in the shader program used to render.
  16955. * @param name Define the name of the uniform samplers as defined in the shader
  16956. * @param texture Define the texture to bind to this sampler
  16957. * @return the texture itself allowing "fluent" like uniform updates
  16958. */
  16959. setTexture(name: string, texture: Texture): ProceduralTexture;
  16960. /**
  16961. * Set a float in the shader.
  16962. * @param name Define the name of the uniform as defined in the shader
  16963. * @param value Define the value to give to the uniform
  16964. * @return the texture itself allowing "fluent" like uniform updates
  16965. */
  16966. setFloat(name: string, value: number): ProceduralTexture;
  16967. /**
  16968. * Set a int in the shader.
  16969. * @param name Define the name of the uniform as defined in the shader
  16970. * @param value Define the value to give to the uniform
  16971. * @return the texture itself allowing "fluent" like uniform updates
  16972. */
  16973. setInt(name: string, value: number): ProceduralTexture;
  16974. /**
  16975. * Set an array of floats in the shader.
  16976. * @param name Define the name of the uniform as defined in the shader
  16977. * @param value Define the value to give to the uniform
  16978. * @return the texture itself allowing "fluent" like uniform updates
  16979. */
  16980. setFloats(name: string, value: number[]): ProceduralTexture;
  16981. /**
  16982. * Set a vec3 in the shader from a Color3.
  16983. * @param name Define the name of the uniform as defined in the shader
  16984. * @param value Define the value to give to the uniform
  16985. * @return the texture itself allowing "fluent" like uniform updates
  16986. */
  16987. setColor3(name: string, value: Color3): ProceduralTexture;
  16988. /**
  16989. * Set a vec4 in the shader from a Color4.
  16990. * @param name Define the name of the uniform as defined in the shader
  16991. * @param value Define the value to give to the uniform
  16992. * @return the texture itself allowing "fluent" like uniform updates
  16993. */
  16994. setColor4(name: string, value: Color4): ProceduralTexture;
  16995. /**
  16996. * Set a vec2 in the shader from a Vector2.
  16997. * @param name Define the name of the uniform as defined in the shader
  16998. * @param value Define the value to give to the uniform
  16999. * @return the texture itself allowing "fluent" like uniform updates
  17000. */
  17001. setVector2(name: string, value: Vector2): ProceduralTexture;
  17002. /**
  17003. * Set a vec3 in the shader from a Vector3.
  17004. * @param name Define the name of the uniform as defined in the shader
  17005. * @param value Define the value to give to the uniform
  17006. * @return the texture itself allowing "fluent" like uniform updates
  17007. */
  17008. setVector3(name: string, value: Vector3): ProceduralTexture;
  17009. /**
  17010. * Set a mat4 in the shader from a MAtrix.
  17011. * @param name Define the name of the uniform as defined in the shader
  17012. * @param value Define the value to give to the uniform
  17013. * @return the texture itself allowing "fluent" like uniform updates
  17014. */
  17015. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17016. /**
  17017. * Render the texture to its associated render target.
  17018. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17019. */
  17020. render(useCameraPostProcess?: boolean): void;
  17021. /**
  17022. * Clone the texture.
  17023. * @returns the cloned texture
  17024. */
  17025. clone(): ProceduralTexture;
  17026. /**
  17027. * Dispose the texture and release its asoociated resources.
  17028. */
  17029. dispose(): void;
  17030. }
  17031. }
  17032. declare module "babylonjs/Particles/baseParticleSystem" {
  17033. import { Nullable } from "babylonjs/types";
  17034. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17036. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17037. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17038. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17039. import { Scene } from "babylonjs/scene";
  17040. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17041. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17042. import { Texture } from "babylonjs/Materials/Textures/texture";
  17043. import { Color4 } from "babylonjs/Maths/math.color";
  17044. import { Animation } from "babylonjs/Animations/animation";
  17045. /**
  17046. * This represents the base class for particle system in Babylon.
  17047. * 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.
  17048. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17049. * @example https://doc.babylonjs.com/babylon101/particles
  17050. */
  17051. export class BaseParticleSystem {
  17052. /**
  17053. * Source color is added to the destination color without alpha affecting the result
  17054. */
  17055. static BLENDMODE_ONEONE: number;
  17056. /**
  17057. * Blend current color and particle color using particle’s alpha
  17058. */
  17059. static BLENDMODE_STANDARD: number;
  17060. /**
  17061. * Add current color and particle color multiplied by particle’s alpha
  17062. */
  17063. static BLENDMODE_ADD: number;
  17064. /**
  17065. * Multiply current color with particle color
  17066. */
  17067. static BLENDMODE_MULTIPLY: number;
  17068. /**
  17069. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17070. */
  17071. static BLENDMODE_MULTIPLYADD: number;
  17072. /**
  17073. * List of animations used by the particle system.
  17074. */
  17075. animations: Animation[];
  17076. /**
  17077. * The id of the Particle system.
  17078. */
  17079. id: string;
  17080. /**
  17081. * The friendly name of the Particle system.
  17082. */
  17083. name: string;
  17084. /**
  17085. * The rendering group used by the Particle system to chose when to render.
  17086. */
  17087. renderingGroupId: number;
  17088. /**
  17089. * The emitter represents the Mesh or position we are attaching the particle system to.
  17090. */
  17091. emitter: Nullable<AbstractMesh | Vector3>;
  17092. /**
  17093. * The maximum number of particles to emit per frame
  17094. */
  17095. emitRate: number;
  17096. /**
  17097. * If you want to launch only a few particles at once, that can be done, as well.
  17098. */
  17099. manualEmitCount: number;
  17100. /**
  17101. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17102. */
  17103. updateSpeed: number;
  17104. /**
  17105. * The amount of time the particle system is running (depends of the overall update speed).
  17106. */
  17107. targetStopDuration: number;
  17108. /**
  17109. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17110. */
  17111. disposeOnStop: boolean;
  17112. /**
  17113. * Minimum power of emitting particles.
  17114. */
  17115. minEmitPower: number;
  17116. /**
  17117. * Maximum power of emitting particles.
  17118. */
  17119. maxEmitPower: number;
  17120. /**
  17121. * Minimum life time of emitting particles.
  17122. */
  17123. minLifeTime: number;
  17124. /**
  17125. * Maximum life time of emitting particles.
  17126. */
  17127. maxLifeTime: number;
  17128. /**
  17129. * Minimum Size of emitting particles.
  17130. */
  17131. minSize: number;
  17132. /**
  17133. * Maximum Size of emitting particles.
  17134. */
  17135. maxSize: number;
  17136. /**
  17137. * Minimum scale of emitting particles on X axis.
  17138. */
  17139. minScaleX: number;
  17140. /**
  17141. * Maximum scale of emitting particles on X axis.
  17142. */
  17143. maxScaleX: number;
  17144. /**
  17145. * Minimum scale of emitting particles on Y axis.
  17146. */
  17147. minScaleY: number;
  17148. /**
  17149. * Maximum scale of emitting particles on Y axis.
  17150. */
  17151. maxScaleY: number;
  17152. /**
  17153. * Gets or sets the minimal initial rotation in radians.
  17154. */
  17155. minInitialRotation: number;
  17156. /**
  17157. * Gets or sets the maximal initial rotation in radians.
  17158. */
  17159. maxInitialRotation: number;
  17160. /**
  17161. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17162. */
  17163. minAngularSpeed: number;
  17164. /**
  17165. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17166. */
  17167. maxAngularSpeed: number;
  17168. /**
  17169. * The texture used to render each particle. (this can be a spritesheet)
  17170. */
  17171. particleTexture: Nullable<Texture>;
  17172. /**
  17173. * The layer mask we are rendering the particles through.
  17174. */
  17175. layerMask: number;
  17176. /**
  17177. * This can help using your own shader to render the particle system.
  17178. * The according effect will be created
  17179. */
  17180. customShader: any;
  17181. /**
  17182. * By default particle system starts as soon as they are created. This prevents the
  17183. * automatic start to happen and let you decide when to start emitting particles.
  17184. */
  17185. preventAutoStart: boolean;
  17186. private _noiseTexture;
  17187. /**
  17188. * Gets or sets a texture used to add random noise to particle positions
  17189. */
  17190. noiseTexture: Nullable<ProceduralTexture>;
  17191. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17192. noiseStrength: Vector3;
  17193. /**
  17194. * Callback triggered when the particle animation is ending.
  17195. */
  17196. onAnimationEnd: Nullable<() => void>;
  17197. /**
  17198. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17199. */
  17200. blendMode: number;
  17201. /**
  17202. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17203. * to override the particles.
  17204. */
  17205. forceDepthWrite: boolean;
  17206. /** 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 */
  17207. preWarmCycles: number;
  17208. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17209. preWarmStepOffset: number;
  17210. /**
  17211. * 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)
  17212. */
  17213. spriteCellChangeSpeed: number;
  17214. /**
  17215. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17216. */
  17217. startSpriteCellID: number;
  17218. /**
  17219. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17220. */
  17221. endSpriteCellID: number;
  17222. /**
  17223. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17224. */
  17225. spriteCellWidth: number;
  17226. /**
  17227. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17228. */
  17229. spriteCellHeight: number;
  17230. /**
  17231. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17232. */
  17233. spriteRandomStartCell: boolean;
  17234. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17235. translationPivot: Vector2;
  17236. /** @hidden */
  17237. protected _isAnimationSheetEnabled: boolean;
  17238. /**
  17239. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17240. */
  17241. beginAnimationOnStart: boolean;
  17242. /**
  17243. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17244. */
  17245. beginAnimationFrom: number;
  17246. /**
  17247. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17248. */
  17249. beginAnimationTo: number;
  17250. /**
  17251. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17252. */
  17253. beginAnimationLoop: boolean;
  17254. /**
  17255. * Gets or sets a world offset applied to all particles
  17256. */
  17257. worldOffset: Vector3;
  17258. /**
  17259. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17260. */
  17261. isAnimationSheetEnabled: boolean;
  17262. /**
  17263. * Get hosting scene
  17264. * @returns the scene
  17265. */
  17266. getScene(): Scene;
  17267. /**
  17268. * You can use gravity if you want to give an orientation to your particles.
  17269. */
  17270. gravity: Vector3;
  17271. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17272. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17273. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17274. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17275. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17276. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17277. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17278. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17279. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17280. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17281. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17282. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17283. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17284. /**
  17285. * Defines the delay in milliseconds before starting the system (0 by default)
  17286. */
  17287. startDelay: number;
  17288. /**
  17289. * Gets the current list of drag gradients.
  17290. * You must use addDragGradient and removeDragGradient to udpate this list
  17291. * @returns the list of drag gradients
  17292. */
  17293. getDragGradients(): Nullable<Array<FactorGradient>>;
  17294. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17295. limitVelocityDamping: number;
  17296. /**
  17297. * Gets the current list of limit velocity gradients.
  17298. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17299. * @returns the list of limit velocity gradients
  17300. */
  17301. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17302. /**
  17303. * Gets the current list of color gradients.
  17304. * You must use addColorGradient and removeColorGradient to udpate this list
  17305. * @returns the list of color gradients
  17306. */
  17307. getColorGradients(): Nullable<Array<ColorGradient>>;
  17308. /**
  17309. * Gets the current list of size gradients.
  17310. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17311. * @returns the list of size gradients
  17312. */
  17313. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17314. /**
  17315. * Gets the current list of color remap gradients.
  17316. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17317. * @returns the list of color remap gradients
  17318. */
  17319. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17320. /**
  17321. * Gets the current list of alpha remap gradients.
  17322. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17323. * @returns the list of alpha remap gradients
  17324. */
  17325. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17326. /**
  17327. * Gets the current list of life time gradients.
  17328. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17329. * @returns the list of life time gradients
  17330. */
  17331. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17332. /**
  17333. * Gets the current list of angular speed gradients.
  17334. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17335. * @returns the list of angular speed gradients
  17336. */
  17337. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17338. /**
  17339. * Gets the current list of velocity gradients.
  17340. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17341. * @returns the list of velocity gradients
  17342. */
  17343. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17344. /**
  17345. * Gets the current list of start size gradients.
  17346. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17347. * @returns the list of start size gradients
  17348. */
  17349. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17350. /**
  17351. * Gets the current list of emit rate gradients.
  17352. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17353. * @returns the list of emit rate gradients
  17354. */
  17355. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17356. /**
  17357. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17358. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17359. */
  17360. direction1: Vector3;
  17361. /**
  17362. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17363. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17364. */
  17365. direction2: Vector3;
  17366. /**
  17367. * 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.
  17368. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17369. */
  17370. minEmitBox: Vector3;
  17371. /**
  17372. * 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.
  17373. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17374. */
  17375. maxEmitBox: Vector3;
  17376. /**
  17377. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17378. */
  17379. color1: Color4;
  17380. /**
  17381. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17382. */
  17383. color2: Color4;
  17384. /**
  17385. * Color the particle will have at the end of its lifetime
  17386. */
  17387. colorDead: Color4;
  17388. /**
  17389. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17390. */
  17391. textureMask: Color4;
  17392. /**
  17393. * The particle emitter type defines the emitter used by the particle system.
  17394. * It can be for example box, sphere, or cone...
  17395. */
  17396. particleEmitterType: IParticleEmitterType;
  17397. /** @hidden */
  17398. _isSubEmitter: boolean;
  17399. /**
  17400. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17401. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17402. */
  17403. billboardMode: number;
  17404. protected _isBillboardBased: boolean;
  17405. /**
  17406. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17407. */
  17408. isBillboardBased: boolean;
  17409. /**
  17410. * The scene the particle system belongs to.
  17411. */
  17412. protected _scene: Scene;
  17413. /**
  17414. * Local cache of defines for image processing.
  17415. */
  17416. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17417. /**
  17418. * Default configuration related to image processing available in the standard Material.
  17419. */
  17420. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17421. /**
  17422. * Gets the image processing configuration used either in this material.
  17423. */
  17424. /**
  17425. * Sets the Default image processing configuration used either in the this material.
  17426. *
  17427. * If sets to null, the scene one is in use.
  17428. */
  17429. imageProcessingConfiguration: ImageProcessingConfiguration;
  17430. /**
  17431. * Attaches a new image processing configuration to the Standard Material.
  17432. * @param configuration
  17433. */
  17434. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17435. /** @hidden */
  17436. protected _reset(): void;
  17437. /** @hidden */
  17438. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17439. /**
  17440. * Instantiates a particle system.
  17441. * 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.
  17442. * @param name The name of the particle system
  17443. */
  17444. constructor(name: string);
  17445. /**
  17446. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17449. * @returns the emitter
  17450. */
  17451. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17452. /**
  17453. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17454. * @param radius The radius of the hemisphere to emit from
  17455. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17456. * @returns the emitter
  17457. */
  17458. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17459. /**
  17460. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17461. * @param radius The radius of the sphere to emit from
  17462. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17463. * @returns the emitter
  17464. */
  17465. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17466. /**
  17467. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17468. * @param radius The radius of the sphere to emit from
  17469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17471. * @returns the emitter
  17472. */
  17473. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17474. /**
  17475. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17476. * @param radius The radius of the emission cylinder
  17477. * @param height The height of the emission cylinder
  17478. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17479. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17480. * @returns the emitter
  17481. */
  17482. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17483. /**
  17484. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17485. * @param radius The radius of the cylinder to emit from
  17486. * @param height The height of the emission cylinder
  17487. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17490. * @returns the emitter
  17491. */
  17492. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17493. /**
  17494. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17495. * @param radius The radius of the cone to emit from
  17496. * @param angle The base angle of the cone
  17497. * @returns the emitter
  17498. */
  17499. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17500. /**
  17501. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17502. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17503. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17504. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17505. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17506. * @returns the emitter
  17507. */
  17508. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17509. }
  17510. }
  17511. declare module "babylonjs/Particles/subEmitter" {
  17512. import { Scene } from "babylonjs/scene";
  17513. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17514. /**
  17515. * Type of sub emitter
  17516. */
  17517. export enum SubEmitterType {
  17518. /**
  17519. * Attached to the particle over it's lifetime
  17520. */
  17521. ATTACHED = 0,
  17522. /**
  17523. * Created when the particle dies
  17524. */
  17525. END = 1
  17526. }
  17527. /**
  17528. * Sub emitter class used to emit particles from an existing particle
  17529. */
  17530. export class SubEmitter {
  17531. /**
  17532. * the particle system to be used by the sub emitter
  17533. */
  17534. particleSystem: ParticleSystem;
  17535. /**
  17536. * Type of the submitter (Default: END)
  17537. */
  17538. type: SubEmitterType;
  17539. /**
  17540. * 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)
  17541. * Note: This only is supported when using an emitter of type Mesh
  17542. */
  17543. inheritDirection: boolean;
  17544. /**
  17545. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17546. */
  17547. inheritedVelocityAmount: number;
  17548. /**
  17549. * Creates a sub emitter
  17550. * @param particleSystem the particle system to be used by the sub emitter
  17551. */
  17552. constructor(
  17553. /**
  17554. * the particle system to be used by the sub emitter
  17555. */
  17556. particleSystem: ParticleSystem);
  17557. /**
  17558. * Clones the sub emitter
  17559. * @returns the cloned sub emitter
  17560. */
  17561. clone(): SubEmitter;
  17562. /**
  17563. * Serialize current object to a JSON object
  17564. * @returns the serialized object
  17565. */
  17566. serialize(): any;
  17567. /** @hidden */
  17568. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17569. /**
  17570. * Creates a new SubEmitter from a serialized JSON version
  17571. * @param serializationObject defines the JSON object to read from
  17572. * @param scene defines the hosting scene
  17573. * @param rootUrl defines the rootUrl for data loading
  17574. * @returns a new SubEmitter
  17575. */
  17576. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17577. /** Release associated resources */
  17578. dispose(): void;
  17579. }
  17580. }
  17581. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17582. /** @hidden */
  17583. export var clipPlaneFragmentDeclaration: {
  17584. name: string;
  17585. shader: string;
  17586. };
  17587. }
  17588. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17589. /** @hidden */
  17590. export var imageProcessingDeclaration: {
  17591. name: string;
  17592. shader: string;
  17593. };
  17594. }
  17595. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17596. /** @hidden */
  17597. export var imageProcessingFunctions: {
  17598. name: string;
  17599. shader: string;
  17600. };
  17601. }
  17602. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17603. /** @hidden */
  17604. export var clipPlaneFragment: {
  17605. name: string;
  17606. shader: string;
  17607. };
  17608. }
  17609. declare module "babylonjs/Shaders/particles.fragment" {
  17610. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17611. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17612. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17613. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17614. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17615. /** @hidden */
  17616. export var particlesPixelShader: {
  17617. name: string;
  17618. shader: string;
  17619. };
  17620. }
  17621. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17622. /** @hidden */
  17623. export var clipPlaneVertexDeclaration: {
  17624. name: string;
  17625. shader: string;
  17626. };
  17627. }
  17628. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17629. /** @hidden */
  17630. export var clipPlaneVertex: {
  17631. name: string;
  17632. shader: string;
  17633. };
  17634. }
  17635. declare module "babylonjs/Shaders/particles.vertex" {
  17636. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17637. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17638. /** @hidden */
  17639. export var particlesVertexShader: {
  17640. name: string;
  17641. shader: string;
  17642. };
  17643. }
  17644. declare module "babylonjs/Particles/particleSystem" {
  17645. import { Nullable } from "babylonjs/types";
  17646. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17647. import { Observable } from "babylonjs/Misc/observable";
  17648. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17649. import { Effect } from "babylonjs/Materials/effect";
  17650. import { Scene, IDisposable } from "babylonjs/scene";
  17651. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17652. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17653. import { Particle } from "babylonjs/Particles/particle";
  17654. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17655. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17656. import "babylonjs/Shaders/particles.fragment";
  17657. import "babylonjs/Shaders/particles.vertex";
  17658. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17659. /**
  17660. * This represents a particle system in Babylon.
  17661. * 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.
  17662. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17663. * @example https://doc.babylonjs.com/babylon101/particles
  17664. */
  17665. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17666. /**
  17667. * Billboard mode will only apply to Y axis
  17668. */
  17669. static readonly BILLBOARDMODE_Y: number;
  17670. /**
  17671. * Billboard mode will apply to all axes
  17672. */
  17673. static readonly BILLBOARDMODE_ALL: number;
  17674. /**
  17675. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17676. */
  17677. static readonly BILLBOARDMODE_STRETCHED: number;
  17678. /**
  17679. * This function can be defined to provide custom update for active particles.
  17680. * This function will be called instead of regular update (age, position, color, etc.).
  17681. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17682. */
  17683. updateFunction: (particles: Particle[]) => void;
  17684. private _emitterWorldMatrix;
  17685. /**
  17686. * This function can be defined to specify initial direction for every new particle.
  17687. * It by default use the emitterType defined function
  17688. */
  17689. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17690. /**
  17691. * This function can be defined to specify initial position for every new particle.
  17692. * It by default use the emitterType defined function
  17693. */
  17694. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17695. /**
  17696. * @hidden
  17697. */
  17698. _inheritedVelocityOffset: Vector3;
  17699. /**
  17700. * An event triggered when the system is disposed
  17701. */
  17702. onDisposeObservable: Observable<ParticleSystem>;
  17703. private _onDisposeObserver;
  17704. /**
  17705. * Sets a callback that will be triggered when the system is disposed
  17706. */
  17707. onDispose: () => void;
  17708. private _particles;
  17709. private _epsilon;
  17710. private _capacity;
  17711. private _stockParticles;
  17712. private _newPartsExcess;
  17713. private _vertexData;
  17714. private _vertexBuffer;
  17715. private _vertexBuffers;
  17716. private _spriteBuffer;
  17717. private _indexBuffer;
  17718. private _effect;
  17719. private _customEffect;
  17720. private _cachedDefines;
  17721. private _scaledColorStep;
  17722. private _colorDiff;
  17723. private _scaledDirection;
  17724. private _scaledGravity;
  17725. private _currentRenderId;
  17726. private _alive;
  17727. private _useInstancing;
  17728. private _started;
  17729. private _stopped;
  17730. private _actualFrame;
  17731. private _scaledUpdateSpeed;
  17732. private _vertexBufferSize;
  17733. /** @hidden */
  17734. _currentEmitRateGradient: Nullable<FactorGradient>;
  17735. /** @hidden */
  17736. _currentEmitRate1: number;
  17737. /** @hidden */
  17738. _currentEmitRate2: number;
  17739. /** @hidden */
  17740. _currentStartSizeGradient: Nullable<FactorGradient>;
  17741. /** @hidden */
  17742. _currentStartSize1: number;
  17743. /** @hidden */
  17744. _currentStartSize2: number;
  17745. private readonly _rawTextureWidth;
  17746. private _rampGradientsTexture;
  17747. private _useRampGradients;
  17748. /** Gets or sets a boolean indicating that ramp gradients must be used
  17749. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17750. */
  17751. useRampGradients: boolean;
  17752. /**
  17753. * 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.
  17754. * 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: [])
  17755. */
  17756. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17757. private _subEmitters;
  17758. /**
  17759. * @hidden
  17760. * If the particle systems emitter should be disposed when the particle system is disposed
  17761. */
  17762. _disposeEmitterOnDispose: boolean;
  17763. /**
  17764. * The current active Sub-systems, this property is used by the root particle system only.
  17765. */
  17766. activeSubSystems: Array<ParticleSystem>;
  17767. private _rootParticleSystem;
  17768. /**
  17769. * Gets the current list of active particles
  17770. */
  17771. readonly particles: Particle[];
  17772. /**
  17773. * Returns the string "ParticleSystem"
  17774. * @returns a string containing the class name
  17775. */
  17776. getClassName(): string;
  17777. /**
  17778. * Instantiates a particle system.
  17779. * 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.
  17780. * @param name The name of the particle system
  17781. * @param capacity The max number of particles alive at the same time
  17782. * @param scene The scene the particle system belongs to
  17783. * @param customEffect a custom effect used to change the way particles are rendered by default
  17784. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17785. * @param epsilon Offset used to render the particles
  17786. */
  17787. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17788. private _addFactorGradient;
  17789. private _removeFactorGradient;
  17790. /**
  17791. * Adds a new life time gradient
  17792. * @param gradient defines the gradient to use (between 0 and 1)
  17793. * @param factor defines the life time factor to affect to the specified gradient
  17794. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17795. * @returns the current particle system
  17796. */
  17797. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17798. /**
  17799. * Remove a specific life time gradient
  17800. * @param gradient defines the gradient to remove
  17801. * @returns the current particle system
  17802. */
  17803. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17804. /**
  17805. * Adds a new size gradient
  17806. * @param gradient defines the gradient to use (between 0 and 1)
  17807. * @param factor defines the size factor to affect to the specified gradient
  17808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17809. * @returns the current particle system
  17810. */
  17811. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17812. /**
  17813. * Remove a specific size gradient
  17814. * @param gradient defines the gradient to remove
  17815. * @returns the current particle system
  17816. */
  17817. removeSizeGradient(gradient: number): IParticleSystem;
  17818. /**
  17819. * Adds a new color remap gradient
  17820. * @param gradient defines the gradient to use (between 0 and 1)
  17821. * @param min defines the color remap minimal range
  17822. * @param max defines the color remap maximal range
  17823. * @returns the current particle system
  17824. */
  17825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17826. /**
  17827. * Remove a specific color remap gradient
  17828. * @param gradient defines the gradient to remove
  17829. * @returns the current particle system
  17830. */
  17831. removeColorRemapGradient(gradient: number): IParticleSystem;
  17832. /**
  17833. * Adds a new alpha remap gradient
  17834. * @param gradient defines the gradient to use (between 0 and 1)
  17835. * @param min defines the alpha remap minimal range
  17836. * @param max defines the alpha remap maximal range
  17837. * @returns the current particle system
  17838. */
  17839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17840. /**
  17841. * Remove a specific alpha remap gradient
  17842. * @param gradient defines the gradient to remove
  17843. * @returns the current particle system
  17844. */
  17845. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17846. /**
  17847. * Adds a new angular speed gradient
  17848. * @param gradient defines the gradient to use (between 0 and 1)
  17849. * @param factor defines the angular speed to affect to the specified gradient
  17850. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17851. * @returns the current particle system
  17852. */
  17853. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17854. /**
  17855. * Remove a specific angular speed gradient
  17856. * @param gradient defines the gradient to remove
  17857. * @returns the current particle system
  17858. */
  17859. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17860. /**
  17861. * Adds a new velocity gradient
  17862. * @param gradient defines the gradient to use (between 0 and 1)
  17863. * @param factor defines the velocity to affect to the specified gradient
  17864. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17865. * @returns the current particle system
  17866. */
  17867. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17868. /**
  17869. * Remove a specific velocity gradient
  17870. * @param gradient defines the gradient to remove
  17871. * @returns the current particle system
  17872. */
  17873. removeVelocityGradient(gradient: number): IParticleSystem;
  17874. /**
  17875. * Adds a new limit velocity gradient
  17876. * @param gradient defines the gradient to use (between 0 and 1)
  17877. * @param factor defines the limit velocity value to affect to the specified gradient
  17878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17879. * @returns the current particle system
  17880. */
  17881. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17882. /**
  17883. * Remove a specific limit velocity gradient
  17884. * @param gradient defines the gradient to remove
  17885. * @returns the current particle system
  17886. */
  17887. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17888. /**
  17889. * Adds a new drag gradient
  17890. * @param gradient defines the gradient to use (between 0 and 1)
  17891. * @param factor defines the drag value to affect to the specified gradient
  17892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17893. * @returns the current particle system
  17894. */
  17895. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17896. /**
  17897. * Remove a specific drag gradient
  17898. * @param gradient defines the gradient to remove
  17899. * @returns the current particle system
  17900. */
  17901. removeDragGradient(gradient: number): IParticleSystem;
  17902. /**
  17903. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17904. * @param gradient defines the gradient to use (between 0 and 1)
  17905. * @param factor defines the emit rate value to affect to the specified gradient
  17906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17907. * @returns the current particle system
  17908. */
  17909. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17910. /**
  17911. * Remove a specific emit rate gradient
  17912. * @param gradient defines the gradient to remove
  17913. * @returns the current particle system
  17914. */
  17915. removeEmitRateGradient(gradient: number): IParticleSystem;
  17916. /**
  17917. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17918. * @param gradient defines the gradient to use (between 0 and 1)
  17919. * @param factor defines the start size value to affect to the specified gradient
  17920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17921. * @returns the current particle system
  17922. */
  17923. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17924. /**
  17925. * Remove a specific start size gradient
  17926. * @param gradient defines the gradient to remove
  17927. * @returns the current particle system
  17928. */
  17929. removeStartSizeGradient(gradient: number): IParticleSystem;
  17930. private _createRampGradientTexture;
  17931. /**
  17932. * Gets the current list of ramp gradients.
  17933. * You must use addRampGradient and removeRampGradient to udpate this list
  17934. * @returns the list of ramp gradients
  17935. */
  17936. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17937. /**
  17938. * Adds a new ramp gradient used to remap particle colors
  17939. * @param gradient defines the gradient to use (between 0 and 1)
  17940. * @param color defines the color to affect to the specified gradient
  17941. * @returns the current particle system
  17942. */
  17943. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17944. /**
  17945. * Remove a specific ramp gradient
  17946. * @param gradient defines the gradient to remove
  17947. * @returns the current particle system
  17948. */
  17949. removeRampGradient(gradient: number): ParticleSystem;
  17950. /**
  17951. * Adds a new color gradient
  17952. * @param gradient defines the gradient to use (between 0 and 1)
  17953. * @param color1 defines the color to affect to the specified gradient
  17954. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17955. * @returns this particle system
  17956. */
  17957. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17958. /**
  17959. * Remove a specific color gradient
  17960. * @param gradient defines the gradient to remove
  17961. * @returns this particle system
  17962. */
  17963. removeColorGradient(gradient: number): IParticleSystem;
  17964. private _fetchR;
  17965. protected _reset(): void;
  17966. private _resetEffect;
  17967. private _createVertexBuffers;
  17968. private _createIndexBuffer;
  17969. /**
  17970. * Gets the maximum number of particles active at the same time.
  17971. * @returns The max number of active particles.
  17972. */
  17973. getCapacity(): number;
  17974. /**
  17975. * Gets whether there are still active particles in the system.
  17976. * @returns True if it is alive, otherwise false.
  17977. */
  17978. isAlive(): boolean;
  17979. /**
  17980. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17981. * @returns True if it has been started, otherwise false.
  17982. */
  17983. isStarted(): boolean;
  17984. private _prepareSubEmitterInternalArray;
  17985. /**
  17986. * Starts the particle system and begins to emit
  17987. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17988. */
  17989. start(delay?: number): void;
  17990. /**
  17991. * Stops the particle system.
  17992. * @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.
  17993. */
  17994. stop(stopSubEmitters?: boolean): void;
  17995. /**
  17996. * Remove all active particles
  17997. */
  17998. reset(): void;
  17999. /**
  18000. * @hidden (for internal use only)
  18001. */
  18002. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18003. /**
  18004. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18005. * Its lifetime will start back at 0.
  18006. */
  18007. recycleParticle: (particle: Particle) => void;
  18008. private _stopSubEmitters;
  18009. private _createParticle;
  18010. private _removeFromRoot;
  18011. private _emitFromParticle;
  18012. private _update;
  18013. /** @hidden */
  18014. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18015. /** @hidden */
  18016. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18017. /** @hidden */
  18018. private _getEffect;
  18019. /**
  18020. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18021. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18022. */
  18023. animate(preWarmOnly?: boolean): void;
  18024. private _appendParticleVertices;
  18025. /**
  18026. * Rebuilds the particle system.
  18027. */
  18028. rebuild(): void;
  18029. /**
  18030. * Is this system ready to be used/rendered
  18031. * @return true if the system is ready
  18032. */
  18033. isReady(): boolean;
  18034. private _render;
  18035. /**
  18036. * Renders the particle system in its current state.
  18037. * @returns the current number of particles
  18038. */
  18039. render(): number;
  18040. /**
  18041. * Disposes the particle system and free the associated resources
  18042. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18043. */
  18044. dispose(disposeTexture?: boolean): void;
  18045. /**
  18046. * Clones the particle system.
  18047. * @param name The name of the cloned object
  18048. * @param newEmitter The new emitter to use
  18049. * @returns the cloned particle system
  18050. */
  18051. clone(name: string, newEmitter: any): ParticleSystem;
  18052. /**
  18053. * Serializes the particle system to a JSON object.
  18054. * @returns the JSON object
  18055. */
  18056. serialize(): any;
  18057. /** @hidden */
  18058. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18059. /** @hidden */
  18060. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18061. /**
  18062. * Parses a JSON object to create a particle system.
  18063. * @param parsedParticleSystem The JSON object to parse
  18064. * @param scene The scene to create the particle system in
  18065. * @param rootUrl The root url to use to load external dependencies like texture
  18066. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18067. * @returns the Parsed particle system
  18068. */
  18069. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18070. }
  18071. }
  18072. declare module "babylonjs/Particles/particle" {
  18073. import { Nullable } from "babylonjs/types";
  18074. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18075. import { Color4 } from "babylonjs/Maths/math.color";
  18076. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18077. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18078. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18079. /**
  18080. * A particle represents one of the element emitted by a particle system.
  18081. * This is mainly define by its coordinates, direction, velocity and age.
  18082. */
  18083. export class Particle {
  18084. /**
  18085. * The particle system the particle belongs to.
  18086. */
  18087. particleSystem: ParticleSystem;
  18088. private static _Count;
  18089. /**
  18090. * Unique ID of the particle
  18091. */
  18092. id: number;
  18093. /**
  18094. * The world position of the particle in the scene.
  18095. */
  18096. position: Vector3;
  18097. /**
  18098. * The world direction of the particle in the scene.
  18099. */
  18100. direction: Vector3;
  18101. /**
  18102. * The color of the particle.
  18103. */
  18104. color: Color4;
  18105. /**
  18106. * The color change of the particle per step.
  18107. */
  18108. colorStep: Color4;
  18109. /**
  18110. * Defines how long will the life of the particle be.
  18111. */
  18112. lifeTime: number;
  18113. /**
  18114. * The current age of the particle.
  18115. */
  18116. age: number;
  18117. /**
  18118. * The current size of the particle.
  18119. */
  18120. size: number;
  18121. /**
  18122. * The current scale of the particle.
  18123. */
  18124. scale: Vector2;
  18125. /**
  18126. * The current angle of the particle.
  18127. */
  18128. angle: number;
  18129. /**
  18130. * Defines how fast is the angle changing.
  18131. */
  18132. angularSpeed: number;
  18133. /**
  18134. * Defines the cell index used by the particle to be rendered from a sprite.
  18135. */
  18136. cellIndex: number;
  18137. /**
  18138. * The information required to support color remapping
  18139. */
  18140. remapData: Vector4;
  18141. /** @hidden */
  18142. _randomCellOffset?: number;
  18143. /** @hidden */
  18144. _initialDirection: Nullable<Vector3>;
  18145. /** @hidden */
  18146. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18147. /** @hidden */
  18148. _initialStartSpriteCellID: number;
  18149. /** @hidden */
  18150. _initialEndSpriteCellID: number;
  18151. /** @hidden */
  18152. _currentColorGradient: Nullable<ColorGradient>;
  18153. /** @hidden */
  18154. _currentColor1: Color4;
  18155. /** @hidden */
  18156. _currentColor2: Color4;
  18157. /** @hidden */
  18158. _currentSizeGradient: Nullable<FactorGradient>;
  18159. /** @hidden */
  18160. _currentSize1: number;
  18161. /** @hidden */
  18162. _currentSize2: number;
  18163. /** @hidden */
  18164. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18165. /** @hidden */
  18166. _currentAngularSpeed1: number;
  18167. /** @hidden */
  18168. _currentAngularSpeed2: number;
  18169. /** @hidden */
  18170. _currentVelocityGradient: Nullable<FactorGradient>;
  18171. /** @hidden */
  18172. _currentVelocity1: number;
  18173. /** @hidden */
  18174. _currentVelocity2: number;
  18175. /** @hidden */
  18176. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18177. /** @hidden */
  18178. _currentLimitVelocity1: number;
  18179. /** @hidden */
  18180. _currentLimitVelocity2: number;
  18181. /** @hidden */
  18182. _currentDragGradient: Nullable<FactorGradient>;
  18183. /** @hidden */
  18184. _currentDrag1: number;
  18185. /** @hidden */
  18186. _currentDrag2: number;
  18187. /** @hidden */
  18188. _randomNoiseCoordinates1: Vector3;
  18189. /** @hidden */
  18190. _randomNoiseCoordinates2: Vector3;
  18191. /**
  18192. * Creates a new instance Particle
  18193. * @param particleSystem the particle system the particle belongs to
  18194. */
  18195. constructor(
  18196. /**
  18197. * The particle system the particle belongs to.
  18198. */
  18199. particleSystem: ParticleSystem);
  18200. private updateCellInfoFromSystem;
  18201. /**
  18202. * Defines how the sprite cell index is updated for the particle
  18203. */
  18204. updateCellIndex(): void;
  18205. /** @hidden */
  18206. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18207. /** @hidden */
  18208. _inheritParticleInfoToSubEmitters(): void;
  18209. /** @hidden */
  18210. _reset(): void;
  18211. /**
  18212. * Copy the properties of particle to another one.
  18213. * @param other the particle to copy the information to.
  18214. */
  18215. copyTo(other: Particle): void;
  18216. }
  18217. }
  18218. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18219. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18220. import { Effect } from "babylonjs/Materials/effect";
  18221. import { Particle } from "babylonjs/Particles/particle";
  18222. /**
  18223. * Particle emitter represents a volume emitting particles.
  18224. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18225. */
  18226. export interface IParticleEmitterType {
  18227. /**
  18228. * Called by the particle System when the direction is computed for the created particle.
  18229. * @param worldMatrix is the world matrix of the particle system
  18230. * @param directionToUpdate is the direction vector to update with the result
  18231. * @param particle is the particle we are computed the direction for
  18232. */
  18233. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18234. /**
  18235. * Called by the particle System when the position is computed for the created particle.
  18236. * @param worldMatrix is the world matrix of the particle system
  18237. * @param positionToUpdate is the position vector to update with the result
  18238. * @param particle is the particle we are computed the position for
  18239. */
  18240. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18241. /**
  18242. * Clones the current emitter and returns a copy of it
  18243. * @returns the new emitter
  18244. */
  18245. clone(): IParticleEmitterType;
  18246. /**
  18247. * Called by the GPUParticleSystem to setup the update shader
  18248. * @param effect defines the update shader
  18249. */
  18250. applyToShader(effect: Effect): void;
  18251. /**
  18252. * Returns a string to use to update the GPU particles update shader
  18253. * @returns the effect defines string
  18254. */
  18255. getEffectDefines(): string;
  18256. /**
  18257. * Returns a string representing the class name
  18258. * @returns a string containing the class name
  18259. */
  18260. getClassName(): string;
  18261. /**
  18262. * Serializes the particle system to a JSON object.
  18263. * @returns the JSON object
  18264. */
  18265. serialize(): any;
  18266. /**
  18267. * Parse properties from a JSON object
  18268. * @param serializationObject defines the JSON object
  18269. */
  18270. parse(serializationObject: any): void;
  18271. }
  18272. }
  18273. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18274. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18275. import { Effect } from "babylonjs/Materials/effect";
  18276. import { Particle } from "babylonjs/Particles/particle";
  18277. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18278. /**
  18279. * Particle emitter emitting particles from the inside of a box.
  18280. * It emits the particles randomly between 2 given directions.
  18281. */
  18282. export class BoxParticleEmitter implements IParticleEmitterType {
  18283. /**
  18284. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18285. */
  18286. direction1: Vector3;
  18287. /**
  18288. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18289. */
  18290. direction2: Vector3;
  18291. /**
  18292. * 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.
  18293. */
  18294. minEmitBox: Vector3;
  18295. /**
  18296. * 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.
  18297. */
  18298. maxEmitBox: Vector3;
  18299. /**
  18300. * Creates a new instance BoxParticleEmitter
  18301. */
  18302. constructor();
  18303. /**
  18304. * Called by the particle System when the direction is computed for the created particle.
  18305. * @param worldMatrix is the world matrix of the particle system
  18306. * @param directionToUpdate is the direction vector to update with the result
  18307. * @param particle is the particle we are computed the direction for
  18308. */
  18309. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18310. /**
  18311. * Called by the particle System when the position is computed for the created particle.
  18312. * @param worldMatrix is the world matrix of the particle system
  18313. * @param positionToUpdate is the position vector to update with the result
  18314. * @param particle is the particle we are computed the position for
  18315. */
  18316. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18317. /**
  18318. * Clones the current emitter and returns a copy of it
  18319. * @returns the new emitter
  18320. */
  18321. clone(): BoxParticleEmitter;
  18322. /**
  18323. * Called by the GPUParticleSystem to setup the update shader
  18324. * @param effect defines the update shader
  18325. */
  18326. applyToShader(effect: Effect): void;
  18327. /**
  18328. * Returns a string to use to update the GPU particles update shader
  18329. * @returns a string containng the defines string
  18330. */
  18331. getEffectDefines(): string;
  18332. /**
  18333. * Returns the string "BoxParticleEmitter"
  18334. * @returns a string containing the class name
  18335. */
  18336. getClassName(): string;
  18337. /**
  18338. * Serializes the particle system to a JSON object.
  18339. * @returns the JSON object
  18340. */
  18341. serialize(): any;
  18342. /**
  18343. * Parse properties from a JSON object
  18344. * @param serializationObject defines the JSON object
  18345. */
  18346. parse(serializationObject: any): void;
  18347. }
  18348. }
  18349. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18350. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18351. import { Effect } from "babylonjs/Materials/effect";
  18352. import { Particle } from "babylonjs/Particles/particle";
  18353. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18354. /**
  18355. * Particle emitter emitting particles from the inside of a cone.
  18356. * It emits the particles alongside the cone volume from the base to the particle.
  18357. * The emission direction might be randomized.
  18358. */
  18359. export class ConeParticleEmitter implements IParticleEmitterType {
  18360. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18361. directionRandomizer: number;
  18362. private _radius;
  18363. private _angle;
  18364. private _height;
  18365. /**
  18366. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18367. */
  18368. radiusRange: number;
  18369. /**
  18370. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18371. */
  18372. heightRange: number;
  18373. /**
  18374. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18375. */
  18376. emitFromSpawnPointOnly: boolean;
  18377. /**
  18378. * Gets or sets the radius of the emission cone
  18379. */
  18380. radius: number;
  18381. /**
  18382. * Gets or sets the angle of the emission cone
  18383. */
  18384. angle: number;
  18385. private _buildHeight;
  18386. /**
  18387. * Creates a new instance ConeParticleEmitter
  18388. * @param radius the radius of the emission cone (1 by default)
  18389. * @param angle the cone base angle (PI by default)
  18390. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18391. */
  18392. constructor(radius?: number, angle?: number,
  18393. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18394. directionRandomizer?: number);
  18395. /**
  18396. * Called by the particle System when the direction is computed for the created particle.
  18397. * @param worldMatrix is the world matrix of the particle system
  18398. * @param directionToUpdate is the direction vector to update with the result
  18399. * @param particle is the particle we are computed the direction for
  18400. */
  18401. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18402. /**
  18403. * Called by the particle System when the position is computed for the created particle.
  18404. * @param worldMatrix is the world matrix of the particle system
  18405. * @param positionToUpdate is the position vector to update with the result
  18406. * @param particle is the particle we are computed the position for
  18407. */
  18408. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18409. /**
  18410. * Clones the current emitter and returns a copy of it
  18411. * @returns the new emitter
  18412. */
  18413. clone(): ConeParticleEmitter;
  18414. /**
  18415. * Called by the GPUParticleSystem to setup the update shader
  18416. * @param effect defines the update shader
  18417. */
  18418. applyToShader(effect: Effect): void;
  18419. /**
  18420. * Returns a string to use to update the GPU particles update shader
  18421. * @returns a string containng the defines string
  18422. */
  18423. getEffectDefines(): string;
  18424. /**
  18425. * Returns the string "ConeParticleEmitter"
  18426. * @returns a string containing the class name
  18427. */
  18428. getClassName(): string;
  18429. /**
  18430. * Serializes the particle system to a JSON object.
  18431. * @returns the JSON object
  18432. */
  18433. serialize(): any;
  18434. /**
  18435. * Parse properties from a JSON object
  18436. * @param serializationObject defines the JSON object
  18437. */
  18438. parse(serializationObject: any): void;
  18439. }
  18440. }
  18441. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18442. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18443. import { Effect } from "babylonjs/Materials/effect";
  18444. import { Particle } from "babylonjs/Particles/particle";
  18445. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18446. /**
  18447. * Particle emitter emitting particles from the inside of a cylinder.
  18448. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18449. */
  18450. export class CylinderParticleEmitter implements IParticleEmitterType {
  18451. /**
  18452. * The radius of the emission cylinder.
  18453. */
  18454. radius: number;
  18455. /**
  18456. * The height of the emission cylinder.
  18457. */
  18458. height: number;
  18459. /**
  18460. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18461. */
  18462. radiusRange: number;
  18463. /**
  18464. * How much to randomize the particle direction [0-1].
  18465. */
  18466. directionRandomizer: number;
  18467. /**
  18468. * Creates a new instance CylinderParticleEmitter
  18469. * @param radius the radius of the emission cylinder (1 by default)
  18470. * @param height the height of the emission cylinder (1 by default)
  18471. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18472. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18473. */
  18474. constructor(
  18475. /**
  18476. * The radius of the emission cylinder.
  18477. */
  18478. radius?: number,
  18479. /**
  18480. * The height of the emission cylinder.
  18481. */
  18482. height?: number,
  18483. /**
  18484. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18485. */
  18486. radiusRange?: number,
  18487. /**
  18488. * How much to randomize the particle direction [0-1].
  18489. */
  18490. directionRandomizer?: number);
  18491. /**
  18492. * Called by the particle System when the direction is computed for the created particle.
  18493. * @param worldMatrix is the world matrix of the particle system
  18494. * @param directionToUpdate is the direction vector to update with the result
  18495. * @param particle is the particle we are computed the direction for
  18496. */
  18497. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18498. /**
  18499. * Called by the particle System when the position is computed for the created particle.
  18500. * @param worldMatrix is the world matrix of the particle system
  18501. * @param positionToUpdate is the position vector to update with the result
  18502. * @param particle is the particle we are computed the position for
  18503. */
  18504. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18505. /**
  18506. * Clones the current emitter and returns a copy of it
  18507. * @returns the new emitter
  18508. */
  18509. clone(): CylinderParticleEmitter;
  18510. /**
  18511. * Called by the GPUParticleSystem to setup the update shader
  18512. * @param effect defines the update shader
  18513. */
  18514. applyToShader(effect: Effect): void;
  18515. /**
  18516. * Returns a string to use to update the GPU particles update shader
  18517. * @returns a string containng the defines string
  18518. */
  18519. getEffectDefines(): string;
  18520. /**
  18521. * Returns the string "CylinderParticleEmitter"
  18522. * @returns a string containing the class name
  18523. */
  18524. getClassName(): string;
  18525. /**
  18526. * Serializes the particle system to a JSON object.
  18527. * @returns the JSON object
  18528. */
  18529. serialize(): any;
  18530. /**
  18531. * Parse properties from a JSON object
  18532. * @param serializationObject defines the JSON object
  18533. */
  18534. parse(serializationObject: any): void;
  18535. }
  18536. /**
  18537. * Particle emitter emitting particles from the inside of a cylinder.
  18538. * It emits the particles randomly between two vectors.
  18539. */
  18540. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18541. /**
  18542. * The min limit of the emission direction.
  18543. */
  18544. direction1: Vector3;
  18545. /**
  18546. * The max limit of the emission direction.
  18547. */
  18548. direction2: Vector3;
  18549. /**
  18550. * Creates a new instance CylinderDirectedParticleEmitter
  18551. * @param radius the radius of the emission cylinder (1 by default)
  18552. * @param height the height of the emission cylinder (1 by default)
  18553. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18554. * @param direction1 the min limit of the emission direction (up vector by default)
  18555. * @param direction2 the max limit of the emission direction (up vector by default)
  18556. */
  18557. constructor(radius?: number, height?: number, radiusRange?: number,
  18558. /**
  18559. * The min limit of the emission direction.
  18560. */
  18561. direction1?: Vector3,
  18562. /**
  18563. * The max limit of the emission direction.
  18564. */
  18565. direction2?: Vector3);
  18566. /**
  18567. * Called by the particle System when the direction is computed for the created particle.
  18568. * @param worldMatrix is the world matrix of the particle system
  18569. * @param directionToUpdate is the direction vector to update with the result
  18570. * @param particle is the particle we are computed the direction for
  18571. */
  18572. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18573. /**
  18574. * Clones the current emitter and returns a copy of it
  18575. * @returns the new emitter
  18576. */
  18577. clone(): CylinderDirectedParticleEmitter;
  18578. /**
  18579. * Called by the GPUParticleSystem to setup the update shader
  18580. * @param effect defines the update shader
  18581. */
  18582. applyToShader(effect: Effect): void;
  18583. /**
  18584. * Returns a string to use to update the GPU particles update shader
  18585. * @returns a string containng the defines string
  18586. */
  18587. getEffectDefines(): string;
  18588. /**
  18589. * Returns the string "CylinderDirectedParticleEmitter"
  18590. * @returns a string containing the class name
  18591. */
  18592. getClassName(): string;
  18593. /**
  18594. * Serializes the particle system to a JSON object.
  18595. * @returns the JSON object
  18596. */
  18597. serialize(): any;
  18598. /**
  18599. * Parse properties from a JSON object
  18600. * @param serializationObject defines the JSON object
  18601. */
  18602. parse(serializationObject: any): void;
  18603. }
  18604. }
  18605. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18606. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18607. import { Effect } from "babylonjs/Materials/effect";
  18608. import { Particle } from "babylonjs/Particles/particle";
  18609. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18610. /**
  18611. * Particle emitter emitting particles from the inside of a hemisphere.
  18612. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18613. */
  18614. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18615. /**
  18616. * The radius of the emission hemisphere.
  18617. */
  18618. radius: number;
  18619. /**
  18620. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18621. */
  18622. radiusRange: number;
  18623. /**
  18624. * How much to randomize the particle direction [0-1].
  18625. */
  18626. directionRandomizer: number;
  18627. /**
  18628. * Creates a new instance HemisphericParticleEmitter
  18629. * @param radius the radius of the emission hemisphere (1 by default)
  18630. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18631. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18632. */
  18633. constructor(
  18634. /**
  18635. * The radius of the emission hemisphere.
  18636. */
  18637. radius?: number,
  18638. /**
  18639. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18640. */
  18641. radiusRange?: number,
  18642. /**
  18643. * How much to randomize the particle direction [0-1].
  18644. */
  18645. directionRandomizer?: number);
  18646. /**
  18647. * Called by the particle System when the direction is computed for the created particle.
  18648. * @param worldMatrix is the world matrix of the particle system
  18649. * @param directionToUpdate is the direction vector to update with the result
  18650. * @param particle is the particle we are computed the direction for
  18651. */
  18652. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18653. /**
  18654. * Called by the particle System when the position is computed for the created particle.
  18655. * @param worldMatrix is the world matrix of the particle system
  18656. * @param positionToUpdate is the position vector to update with the result
  18657. * @param particle is the particle we are computed the position for
  18658. */
  18659. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18660. /**
  18661. * Clones the current emitter and returns a copy of it
  18662. * @returns the new emitter
  18663. */
  18664. clone(): HemisphericParticleEmitter;
  18665. /**
  18666. * Called by the GPUParticleSystem to setup the update shader
  18667. * @param effect defines the update shader
  18668. */
  18669. applyToShader(effect: Effect): void;
  18670. /**
  18671. * Returns a string to use to update the GPU particles update shader
  18672. * @returns a string containng the defines string
  18673. */
  18674. getEffectDefines(): string;
  18675. /**
  18676. * Returns the string "HemisphericParticleEmitter"
  18677. * @returns a string containing the class name
  18678. */
  18679. getClassName(): string;
  18680. /**
  18681. * Serializes the particle system to a JSON object.
  18682. * @returns the JSON object
  18683. */
  18684. serialize(): any;
  18685. /**
  18686. * Parse properties from a JSON object
  18687. * @param serializationObject defines the JSON object
  18688. */
  18689. parse(serializationObject: any): void;
  18690. }
  18691. }
  18692. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18693. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18694. import { Effect } from "babylonjs/Materials/effect";
  18695. import { Particle } from "babylonjs/Particles/particle";
  18696. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18697. /**
  18698. * Particle emitter emitting particles from a point.
  18699. * It emits the particles randomly between 2 given directions.
  18700. */
  18701. export class PointParticleEmitter implements IParticleEmitterType {
  18702. /**
  18703. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18704. */
  18705. direction1: Vector3;
  18706. /**
  18707. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18708. */
  18709. direction2: Vector3;
  18710. /**
  18711. * Creates a new instance PointParticleEmitter
  18712. */
  18713. constructor();
  18714. /**
  18715. * Called by the particle System when the direction is computed for the created particle.
  18716. * @param worldMatrix is the world matrix of the particle system
  18717. * @param directionToUpdate is the direction vector to update with the result
  18718. * @param particle is the particle we are computed the direction for
  18719. */
  18720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18721. /**
  18722. * Called by the particle System when the position is computed for the created particle.
  18723. * @param worldMatrix is the world matrix of the particle system
  18724. * @param positionToUpdate is the position vector to update with the result
  18725. * @param particle is the particle we are computed the position for
  18726. */
  18727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18728. /**
  18729. * Clones the current emitter and returns a copy of it
  18730. * @returns the new emitter
  18731. */
  18732. clone(): PointParticleEmitter;
  18733. /**
  18734. * Called by the GPUParticleSystem to setup the update shader
  18735. * @param effect defines the update shader
  18736. */
  18737. applyToShader(effect: Effect): void;
  18738. /**
  18739. * Returns a string to use to update the GPU particles update shader
  18740. * @returns a string containng the defines string
  18741. */
  18742. getEffectDefines(): string;
  18743. /**
  18744. * Returns the string "PointParticleEmitter"
  18745. * @returns a string containing the class name
  18746. */
  18747. getClassName(): string;
  18748. /**
  18749. * Serializes the particle system to a JSON object.
  18750. * @returns the JSON object
  18751. */
  18752. serialize(): any;
  18753. /**
  18754. * Parse properties from a JSON object
  18755. * @param serializationObject defines the JSON object
  18756. */
  18757. parse(serializationObject: any): void;
  18758. }
  18759. }
  18760. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18761. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18762. import { Effect } from "babylonjs/Materials/effect";
  18763. import { Particle } from "babylonjs/Particles/particle";
  18764. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18765. /**
  18766. * Particle emitter emitting particles from the inside of a sphere.
  18767. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18768. */
  18769. export class SphereParticleEmitter implements IParticleEmitterType {
  18770. /**
  18771. * The radius of the emission sphere.
  18772. */
  18773. radius: number;
  18774. /**
  18775. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18776. */
  18777. radiusRange: number;
  18778. /**
  18779. * How much to randomize the particle direction [0-1].
  18780. */
  18781. directionRandomizer: number;
  18782. /**
  18783. * Creates a new instance SphereParticleEmitter
  18784. * @param radius the radius of the emission sphere (1 by default)
  18785. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18786. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18787. */
  18788. constructor(
  18789. /**
  18790. * The radius of the emission sphere.
  18791. */
  18792. radius?: number,
  18793. /**
  18794. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18795. */
  18796. radiusRange?: number,
  18797. /**
  18798. * How much to randomize the particle direction [0-1].
  18799. */
  18800. directionRandomizer?: number);
  18801. /**
  18802. * Called by the particle System when the direction is computed for the created particle.
  18803. * @param worldMatrix is the world matrix of the particle system
  18804. * @param directionToUpdate is the direction vector to update with the result
  18805. * @param particle is the particle we are computed the direction for
  18806. */
  18807. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18808. /**
  18809. * Called by the particle System when the position is computed for the created particle.
  18810. * @param worldMatrix is the world matrix of the particle system
  18811. * @param positionToUpdate is the position vector to update with the result
  18812. * @param particle is the particle we are computed the position for
  18813. */
  18814. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18815. /**
  18816. * Clones the current emitter and returns a copy of it
  18817. * @returns the new emitter
  18818. */
  18819. clone(): SphereParticleEmitter;
  18820. /**
  18821. * Called by the GPUParticleSystem to setup the update shader
  18822. * @param effect defines the update shader
  18823. */
  18824. applyToShader(effect: Effect): void;
  18825. /**
  18826. * Returns a string to use to update the GPU particles update shader
  18827. * @returns a string containng the defines string
  18828. */
  18829. getEffectDefines(): string;
  18830. /**
  18831. * Returns the string "SphereParticleEmitter"
  18832. * @returns a string containing the class name
  18833. */
  18834. getClassName(): string;
  18835. /**
  18836. * Serializes the particle system to a JSON object.
  18837. * @returns the JSON object
  18838. */
  18839. serialize(): any;
  18840. /**
  18841. * Parse properties from a JSON object
  18842. * @param serializationObject defines the JSON object
  18843. */
  18844. parse(serializationObject: any): void;
  18845. }
  18846. /**
  18847. * Particle emitter emitting particles from the inside of a sphere.
  18848. * It emits the particles randomly between two vectors.
  18849. */
  18850. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18851. /**
  18852. * The min limit of the emission direction.
  18853. */
  18854. direction1: Vector3;
  18855. /**
  18856. * The max limit of the emission direction.
  18857. */
  18858. direction2: Vector3;
  18859. /**
  18860. * Creates a new instance SphereDirectedParticleEmitter
  18861. * @param radius the radius of the emission sphere (1 by default)
  18862. * @param direction1 the min limit of the emission direction (up vector by default)
  18863. * @param direction2 the max limit of the emission direction (up vector by default)
  18864. */
  18865. constructor(radius?: number,
  18866. /**
  18867. * The min limit of the emission direction.
  18868. */
  18869. direction1?: Vector3,
  18870. /**
  18871. * The max limit of the emission direction.
  18872. */
  18873. direction2?: Vector3);
  18874. /**
  18875. * Called by the particle System when the direction is computed for the created particle.
  18876. * @param worldMatrix is the world matrix of the particle system
  18877. * @param directionToUpdate is the direction vector to update with the result
  18878. * @param particle is the particle we are computed the direction for
  18879. */
  18880. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18881. /**
  18882. * Clones the current emitter and returns a copy of it
  18883. * @returns the new emitter
  18884. */
  18885. clone(): SphereDirectedParticleEmitter;
  18886. /**
  18887. * Called by the GPUParticleSystem to setup the update shader
  18888. * @param effect defines the update shader
  18889. */
  18890. applyToShader(effect: Effect): void;
  18891. /**
  18892. * Returns a string to use to update the GPU particles update shader
  18893. * @returns a string containng the defines string
  18894. */
  18895. getEffectDefines(): string;
  18896. /**
  18897. * Returns the string "SphereDirectedParticleEmitter"
  18898. * @returns a string containing the class name
  18899. */
  18900. getClassName(): string;
  18901. /**
  18902. * Serializes the particle system to a JSON object.
  18903. * @returns the JSON object
  18904. */
  18905. serialize(): any;
  18906. /**
  18907. * Parse properties from a JSON object
  18908. * @param serializationObject defines the JSON object
  18909. */
  18910. parse(serializationObject: any): void;
  18911. }
  18912. }
  18913. declare module "babylonjs/Particles/EmitterTypes/index" {
  18914. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18915. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18916. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18917. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18918. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18919. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18920. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18921. }
  18922. declare module "babylonjs/Particles/IParticleSystem" {
  18923. import { Nullable } from "babylonjs/types";
  18924. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18925. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18928. import { Texture } from "babylonjs/Materials/Textures/texture";
  18929. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18930. import { Scene } from "babylonjs/scene";
  18931. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18932. import { Animation } from "babylonjs/Animations/animation";
  18933. /**
  18934. * Interface representing a particle system in Babylon.js.
  18935. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18936. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18937. */
  18938. export interface IParticleSystem {
  18939. /**
  18940. * List of animations used by the particle system.
  18941. */
  18942. animations: Animation[];
  18943. /**
  18944. * The id of the Particle system.
  18945. */
  18946. id: string;
  18947. /**
  18948. * The name of the Particle system.
  18949. */
  18950. name: string;
  18951. /**
  18952. * The emitter represents the Mesh or position we are attaching the particle system to.
  18953. */
  18954. emitter: Nullable<AbstractMesh | Vector3>;
  18955. /**
  18956. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18957. */
  18958. isBillboardBased: boolean;
  18959. /**
  18960. * The rendering group used by the Particle system to chose when to render.
  18961. */
  18962. renderingGroupId: number;
  18963. /**
  18964. * The layer mask we are rendering the particles through.
  18965. */
  18966. layerMask: number;
  18967. /**
  18968. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18969. */
  18970. updateSpeed: number;
  18971. /**
  18972. * The amount of time the particle system is running (depends of the overall update speed).
  18973. */
  18974. targetStopDuration: number;
  18975. /**
  18976. * The texture used to render each particle. (this can be a spritesheet)
  18977. */
  18978. particleTexture: Nullable<Texture>;
  18979. /**
  18980. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18981. */
  18982. blendMode: number;
  18983. /**
  18984. * Minimum life time of emitting particles.
  18985. */
  18986. minLifeTime: number;
  18987. /**
  18988. * Maximum life time of emitting particles.
  18989. */
  18990. maxLifeTime: number;
  18991. /**
  18992. * Minimum Size of emitting particles.
  18993. */
  18994. minSize: number;
  18995. /**
  18996. * Maximum Size of emitting particles.
  18997. */
  18998. maxSize: number;
  18999. /**
  19000. * Minimum scale of emitting particles on X axis.
  19001. */
  19002. minScaleX: number;
  19003. /**
  19004. * Maximum scale of emitting particles on X axis.
  19005. */
  19006. maxScaleX: number;
  19007. /**
  19008. * Minimum scale of emitting particles on Y axis.
  19009. */
  19010. minScaleY: number;
  19011. /**
  19012. * Maximum scale of emitting particles on Y axis.
  19013. */
  19014. maxScaleY: number;
  19015. /**
  19016. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19017. */
  19018. color1: Color4;
  19019. /**
  19020. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19021. */
  19022. color2: Color4;
  19023. /**
  19024. * Color the particle will have at the end of its lifetime.
  19025. */
  19026. colorDead: Color4;
  19027. /**
  19028. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19029. */
  19030. emitRate: number;
  19031. /**
  19032. * You can use gravity if you want to give an orientation to your particles.
  19033. */
  19034. gravity: Vector3;
  19035. /**
  19036. * Minimum power of emitting particles.
  19037. */
  19038. minEmitPower: number;
  19039. /**
  19040. * Maximum power of emitting particles.
  19041. */
  19042. maxEmitPower: number;
  19043. /**
  19044. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19045. */
  19046. minAngularSpeed: number;
  19047. /**
  19048. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19049. */
  19050. maxAngularSpeed: number;
  19051. /**
  19052. * Gets or sets the minimal initial rotation in radians.
  19053. */
  19054. minInitialRotation: number;
  19055. /**
  19056. * Gets or sets the maximal initial rotation in radians.
  19057. */
  19058. maxInitialRotation: number;
  19059. /**
  19060. * The particle emitter type defines the emitter used by the particle system.
  19061. * It can be for example box, sphere, or cone...
  19062. */
  19063. particleEmitterType: Nullable<IParticleEmitterType>;
  19064. /**
  19065. * Defines the delay in milliseconds before starting the system (0 by default)
  19066. */
  19067. startDelay: number;
  19068. /**
  19069. * 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
  19070. */
  19071. preWarmCycles: number;
  19072. /**
  19073. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19074. */
  19075. preWarmStepOffset: number;
  19076. /**
  19077. * 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)
  19078. */
  19079. spriteCellChangeSpeed: number;
  19080. /**
  19081. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19082. */
  19083. startSpriteCellID: number;
  19084. /**
  19085. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19086. */
  19087. endSpriteCellID: number;
  19088. /**
  19089. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19090. */
  19091. spriteCellWidth: number;
  19092. /**
  19093. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19094. */
  19095. spriteCellHeight: number;
  19096. /**
  19097. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19098. */
  19099. spriteRandomStartCell: boolean;
  19100. /**
  19101. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19102. */
  19103. isAnimationSheetEnabled: boolean;
  19104. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19105. translationPivot: Vector2;
  19106. /**
  19107. * Gets or sets a texture used to add random noise to particle positions
  19108. */
  19109. noiseTexture: Nullable<BaseTexture>;
  19110. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19111. noiseStrength: Vector3;
  19112. /**
  19113. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19114. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19115. */
  19116. billboardMode: number;
  19117. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19118. limitVelocityDamping: number;
  19119. /**
  19120. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19121. */
  19122. beginAnimationOnStart: boolean;
  19123. /**
  19124. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19125. */
  19126. beginAnimationFrom: number;
  19127. /**
  19128. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19129. */
  19130. beginAnimationTo: number;
  19131. /**
  19132. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19133. */
  19134. beginAnimationLoop: boolean;
  19135. /**
  19136. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19137. */
  19138. disposeOnStop: boolean;
  19139. /**
  19140. * Gets the maximum number of particles active at the same time.
  19141. * @returns The max number of active particles.
  19142. */
  19143. getCapacity(): number;
  19144. /**
  19145. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19146. * @returns True if it has been started, otherwise false.
  19147. */
  19148. isStarted(): boolean;
  19149. /**
  19150. * Animates the particle system for this frame.
  19151. */
  19152. animate(): void;
  19153. /**
  19154. * Renders the particle system in its current state.
  19155. * @returns the current number of particles
  19156. */
  19157. render(): number;
  19158. /**
  19159. * Dispose the particle system and frees its associated resources.
  19160. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19161. */
  19162. dispose(disposeTexture?: boolean): void;
  19163. /**
  19164. * Clones the particle system.
  19165. * @param name The name of the cloned object
  19166. * @param newEmitter The new emitter to use
  19167. * @returns the cloned particle system
  19168. */
  19169. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19170. /**
  19171. * Serializes the particle system to a JSON object.
  19172. * @returns the JSON object
  19173. */
  19174. serialize(): any;
  19175. /**
  19176. * Rebuild the particle system
  19177. */
  19178. rebuild(): void;
  19179. /**
  19180. * Starts the particle system and begins to emit
  19181. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19182. */
  19183. start(delay?: number): void;
  19184. /**
  19185. * Stops the particle system.
  19186. */
  19187. stop(): void;
  19188. /**
  19189. * Remove all active particles
  19190. */
  19191. reset(): void;
  19192. /**
  19193. * Is this system ready to be used/rendered
  19194. * @return true if the system is ready
  19195. */
  19196. isReady(): boolean;
  19197. /**
  19198. * Adds a new color gradient
  19199. * @param gradient defines the gradient to use (between 0 and 1)
  19200. * @param color1 defines the color to affect to the specified gradient
  19201. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19202. * @returns the current particle system
  19203. */
  19204. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19205. /**
  19206. * Remove a specific color gradient
  19207. * @param gradient defines the gradient to remove
  19208. * @returns the current particle system
  19209. */
  19210. removeColorGradient(gradient: number): IParticleSystem;
  19211. /**
  19212. * Adds a new size gradient
  19213. * @param gradient defines the gradient to use (between 0 and 1)
  19214. * @param factor defines the size factor to affect to the specified gradient
  19215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19216. * @returns the current particle system
  19217. */
  19218. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19219. /**
  19220. * Remove a specific size gradient
  19221. * @param gradient defines the gradient to remove
  19222. * @returns the current particle system
  19223. */
  19224. removeSizeGradient(gradient: number): IParticleSystem;
  19225. /**
  19226. * Gets the current list of color gradients.
  19227. * You must use addColorGradient and removeColorGradient to udpate this list
  19228. * @returns the list of color gradients
  19229. */
  19230. getColorGradients(): Nullable<Array<ColorGradient>>;
  19231. /**
  19232. * Gets the current list of size gradients.
  19233. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19234. * @returns the list of size gradients
  19235. */
  19236. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19237. /**
  19238. * Gets the current list of angular speed gradients.
  19239. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19240. * @returns the list of angular speed gradients
  19241. */
  19242. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19243. /**
  19244. * Adds a new angular speed gradient
  19245. * @param gradient defines the gradient to use (between 0 and 1)
  19246. * @param factor defines the angular speed 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. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19251. /**
  19252. * Remove a specific angular speed gradient
  19253. * @param gradient defines the gradient to remove
  19254. * @returns the current particle system
  19255. */
  19256. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19257. /**
  19258. * Gets the current list of velocity gradients.
  19259. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19260. * @returns the list of velocity gradients
  19261. */
  19262. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19263. /**
  19264. * Adds a new velocity gradient
  19265. * @param gradient defines the gradient to use (between 0 and 1)
  19266. * @param factor defines the 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19271. /**
  19272. * Remove a specific velocity gradient
  19273. * @param gradient defines the gradient to remove
  19274. * @returns the current particle system
  19275. */
  19276. removeVelocityGradient(gradient: number): IParticleSystem;
  19277. /**
  19278. * Gets the current list of limit velocity gradients.
  19279. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19280. * @returns the list of limit velocity gradients
  19281. */
  19282. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19283. /**
  19284. * Adds a new limit velocity gradient
  19285. * @param gradient defines the gradient to use (between 0 and 1)
  19286. * @param factor defines the limit velocity to affect to the specified gradient
  19287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19288. * @returns the current particle system
  19289. */
  19290. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19291. /**
  19292. * Remove a specific limit velocity gradient
  19293. * @param gradient defines the gradient to remove
  19294. * @returns the current particle system
  19295. */
  19296. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19297. /**
  19298. * Adds a new drag gradient
  19299. * @param gradient defines the gradient to use (between 0 and 1)
  19300. * @param factor defines the drag 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. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19305. /**
  19306. * Remove a specific drag gradient
  19307. * @param gradient defines the gradient to remove
  19308. * @returns the current particle system
  19309. */
  19310. removeDragGradient(gradient: number): IParticleSystem;
  19311. /**
  19312. * Gets the current list of drag gradients.
  19313. * You must use addDragGradient and removeDragGradient to udpate this list
  19314. * @returns the list of drag gradients
  19315. */
  19316. getDragGradients(): Nullable<Array<FactorGradient>>;
  19317. /**
  19318. * Adds a new emit rate 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 emit rate 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. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19325. /**
  19326. * Remove a specific emit rate gradient
  19327. * @param gradient defines the gradient to remove
  19328. * @returns the current particle system
  19329. */
  19330. removeEmitRateGradient(gradient: number): IParticleSystem;
  19331. /**
  19332. * Gets the current list of emit rate gradients.
  19333. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19334. * @returns the list of emit rate gradients
  19335. */
  19336. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19337. /**
  19338. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19339. * @param gradient defines the gradient to use (between 0 and 1)
  19340. * @param factor defines the start size 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. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19345. /**
  19346. * Remove a specific start size gradient
  19347. * @param gradient defines the gradient to remove
  19348. * @returns the current particle system
  19349. */
  19350. removeStartSizeGradient(gradient: number): IParticleSystem;
  19351. /**
  19352. * Gets the current list of start size gradients.
  19353. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19354. * @returns the list of start size gradients
  19355. */
  19356. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19357. /**
  19358. * Adds a new life time gradient
  19359. * @param gradient defines the gradient to use (between 0 and 1)
  19360. * @param factor defines the life time factor to affect to the specified gradient
  19361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19362. * @returns the current particle system
  19363. */
  19364. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19365. /**
  19366. * Remove a specific life time gradient
  19367. * @param gradient defines the gradient to remove
  19368. * @returns the current particle system
  19369. */
  19370. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19371. /**
  19372. * Gets the current list of life time gradients.
  19373. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19374. * @returns the list of life time gradients
  19375. */
  19376. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19377. /**
  19378. * Gets the current list of color gradients.
  19379. * You must use addColorGradient and removeColorGradient to udpate this list
  19380. * @returns the list of color gradients
  19381. */
  19382. getColorGradients(): Nullable<Array<ColorGradient>>;
  19383. /**
  19384. * Adds a new ramp gradient used to remap particle colors
  19385. * @param gradient defines the gradient to use (between 0 and 1)
  19386. * @param color defines the color to affect to the specified gradient
  19387. * @returns the current particle system
  19388. */
  19389. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19390. /**
  19391. * Gets the current list of ramp gradients.
  19392. * You must use addRampGradient and removeRampGradient to udpate this list
  19393. * @returns the list of ramp gradients
  19394. */
  19395. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19396. /** Gets or sets a boolean indicating that ramp gradients must be used
  19397. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19398. */
  19399. useRampGradients: boolean;
  19400. /**
  19401. * Adds a new color remap gradient
  19402. * @param gradient defines the gradient to use (between 0 and 1)
  19403. * @param min defines the color remap minimal range
  19404. * @param max defines the color remap maximal range
  19405. * @returns the current particle system
  19406. */
  19407. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19408. /**
  19409. * Gets the current list of color remap gradients.
  19410. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19411. * @returns the list of color remap gradients
  19412. */
  19413. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19414. /**
  19415. * Adds a new alpha remap gradient
  19416. * @param gradient defines the gradient to use (between 0 and 1)
  19417. * @param min defines the alpha remap minimal range
  19418. * @param max defines the alpha remap maximal range
  19419. * @returns the current particle system
  19420. */
  19421. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19422. /**
  19423. * Gets the current list of alpha remap gradients.
  19424. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19425. * @returns the list of alpha remap gradients
  19426. */
  19427. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19428. /**
  19429. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19430. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19431. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19432. * @returns the emitter
  19433. */
  19434. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19435. /**
  19436. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19437. * @param radius The radius of the hemisphere to emit from
  19438. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19439. * @returns the emitter
  19440. */
  19441. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19442. /**
  19443. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19444. * @param radius The radius of the sphere to emit from
  19445. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19446. * @returns the emitter
  19447. */
  19448. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19449. /**
  19450. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19451. * @param radius The radius of the sphere to emit from
  19452. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19453. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19454. * @returns the emitter
  19455. */
  19456. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19457. /**
  19458. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19459. * @param radius The radius of the emission cylinder
  19460. * @param height The height of the emission cylinder
  19461. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19462. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19463. * @returns the emitter
  19464. */
  19465. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19466. /**
  19467. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19468. * @param radius The radius of the cylinder to emit from
  19469. * @param height The height of the emission cylinder
  19470. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19471. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19472. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19473. * @returns the emitter
  19474. */
  19475. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19476. /**
  19477. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19478. * @param radius The radius of the cone to emit from
  19479. * @param angle The base angle of the cone
  19480. * @returns the emitter
  19481. */
  19482. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19483. /**
  19484. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19485. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19486. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19487. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19488. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19489. * @returns the emitter
  19490. */
  19491. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19492. /**
  19493. * Get hosting scene
  19494. * @returns the scene
  19495. */
  19496. getScene(): Scene;
  19497. }
  19498. }
  19499. declare module "babylonjs/Meshes/instancedMesh" {
  19500. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19501. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19502. import { Camera } from "babylonjs/Cameras/camera";
  19503. import { Node } from "babylonjs/node";
  19504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19505. import { Mesh } from "babylonjs/Meshes/mesh";
  19506. import { Material } from "babylonjs/Materials/material";
  19507. import { Skeleton } from "babylonjs/Bones/skeleton";
  19508. import { Light } from "babylonjs/Lights/light";
  19509. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19510. /**
  19511. * Creates an instance based on a source mesh.
  19512. */
  19513. export class InstancedMesh extends AbstractMesh {
  19514. private _sourceMesh;
  19515. private _currentLOD;
  19516. /** @hidden */
  19517. _indexInSourceMeshInstanceArray: number;
  19518. constructor(name: string, source: Mesh);
  19519. /**
  19520. * Returns the string "InstancedMesh".
  19521. */
  19522. getClassName(): string;
  19523. /** Gets the list of lights affecting that mesh */
  19524. readonly lightSources: Light[];
  19525. _resyncLightSources(): void;
  19526. _resyncLighSource(light: Light): void;
  19527. _removeLightSource(light: Light, dispose: boolean): void;
  19528. /**
  19529. * If the source mesh receives shadows
  19530. */
  19531. readonly receiveShadows: boolean;
  19532. /**
  19533. * The material of the source mesh
  19534. */
  19535. readonly material: Nullable<Material>;
  19536. /**
  19537. * Visibility of the source mesh
  19538. */
  19539. readonly visibility: number;
  19540. /**
  19541. * Skeleton of the source mesh
  19542. */
  19543. readonly skeleton: Nullable<Skeleton>;
  19544. /**
  19545. * Rendering ground id of the source mesh
  19546. */
  19547. renderingGroupId: number;
  19548. /**
  19549. * Returns the total number of vertices (integer).
  19550. */
  19551. getTotalVertices(): number;
  19552. /**
  19553. * Returns a positive integer : the total number of indices in this mesh geometry.
  19554. * @returns the numner of indices or zero if the mesh has no geometry.
  19555. */
  19556. getTotalIndices(): number;
  19557. /**
  19558. * The source mesh of the instance
  19559. */
  19560. readonly sourceMesh: Mesh;
  19561. /**
  19562. * Is this node ready to be used/rendered
  19563. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19564. * @return {boolean} is it ready
  19565. */
  19566. isReady(completeCheck?: boolean): boolean;
  19567. /**
  19568. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19569. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19570. * @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.
  19571. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19572. */
  19573. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19574. /**
  19575. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19576. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19577. * The `data` are either a numeric array either a Float32Array.
  19578. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19579. * 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).
  19580. * Note that a new underlying VertexBuffer object is created each call.
  19581. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19582. *
  19583. * Possible `kind` values :
  19584. * - VertexBuffer.PositionKind
  19585. * - VertexBuffer.UVKind
  19586. * - VertexBuffer.UV2Kind
  19587. * - VertexBuffer.UV3Kind
  19588. * - VertexBuffer.UV4Kind
  19589. * - VertexBuffer.UV5Kind
  19590. * - VertexBuffer.UV6Kind
  19591. * - VertexBuffer.ColorKind
  19592. * - VertexBuffer.MatricesIndicesKind
  19593. * - VertexBuffer.MatricesIndicesExtraKind
  19594. * - VertexBuffer.MatricesWeightsKind
  19595. * - VertexBuffer.MatricesWeightsExtraKind
  19596. *
  19597. * Returns the Mesh.
  19598. */
  19599. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19600. /**
  19601. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19602. * If the mesh has no geometry, it is simply returned as it is.
  19603. * The `data` are either a numeric array either a Float32Array.
  19604. * No new underlying VertexBuffer object is created.
  19605. * 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.
  19606. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19607. *
  19608. * Possible `kind` values :
  19609. * - VertexBuffer.PositionKind
  19610. * - VertexBuffer.UVKind
  19611. * - VertexBuffer.UV2Kind
  19612. * - VertexBuffer.UV3Kind
  19613. * - VertexBuffer.UV4Kind
  19614. * - VertexBuffer.UV5Kind
  19615. * - VertexBuffer.UV6Kind
  19616. * - VertexBuffer.ColorKind
  19617. * - VertexBuffer.MatricesIndicesKind
  19618. * - VertexBuffer.MatricesIndicesExtraKind
  19619. * - VertexBuffer.MatricesWeightsKind
  19620. * - VertexBuffer.MatricesWeightsExtraKind
  19621. *
  19622. * Returns the Mesh.
  19623. */
  19624. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19625. /**
  19626. * Sets the mesh indices.
  19627. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19628. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19629. * This method creates a new index buffer each call.
  19630. * Returns the Mesh.
  19631. */
  19632. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19633. /**
  19634. * Boolean : True if the mesh owns the requested kind of data.
  19635. */
  19636. isVerticesDataPresent(kind: string): boolean;
  19637. /**
  19638. * Returns an array of indices (IndicesArray).
  19639. */
  19640. getIndices(): Nullable<IndicesArray>;
  19641. readonly _positions: Nullable<Vector3[]>;
  19642. /**
  19643. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19644. * This means the mesh underlying bounding box and sphere are recomputed.
  19645. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19646. * @returns the current mesh
  19647. */
  19648. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19649. /** @hidden */
  19650. _preActivate(): InstancedMesh;
  19651. /** @hidden */
  19652. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19653. /** @hidden */
  19654. _postActivate(): void;
  19655. getWorldMatrix(): Matrix;
  19656. readonly isAnInstance: boolean;
  19657. /**
  19658. * Returns the current associated LOD AbstractMesh.
  19659. */
  19660. getLOD(camera: Camera): AbstractMesh;
  19661. /** @hidden */
  19662. _syncSubMeshes(): InstancedMesh;
  19663. /** @hidden */
  19664. _generatePointsArray(): boolean;
  19665. /**
  19666. * Creates a new InstancedMesh from the current mesh.
  19667. * - name (string) : the cloned mesh name
  19668. * - newParent (optional Node) : the optional Node to parent the clone to.
  19669. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19670. *
  19671. * Returns the clone.
  19672. */
  19673. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19674. /**
  19675. * Disposes the InstancedMesh.
  19676. * Returns nothing.
  19677. */
  19678. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19679. }
  19680. module "babylonjs/Meshes/mesh" {
  19681. interface Mesh {
  19682. /**
  19683. * Register a custom buffer that will be instanced
  19684. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19685. * @param kind defines the buffer kind
  19686. * @param stride defines the stride in floats
  19687. */
  19688. registerInstancedBuffer(kind: string, stride: number): void;
  19689. /** @hidden */
  19690. _userInstancedBuffersStorage: {
  19691. data: {
  19692. [key: string]: Float32Array;
  19693. };
  19694. sizes: {
  19695. [key: string]: number;
  19696. };
  19697. vertexBuffers: {
  19698. [key: string]: Nullable<VertexBuffer>;
  19699. };
  19700. strides: {
  19701. [key: string]: number;
  19702. };
  19703. };
  19704. }
  19705. }
  19706. module "babylonjs/Meshes/abstractMesh" {
  19707. interface AbstractMesh {
  19708. /**
  19709. * Object used to store instanced buffers defined by user
  19710. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19711. */
  19712. instancedBuffers: {
  19713. [key: string]: any;
  19714. };
  19715. }
  19716. }
  19717. }
  19718. declare module "babylonjs/Materials/shaderMaterial" {
  19719. import { Scene } from "babylonjs/scene";
  19720. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19722. import { Mesh } from "babylonjs/Meshes/mesh";
  19723. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19724. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19725. import { Texture } from "babylonjs/Materials/Textures/texture";
  19726. import { Material } from "babylonjs/Materials/material";
  19727. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19728. /**
  19729. * Defines the options associated with the creation of a shader material.
  19730. */
  19731. export interface IShaderMaterialOptions {
  19732. /**
  19733. * Does the material work in alpha blend mode
  19734. */
  19735. needAlphaBlending: boolean;
  19736. /**
  19737. * Does the material work in alpha test mode
  19738. */
  19739. needAlphaTesting: boolean;
  19740. /**
  19741. * The list of attribute names used in the shader
  19742. */
  19743. attributes: string[];
  19744. /**
  19745. * The list of unifrom names used in the shader
  19746. */
  19747. uniforms: string[];
  19748. /**
  19749. * The list of UBO names used in the shader
  19750. */
  19751. uniformBuffers: string[];
  19752. /**
  19753. * The list of sampler names used in the shader
  19754. */
  19755. samplers: string[];
  19756. /**
  19757. * The list of defines used in the shader
  19758. */
  19759. defines: string[];
  19760. }
  19761. /**
  19762. * 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.
  19763. *
  19764. * This returned material effects how the mesh will look based on the code in the shaders.
  19765. *
  19766. * @see http://doc.babylonjs.com/how_to/shader_material
  19767. */
  19768. export class ShaderMaterial extends Material {
  19769. private _shaderPath;
  19770. private _options;
  19771. private _textures;
  19772. private _textureArrays;
  19773. private _floats;
  19774. private _ints;
  19775. private _floatsArrays;
  19776. private _colors3;
  19777. private _colors3Arrays;
  19778. private _colors4;
  19779. private _colors4Arrays;
  19780. private _vectors2;
  19781. private _vectors3;
  19782. private _vectors4;
  19783. private _matrices;
  19784. private _matrixArrays;
  19785. private _matrices3x3;
  19786. private _matrices2x2;
  19787. private _vectors2Arrays;
  19788. private _vectors3Arrays;
  19789. private _vectors4Arrays;
  19790. private _cachedWorldViewMatrix;
  19791. private _cachedWorldViewProjectionMatrix;
  19792. private _renderId;
  19793. private _multiview;
  19794. /**
  19795. * Instantiate a new shader material.
  19796. * 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.
  19797. * This returned material effects how the mesh will look based on the code in the shaders.
  19798. * @see http://doc.babylonjs.com/how_to/shader_material
  19799. * @param name Define the name of the material in the scene
  19800. * @param scene Define the scene the material belongs to
  19801. * @param shaderPath Defines the route to the shader code in one of three ways:
  19802. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19803. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19804. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19805. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19806. * @param options Define the options used to create the shader
  19807. */
  19808. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19809. /**
  19810. * Gets the shader path used to define the shader code
  19811. * It can be modified to trigger a new compilation
  19812. */
  19813. /**
  19814. * Sets the shader path used to define the shader code
  19815. * It can be modified to trigger a new compilation
  19816. */
  19817. shaderPath: any;
  19818. /**
  19819. * Gets the options used to compile the shader.
  19820. * They can be modified to trigger a new compilation
  19821. */
  19822. readonly options: IShaderMaterialOptions;
  19823. /**
  19824. * Gets the current class name of the material e.g. "ShaderMaterial"
  19825. * Mainly use in serialization.
  19826. * @returns the class name
  19827. */
  19828. getClassName(): string;
  19829. /**
  19830. * Specifies if the material will require alpha blending
  19831. * @returns a boolean specifying if alpha blending is needed
  19832. */
  19833. needAlphaBlending(): boolean;
  19834. /**
  19835. * Specifies if this material should be rendered in alpha test mode
  19836. * @returns a boolean specifying if an alpha test is needed.
  19837. */
  19838. needAlphaTesting(): boolean;
  19839. private _checkUniform;
  19840. /**
  19841. * Set a texture in the shader.
  19842. * @param name Define the name of the uniform samplers as defined in the shader
  19843. * @param texture Define the texture to bind to this sampler
  19844. * @return the material itself allowing "fluent" like uniform updates
  19845. */
  19846. setTexture(name: string, texture: Texture): ShaderMaterial;
  19847. /**
  19848. * Set a texture array in the shader.
  19849. * @param name Define the name of the uniform sampler array as defined in the shader
  19850. * @param textures Define the list of textures to bind to this sampler
  19851. * @return the material itself allowing "fluent" like uniform updates
  19852. */
  19853. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19854. /**
  19855. * Set a float in the shader.
  19856. * @param name Define the name of the uniform as defined in the shader
  19857. * @param value Define the value to give to the uniform
  19858. * @return the material itself allowing "fluent" like uniform updates
  19859. */
  19860. setFloat(name: string, value: number): ShaderMaterial;
  19861. /**
  19862. * Set a int in the shader.
  19863. * @param name Define the name of the uniform as defined in the shader
  19864. * @param value Define the value to give to the uniform
  19865. * @return the material itself allowing "fluent" like uniform updates
  19866. */
  19867. setInt(name: string, value: number): ShaderMaterial;
  19868. /**
  19869. * Set an array of floats in the shader.
  19870. * @param name Define the name of the uniform as defined in the shader
  19871. * @param value Define the value to give to the uniform
  19872. * @return the material itself allowing "fluent" like uniform updates
  19873. */
  19874. setFloats(name: string, value: number[]): ShaderMaterial;
  19875. /**
  19876. * Set a vec3 in the shader from a Color3.
  19877. * @param name Define the name of the uniform as defined in the shader
  19878. * @param value Define the value to give to the uniform
  19879. * @return the material itself allowing "fluent" like uniform updates
  19880. */
  19881. setColor3(name: string, value: Color3): ShaderMaterial;
  19882. /**
  19883. * Set a vec3 array in the shader from a Color3 array.
  19884. * @param name Define the name of the uniform as defined in the shader
  19885. * @param value Define the value to give to the uniform
  19886. * @return the material itself allowing "fluent" like uniform updates
  19887. */
  19888. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19889. /**
  19890. * Set a vec4 in the shader from a Color4.
  19891. * @param name Define the name of the uniform as defined in the shader
  19892. * @param value Define the value to give to the uniform
  19893. * @return the material itself allowing "fluent" like uniform updates
  19894. */
  19895. setColor4(name: string, value: Color4): ShaderMaterial;
  19896. /**
  19897. * Set a vec4 array in the shader from a Color4 array.
  19898. * @param name Define the name of the uniform as defined in the shader
  19899. * @param value Define the value to give to the uniform
  19900. * @return the material itself allowing "fluent" like uniform updates
  19901. */
  19902. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19903. /**
  19904. * Set a vec2 in the shader from a Vector2.
  19905. * @param name Define the name of the uniform as defined in the shader
  19906. * @param value Define the value to give to the uniform
  19907. * @return the material itself allowing "fluent" like uniform updates
  19908. */
  19909. setVector2(name: string, value: Vector2): ShaderMaterial;
  19910. /**
  19911. * Set a vec3 in the shader from a Vector3.
  19912. * @param name Define the name of the uniform as defined in the shader
  19913. * @param value Define the value to give to the uniform
  19914. * @return the material itself allowing "fluent" like uniform updates
  19915. */
  19916. setVector3(name: string, value: Vector3): ShaderMaterial;
  19917. /**
  19918. * Set a vec4 in the shader from a Vector4.
  19919. * @param name Define the name of the uniform as defined in the shader
  19920. * @param value Define the value to give to the uniform
  19921. * @return the material itself allowing "fluent" like uniform updates
  19922. */
  19923. setVector4(name: string, value: Vector4): ShaderMaterial;
  19924. /**
  19925. * Set a mat4 in the shader from a Matrix.
  19926. * @param name Define the name of the uniform as defined in the shader
  19927. * @param value Define the value to give to the uniform
  19928. * @return the material itself allowing "fluent" like uniform updates
  19929. */
  19930. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19931. /**
  19932. * Set a float32Array in the shader from a matrix array.
  19933. * @param name Define the name of the uniform as defined in the shader
  19934. * @param value Define the value to give to the uniform
  19935. * @return the material itself allowing "fluent" like uniform updates
  19936. */
  19937. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  19938. /**
  19939. * Set a mat3 in the shader from a Float32Array.
  19940. * @param name Define the name of the uniform as defined in the shader
  19941. * @param value Define the value to give to the uniform
  19942. * @return the material itself allowing "fluent" like uniform updates
  19943. */
  19944. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19945. /**
  19946. * Set a mat2 in the shader from a Float32Array.
  19947. * @param name Define the name of the uniform as defined in the shader
  19948. * @param value Define the value to give to the uniform
  19949. * @return the material itself allowing "fluent" like uniform updates
  19950. */
  19951. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19952. /**
  19953. * Set a vec2 array in the shader from a number array.
  19954. * @param name Define the name of the uniform as defined in the shader
  19955. * @param value Define the value to give to the uniform
  19956. * @return the material itself allowing "fluent" like uniform updates
  19957. */
  19958. setArray2(name: string, value: number[]): ShaderMaterial;
  19959. /**
  19960. * Set a vec3 array in the shader from a number array.
  19961. * @param name Define the name of the uniform as defined in the shader
  19962. * @param value Define the value to give to the uniform
  19963. * @return the material itself allowing "fluent" like uniform updates
  19964. */
  19965. setArray3(name: string, value: number[]): ShaderMaterial;
  19966. /**
  19967. * Set a vec4 array in the shader from a number array.
  19968. * @param name Define the name of the uniform as defined in the shader
  19969. * @param value Define the value to give to the uniform
  19970. * @return the material itself allowing "fluent" like uniform updates
  19971. */
  19972. setArray4(name: string, value: number[]): ShaderMaterial;
  19973. private _checkCache;
  19974. /**
  19975. * Specifies that the submesh is ready to be used
  19976. * @param mesh defines the mesh to check
  19977. * @param subMesh defines which submesh to check
  19978. * @param useInstances specifies that instances should be used
  19979. * @returns a boolean indicating that the submesh is ready or not
  19980. */
  19981. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19982. /**
  19983. * Checks if the material is ready to render the requested mesh
  19984. * @param mesh Define the mesh to render
  19985. * @param useInstances Define whether or not the material is used with instances
  19986. * @returns true if ready, otherwise false
  19987. */
  19988. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19989. /**
  19990. * Binds the world matrix to the material
  19991. * @param world defines the world transformation matrix
  19992. */
  19993. bindOnlyWorldMatrix(world: Matrix): void;
  19994. /**
  19995. * Binds the material to the mesh
  19996. * @param world defines the world transformation matrix
  19997. * @param mesh defines the mesh to bind the material to
  19998. */
  19999. bind(world: Matrix, mesh?: Mesh): void;
  20000. /**
  20001. * Gets the active textures from the material
  20002. * @returns an array of textures
  20003. */
  20004. getActiveTextures(): BaseTexture[];
  20005. /**
  20006. * Specifies if the material uses a texture
  20007. * @param texture defines the texture to check against the material
  20008. * @returns a boolean specifying if the material uses the texture
  20009. */
  20010. hasTexture(texture: BaseTexture): boolean;
  20011. /**
  20012. * Makes a duplicate of the material, and gives it a new name
  20013. * @param name defines the new name for the duplicated material
  20014. * @returns the cloned material
  20015. */
  20016. clone(name: string): ShaderMaterial;
  20017. /**
  20018. * Disposes the material
  20019. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20020. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20021. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20022. */
  20023. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20024. /**
  20025. * Serializes this material in a JSON representation
  20026. * @returns the serialized material object
  20027. */
  20028. serialize(): any;
  20029. /**
  20030. * Creates a shader material from parsed shader material data
  20031. * @param source defines the JSON represnetation of the material
  20032. * @param scene defines the hosting scene
  20033. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20034. * @returns a new material
  20035. */
  20036. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20037. }
  20038. }
  20039. declare module "babylonjs/Shaders/color.fragment" {
  20040. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20041. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20042. /** @hidden */
  20043. export var colorPixelShader: {
  20044. name: string;
  20045. shader: string;
  20046. };
  20047. }
  20048. declare module "babylonjs/Shaders/color.vertex" {
  20049. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20050. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20051. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20052. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20053. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20054. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20055. /** @hidden */
  20056. export var colorVertexShader: {
  20057. name: string;
  20058. shader: string;
  20059. };
  20060. }
  20061. declare module "babylonjs/Meshes/linesMesh" {
  20062. import { Nullable } from "babylonjs/types";
  20063. import { Scene } from "babylonjs/scene";
  20064. import { Color3 } from "babylonjs/Maths/math.color";
  20065. import { Node } from "babylonjs/node";
  20066. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20067. import { Mesh } from "babylonjs/Meshes/mesh";
  20068. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20069. import { Effect } from "babylonjs/Materials/effect";
  20070. import { Material } from "babylonjs/Materials/material";
  20071. import "babylonjs/Shaders/color.fragment";
  20072. import "babylonjs/Shaders/color.vertex";
  20073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20074. /**
  20075. * Line mesh
  20076. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20077. */
  20078. export class LinesMesh extends Mesh {
  20079. /**
  20080. * If vertex color should be applied to the mesh
  20081. */
  20082. readonly useVertexColor?: boolean | undefined;
  20083. /**
  20084. * If vertex alpha should be applied to the mesh
  20085. */
  20086. readonly useVertexAlpha?: boolean | undefined;
  20087. /**
  20088. * Color of the line (Default: White)
  20089. */
  20090. color: Color3;
  20091. /**
  20092. * Alpha of the line (Default: 1)
  20093. */
  20094. alpha: number;
  20095. /**
  20096. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20097. * This margin is expressed in world space coordinates, so its value may vary.
  20098. * Default value is 0.1
  20099. */
  20100. intersectionThreshold: number;
  20101. private _colorShader;
  20102. private color4;
  20103. /**
  20104. * Creates a new LinesMesh
  20105. * @param name defines the name
  20106. * @param scene defines the hosting scene
  20107. * @param parent defines the parent mesh if any
  20108. * @param source defines the optional source LinesMesh used to clone data from
  20109. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20110. * When false, achieved by calling a clone(), also passing False.
  20111. * This will make creation of children, recursive.
  20112. * @param useVertexColor defines if this LinesMesh supports vertex color
  20113. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20114. */
  20115. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20116. /**
  20117. * If vertex color should be applied to the mesh
  20118. */
  20119. useVertexColor?: boolean | undefined,
  20120. /**
  20121. * If vertex alpha should be applied to the mesh
  20122. */
  20123. useVertexAlpha?: boolean | undefined);
  20124. private _addClipPlaneDefine;
  20125. private _removeClipPlaneDefine;
  20126. isReady(): boolean;
  20127. /**
  20128. * Returns the string "LineMesh"
  20129. */
  20130. getClassName(): string;
  20131. /**
  20132. * @hidden
  20133. */
  20134. /**
  20135. * @hidden
  20136. */
  20137. material: Material;
  20138. /**
  20139. * @hidden
  20140. */
  20141. readonly checkCollisions: boolean;
  20142. /** @hidden */
  20143. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20144. /** @hidden */
  20145. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20146. /**
  20147. * Disposes of the line mesh
  20148. * @param doNotRecurse If children should be disposed
  20149. */
  20150. dispose(doNotRecurse?: boolean): void;
  20151. /**
  20152. * Returns a new LineMesh object cloned from the current one.
  20153. */
  20154. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20155. /**
  20156. * Creates a new InstancedLinesMesh object from the mesh model.
  20157. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20158. * @param name defines the name of the new instance
  20159. * @returns a new InstancedLinesMesh
  20160. */
  20161. createInstance(name: string): InstancedLinesMesh;
  20162. }
  20163. /**
  20164. * Creates an instance based on a source LinesMesh
  20165. */
  20166. export class InstancedLinesMesh extends InstancedMesh {
  20167. /**
  20168. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20169. * This margin is expressed in world space coordinates, so its value may vary.
  20170. * Initilized with the intersectionThreshold value of the source LinesMesh
  20171. */
  20172. intersectionThreshold: number;
  20173. constructor(name: string, source: LinesMesh);
  20174. /**
  20175. * Returns the string "InstancedLinesMesh".
  20176. */
  20177. getClassName(): string;
  20178. }
  20179. }
  20180. declare module "babylonjs/Shaders/line.fragment" {
  20181. /** @hidden */
  20182. export var linePixelShader: {
  20183. name: string;
  20184. shader: string;
  20185. };
  20186. }
  20187. declare module "babylonjs/Shaders/line.vertex" {
  20188. /** @hidden */
  20189. export var lineVertexShader: {
  20190. name: string;
  20191. shader: string;
  20192. };
  20193. }
  20194. declare module "babylonjs/Rendering/edgesRenderer" {
  20195. import { Nullable } from "babylonjs/types";
  20196. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20198. import { Vector3 } from "babylonjs/Maths/math.vector";
  20199. import { IDisposable } from "babylonjs/scene";
  20200. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20201. import "babylonjs/Shaders/line.fragment";
  20202. import "babylonjs/Shaders/line.vertex";
  20203. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20204. module "babylonjs/Meshes/abstractMesh" {
  20205. interface AbstractMesh {
  20206. /**
  20207. * Gets the edgesRenderer associated with the mesh
  20208. */
  20209. edgesRenderer: Nullable<EdgesRenderer>;
  20210. }
  20211. }
  20212. module "babylonjs/Meshes/linesMesh" {
  20213. interface LinesMesh {
  20214. /**
  20215. * Enables the edge rendering mode on the mesh.
  20216. * This mode makes the mesh edges visible
  20217. * @param epsilon defines the maximal distance between two angles to detect a face
  20218. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20219. * @returns the currentAbstractMesh
  20220. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20221. */
  20222. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20223. }
  20224. }
  20225. module "babylonjs/Meshes/linesMesh" {
  20226. interface InstancedLinesMesh {
  20227. /**
  20228. * Enables the edge rendering mode on the mesh.
  20229. * This mode makes the mesh edges visible
  20230. * @param epsilon defines the maximal distance between two angles to detect a face
  20231. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20232. * @returns the current InstancedLinesMesh
  20233. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20234. */
  20235. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20236. }
  20237. }
  20238. /**
  20239. * Defines the minimum contract an Edges renderer should follow.
  20240. */
  20241. export interface IEdgesRenderer extends IDisposable {
  20242. /**
  20243. * Gets or sets a boolean indicating if the edgesRenderer is active
  20244. */
  20245. isEnabled: boolean;
  20246. /**
  20247. * Renders the edges of the attached mesh,
  20248. */
  20249. render(): void;
  20250. /**
  20251. * Checks wether or not the edges renderer is ready to render.
  20252. * @return true if ready, otherwise false.
  20253. */
  20254. isReady(): boolean;
  20255. }
  20256. /**
  20257. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20258. */
  20259. export class EdgesRenderer implements IEdgesRenderer {
  20260. /**
  20261. * Define the size of the edges with an orthographic camera
  20262. */
  20263. edgesWidthScalerForOrthographic: number;
  20264. /**
  20265. * Define the size of the edges with a perspective camera
  20266. */
  20267. edgesWidthScalerForPerspective: number;
  20268. protected _source: AbstractMesh;
  20269. protected _linesPositions: number[];
  20270. protected _linesNormals: number[];
  20271. protected _linesIndices: number[];
  20272. protected _epsilon: number;
  20273. protected _indicesCount: number;
  20274. protected _lineShader: ShaderMaterial;
  20275. protected _ib: DataBuffer;
  20276. protected _buffers: {
  20277. [key: string]: Nullable<VertexBuffer>;
  20278. };
  20279. protected _checkVerticesInsteadOfIndices: boolean;
  20280. private _meshRebuildObserver;
  20281. private _meshDisposeObserver;
  20282. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20283. isEnabled: boolean;
  20284. /**
  20285. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20286. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20287. * @param source Mesh used to create edges
  20288. * @param epsilon sum of angles in adjacency to check for edge
  20289. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20290. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20291. */
  20292. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20293. protected _prepareRessources(): void;
  20294. /** @hidden */
  20295. _rebuild(): void;
  20296. /**
  20297. * Releases the required resources for the edges renderer
  20298. */
  20299. dispose(): void;
  20300. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20301. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20302. /**
  20303. * Checks if the pair of p0 and p1 is en edge
  20304. * @param faceIndex
  20305. * @param edge
  20306. * @param faceNormals
  20307. * @param p0
  20308. * @param p1
  20309. * @private
  20310. */
  20311. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20312. /**
  20313. * push line into the position, normal and index buffer
  20314. * @protected
  20315. */
  20316. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20317. /**
  20318. * Generates lines edges from adjacencjes
  20319. * @private
  20320. */
  20321. _generateEdgesLines(): void;
  20322. /**
  20323. * Checks wether or not the edges renderer is ready to render.
  20324. * @return true if ready, otherwise false.
  20325. */
  20326. isReady(): boolean;
  20327. /**
  20328. * Renders the edges of the attached mesh,
  20329. */
  20330. render(): void;
  20331. }
  20332. /**
  20333. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20334. */
  20335. export class LineEdgesRenderer extends EdgesRenderer {
  20336. /**
  20337. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20338. * @param source LineMesh used to generate edges
  20339. * @param epsilon not important (specified angle for edge detection)
  20340. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20341. */
  20342. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20343. /**
  20344. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20345. */
  20346. _generateEdgesLines(): void;
  20347. }
  20348. }
  20349. declare module "babylonjs/Rendering/renderingGroup" {
  20350. import { SmartArray } from "babylonjs/Misc/smartArray";
  20351. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20353. import { Nullable } from "babylonjs/types";
  20354. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20355. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20356. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20357. import { Material } from "babylonjs/Materials/material";
  20358. import { Scene } from "babylonjs/scene";
  20359. /**
  20360. * This represents the object necessary to create a rendering group.
  20361. * This is exclusively used and created by the rendering manager.
  20362. * To modify the behavior, you use the available helpers in your scene or meshes.
  20363. * @hidden
  20364. */
  20365. export class RenderingGroup {
  20366. index: number;
  20367. private static _zeroVector;
  20368. private _scene;
  20369. private _opaqueSubMeshes;
  20370. private _transparentSubMeshes;
  20371. private _alphaTestSubMeshes;
  20372. private _depthOnlySubMeshes;
  20373. private _particleSystems;
  20374. private _spriteManagers;
  20375. private _opaqueSortCompareFn;
  20376. private _alphaTestSortCompareFn;
  20377. private _transparentSortCompareFn;
  20378. private _renderOpaque;
  20379. private _renderAlphaTest;
  20380. private _renderTransparent;
  20381. /** @hidden */
  20382. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20383. onBeforeTransparentRendering: () => void;
  20384. /**
  20385. * Set the opaque sort comparison function.
  20386. * If null the sub meshes will be render in the order they were created
  20387. */
  20388. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20389. /**
  20390. * Set the alpha test sort comparison function.
  20391. * If null the sub meshes will be render in the order they were created
  20392. */
  20393. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20394. /**
  20395. * Set the transparent sort comparison function.
  20396. * If null the sub meshes will be render in the order they were created
  20397. */
  20398. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20399. /**
  20400. * Creates a new rendering group.
  20401. * @param index The rendering group index
  20402. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20403. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20404. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20405. */
  20406. 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>);
  20407. /**
  20408. * Render all the sub meshes contained in the group.
  20409. * @param customRenderFunction Used to override the default render behaviour of the group.
  20410. * @returns true if rendered some submeshes.
  20411. */
  20412. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20413. /**
  20414. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20415. * @param subMeshes The submeshes to render
  20416. */
  20417. private renderOpaqueSorted;
  20418. /**
  20419. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20420. * @param subMeshes The submeshes to render
  20421. */
  20422. private renderAlphaTestSorted;
  20423. /**
  20424. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20425. * @param subMeshes The submeshes to render
  20426. */
  20427. private renderTransparentSorted;
  20428. /**
  20429. * Renders the submeshes in a specified order.
  20430. * @param subMeshes The submeshes to sort before render
  20431. * @param sortCompareFn The comparison function use to sort
  20432. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20433. * @param transparent Specifies to activate blending if true
  20434. */
  20435. private static renderSorted;
  20436. /**
  20437. * Renders the submeshes in the order they were dispatched (no sort applied).
  20438. * @param subMeshes The submeshes to render
  20439. */
  20440. private static renderUnsorted;
  20441. /**
  20442. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20443. * are rendered back to front if in the same alpha index.
  20444. *
  20445. * @param a The first submesh
  20446. * @param b The second submesh
  20447. * @returns The result of the comparison
  20448. */
  20449. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20450. /**
  20451. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20452. * are rendered back to front.
  20453. *
  20454. * @param a The first submesh
  20455. * @param b The second submesh
  20456. * @returns The result of the comparison
  20457. */
  20458. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20459. /**
  20460. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20461. * are rendered front to back (prevent overdraw).
  20462. *
  20463. * @param a The first submesh
  20464. * @param b The second submesh
  20465. * @returns The result of the comparison
  20466. */
  20467. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20468. /**
  20469. * Resets the different lists of submeshes to prepare a new frame.
  20470. */
  20471. prepare(): void;
  20472. dispose(): void;
  20473. /**
  20474. * Inserts the submesh in its correct queue depending on its material.
  20475. * @param subMesh The submesh to dispatch
  20476. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20477. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20478. */
  20479. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20480. dispatchSprites(spriteManager: ISpriteManager): void;
  20481. dispatchParticles(particleSystem: IParticleSystem): void;
  20482. private _renderParticles;
  20483. private _renderSprites;
  20484. }
  20485. }
  20486. declare module "babylonjs/Rendering/renderingManager" {
  20487. import { Nullable } from "babylonjs/types";
  20488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20489. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20490. import { SmartArray } from "babylonjs/Misc/smartArray";
  20491. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20492. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20493. import { Material } from "babylonjs/Materials/material";
  20494. import { Scene } from "babylonjs/scene";
  20495. import { Camera } from "babylonjs/Cameras/camera";
  20496. /**
  20497. * Interface describing the different options available in the rendering manager
  20498. * regarding Auto Clear between groups.
  20499. */
  20500. export interface IRenderingManagerAutoClearSetup {
  20501. /**
  20502. * Defines whether or not autoclear is enable.
  20503. */
  20504. autoClear: boolean;
  20505. /**
  20506. * Defines whether or not to autoclear the depth buffer.
  20507. */
  20508. depth: boolean;
  20509. /**
  20510. * Defines whether or not to autoclear the stencil buffer.
  20511. */
  20512. stencil: boolean;
  20513. }
  20514. /**
  20515. * This class is used by the onRenderingGroupObservable
  20516. */
  20517. export class RenderingGroupInfo {
  20518. /**
  20519. * The Scene that being rendered
  20520. */
  20521. scene: Scene;
  20522. /**
  20523. * The camera currently used for the rendering pass
  20524. */
  20525. camera: Nullable<Camera>;
  20526. /**
  20527. * The ID of the renderingGroup being processed
  20528. */
  20529. renderingGroupId: number;
  20530. }
  20531. /**
  20532. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20533. * It is enable to manage the different groups as well as the different necessary sort functions.
  20534. * This should not be used directly aside of the few static configurations
  20535. */
  20536. export class RenderingManager {
  20537. /**
  20538. * The max id used for rendering groups (not included)
  20539. */
  20540. static MAX_RENDERINGGROUPS: number;
  20541. /**
  20542. * The min id used for rendering groups (included)
  20543. */
  20544. static MIN_RENDERINGGROUPS: number;
  20545. /**
  20546. * Used to globally prevent autoclearing scenes.
  20547. */
  20548. static AUTOCLEAR: boolean;
  20549. /**
  20550. * @hidden
  20551. */
  20552. _useSceneAutoClearSetup: boolean;
  20553. private _scene;
  20554. private _renderingGroups;
  20555. private _depthStencilBufferAlreadyCleaned;
  20556. private _autoClearDepthStencil;
  20557. private _customOpaqueSortCompareFn;
  20558. private _customAlphaTestSortCompareFn;
  20559. private _customTransparentSortCompareFn;
  20560. private _renderingGroupInfo;
  20561. /**
  20562. * Instantiates a new rendering group for a particular scene
  20563. * @param scene Defines the scene the groups belongs to
  20564. */
  20565. constructor(scene: Scene);
  20566. private _clearDepthStencilBuffer;
  20567. /**
  20568. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20569. * @hidden
  20570. */
  20571. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20572. /**
  20573. * Resets the different information of the group to prepare a new frame
  20574. * @hidden
  20575. */
  20576. reset(): void;
  20577. /**
  20578. * Dispose and release the group and its associated resources.
  20579. * @hidden
  20580. */
  20581. dispose(): void;
  20582. /**
  20583. * Clear the info related to rendering groups preventing retention points during dispose.
  20584. */
  20585. freeRenderingGroups(): void;
  20586. private _prepareRenderingGroup;
  20587. /**
  20588. * Add a sprite manager to the rendering manager in order to render it this frame.
  20589. * @param spriteManager Define the sprite manager to render
  20590. */
  20591. dispatchSprites(spriteManager: ISpriteManager): void;
  20592. /**
  20593. * Add a particle system to the rendering manager in order to render it this frame.
  20594. * @param particleSystem Define the particle system to render
  20595. */
  20596. dispatchParticles(particleSystem: IParticleSystem): void;
  20597. /**
  20598. * Add a submesh to the manager in order to render it this frame
  20599. * @param subMesh The submesh to dispatch
  20600. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20601. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20602. */
  20603. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20604. /**
  20605. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20606. * This allowed control for front to back rendering or reversly depending of the special needs.
  20607. *
  20608. * @param renderingGroupId The rendering group id corresponding to its index
  20609. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20610. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20611. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20612. */
  20613. 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;
  20614. /**
  20615. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20616. *
  20617. * @param renderingGroupId The rendering group id corresponding to its index
  20618. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20619. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20620. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20621. */
  20622. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20623. /**
  20624. * Gets the current auto clear configuration for one rendering group of the rendering
  20625. * manager.
  20626. * @param index the rendering group index to get the information for
  20627. * @returns The auto clear setup for the requested rendering group
  20628. */
  20629. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20630. }
  20631. }
  20632. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20633. import { Observable } from "babylonjs/Misc/observable";
  20634. import { SmartArray } from "babylonjs/Misc/smartArray";
  20635. import { Nullable } from "babylonjs/types";
  20636. import { Camera } from "babylonjs/Cameras/camera";
  20637. import { Scene } from "babylonjs/scene";
  20638. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20639. import { Color4 } from "babylonjs/Maths/math.color";
  20640. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20642. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20643. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20644. import { Texture } from "babylonjs/Materials/Textures/texture";
  20645. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20646. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20647. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20648. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20649. import { Engine } from "babylonjs/Engines/engine";
  20650. /**
  20651. * This Helps creating a texture that will be created from a camera in your scene.
  20652. * It is basically a dynamic texture that could be used to create special effects for instance.
  20653. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20654. */
  20655. export class RenderTargetTexture extends Texture {
  20656. isCube: boolean;
  20657. /**
  20658. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20659. */
  20660. static readonly REFRESHRATE_RENDER_ONCE: number;
  20661. /**
  20662. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20663. */
  20664. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20665. /**
  20666. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20667. * the central point of your effect and can save a lot of performances.
  20668. */
  20669. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20670. /**
  20671. * Use this predicate to dynamically define the list of mesh you want to render.
  20672. * If set, the renderList property will be overwritten.
  20673. */
  20674. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20675. private _renderList;
  20676. /**
  20677. * Use this list to define the list of mesh you want to render.
  20678. */
  20679. renderList: Nullable<Array<AbstractMesh>>;
  20680. private _hookArray;
  20681. /**
  20682. * Define if particles should be rendered in your texture.
  20683. */
  20684. renderParticles: boolean;
  20685. /**
  20686. * Define if sprites should be rendered in your texture.
  20687. */
  20688. renderSprites: boolean;
  20689. /**
  20690. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20691. */
  20692. coordinatesMode: number;
  20693. /**
  20694. * Define the camera used to render the texture.
  20695. */
  20696. activeCamera: Nullable<Camera>;
  20697. /**
  20698. * Override the render function of the texture with your own one.
  20699. */
  20700. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20701. /**
  20702. * Define if camera post processes should be use while rendering the texture.
  20703. */
  20704. useCameraPostProcesses: boolean;
  20705. /**
  20706. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20707. */
  20708. ignoreCameraViewport: boolean;
  20709. private _postProcessManager;
  20710. private _postProcesses;
  20711. private _resizeObserver;
  20712. /**
  20713. * An event triggered when the texture is unbind.
  20714. */
  20715. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20716. /**
  20717. * An event triggered when the texture is unbind.
  20718. */
  20719. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20720. private _onAfterUnbindObserver;
  20721. /**
  20722. * Set a after unbind callback in the texture.
  20723. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20724. */
  20725. onAfterUnbind: () => void;
  20726. /**
  20727. * An event triggered before rendering the texture
  20728. */
  20729. onBeforeRenderObservable: Observable<number>;
  20730. private _onBeforeRenderObserver;
  20731. /**
  20732. * Set a before render callback in the texture.
  20733. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20734. */
  20735. onBeforeRender: (faceIndex: number) => void;
  20736. /**
  20737. * An event triggered after rendering the texture
  20738. */
  20739. onAfterRenderObservable: Observable<number>;
  20740. private _onAfterRenderObserver;
  20741. /**
  20742. * Set a after render callback in the texture.
  20743. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20744. */
  20745. onAfterRender: (faceIndex: number) => void;
  20746. /**
  20747. * An event triggered after the texture clear
  20748. */
  20749. onClearObservable: Observable<Engine>;
  20750. private _onClearObserver;
  20751. /**
  20752. * Set a clear callback in the texture.
  20753. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20754. */
  20755. onClear: (Engine: Engine) => void;
  20756. /**
  20757. * An event triggered when the texture is resized.
  20758. */
  20759. onResizeObservable: Observable<RenderTargetTexture>;
  20760. /**
  20761. * Define the clear color of the Render Target if it should be different from the scene.
  20762. */
  20763. clearColor: Color4;
  20764. protected _size: number | {
  20765. width: number;
  20766. height: number;
  20767. };
  20768. protected _initialSizeParameter: number | {
  20769. width: number;
  20770. height: number;
  20771. } | {
  20772. ratio: number;
  20773. };
  20774. protected _sizeRatio: Nullable<number>;
  20775. /** @hidden */
  20776. _generateMipMaps: boolean;
  20777. protected _renderingManager: RenderingManager;
  20778. /** @hidden */
  20779. _waitingRenderList: string[];
  20780. protected _doNotChangeAspectRatio: boolean;
  20781. protected _currentRefreshId: number;
  20782. protected _refreshRate: number;
  20783. protected _textureMatrix: Matrix;
  20784. protected _samples: number;
  20785. protected _renderTargetOptions: RenderTargetCreationOptions;
  20786. /**
  20787. * Gets render target creation options that were used.
  20788. */
  20789. readonly renderTargetOptions: RenderTargetCreationOptions;
  20790. protected _engine: Engine;
  20791. protected _onRatioRescale(): void;
  20792. /**
  20793. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20794. * It must define where the camera used to render the texture is set
  20795. */
  20796. boundingBoxPosition: Vector3;
  20797. private _boundingBoxSize;
  20798. /**
  20799. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20800. * When defined, the cubemap will switch to local mode
  20801. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20802. * @example https://www.babylonjs-playground.com/#RNASML
  20803. */
  20804. boundingBoxSize: Vector3;
  20805. /**
  20806. * In case the RTT has been created with a depth texture, get the associated
  20807. * depth texture.
  20808. * Otherwise, return null.
  20809. */
  20810. depthStencilTexture: Nullable<InternalTexture>;
  20811. /**
  20812. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20813. * or used a shadow, depth texture...
  20814. * @param name The friendly name of the texture
  20815. * @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)
  20816. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20817. * @param generateMipMaps True if mip maps need to be generated after render.
  20818. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20819. * @param type The type of the buffer in the RTT (int, half float, float...)
  20820. * @param isCube True if a cube texture needs to be created
  20821. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20822. * @param generateDepthBuffer True to generate a depth buffer
  20823. * @param generateStencilBuffer True to generate a stencil buffer
  20824. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20825. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20826. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20827. */
  20828. constructor(name: string, size: number | {
  20829. width: number;
  20830. height: number;
  20831. } | {
  20832. ratio: number;
  20833. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20834. /**
  20835. * Creates a depth stencil texture.
  20836. * This is only available in WebGL 2 or with the depth texture extension available.
  20837. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20838. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20839. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20840. */
  20841. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20842. private _processSizeParameter;
  20843. /**
  20844. * Define the number of samples to use in case of MSAA.
  20845. * It defaults to one meaning no MSAA has been enabled.
  20846. */
  20847. samples: number;
  20848. /**
  20849. * Resets the refresh counter of the texture and start bak from scratch.
  20850. * Could be useful to regenerate the texture if it is setup to render only once.
  20851. */
  20852. resetRefreshCounter(): void;
  20853. /**
  20854. * Define the refresh rate of the texture or the rendering frequency.
  20855. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20856. */
  20857. refreshRate: number;
  20858. /**
  20859. * Adds a post process to the render target rendering passes.
  20860. * @param postProcess define the post process to add
  20861. */
  20862. addPostProcess(postProcess: PostProcess): void;
  20863. /**
  20864. * Clear all the post processes attached to the render target
  20865. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20866. */
  20867. clearPostProcesses(dispose?: boolean): void;
  20868. /**
  20869. * Remove one of the post process from the list of attached post processes to the texture
  20870. * @param postProcess define the post process to remove from the list
  20871. */
  20872. removePostProcess(postProcess: PostProcess): void;
  20873. /** @hidden */
  20874. _shouldRender(): boolean;
  20875. /**
  20876. * Gets the actual render size of the texture.
  20877. * @returns the width of the render size
  20878. */
  20879. getRenderSize(): number;
  20880. /**
  20881. * Gets the actual render width of the texture.
  20882. * @returns the width of the render size
  20883. */
  20884. getRenderWidth(): number;
  20885. /**
  20886. * Gets the actual render height of the texture.
  20887. * @returns the height of the render size
  20888. */
  20889. getRenderHeight(): number;
  20890. /**
  20891. * Get if the texture can be rescaled or not.
  20892. */
  20893. readonly canRescale: boolean;
  20894. /**
  20895. * Resize the texture using a ratio.
  20896. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20897. */
  20898. scale(ratio: number): void;
  20899. /**
  20900. * Get the texture reflection matrix used to rotate/transform the reflection.
  20901. * @returns the reflection matrix
  20902. */
  20903. getReflectionTextureMatrix(): Matrix;
  20904. /**
  20905. * Resize the texture to a new desired size.
  20906. * Be carrefull as it will recreate all the data in the new texture.
  20907. * @param size Define the new size. It can be:
  20908. * - a number for squared texture,
  20909. * - an object containing { width: number, height: number }
  20910. * - or an object containing a ratio { ratio: number }
  20911. */
  20912. resize(size: number | {
  20913. width: number;
  20914. height: number;
  20915. } | {
  20916. ratio: number;
  20917. }): void;
  20918. /**
  20919. * Renders all the objects from the render list into the texture.
  20920. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20921. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20922. */
  20923. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20924. private _bestReflectionRenderTargetDimension;
  20925. /**
  20926. * @hidden
  20927. * @param faceIndex face index to bind to if this is a cubetexture
  20928. */
  20929. _bindFrameBuffer(faceIndex?: number): void;
  20930. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20931. private renderToTarget;
  20932. /**
  20933. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20934. * This allowed control for front to back rendering or reversly depending of the special needs.
  20935. *
  20936. * @param renderingGroupId The rendering group id corresponding to its index
  20937. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20938. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20939. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20940. */
  20941. 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;
  20942. /**
  20943. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20944. *
  20945. * @param renderingGroupId The rendering group id corresponding to its index
  20946. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20947. */
  20948. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20949. /**
  20950. * Clones the texture.
  20951. * @returns the cloned texture
  20952. */
  20953. clone(): RenderTargetTexture;
  20954. /**
  20955. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20956. * @returns The JSON representation of the texture
  20957. */
  20958. serialize(): any;
  20959. /**
  20960. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20961. */
  20962. disposeFramebufferObjects(): void;
  20963. /**
  20964. * Dispose the texture and release its associated resources.
  20965. */
  20966. dispose(): void;
  20967. /** @hidden */
  20968. _rebuild(): void;
  20969. /**
  20970. * Clear the info related to rendering groups preventing retention point in material dispose.
  20971. */
  20972. freeRenderingGroups(): void;
  20973. /**
  20974. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20975. * @returns the view count
  20976. */
  20977. getViewCount(): number;
  20978. }
  20979. }
  20980. declare module "babylonjs/Materials/material" {
  20981. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20982. import { SmartArray } from "babylonjs/Misc/smartArray";
  20983. import { Observable } from "babylonjs/Misc/observable";
  20984. import { Nullable } from "babylonjs/types";
  20985. import { Scene } from "babylonjs/scene";
  20986. import { Matrix } from "babylonjs/Maths/math.vector";
  20987. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20989. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20990. import { Effect } from "babylonjs/Materials/effect";
  20991. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20992. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20993. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20994. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20995. import { Mesh } from "babylonjs/Meshes/mesh";
  20996. import { Animation } from "babylonjs/Animations/animation";
  20997. /**
  20998. * Options for compiling materials.
  20999. */
  21000. export interface IMaterialCompilationOptions {
  21001. /**
  21002. * Defines whether clip planes are enabled.
  21003. */
  21004. clipPlane: boolean;
  21005. /**
  21006. * Defines whether instances are enabled.
  21007. */
  21008. useInstances: boolean;
  21009. }
  21010. /**
  21011. * Base class for the main features of a material in Babylon.js
  21012. */
  21013. export class Material implements IAnimatable {
  21014. /**
  21015. * Returns the triangle fill mode
  21016. */
  21017. static readonly TriangleFillMode: number;
  21018. /**
  21019. * Returns the wireframe mode
  21020. */
  21021. static readonly WireFrameFillMode: number;
  21022. /**
  21023. * Returns the point fill mode
  21024. */
  21025. static readonly PointFillMode: number;
  21026. /**
  21027. * Returns the point list draw mode
  21028. */
  21029. static readonly PointListDrawMode: number;
  21030. /**
  21031. * Returns the line list draw mode
  21032. */
  21033. static readonly LineListDrawMode: number;
  21034. /**
  21035. * Returns the line loop draw mode
  21036. */
  21037. static readonly LineLoopDrawMode: number;
  21038. /**
  21039. * Returns the line strip draw mode
  21040. */
  21041. static readonly LineStripDrawMode: number;
  21042. /**
  21043. * Returns the triangle strip draw mode
  21044. */
  21045. static readonly TriangleStripDrawMode: number;
  21046. /**
  21047. * Returns the triangle fan draw mode
  21048. */
  21049. static readonly TriangleFanDrawMode: number;
  21050. /**
  21051. * Stores the clock-wise side orientation
  21052. */
  21053. static readonly ClockWiseSideOrientation: number;
  21054. /**
  21055. * Stores the counter clock-wise side orientation
  21056. */
  21057. static readonly CounterClockWiseSideOrientation: number;
  21058. /**
  21059. * The dirty texture flag value
  21060. */
  21061. static readonly TextureDirtyFlag: number;
  21062. /**
  21063. * The dirty light flag value
  21064. */
  21065. static readonly LightDirtyFlag: number;
  21066. /**
  21067. * The dirty fresnel flag value
  21068. */
  21069. static readonly FresnelDirtyFlag: number;
  21070. /**
  21071. * The dirty attribute flag value
  21072. */
  21073. static readonly AttributesDirtyFlag: number;
  21074. /**
  21075. * The dirty misc flag value
  21076. */
  21077. static readonly MiscDirtyFlag: number;
  21078. /**
  21079. * The all dirty flag value
  21080. */
  21081. static readonly AllDirtyFlag: number;
  21082. /**
  21083. * The ID of the material
  21084. */
  21085. id: string;
  21086. /**
  21087. * Gets or sets the unique id of the material
  21088. */
  21089. uniqueId: number;
  21090. /**
  21091. * The name of the material
  21092. */
  21093. name: string;
  21094. /**
  21095. * Gets or sets user defined metadata
  21096. */
  21097. metadata: any;
  21098. /**
  21099. * For internal use only. Please do not use.
  21100. */
  21101. reservedDataStore: any;
  21102. /**
  21103. * Specifies if the ready state should be checked on each call
  21104. */
  21105. checkReadyOnEveryCall: boolean;
  21106. /**
  21107. * Specifies if the ready state should be checked once
  21108. */
  21109. checkReadyOnlyOnce: boolean;
  21110. /**
  21111. * The state of the material
  21112. */
  21113. state: string;
  21114. /**
  21115. * The alpha value of the material
  21116. */
  21117. protected _alpha: number;
  21118. /**
  21119. * List of inspectable custom properties (used by the Inspector)
  21120. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21121. */
  21122. inspectableCustomProperties: IInspectable[];
  21123. /**
  21124. * Sets the alpha value of the material
  21125. */
  21126. /**
  21127. * Gets the alpha value of the material
  21128. */
  21129. alpha: number;
  21130. /**
  21131. * Specifies if back face culling is enabled
  21132. */
  21133. protected _backFaceCulling: boolean;
  21134. /**
  21135. * Sets the back-face culling state
  21136. */
  21137. /**
  21138. * Gets the back-face culling state
  21139. */
  21140. backFaceCulling: boolean;
  21141. /**
  21142. * Stores the value for side orientation
  21143. */
  21144. sideOrientation: number;
  21145. /**
  21146. * Callback triggered when the material is compiled
  21147. */
  21148. onCompiled: Nullable<(effect: Effect) => void>;
  21149. /**
  21150. * Callback triggered when an error occurs
  21151. */
  21152. onError: Nullable<(effect: Effect, errors: string) => void>;
  21153. /**
  21154. * Callback triggered to get the render target textures
  21155. */
  21156. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21157. /**
  21158. * Gets a boolean indicating that current material needs to register RTT
  21159. */
  21160. readonly hasRenderTargetTextures: boolean;
  21161. /**
  21162. * Specifies if the material should be serialized
  21163. */
  21164. doNotSerialize: boolean;
  21165. /**
  21166. * @hidden
  21167. */
  21168. _storeEffectOnSubMeshes: boolean;
  21169. /**
  21170. * Stores the animations for the material
  21171. */
  21172. animations: Nullable<Array<Animation>>;
  21173. /**
  21174. * An event triggered when the material is disposed
  21175. */
  21176. onDisposeObservable: Observable<Material>;
  21177. /**
  21178. * An observer which watches for dispose events
  21179. */
  21180. private _onDisposeObserver;
  21181. private _onUnBindObservable;
  21182. /**
  21183. * Called during a dispose event
  21184. */
  21185. onDispose: () => void;
  21186. private _onBindObservable;
  21187. /**
  21188. * An event triggered when the material is bound
  21189. */
  21190. readonly onBindObservable: Observable<AbstractMesh>;
  21191. /**
  21192. * An observer which watches for bind events
  21193. */
  21194. private _onBindObserver;
  21195. /**
  21196. * Called during a bind event
  21197. */
  21198. onBind: (Mesh: AbstractMesh) => void;
  21199. /**
  21200. * An event triggered when the material is unbound
  21201. */
  21202. readonly onUnBindObservable: Observable<Material>;
  21203. /**
  21204. * Stores the value of the alpha mode
  21205. */
  21206. private _alphaMode;
  21207. /**
  21208. * Sets the value of the alpha mode.
  21209. *
  21210. * | Value | Type | Description |
  21211. * | --- | --- | --- |
  21212. * | 0 | ALPHA_DISABLE | |
  21213. * | 1 | ALPHA_ADD | |
  21214. * | 2 | ALPHA_COMBINE | |
  21215. * | 3 | ALPHA_SUBTRACT | |
  21216. * | 4 | ALPHA_MULTIPLY | |
  21217. * | 5 | ALPHA_MAXIMIZED | |
  21218. * | 6 | ALPHA_ONEONE | |
  21219. * | 7 | ALPHA_PREMULTIPLIED | |
  21220. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21221. * | 9 | ALPHA_INTERPOLATE | |
  21222. * | 10 | ALPHA_SCREENMODE | |
  21223. *
  21224. */
  21225. /**
  21226. * Gets the value of the alpha mode
  21227. */
  21228. alphaMode: number;
  21229. /**
  21230. * Stores the state of the need depth pre-pass value
  21231. */
  21232. private _needDepthPrePass;
  21233. /**
  21234. * Sets the need depth pre-pass value
  21235. */
  21236. /**
  21237. * Gets the depth pre-pass value
  21238. */
  21239. needDepthPrePass: boolean;
  21240. /**
  21241. * Specifies if depth writing should be disabled
  21242. */
  21243. disableDepthWrite: boolean;
  21244. /**
  21245. * Specifies if depth writing should be forced
  21246. */
  21247. forceDepthWrite: boolean;
  21248. /**
  21249. * Specifies the depth function that should be used. 0 means the default engine function
  21250. */
  21251. depthFunction: number;
  21252. /**
  21253. * Specifies if there should be a separate pass for culling
  21254. */
  21255. separateCullingPass: boolean;
  21256. /**
  21257. * Stores the state specifing if fog should be enabled
  21258. */
  21259. private _fogEnabled;
  21260. /**
  21261. * Sets the state for enabling fog
  21262. */
  21263. /**
  21264. * Gets the value of the fog enabled state
  21265. */
  21266. fogEnabled: boolean;
  21267. /**
  21268. * Stores the size of points
  21269. */
  21270. pointSize: number;
  21271. /**
  21272. * Stores the z offset value
  21273. */
  21274. zOffset: number;
  21275. /**
  21276. * Gets a value specifying if wireframe mode is enabled
  21277. */
  21278. /**
  21279. * Sets the state of wireframe mode
  21280. */
  21281. wireframe: boolean;
  21282. /**
  21283. * Gets the value specifying if point clouds are enabled
  21284. */
  21285. /**
  21286. * Sets the state of point cloud mode
  21287. */
  21288. pointsCloud: boolean;
  21289. /**
  21290. * Gets the material fill mode
  21291. */
  21292. /**
  21293. * Sets the material fill mode
  21294. */
  21295. fillMode: number;
  21296. /**
  21297. * @hidden
  21298. * Stores the effects for the material
  21299. */
  21300. _effect: Nullable<Effect>;
  21301. /**
  21302. * @hidden
  21303. * Specifies if the material was previously ready
  21304. */
  21305. _wasPreviouslyReady: boolean;
  21306. /**
  21307. * Specifies if uniform buffers should be used
  21308. */
  21309. private _useUBO;
  21310. /**
  21311. * Stores a reference to the scene
  21312. */
  21313. private _scene;
  21314. /**
  21315. * Stores the fill mode state
  21316. */
  21317. private _fillMode;
  21318. /**
  21319. * Specifies if the depth write state should be cached
  21320. */
  21321. private _cachedDepthWriteState;
  21322. /**
  21323. * Specifies if the depth function state should be cached
  21324. */
  21325. private _cachedDepthFunctionState;
  21326. /**
  21327. * Stores the uniform buffer
  21328. */
  21329. protected _uniformBuffer: UniformBuffer;
  21330. /** @hidden */
  21331. _indexInSceneMaterialArray: number;
  21332. /** @hidden */
  21333. meshMap: Nullable<{
  21334. [id: string]: AbstractMesh | undefined;
  21335. }>;
  21336. /**
  21337. * Creates a material instance
  21338. * @param name defines the name of the material
  21339. * @param scene defines the scene to reference
  21340. * @param doNotAdd specifies if the material should be added to the scene
  21341. */
  21342. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21343. /**
  21344. * Returns a string representation of the current material
  21345. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21346. * @returns a string with material information
  21347. */
  21348. toString(fullDetails?: boolean): string;
  21349. /**
  21350. * Gets the class name of the material
  21351. * @returns a string with the class name of the material
  21352. */
  21353. getClassName(): string;
  21354. /**
  21355. * Specifies if updates for the material been locked
  21356. */
  21357. readonly isFrozen: boolean;
  21358. /**
  21359. * Locks updates for the material
  21360. */
  21361. freeze(): void;
  21362. /**
  21363. * Unlocks updates for the material
  21364. */
  21365. unfreeze(): void;
  21366. /**
  21367. * Specifies if the material is ready to be used
  21368. * @param mesh defines the mesh to check
  21369. * @param useInstances specifies if instances should be used
  21370. * @returns a boolean indicating if the material is ready to be used
  21371. */
  21372. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21373. /**
  21374. * Specifies that the submesh is ready to be used
  21375. * @param mesh defines the mesh to check
  21376. * @param subMesh defines which submesh to check
  21377. * @param useInstances specifies that instances should be used
  21378. * @returns a boolean indicating that the submesh is ready or not
  21379. */
  21380. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21381. /**
  21382. * Returns the material effect
  21383. * @returns the effect associated with the material
  21384. */
  21385. getEffect(): Nullable<Effect>;
  21386. /**
  21387. * Returns the current scene
  21388. * @returns a Scene
  21389. */
  21390. getScene(): Scene;
  21391. /**
  21392. * Specifies if the material will require alpha blending
  21393. * @returns a boolean specifying if alpha blending is needed
  21394. */
  21395. needAlphaBlending(): boolean;
  21396. /**
  21397. * Specifies if the mesh will require alpha blending
  21398. * @param mesh defines the mesh to check
  21399. * @returns a boolean specifying if alpha blending is needed for the mesh
  21400. */
  21401. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21402. /**
  21403. * Specifies if this material should be rendered in alpha test mode
  21404. * @returns a boolean specifying if an alpha test is needed.
  21405. */
  21406. needAlphaTesting(): boolean;
  21407. /**
  21408. * Gets the texture used for the alpha test
  21409. * @returns the texture to use for alpha testing
  21410. */
  21411. getAlphaTestTexture(): Nullable<BaseTexture>;
  21412. /**
  21413. * Marks the material to indicate that it needs to be re-calculated
  21414. */
  21415. markDirty(): void;
  21416. /** @hidden */
  21417. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21418. /**
  21419. * Binds the material to the mesh
  21420. * @param world defines the world transformation matrix
  21421. * @param mesh defines the mesh to bind the material to
  21422. */
  21423. bind(world: Matrix, mesh?: Mesh): void;
  21424. /**
  21425. * Binds the submesh to the material
  21426. * @param world defines the world transformation matrix
  21427. * @param mesh defines the mesh containing the submesh
  21428. * @param subMesh defines the submesh to bind the material to
  21429. */
  21430. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21431. /**
  21432. * Binds the world matrix to the material
  21433. * @param world defines the world transformation matrix
  21434. */
  21435. bindOnlyWorldMatrix(world: Matrix): void;
  21436. /**
  21437. * Binds the scene's uniform buffer to the effect.
  21438. * @param effect defines the effect to bind to the scene uniform buffer
  21439. * @param sceneUbo defines the uniform buffer storing scene data
  21440. */
  21441. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21442. /**
  21443. * Binds the view matrix to the effect
  21444. * @param effect defines the effect to bind the view matrix to
  21445. */
  21446. bindView(effect: Effect): void;
  21447. /**
  21448. * Binds the view projection matrix to the effect
  21449. * @param effect defines the effect to bind the view projection matrix to
  21450. */
  21451. bindViewProjection(effect: Effect): void;
  21452. /**
  21453. * Specifies if material alpha testing should be turned on for the mesh
  21454. * @param mesh defines the mesh to check
  21455. */
  21456. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21457. /**
  21458. * Processes to execute after binding the material to a mesh
  21459. * @param mesh defines the rendered mesh
  21460. */
  21461. protected _afterBind(mesh?: Mesh): void;
  21462. /**
  21463. * Unbinds the material from the mesh
  21464. */
  21465. unbind(): void;
  21466. /**
  21467. * Gets the active textures from the material
  21468. * @returns an array of textures
  21469. */
  21470. getActiveTextures(): BaseTexture[];
  21471. /**
  21472. * Specifies if the material uses a texture
  21473. * @param texture defines the texture to check against the material
  21474. * @returns a boolean specifying if the material uses the texture
  21475. */
  21476. hasTexture(texture: BaseTexture): boolean;
  21477. /**
  21478. * Makes a duplicate of the material, and gives it a new name
  21479. * @param name defines the new name for the duplicated material
  21480. * @returns the cloned material
  21481. */
  21482. clone(name: string): Nullable<Material>;
  21483. /**
  21484. * Gets the meshes bound to the material
  21485. * @returns an array of meshes bound to the material
  21486. */
  21487. getBindedMeshes(): AbstractMesh[];
  21488. /**
  21489. * Force shader compilation
  21490. * @param mesh defines the mesh associated with this material
  21491. * @param onCompiled defines a function to execute once the material is compiled
  21492. * @param options defines the options to configure the compilation
  21493. * @param onError defines a function to execute if the material fails compiling
  21494. */
  21495. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21496. /**
  21497. * Force shader compilation
  21498. * @param mesh defines the mesh that will use this material
  21499. * @param options defines additional options for compiling the shaders
  21500. * @returns a promise that resolves when the compilation completes
  21501. */
  21502. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21503. private static readonly _AllDirtyCallBack;
  21504. private static readonly _ImageProcessingDirtyCallBack;
  21505. private static readonly _TextureDirtyCallBack;
  21506. private static readonly _FresnelDirtyCallBack;
  21507. private static readonly _MiscDirtyCallBack;
  21508. private static readonly _LightsDirtyCallBack;
  21509. private static readonly _AttributeDirtyCallBack;
  21510. private static _FresnelAndMiscDirtyCallBack;
  21511. private static _TextureAndMiscDirtyCallBack;
  21512. private static readonly _DirtyCallbackArray;
  21513. private static readonly _RunDirtyCallBacks;
  21514. /**
  21515. * Marks a define in the material to indicate that it needs to be re-computed
  21516. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21517. */
  21518. markAsDirty(flag: number): void;
  21519. /**
  21520. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21521. * @param func defines a function which checks material defines against the submeshes
  21522. */
  21523. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21524. /**
  21525. * Indicates that we need to re-calculated for all submeshes
  21526. */
  21527. protected _markAllSubMeshesAsAllDirty(): void;
  21528. /**
  21529. * Indicates that image processing needs to be re-calculated for all submeshes
  21530. */
  21531. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21532. /**
  21533. * Indicates that textures need to be re-calculated for all submeshes
  21534. */
  21535. protected _markAllSubMeshesAsTexturesDirty(): void;
  21536. /**
  21537. * Indicates that fresnel needs to be re-calculated for all submeshes
  21538. */
  21539. protected _markAllSubMeshesAsFresnelDirty(): void;
  21540. /**
  21541. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21542. */
  21543. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21544. /**
  21545. * Indicates that lights need to be re-calculated for all submeshes
  21546. */
  21547. protected _markAllSubMeshesAsLightsDirty(): void;
  21548. /**
  21549. * Indicates that attributes need to be re-calculated for all submeshes
  21550. */
  21551. protected _markAllSubMeshesAsAttributesDirty(): void;
  21552. /**
  21553. * Indicates that misc needs to be re-calculated for all submeshes
  21554. */
  21555. protected _markAllSubMeshesAsMiscDirty(): void;
  21556. /**
  21557. * Indicates that textures and misc need to be re-calculated for all submeshes
  21558. */
  21559. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21560. /**
  21561. * Disposes the material
  21562. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21563. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21564. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21565. */
  21566. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21567. /** @hidden */
  21568. private releaseVertexArrayObject;
  21569. /**
  21570. * Serializes this material
  21571. * @returns the serialized material object
  21572. */
  21573. serialize(): any;
  21574. /**
  21575. * Creates a material from parsed material data
  21576. * @param parsedMaterial defines parsed material data
  21577. * @param scene defines the hosting scene
  21578. * @param rootUrl defines the root URL to use to load textures
  21579. * @returns a new material
  21580. */
  21581. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21582. }
  21583. }
  21584. declare module "babylonjs/Materials/multiMaterial" {
  21585. import { Nullable } from "babylonjs/types";
  21586. import { Scene } from "babylonjs/scene";
  21587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21588. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21590. import { Material } from "babylonjs/Materials/material";
  21591. /**
  21592. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21593. * separate meshes. This can be use to improve performances.
  21594. * @see http://doc.babylonjs.com/how_to/multi_materials
  21595. */
  21596. export class MultiMaterial extends Material {
  21597. private _subMaterials;
  21598. /**
  21599. * Gets or Sets the list of Materials used within the multi material.
  21600. * They need to be ordered according to the submeshes order in the associated mesh
  21601. */
  21602. subMaterials: Nullable<Material>[];
  21603. /**
  21604. * Function used to align with Node.getChildren()
  21605. * @returns the list of Materials used within the multi material
  21606. */
  21607. getChildren(): Nullable<Material>[];
  21608. /**
  21609. * Instantiates a new Multi Material
  21610. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21611. * separate meshes. This can be use to improve performances.
  21612. * @see http://doc.babylonjs.com/how_to/multi_materials
  21613. * @param name Define the name in the scene
  21614. * @param scene Define the scene the material belongs to
  21615. */
  21616. constructor(name: string, scene: Scene);
  21617. private _hookArray;
  21618. /**
  21619. * Get one of the submaterial by its index in the submaterials array
  21620. * @param index The index to look the sub material at
  21621. * @returns The Material if the index has been defined
  21622. */
  21623. getSubMaterial(index: number): Nullable<Material>;
  21624. /**
  21625. * Get the list of active textures for the whole sub materials list.
  21626. * @returns All the textures that will be used during the rendering
  21627. */
  21628. getActiveTextures(): BaseTexture[];
  21629. /**
  21630. * Gets the current class name of the material e.g. "MultiMaterial"
  21631. * Mainly use in serialization.
  21632. * @returns the class name
  21633. */
  21634. getClassName(): string;
  21635. /**
  21636. * Checks if the material is ready to render the requested sub mesh
  21637. * @param mesh Define the mesh the submesh belongs to
  21638. * @param subMesh Define the sub mesh to look readyness for
  21639. * @param useInstances Define whether or not the material is used with instances
  21640. * @returns true if ready, otherwise false
  21641. */
  21642. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21643. /**
  21644. * Clones the current material and its related sub materials
  21645. * @param name Define the name of the newly cloned material
  21646. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21647. * @returns the cloned material
  21648. */
  21649. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21650. /**
  21651. * Serializes the materials into a JSON representation.
  21652. * @returns the JSON representation
  21653. */
  21654. serialize(): any;
  21655. /**
  21656. * Dispose the material and release its associated resources
  21657. * @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)
  21658. * @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)
  21659. * @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)
  21660. */
  21661. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21662. /**
  21663. * Creates a MultiMaterial from parsed MultiMaterial data.
  21664. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21665. * @param scene defines the hosting scene
  21666. * @returns a new MultiMaterial
  21667. */
  21668. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21669. }
  21670. }
  21671. declare module "babylonjs/Meshes/subMesh" {
  21672. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21673. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21674. import { Engine } from "babylonjs/Engines/engine";
  21675. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21676. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21677. import { Effect } from "babylonjs/Materials/effect";
  21678. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21679. import { Plane } from "babylonjs/Maths/math.plane";
  21680. import { Collider } from "babylonjs/Collisions/collider";
  21681. import { Material } from "babylonjs/Materials/material";
  21682. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21684. import { Mesh } from "babylonjs/Meshes/mesh";
  21685. import { Ray } from "babylonjs/Culling/ray";
  21686. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21687. /**
  21688. * Base class for submeshes
  21689. */
  21690. export class BaseSubMesh {
  21691. /** @hidden */
  21692. _materialDefines: Nullable<MaterialDefines>;
  21693. /** @hidden */
  21694. _materialEffect: Nullable<Effect>;
  21695. /**
  21696. * Gets associated effect
  21697. */
  21698. readonly effect: Nullable<Effect>;
  21699. /**
  21700. * Sets associated effect (effect used to render this submesh)
  21701. * @param effect defines the effect to associate with
  21702. * @param defines defines the set of defines used to compile this effect
  21703. */
  21704. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21705. }
  21706. /**
  21707. * Defines a subdivision inside a mesh
  21708. */
  21709. export class SubMesh extends BaseSubMesh implements ICullable {
  21710. /** the material index to use */
  21711. materialIndex: number;
  21712. /** vertex index start */
  21713. verticesStart: number;
  21714. /** vertices count */
  21715. verticesCount: number;
  21716. /** index start */
  21717. indexStart: number;
  21718. /** indices count */
  21719. indexCount: number;
  21720. /** @hidden */
  21721. _linesIndexCount: number;
  21722. private _mesh;
  21723. private _renderingMesh;
  21724. private _boundingInfo;
  21725. private _linesIndexBuffer;
  21726. /** @hidden */
  21727. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21728. /** @hidden */
  21729. _trianglePlanes: Plane[];
  21730. /** @hidden */
  21731. _lastColliderTransformMatrix: Nullable<Matrix>;
  21732. /** @hidden */
  21733. _renderId: number;
  21734. /** @hidden */
  21735. _alphaIndex: number;
  21736. /** @hidden */
  21737. _distanceToCamera: number;
  21738. /** @hidden */
  21739. _id: number;
  21740. private _currentMaterial;
  21741. /**
  21742. * Add a new submesh to a mesh
  21743. * @param materialIndex defines the material index to use
  21744. * @param verticesStart defines vertex index start
  21745. * @param verticesCount defines vertices count
  21746. * @param indexStart defines index start
  21747. * @param indexCount defines indices count
  21748. * @param mesh defines the parent mesh
  21749. * @param renderingMesh defines an optional rendering mesh
  21750. * @param createBoundingBox defines if bounding box should be created for this submesh
  21751. * @returns the new submesh
  21752. */
  21753. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21754. /**
  21755. * Creates a new submesh
  21756. * @param materialIndex defines the material index to use
  21757. * @param verticesStart defines vertex index start
  21758. * @param verticesCount defines vertices count
  21759. * @param indexStart defines index start
  21760. * @param indexCount defines indices count
  21761. * @param mesh defines the parent mesh
  21762. * @param renderingMesh defines an optional rendering mesh
  21763. * @param createBoundingBox defines if bounding box should be created for this submesh
  21764. */
  21765. constructor(
  21766. /** the material index to use */
  21767. materialIndex: number,
  21768. /** vertex index start */
  21769. verticesStart: number,
  21770. /** vertices count */
  21771. verticesCount: number,
  21772. /** index start */
  21773. indexStart: number,
  21774. /** indices count */
  21775. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21776. /**
  21777. * Returns true if this submesh covers the entire parent mesh
  21778. * @ignorenaming
  21779. */
  21780. readonly IsGlobal: boolean;
  21781. /**
  21782. * Returns the submesh BoudingInfo object
  21783. * @returns current bounding info (or mesh's one if the submesh is global)
  21784. */
  21785. getBoundingInfo(): BoundingInfo;
  21786. /**
  21787. * Sets the submesh BoundingInfo
  21788. * @param boundingInfo defines the new bounding info to use
  21789. * @returns the SubMesh
  21790. */
  21791. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21792. /**
  21793. * Returns the mesh of the current submesh
  21794. * @return the parent mesh
  21795. */
  21796. getMesh(): AbstractMesh;
  21797. /**
  21798. * Returns the rendering mesh of the submesh
  21799. * @returns the rendering mesh (could be different from parent mesh)
  21800. */
  21801. getRenderingMesh(): Mesh;
  21802. /**
  21803. * Returns the submesh material
  21804. * @returns null or the current material
  21805. */
  21806. getMaterial(): Nullable<Material>;
  21807. /**
  21808. * Sets a new updated BoundingInfo object to the submesh
  21809. * @param data defines an optional position array to use to determine the bounding info
  21810. * @returns the SubMesh
  21811. */
  21812. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21813. /** @hidden */
  21814. _checkCollision(collider: Collider): boolean;
  21815. /**
  21816. * Updates the submesh BoundingInfo
  21817. * @param world defines the world matrix to use to update the bounding info
  21818. * @returns the submesh
  21819. */
  21820. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21821. /**
  21822. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21823. * @param frustumPlanes defines the frustum planes
  21824. * @returns true if the submesh is intersecting with the frustum
  21825. */
  21826. isInFrustum(frustumPlanes: Plane[]): boolean;
  21827. /**
  21828. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21829. * @param frustumPlanes defines the frustum planes
  21830. * @returns true if the submesh is inside the frustum
  21831. */
  21832. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21833. /**
  21834. * Renders the submesh
  21835. * @param enableAlphaMode defines if alpha needs to be used
  21836. * @returns the submesh
  21837. */
  21838. render(enableAlphaMode: boolean): SubMesh;
  21839. /**
  21840. * @hidden
  21841. */
  21842. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21843. /**
  21844. * Checks if the submesh intersects with a ray
  21845. * @param ray defines the ray to test
  21846. * @returns true is the passed ray intersects the submesh bounding box
  21847. */
  21848. canIntersects(ray: Ray): boolean;
  21849. /**
  21850. * Intersects current submesh with a ray
  21851. * @param ray defines the ray to test
  21852. * @param positions defines mesh's positions array
  21853. * @param indices defines mesh's indices array
  21854. * @param fastCheck defines if only bounding info should be used
  21855. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21856. * @returns intersection info or null if no intersection
  21857. */
  21858. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21859. /** @hidden */
  21860. private _intersectLines;
  21861. /** @hidden */
  21862. private _intersectUnIndexedLines;
  21863. /** @hidden */
  21864. private _intersectTriangles;
  21865. /** @hidden */
  21866. private _intersectUnIndexedTriangles;
  21867. /** @hidden */
  21868. _rebuild(): void;
  21869. /**
  21870. * Creates a new submesh from the passed mesh
  21871. * @param newMesh defines the new hosting mesh
  21872. * @param newRenderingMesh defines an optional rendering mesh
  21873. * @returns the new submesh
  21874. */
  21875. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21876. /**
  21877. * Release associated resources
  21878. */
  21879. dispose(): void;
  21880. /**
  21881. * Gets the class name
  21882. * @returns the string "SubMesh".
  21883. */
  21884. getClassName(): string;
  21885. /**
  21886. * Creates a new submesh from indices data
  21887. * @param materialIndex the index of the main mesh material
  21888. * @param startIndex the index where to start the copy in the mesh indices array
  21889. * @param indexCount the number of indices to copy then from the startIndex
  21890. * @param mesh the main mesh to create the submesh from
  21891. * @param renderingMesh the optional rendering mesh
  21892. * @returns a new submesh
  21893. */
  21894. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21895. }
  21896. }
  21897. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21898. /**
  21899. * Class used to represent data loading progression
  21900. */
  21901. export class SceneLoaderFlags {
  21902. private static _ForceFullSceneLoadingForIncremental;
  21903. private static _ShowLoadingScreen;
  21904. private static _CleanBoneMatrixWeights;
  21905. private static _loggingLevel;
  21906. /**
  21907. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21908. */
  21909. static ForceFullSceneLoadingForIncremental: boolean;
  21910. /**
  21911. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21912. */
  21913. static ShowLoadingScreen: boolean;
  21914. /**
  21915. * Defines the current logging level (while loading the scene)
  21916. * @ignorenaming
  21917. */
  21918. static loggingLevel: number;
  21919. /**
  21920. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21921. */
  21922. static CleanBoneMatrixWeights: boolean;
  21923. }
  21924. }
  21925. declare module "babylonjs/Meshes/geometry" {
  21926. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21927. import { Scene } from "babylonjs/scene";
  21928. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21929. import { Engine } from "babylonjs/Engines/engine";
  21930. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21931. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21932. import { Effect } from "babylonjs/Materials/effect";
  21933. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21934. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21935. import { Mesh } from "babylonjs/Meshes/mesh";
  21936. /**
  21937. * Class used to store geometry data (vertex buffers + index buffer)
  21938. */
  21939. export class Geometry implements IGetSetVerticesData {
  21940. /**
  21941. * Gets or sets the ID of the geometry
  21942. */
  21943. id: string;
  21944. /**
  21945. * Gets or sets the unique ID of the geometry
  21946. */
  21947. uniqueId: number;
  21948. /**
  21949. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21950. */
  21951. delayLoadState: number;
  21952. /**
  21953. * Gets the file containing the data to load when running in delay load state
  21954. */
  21955. delayLoadingFile: Nullable<string>;
  21956. /**
  21957. * Callback called when the geometry is updated
  21958. */
  21959. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21960. private _scene;
  21961. private _engine;
  21962. private _meshes;
  21963. private _totalVertices;
  21964. /** @hidden */
  21965. _indices: IndicesArray;
  21966. /** @hidden */
  21967. _vertexBuffers: {
  21968. [key: string]: VertexBuffer;
  21969. };
  21970. private _isDisposed;
  21971. private _extend;
  21972. private _boundingBias;
  21973. /** @hidden */
  21974. _delayInfo: Array<string>;
  21975. private _indexBuffer;
  21976. private _indexBufferIsUpdatable;
  21977. /** @hidden */
  21978. _boundingInfo: Nullable<BoundingInfo>;
  21979. /** @hidden */
  21980. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21981. /** @hidden */
  21982. _softwareSkinningFrameId: number;
  21983. private _vertexArrayObjects;
  21984. private _updatable;
  21985. /** @hidden */
  21986. _positions: Nullable<Vector3[]>;
  21987. /**
  21988. * 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
  21989. */
  21990. /**
  21991. * 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
  21992. */
  21993. boundingBias: Vector2;
  21994. /**
  21995. * Static function used to attach a new empty geometry to a mesh
  21996. * @param mesh defines the mesh to attach the geometry to
  21997. * @returns the new Geometry
  21998. */
  21999. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22000. /**
  22001. * Creates a new geometry
  22002. * @param id defines the unique ID
  22003. * @param scene defines the hosting scene
  22004. * @param vertexData defines the VertexData used to get geometry data
  22005. * @param updatable defines if geometry must be updatable (false by default)
  22006. * @param mesh defines the mesh that will be associated with the geometry
  22007. */
  22008. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22009. /**
  22010. * Gets the current extend of the geometry
  22011. */
  22012. readonly extend: {
  22013. minimum: Vector3;
  22014. maximum: Vector3;
  22015. };
  22016. /**
  22017. * Gets the hosting scene
  22018. * @returns the hosting Scene
  22019. */
  22020. getScene(): Scene;
  22021. /**
  22022. * Gets the hosting engine
  22023. * @returns the hosting Engine
  22024. */
  22025. getEngine(): Engine;
  22026. /**
  22027. * Defines if the geometry is ready to use
  22028. * @returns true if the geometry is ready to be used
  22029. */
  22030. isReady(): boolean;
  22031. /**
  22032. * Gets a value indicating that the geometry should not be serialized
  22033. */
  22034. readonly doNotSerialize: boolean;
  22035. /** @hidden */
  22036. _rebuild(): void;
  22037. /**
  22038. * Affects all geometry data in one call
  22039. * @param vertexData defines the geometry data
  22040. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22041. */
  22042. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22043. /**
  22044. * Set specific vertex data
  22045. * @param kind defines the data kind (Position, normal, etc...)
  22046. * @param data defines the vertex data to use
  22047. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22048. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22049. */
  22050. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22051. /**
  22052. * Removes a specific vertex data
  22053. * @param kind defines the data kind (Position, normal, etc...)
  22054. */
  22055. removeVerticesData(kind: string): void;
  22056. /**
  22057. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22058. * @param buffer defines the vertex buffer to use
  22059. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22060. */
  22061. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22062. /**
  22063. * Update a specific vertex buffer
  22064. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22065. * It will do nothing if the buffer is not updatable
  22066. * @param kind defines the data kind (Position, normal, etc...)
  22067. * @param data defines the data to use
  22068. * @param offset defines the offset in the target buffer where to store the data
  22069. * @param useBytes set to true if the offset is in bytes
  22070. */
  22071. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22072. /**
  22073. * Update a specific vertex buffer
  22074. * This function will create a new buffer if the current one is not updatable
  22075. * @param kind defines the data kind (Position, normal, etc...)
  22076. * @param data defines the data to use
  22077. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22078. */
  22079. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22080. private _updateBoundingInfo;
  22081. /** @hidden */
  22082. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22083. /**
  22084. * Gets total number of vertices
  22085. * @returns the total number of vertices
  22086. */
  22087. getTotalVertices(): number;
  22088. /**
  22089. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22090. * @param kind defines the data kind (Position, normal, etc...)
  22091. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22092. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22093. * @returns a float array containing vertex data
  22094. */
  22095. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22096. /**
  22097. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22098. * @param kind defines the data kind (Position, normal, etc...)
  22099. * @returns true if the vertex buffer with the specified kind is updatable
  22100. */
  22101. isVertexBufferUpdatable(kind: string): boolean;
  22102. /**
  22103. * Gets a specific vertex buffer
  22104. * @param kind defines the data kind (Position, normal, etc...)
  22105. * @returns a VertexBuffer
  22106. */
  22107. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22108. /**
  22109. * Returns all vertex buffers
  22110. * @return an object holding all vertex buffers indexed by kind
  22111. */
  22112. getVertexBuffers(): Nullable<{
  22113. [key: string]: VertexBuffer;
  22114. }>;
  22115. /**
  22116. * Gets a boolean indicating if specific vertex buffer is present
  22117. * @param kind defines the data kind (Position, normal, etc...)
  22118. * @returns true if data is present
  22119. */
  22120. isVerticesDataPresent(kind: string): boolean;
  22121. /**
  22122. * Gets a list of all attached data kinds (Position, normal, etc...)
  22123. * @returns a list of string containing all kinds
  22124. */
  22125. getVerticesDataKinds(): string[];
  22126. /**
  22127. * Update index buffer
  22128. * @param indices defines the indices to store in the index buffer
  22129. * @param offset defines the offset in the target buffer where to store the data
  22130. * @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)
  22131. */
  22132. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22133. /**
  22134. * Creates a new index buffer
  22135. * @param indices defines the indices to store in the index buffer
  22136. * @param totalVertices defines the total number of vertices (could be null)
  22137. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22138. */
  22139. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22140. /**
  22141. * Return the total number of indices
  22142. * @returns the total number of indices
  22143. */
  22144. getTotalIndices(): number;
  22145. /**
  22146. * Gets the index buffer array
  22147. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22148. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22149. * @returns the index buffer array
  22150. */
  22151. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22152. /**
  22153. * Gets the index buffer
  22154. * @return the index buffer
  22155. */
  22156. getIndexBuffer(): Nullable<DataBuffer>;
  22157. /** @hidden */
  22158. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22159. /**
  22160. * Release the associated resources for a specific mesh
  22161. * @param mesh defines the source mesh
  22162. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22163. */
  22164. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22165. /**
  22166. * Apply current geometry to a given mesh
  22167. * @param mesh defines the mesh to apply geometry to
  22168. */
  22169. applyToMesh(mesh: Mesh): void;
  22170. private _updateExtend;
  22171. private _applyToMesh;
  22172. private notifyUpdate;
  22173. /**
  22174. * Load the geometry if it was flagged as delay loaded
  22175. * @param scene defines the hosting scene
  22176. * @param onLoaded defines a callback called when the geometry is loaded
  22177. */
  22178. load(scene: Scene, onLoaded?: () => void): void;
  22179. private _queueLoad;
  22180. /**
  22181. * Invert the geometry to move from a right handed system to a left handed one.
  22182. */
  22183. toLeftHanded(): void;
  22184. /** @hidden */
  22185. _resetPointsArrayCache(): void;
  22186. /** @hidden */
  22187. _generatePointsArray(): boolean;
  22188. /**
  22189. * Gets a value indicating if the geometry is disposed
  22190. * @returns true if the geometry was disposed
  22191. */
  22192. isDisposed(): boolean;
  22193. private _disposeVertexArrayObjects;
  22194. /**
  22195. * Free all associated resources
  22196. */
  22197. dispose(): void;
  22198. /**
  22199. * Clone the current geometry into a new geometry
  22200. * @param id defines the unique ID of the new geometry
  22201. * @returns a new geometry object
  22202. */
  22203. copy(id: string): Geometry;
  22204. /**
  22205. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22206. * @return a JSON representation of the current geometry data (without the vertices data)
  22207. */
  22208. serialize(): any;
  22209. private toNumberArray;
  22210. /**
  22211. * Serialize all vertices data into a JSON oject
  22212. * @returns a JSON representation of the current geometry data
  22213. */
  22214. serializeVerticeData(): any;
  22215. /**
  22216. * Extracts a clone of a mesh geometry
  22217. * @param mesh defines the source mesh
  22218. * @param id defines the unique ID of the new geometry object
  22219. * @returns the new geometry object
  22220. */
  22221. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22222. /**
  22223. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22224. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22225. * Be aware Math.random() could cause collisions, but:
  22226. * "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"
  22227. * @returns a string containing a new GUID
  22228. */
  22229. static RandomId(): string;
  22230. /** @hidden */
  22231. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22232. private static _CleanMatricesWeights;
  22233. /**
  22234. * Create a new geometry from persisted data (Using .babylon file format)
  22235. * @param parsedVertexData defines the persisted data
  22236. * @param scene defines the hosting scene
  22237. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22238. * @returns the new geometry object
  22239. */
  22240. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22241. }
  22242. }
  22243. declare module "babylonjs/Meshes/mesh.vertexData" {
  22244. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22245. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22246. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22247. import { Geometry } from "babylonjs/Meshes/geometry";
  22248. import { Mesh } from "babylonjs/Meshes/mesh";
  22249. /**
  22250. * Define an interface for all classes that will get and set the data on vertices
  22251. */
  22252. export interface IGetSetVerticesData {
  22253. /**
  22254. * Gets a boolean indicating if specific vertex data is present
  22255. * @param kind defines the vertex data kind to use
  22256. * @returns true is data kind is present
  22257. */
  22258. isVerticesDataPresent(kind: string): boolean;
  22259. /**
  22260. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22261. * @param kind defines the data kind (Position, normal, etc...)
  22262. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22263. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22264. * @returns a float array containing vertex data
  22265. */
  22266. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22267. /**
  22268. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22269. * @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.
  22270. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22271. * @returns the indices array or an empty array if the mesh has no geometry
  22272. */
  22273. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22274. /**
  22275. * Set specific vertex data
  22276. * @param kind defines the data kind (Position, normal, etc...)
  22277. * @param data defines the vertex data to use
  22278. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22279. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22280. */
  22281. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22282. /**
  22283. * Update a specific associated vertex buffer
  22284. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22285. * - VertexBuffer.PositionKind
  22286. * - VertexBuffer.UVKind
  22287. * - VertexBuffer.UV2Kind
  22288. * - VertexBuffer.UV3Kind
  22289. * - VertexBuffer.UV4Kind
  22290. * - VertexBuffer.UV5Kind
  22291. * - VertexBuffer.UV6Kind
  22292. * - VertexBuffer.ColorKind
  22293. * - VertexBuffer.MatricesIndicesKind
  22294. * - VertexBuffer.MatricesIndicesExtraKind
  22295. * - VertexBuffer.MatricesWeightsKind
  22296. * - VertexBuffer.MatricesWeightsExtraKind
  22297. * @param data defines the data source
  22298. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22299. * @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)
  22300. */
  22301. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22302. /**
  22303. * Creates a new index buffer
  22304. * @param indices defines the indices to store in the index buffer
  22305. * @param totalVertices defines the total number of vertices (could be null)
  22306. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22307. */
  22308. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22309. }
  22310. /**
  22311. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22312. */
  22313. export class VertexData {
  22314. /**
  22315. * Mesh side orientation : usually the external or front surface
  22316. */
  22317. static readonly FRONTSIDE: number;
  22318. /**
  22319. * Mesh side orientation : usually the internal or back surface
  22320. */
  22321. static readonly BACKSIDE: number;
  22322. /**
  22323. * Mesh side orientation : both internal and external or front and back surfaces
  22324. */
  22325. static readonly DOUBLESIDE: number;
  22326. /**
  22327. * Mesh side orientation : by default, `FRONTSIDE`
  22328. */
  22329. static readonly DEFAULTSIDE: number;
  22330. /**
  22331. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22332. */
  22333. positions: Nullable<FloatArray>;
  22334. /**
  22335. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22336. */
  22337. normals: Nullable<FloatArray>;
  22338. /**
  22339. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22340. */
  22341. tangents: Nullable<FloatArray>;
  22342. /**
  22343. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22344. */
  22345. uvs: Nullable<FloatArray>;
  22346. /**
  22347. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22348. */
  22349. uvs2: Nullable<FloatArray>;
  22350. /**
  22351. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22352. */
  22353. uvs3: Nullable<FloatArray>;
  22354. /**
  22355. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22356. */
  22357. uvs4: Nullable<FloatArray>;
  22358. /**
  22359. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22360. */
  22361. uvs5: Nullable<FloatArray>;
  22362. /**
  22363. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22364. */
  22365. uvs6: Nullable<FloatArray>;
  22366. /**
  22367. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22368. */
  22369. colors: Nullable<FloatArray>;
  22370. /**
  22371. * 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).
  22372. */
  22373. matricesIndices: Nullable<FloatArray>;
  22374. /**
  22375. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22376. */
  22377. matricesWeights: Nullable<FloatArray>;
  22378. /**
  22379. * An array extending the number of possible indices
  22380. */
  22381. matricesIndicesExtra: Nullable<FloatArray>;
  22382. /**
  22383. * An array extending the number of possible weights when the number of indices is extended
  22384. */
  22385. matricesWeightsExtra: Nullable<FloatArray>;
  22386. /**
  22387. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22388. */
  22389. indices: Nullable<IndicesArray>;
  22390. /**
  22391. * Uses the passed data array to set the set the values for the specified kind of data
  22392. * @param data a linear array of floating numbers
  22393. * @param kind the type of data that is being set, eg positions, colors etc
  22394. */
  22395. set(data: FloatArray, kind: string): void;
  22396. /**
  22397. * Associates the vertexData to the passed Mesh.
  22398. * Sets it as updatable or not (default `false`)
  22399. * @param mesh the mesh the vertexData is applied to
  22400. * @param updatable when used and having the value true allows new data to update the vertexData
  22401. * @returns the VertexData
  22402. */
  22403. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22404. /**
  22405. * Associates the vertexData to the passed Geometry.
  22406. * Sets it as updatable or not (default `false`)
  22407. * @param geometry the geometry the vertexData is applied to
  22408. * @param updatable when used and having the value true allows new data to update the vertexData
  22409. * @returns VertexData
  22410. */
  22411. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22412. /**
  22413. * Updates the associated mesh
  22414. * @param mesh the mesh to be updated
  22415. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22416. * @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
  22417. * @returns VertexData
  22418. */
  22419. updateMesh(mesh: Mesh): VertexData;
  22420. /**
  22421. * Updates the associated geometry
  22422. * @param geometry the geometry to be updated
  22423. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22424. * @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
  22425. * @returns VertexData.
  22426. */
  22427. updateGeometry(geometry: Geometry): VertexData;
  22428. private _applyTo;
  22429. private _update;
  22430. /**
  22431. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22432. * @param matrix the transforming matrix
  22433. * @returns the VertexData
  22434. */
  22435. transform(matrix: Matrix): VertexData;
  22436. /**
  22437. * Merges the passed VertexData into the current one
  22438. * @param other the VertexData to be merged into the current one
  22439. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22440. * @returns the modified VertexData
  22441. */
  22442. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22443. private _mergeElement;
  22444. private _validate;
  22445. /**
  22446. * Serializes the VertexData
  22447. * @returns a serialized object
  22448. */
  22449. serialize(): any;
  22450. /**
  22451. * Extracts the vertexData from a mesh
  22452. * @param mesh the mesh from which to extract the VertexData
  22453. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22454. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22455. * @returns the object VertexData associated to the passed mesh
  22456. */
  22457. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22458. /**
  22459. * Extracts the vertexData from the geometry
  22460. * @param geometry the geometry from which to extract the VertexData
  22461. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22462. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22463. * @returns the object VertexData associated to the passed mesh
  22464. */
  22465. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22466. private static _ExtractFrom;
  22467. /**
  22468. * Creates the VertexData for a Ribbon
  22469. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22470. * * pathArray array of paths, each of which an array of successive Vector3
  22471. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22472. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22473. * * 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
  22474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22475. * * 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)
  22476. * * 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)
  22477. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22478. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22479. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22480. * @returns the VertexData of the ribbon
  22481. */
  22482. static CreateRibbon(options: {
  22483. pathArray: Vector3[][];
  22484. closeArray?: boolean;
  22485. closePath?: boolean;
  22486. offset?: number;
  22487. sideOrientation?: number;
  22488. frontUVs?: Vector4;
  22489. backUVs?: Vector4;
  22490. invertUV?: boolean;
  22491. uvs?: Vector2[];
  22492. colors?: Color4[];
  22493. }): VertexData;
  22494. /**
  22495. * Creates the VertexData for a box
  22496. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22497. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22498. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22499. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22500. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22501. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22502. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22503. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22504. * * 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)
  22505. * * 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)
  22506. * @returns the VertexData of the box
  22507. */
  22508. static CreateBox(options: {
  22509. size?: number;
  22510. width?: number;
  22511. height?: number;
  22512. depth?: number;
  22513. faceUV?: Vector4[];
  22514. faceColors?: Color4[];
  22515. sideOrientation?: number;
  22516. frontUVs?: Vector4;
  22517. backUVs?: Vector4;
  22518. }): VertexData;
  22519. /**
  22520. * Creates the VertexData for a tiled box
  22521. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22522. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22523. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22524. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22526. * @returns the VertexData of the box
  22527. */
  22528. static CreateTiledBox(options: {
  22529. pattern?: number;
  22530. width?: number;
  22531. height?: number;
  22532. depth?: number;
  22533. tileSize?: number;
  22534. tileWidth?: number;
  22535. tileHeight?: number;
  22536. alignHorizontal?: number;
  22537. alignVertical?: number;
  22538. faceUV?: Vector4[];
  22539. faceColors?: Color4[];
  22540. sideOrientation?: number;
  22541. }): VertexData;
  22542. /**
  22543. * Creates the VertexData for a tiled plane
  22544. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22545. * * pattern a limited pattern arrangement depending on the number
  22546. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22547. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22548. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22549. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22550. * * 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)
  22551. * * 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)
  22552. * @returns the VertexData of the tiled plane
  22553. */
  22554. static CreateTiledPlane(options: {
  22555. pattern?: number;
  22556. tileSize?: number;
  22557. tileWidth?: number;
  22558. tileHeight?: number;
  22559. size?: number;
  22560. width?: number;
  22561. height?: number;
  22562. alignHorizontal?: number;
  22563. alignVertical?: number;
  22564. sideOrientation?: number;
  22565. frontUVs?: Vector4;
  22566. backUVs?: Vector4;
  22567. }): VertexData;
  22568. /**
  22569. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22570. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22571. * * segments sets the number of horizontal strips optional, default 32
  22572. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22573. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22574. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22575. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22576. * * 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
  22577. * * 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
  22578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22579. * * 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)
  22580. * * 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)
  22581. * @returns the VertexData of the ellipsoid
  22582. */
  22583. static CreateSphere(options: {
  22584. segments?: number;
  22585. diameter?: number;
  22586. diameterX?: number;
  22587. diameterY?: number;
  22588. diameterZ?: number;
  22589. arc?: number;
  22590. slice?: number;
  22591. sideOrientation?: number;
  22592. frontUVs?: Vector4;
  22593. backUVs?: Vector4;
  22594. }): VertexData;
  22595. /**
  22596. * Creates the VertexData for a cylinder, cone or prism
  22597. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22598. * * height sets the height (y direction) of the cylinder, optional, default 2
  22599. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22600. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22601. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22602. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22603. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22604. * * 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
  22605. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22606. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22607. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22608. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22609. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22610. * * 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)
  22611. * * 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)
  22612. * @returns the VertexData of the cylinder, cone or prism
  22613. */
  22614. static CreateCylinder(options: {
  22615. height?: number;
  22616. diameterTop?: number;
  22617. diameterBottom?: number;
  22618. diameter?: number;
  22619. tessellation?: number;
  22620. subdivisions?: number;
  22621. arc?: number;
  22622. faceColors?: Color4[];
  22623. faceUV?: Vector4[];
  22624. hasRings?: boolean;
  22625. enclose?: boolean;
  22626. sideOrientation?: number;
  22627. frontUVs?: Vector4;
  22628. backUVs?: Vector4;
  22629. }): VertexData;
  22630. /**
  22631. * Creates the VertexData for a torus
  22632. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22633. * * diameter the diameter of the torus, optional default 1
  22634. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22635. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22636. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22637. * * 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)
  22638. * * 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)
  22639. * @returns the VertexData of the torus
  22640. */
  22641. static CreateTorus(options: {
  22642. diameter?: number;
  22643. thickness?: number;
  22644. tessellation?: number;
  22645. sideOrientation?: number;
  22646. frontUVs?: Vector4;
  22647. backUVs?: Vector4;
  22648. }): VertexData;
  22649. /**
  22650. * Creates the VertexData of the LineSystem
  22651. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22652. * - lines an array of lines, each line being an array of successive Vector3
  22653. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22654. * @returns the VertexData of the LineSystem
  22655. */
  22656. static CreateLineSystem(options: {
  22657. lines: Vector3[][];
  22658. colors?: Nullable<Color4[][]>;
  22659. }): VertexData;
  22660. /**
  22661. * Create the VertexData for a DashedLines
  22662. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22663. * - points an array successive Vector3
  22664. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22665. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22666. * - dashNb the intended total number of dashes, optional, default 200
  22667. * @returns the VertexData for the DashedLines
  22668. */
  22669. static CreateDashedLines(options: {
  22670. points: Vector3[];
  22671. dashSize?: number;
  22672. gapSize?: number;
  22673. dashNb?: number;
  22674. }): VertexData;
  22675. /**
  22676. * Creates the VertexData for a Ground
  22677. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22678. * - width the width (x direction) of the ground, optional, default 1
  22679. * - height the height (z direction) of the ground, optional, default 1
  22680. * - subdivisions the number of subdivisions per side, optional, default 1
  22681. * @returns the VertexData of the Ground
  22682. */
  22683. static CreateGround(options: {
  22684. width?: number;
  22685. height?: number;
  22686. subdivisions?: number;
  22687. subdivisionsX?: number;
  22688. subdivisionsY?: number;
  22689. }): VertexData;
  22690. /**
  22691. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22692. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22693. * * xmin the ground minimum X coordinate, optional, default -1
  22694. * * zmin the ground minimum Z coordinate, optional, default -1
  22695. * * xmax the ground maximum X coordinate, optional, default 1
  22696. * * zmax the ground maximum Z coordinate, optional, default 1
  22697. * * 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}
  22698. * * 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}
  22699. * @returns the VertexData of the TiledGround
  22700. */
  22701. static CreateTiledGround(options: {
  22702. xmin: number;
  22703. zmin: number;
  22704. xmax: number;
  22705. zmax: number;
  22706. subdivisions?: {
  22707. w: number;
  22708. h: number;
  22709. };
  22710. precision?: {
  22711. w: number;
  22712. h: number;
  22713. };
  22714. }): VertexData;
  22715. /**
  22716. * Creates the VertexData of the Ground designed from a heightmap
  22717. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22718. * * width the width (x direction) of the ground
  22719. * * height the height (z direction) of the ground
  22720. * * subdivisions the number of subdivisions per side
  22721. * * minHeight the minimum altitude on the ground, optional, default 0
  22722. * * maxHeight the maximum altitude on the ground, optional default 1
  22723. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22724. * * buffer the array holding the image color data
  22725. * * bufferWidth the width of image
  22726. * * bufferHeight the height of image
  22727. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22728. * @returns the VertexData of the Ground designed from a heightmap
  22729. */
  22730. static CreateGroundFromHeightMap(options: {
  22731. width: number;
  22732. height: number;
  22733. subdivisions: number;
  22734. minHeight: number;
  22735. maxHeight: number;
  22736. colorFilter: Color3;
  22737. buffer: Uint8Array;
  22738. bufferWidth: number;
  22739. bufferHeight: number;
  22740. alphaFilter: number;
  22741. }): VertexData;
  22742. /**
  22743. * Creates the VertexData for a Plane
  22744. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22745. * * size sets the width and height of the plane to the value of size, optional default 1
  22746. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22747. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22748. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22749. * * 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)
  22750. * * 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)
  22751. * @returns the VertexData of the box
  22752. */
  22753. static CreatePlane(options: {
  22754. size?: number;
  22755. width?: number;
  22756. height?: number;
  22757. sideOrientation?: number;
  22758. frontUVs?: Vector4;
  22759. backUVs?: Vector4;
  22760. }): VertexData;
  22761. /**
  22762. * Creates the VertexData of the Disc or regular Polygon
  22763. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22764. * * radius the radius of the disc, optional default 0.5
  22765. * * tessellation the number of polygon sides, optional, default 64
  22766. * * 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
  22767. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22768. * * 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)
  22769. * * 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)
  22770. * @returns the VertexData of the box
  22771. */
  22772. static CreateDisc(options: {
  22773. radius?: number;
  22774. tessellation?: number;
  22775. arc?: number;
  22776. sideOrientation?: number;
  22777. frontUVs?: Vector4;
  22778. backUVs?: Vector4;
  22779. }): VertexData;
  22780. /**
  22781. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22782. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22783. * @param polygon a mesh built from polygonTriangulation.build()
  22784. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22785. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22786. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22787. * @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)
  22788. * @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)
  22789. * @returns the VertexData of the Polygon
  22790. */
  22791. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22792. /**
  22793. * Creates the VertexData of the IcoSphere
  22794. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22795. * * radius the radius of the IcoSphere, optional default 1
  22796. * * radiusX allows stretching in the x direction, optional, default radius
  22797. * * radiusY allows stretching in the y direction, optional, default radius
  22798. * * radiusZ allows stretching in the z direction, optional, default radius
  22799. * * flat when true creates a flat shaded mesh, optional, default true
  22800. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22801. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22802. * * 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)
  22803. * * 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)
  22804. * @returns the VertexData of the IcoSphere
  22805. */
  22806. static CreateIcoSphere(options: {
  22807. radius?: number;
  22808. radiusX?: number;
  22809. radiusY?: number;
  22810. radiusZ?: number;
  22811. flat?: boolean;
  22812. subdivisions?: number;
  22813. sideOrientation?: number;
  22814. frontUVs?: Vector4;
  22815. backUVs?: Vector4;
  22816. }): VertexData;
  22817. /**
  22818. * Creates the VertexData for a Polyhedron
  22819. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22820. * * type provided types are:
  22821. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22822. * * 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)
  22823. * * size the size of the IcoSphere, optional default 1
  22824. * * sizeX allows stretching in the x direction, optional, default size
  22825. * * sizeY allows stretching in the y direction, optional, default size
  22826. * * sizeZ allows stretching in the z direction, optional, default size
  22827. * * 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
  22828. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22829. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22830. * * flat when true creates a flat shaded mesh, optional, default true
  22831. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22832. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22833. * * 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)
  22834. * * 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)
  22835. * @returns the VertexData of the Polyhedron
  22836. */
  22837. static CreatePolyhedron(options: {
  22838. type?: number;
  22839. size?: number;
  22840. sizeX?: number;
  22841. sizeY?: number;
  22842. sizeZ?: number;
  22843. custom?: any;
  22844. faceUV?: Vector4[];
  22845. faceColors?: Color4[];
  22846. flat?: boolean;
  22847. sideOrientation?: number;
  22848. frontUVs?: Vector4;
  22849. backUVs?: Vector4;
  22850. }): VertexData;
  22851. /**
  22852. * Creates the VertexData for a TorusKnot
  22853. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22854. * * radius the radius of the torus knot, optional, default 2
  22855. * * tube the thickness of the tube, optional, default 0.5
  22856. * * radialSegments the number of sides on each tube segments, optional, default 32
  22857. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22858. * * p the number of windings around the z axis, optional, default 2
  22859. * * q the number of windings around the x axis, optional, default 3
  22860. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22861. * * 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)
  22862. * * 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)
  22863. * @returns the VertexData of the Torus Knot
  22864. */
  22865. static CreateTorusKnot(options: {
  22866. radius?: number;
  22867. tube?: number;
  22868. radialSegments?: number;
  22869. tubularSegments?: number;
  22870. p?: number;
  22871. q?: number;
  22872. sideOrientation?: number;
  22873. frontUVs?: Vector4;
  22874. backUVs?: Vector4;
  22875. }): VertexData;
  22876. /**
  22877. * Compute normals for given positions and indices
  22878. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22879. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22880. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22881. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22882. * * facetNormals : optional array of facet normals (vector3)
  22883. * * facetPositions : optional array of facet positions (vector3)
  22884. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22885. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22886. * * bInfo : optional bounding info, required for facetPartitioning computation
  22887. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22888. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22889. * * useRightHandedSystem: optional boolean to for right handed system computation
  22890. * * depthSort : optional boolean to enable the facet depth sort computation
  22891. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22892. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22893. */
  22894. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22895. facetNormals?: any;
  22896. facetPositions?: any;
  22897. facetPartitioning?: any;
  22898. ratio?: number;
  22899. bInfo?: any;
  22900. bbSize?: Vector3;
  22901. subDiv?: any;
  22902. useRightHandedSystem?: boolean;
  22903. depthSort?: boolean;
  22904. distanceTo?: Vector3;
  22905. depthSortedFacets?: any;
  22906. }): void;
  22907. /** @hidden */
  22908. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22909. /**
  22910. * Applies VertexData created from the imported parameters to the geometry
  22911. * @param parsedVertexData the parsed data from an imported file
  22912. * @param geometry the geometry to apply the VertexData to
  22913. */
  22914. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22915. }
  22916. }
  22917. declare module "babylonjs/Morph/morphTarget" {
  22918. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22919. import { Observable } from "babylonjs/Misc/observable";
  22920. import { Nullable, FloatArray } from "babylonjs/types";
  22921. import { Scene } from "babylonjs/scene";
  22922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22923. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22924. /**
  22925. * Defines a target to use with MorphTargetManager
  22926. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22927. */
  22928. export class MorphTarget implements IAnimatable {
  22929. /** defines the name of the target */
  22930. name: string;
  22931. /**
  22932. * Gets or sets the list of animations
  22933. */
  22934. animations: import("babylonjs/Animations/animation").Animation[];
  22935. private _scene;
  22936. private _positions;
  22937. private _normals;
  22938. private _tangents;
  22939. private _uvs;
  22940. private _influence;
  22941. private _uniqueId;
  22942. /**
  22943. * Observable raised when the influence changes
  22944. */
  22945. onInfluenceChanged: Observable<boolean>;
  22946. /** @hidden */
  22947. _onDataLayoutChanged: Observable<void>;
  22948. /**
  22949. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22950. */
  22951. influence: number;
  22952. /**
  22953. * Gets or sets the id of the morph Target
  22954. */
  22955. id: string;
  22956. private _animationPropertiesOverride;
  22957. /**
  22958. * Gets or sets the animation properties override
  22959. */
  22960. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22961. /**
  22962. * Creates a new MorphTarget
  22963. * @param name defines the name of the target
  22964. * @param influence defines the influence to use
  22965. * @param scene defines the scene the morphtarget belongs to
  22966. */
  22967. constructor(
  22968. /** defines the name of the target */
  22969. name: string, influence?: number, scene?: Nullable<Scene>);
  22970. /**
  22971. * Gets the unique ID of this manager
  22972. */
  22973. readonly uniqueId: number;
  22974. /**
  22975. * Gets a boolean defining if the target contains position data
  22976. */
  22977. readonly hasPositions: boolean;
  22978. /**
  22979. * Gets a boolean defining if the target contains normal data
  22980. */
  22981. readonly hasNormals: boolean;
  22982. /**
  22983. * Gets a boolean defining if the target contains tangent data
  22984. */
  22985. readonly hasTangents: boolean;
  22986. /**
  22987. * Gets a boolean defining if the target contains texture coordinates data
  22988. */
  22989. readonly hasUVs: boolean;
  22990. /**
  22991. * Affects position data to this target
  22992. * @param data defines the position data to use
  22993. */
  22994. setPositions(data: Nullable<FloatArray>): void;
  22995. /**
  22996. * Gets the position data stored in this target
  22997. * @returns a FloatArray containing the position data (or null if not present)
  22998. */
  22999. getPositions(): Nullable<FloatArray>;
  23000. /**
  23001. * Affects normal data to this target
  23002. * @param data defines the normal data to use
  23003. */
  23004. setNormals(data: Nullable<FloatArray>): void;
  23005. /**
  23006. * Gets the normal data stored in this target
  23007. * @returns a FloatArray containing the normal data (or null if not present)
  23008. */
  23009. getNormals(): Nullable<FloatArray>;
  23010. /**
  23011. * Affects tangent data to this target
  23012. * @param data defines the tangent data to use
  23013. */
  23014. setTangents(data: Nullable<FloatArray>): void;
  23015. /**
  23016. * Gets the tangent data stored in this target
  23017. * @returns a FloatArray containing the tangent data (or null if not present)
  23018. */
  23019. getTangents(): Nullable<FloatArray>;
  23020. /**
  23021. * Affects texture coordinates data to this target
  23022. * @param data defines the texture coordinates data to use
  23023. */
  23024. setUVs(data: Nullable<FloatArray>): void;
  23025. /**
  23026. * Gets the texture coordinates data stored in this target
  23027. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23028. */
  23029. getUVs(): Nullable<FloatArray>;
  23030. /**
  23031. * Clone the current target
  23032. * @returns a new MorphTarget
  23033. */
  23034. clone(): MorphTarget;
  23035. /**
  23036. * Serializes the current target into a Serialization object
  23037. * @returns the serialized object
  23038. */
  23039. serialize(): any;
  23040. /**
  23041. * Returns the string "MorphTarget"
  23042. * @returns "MorphTarget"
  23043. */
  23044. getClassName(): string;
  23045. /**
  23046. * Creates a new target from serialized data
  23047. * @param serializationObject defines the serialized data to use
  23048. * @returns a new MorphTarget
  23049. */
  23050. static Parse(serializationObject: any): MorphTarget;
  23051. /**
  23052. * Creates a MorphTarget from mesh data
  23053. * @param mesh defines the source mesh
  23054. * @param name defines the name to use for the new target
  23055. * @param influence defines the influence to attach to the target
  23056. * @returns a new MorphTarget
  23057. */
  23058. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23059. }
  23060. }
  23061. declare module "babylonjs/Morph/morphTargetManager" {
  23062. import { Nullable } from "babylonjs/types";
  23063. import { Scene } from "babylonjs/scene";
  23064. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23065. /**
  23066. * This class is used to deform meshes using morphing between different targets
  23067. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23068. */
  23069. export class MorphTargetManager {
  23070. private _targets;
  23071. private _targetInfluenceChangedObservers;
  23072. private _targetDataLayoutChangedObservers;
  23073. private _activeTargets;
  23074. private _scene;
  23075. private _influences;
  23076. private _supportsNormals;
  23077. private _supportsTangents;
  23078. private _supportsUVs;
  23079. private _vertexCount;
  23080. private _uniqueId;
  23081. private _tempInfluences;
  23082. /**
  23083. * Gets or sets a boolean indicating if normals must be morphed
  23084. */
  23085. enableNormalMorphing: boolean;
  23086. /**
  23087. * Gets or sets a boolean indicating if tangents must be morphed
  23088. */
  23089. enableTangentMorphing: boolean;
  23090. /**
  23091. * Gets or sets a boolean indicating if UV must be morphed
  23092. */
  23093. enableUVMorphing: boolean;
  23094. /**
  23095. * Creates a new MorphTargetManager
  23096. * @param scene defines the current scene
  23097. */
  23098. constructor(scene?: Nullable<Scene>);
  23099. /**
  23100. * Gets the unique ID of this manager
  23101. */
  23102. readonly uniqueId: number;
  23103. /**
  23104. * Gets the number of vertices handled by this manager
  23105. */
  23106. readonly vertexCount: number;
  23107. /**
  23108. * Gets a boolean indicating if this manager supports morphing of normals
  23109. */
  23110. readonly supportsNormals: boolean;
  23111. /**
  23112. * Gets a boolean indicating if this manager supports morphing of tangents
  23113. */
  23114. readonly supportsTangents: boolean;
  23115. /**
  23116. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23117. */
  23118. readonly supportsUVs: boolean;
  23119. /**
  23120. * Gets the number of targets stored in this manager
  23121. */
  23122. readonly numTargets: number;
  23123. /**
  23124. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23125. */
  23126. readonly numInfluencers: number;
  23127. /**
  23128. * Gets the list of influences (one per target)
  23129. */
  23130. readonly influences: Float32Array;
  23131. /**
  23132. * Gets the active target at specified index. An active target is a target with an influence > 0
  23133. * @param index defines the index to check
  23134. * @returns the requested target
  23135. */
  23136. getActiveTarget(index: number): MorphTarget;
  23137. /**
  23138. * Gets the target at specified index
  23139. * @param index defines the index to check
  23140. * @returns the requested target
  23141. */
  23142. getTarget(index: number): MorphTarget;
  23143. /**
  23144. * Add a new target to this manager
  23145. * @param target defines the target to add
  23146. */
  23147. addTarget(target: MorphTarget): void;
  23148. /**
  23149. * Removes a target from the manager
  23150. * @param target defines the target to remove
  23151. */
  23152. removeTarget(target: MorphTarget): void;
  23153. /**
  23154. * Clone the current manager
  23155. * @returns a new MorphTargetManager
  23156. */
  23157. clone(): MorphTargetManager;
  23158. /**
  23159. * Serializes the current manager into a Serialization object
  23160. * @returns the serialized object
  23161. */
  23162. serialize(): any;
  23163. private _syncActiveTargets;
  23164. /**
  23165. * Syncrhonize the targets with all the meshes using this morph target manager
  23166. */
  23167. synchronize(): void;
  23168. /**
  23169. * Creates a new MorphTargetManager from serialized data
  23170. * @param serializationObject defines the serialized data
  23171. * @param scene defines the hosting scene
  23172. * @returns the new MorphTargetManager
  23173. */
  23174. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23175. }
  23176. }
  23177. declare module "babylonjs/Meshes/meshLODLevel" {
  23178. import { Mesh } from "babylonjs/Meshes/mesh";
  23179. import { Nullable } from "babylonjs/types";
  23180. /**
  23181. * Class used to represent a specific level of detail of a mesh
  23182. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23183. */
  23184. export class MeshLODLevel {
  23185. /** Defines the distance where this level should start being displayed */
  23186. distance: number;
  23187. /** Defines the mesh to use to render this level */
  23188. mesh: Nullable<Mesh>;
  23189. /**
  23190. * Creates a new LOD level
  23191. * @param distance defines the distance where this level should star being displayed
  23192. * @param mesh defines the mesh to use to render this level
  23193. */
  23194. constructor(
  23195. /** Defines the distance where this level should start being displayed */
  23196. distance: number,
  23197. /** Defines the mesh to use to render this level */
  23198. mesh: Nullable<Mesh>);
  23199. }
  23200. }
  23201. declare module "babylonjs/Meshes/groundMesh" {
  23202. import { Scene } from "babylonjs/scene";
  23203. import { Vector3 } from "babylonjs/Maths/math.vector";
  23204. import { Mesh } from "babylonjs/Meshes/mesh";
  23205. /**
  23206. * Mesh representing the gorund
  23207. */
  23208. export class GroundMesh extends Mesh {
  23209. /** If octree should be generated */
  23210. generateOctree: boolean;
  23211. private _heightQuads;
  23212. /** @hidden */
  23213. _subdivisionsX: number;
  23214. /** @hidden */
  23215. _subdivisionsY: number;
  23216. /** @hidden */
  23217. _width: number;
  23218. /** @hidden */
  23219. _height: number;
  23220. /** @hidden */
  23221. _minX: number;
  23222. /** @hidden */
  23223. _maxX: number;
  23224. /** @hidden */
  23225. _minZ: number;
  23226. /** @hidden */
  23227. _maxZ: number;
  23228. constructor(name: string, scene: Scene);
  23229. /**
  23230. * "GroundMesh"
  23231. * @returns "GroundMesh"
  23232. */
  23233. getClassName(): string;
  23234. /**
  23235. * The minimum of x and y subdivisions
  23236. */
  23237. readonly subdivisions: number;
  23238. /**
  23239. * X subdivisions
  23240. */
  23241. readonly subdivisionsX: number;
  23242. /**
  23243. * Y subdivisions
  23244. */
  23245. readonly subdivisionsY: number;
  23246. /**
  23247. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23248. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23249. * @param chunksCount the number of subdivisions for x and y
  23250. * @param octreeBlocksSize (Default: 32)
  23251. */
  23252. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23253. /**
  23254. * Returns a height (y) value in the Worl system :
  23255. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23256. * @param x x coordinate
  23257. * @param z z coordinate
  23258. * @returns the ground y position if (x, z) are outside the ground surface.
  23259. */
  23260. getHeightAtCoordinates(x: number, z: number): number;
  23261. /**
  23262. * Returns a normalized vector (Vector3) orthogonal to the ground
  23263. * at the ground coordinates (x, z) expressed in the World system.
  23264. * @param x x coordinate
  23265. * @param z z coordinate
  23266. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23267. */
  23268. getNormalAtCoordinates(x: number, z: number): Vector3;
  23269. /**
  23270. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23271. * at the ground coordinates (x, z) expressed in the World system.
  23272. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23273. * @param x x coordinate
  23274. * @param z z coordinate
  23275. * @param ref vector to store the result
  23276. * @returns the GroundMesh.
  23277. */
  23278. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23279. /**
  23280. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23281. * if the ground has been updated.
  23282. * This can be used in the render loop.
  23283. * @returns the GroundMesh.
  23284. */
  23285. updateCoordinateHeights(): GroundMesh;
  23286. private _getFacetAt;
  23287. private _initHeightQuads;
  23288. private _computeHeightQuads;
  23289. /**
  23290. * Serializes this ground mesh
  23291. * @param serializationObject object to write serialization to
  23292. */
  23293. serialize(serializationObject: any): void;
  23294. /**
  23295. * Parses a serialized ground mesh
  23296. * @param parsedMesh the serialized mesh
  23297. * @param scene the scene to create the ground mesh in
  23298. * @returns the created ground mesh
  23299. */
  23300. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23301. }
  23302. }
  23303. declare module "babylonjs/Physics/physicsJoint" {
  23304. import { Vector3 } from "babylonjs/Maths/math.vector";
  23305. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23306. /**
  23307. * Interface for Physics-Joint data
  23308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23309. */
  23310. export interface PhysicsJointData {
  23311. /**
  23312. * The main pivot of the joint
  23313. */
  23314. mainPivot?: Vector3;
  23315. /**
  23316. * The connected pivot of the joint
  23317. */
  23318. connectedPivot?: Vector3;
  23319. /**
  23320. * The main axis of the joint
  23321. */
  23322. mainAxis?: Vector3;
  23323. /**
  23324. * The connected axis of the joint
  23325. */
  23326. connectedAxis?: Vector3;
  23327. /**
  23328. * The collision of the joint
  23329. */
  23330. collision?: boolean;
  23331. /**
  23332. * Native Oimo/Cannon/Energy data
  23333. */
  23334. nativeParams?: any;
  23335. }
  23336. /**
  23337. * This is a holder class for the physics joint created by the physics plugin
  23338. * It holds a set of functions to control the underlying joint
  23339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23340. */
  23341. export class PhysicsJoint {
  23342. /**
  23343. * The type of the physics joint
  23344. */
  23345. type: number;
  23346. /**
  23347. * The data for the physics joint
  23348. */
  23349. jointData: PhysicsJointData;
  23350. private _physicsJoint;
  23351. protected _physicsPlugin: IPhysicsEnginePlugin;
  23352. /**
  23353. * Initializes the physics joint
  23354. * @param type The type of the physics joint
  23355. * @param jointData The data for the physics joint
  23356. */
  23357. constructor(
  23358. /**
  23359. * The type of the physics joint
  23360. */
  23361. type: number,
  23362. /**
  23363. * The data for the physics joint
  23364. */
  23365. jointData: PhysicsJointData);
  23366. /**
  23367. * Gets the physics joint
  23368. */
  23369. /**
  23370. * Sets the physics joint
  23371. */
  23372. physicsJoint: any;
  23373. /**
  23374. * Sets the physics plugin
  23375. */
  23376. physicsPlugin: IPhysicsEnginePlugin;
  23377. /**
  23378. * Execute a function that is physics-plugin specific.
  23379. * @param {Function} func the function that will be executed.
  23380. * It accepts two parameters: the physics world and the physics joint
  23381. */
  23382. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23383. /**
  23384. * Distance-Joint type
  23385. */
  23386. static DistanceJoint: number;
  23387. /**
  23388. * Hinge-Joint type
  23389. */
  23390. static HingeJoint: number;
  23391. /**
  23392. * Ball-and-Socket joint type
  23393. */
  23394. static BallAndSocketJoint: number;
  23395. /**
  23396. * Wheel-Joint type
  23397. */
  23398. static WheelJoint: number;
  23399. /**
  23400. * Slider-Joint type
  23401. */
  23402. static SliderJoint: number;
  23403. /**
  23404. * Prismatic-Joint type
  23405. */
  23406. static PrismaticJoint: number;
  23407. /**
  23408. * Universal-Joint type
  23409. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23410. */
  23411. static UniversalJoint: number;
  23412. /**
  23413. * Hinge-Joint 2 type
  23414. */
  23415. static Hinge2Joint: number;
  23416. /**
  23417. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23418. */
  23419. static PointToPointJoint: number;
  23420. /**
  23421. * Spring-Joint type
  23422. */
  23423. static SpringJoint: number;
  23424. /**
  23425. * Lock-Joint type
  23426. */
  23427. static LockJoint: number;
  23428. }
  23429. /**
  23430. * A class representing a physics distance joint
  23431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23432. */
  23433. export class DistanceJoint extends PhysicsJoint {
  23434. /**
  23435. *
  23436. * @param jointData The data for the Distance-Joint
  23437. */
  23438. constructor(jointData: DistanceJointData);
  23439. /**
  23440. * Update the predefined distance.
  23441. * @param maxDistance The maximum preferred distance
  23442. * @param minDistance The minimum preferred distance
  23443. */
  23444. updateDistance(maxDistance: number, minDistance?: number): void;
  23445. }
  23446. /**
  23447. * Represents a Motor-Enabled Joint
  23448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23449. */
  23450. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23451. /**
  23452. * Initializes the Motor-Enabled Joint
  23453. * @param type The type of the joint
  23454. * @param jointData The physica joint data for the joint
  23455. */
  23456. constructor(type: number, jointData: PhysicsJointData);
  23457. /**
  23458. * Set the motor values.
  23459. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23460. * @param force the force to apply
  23461. * @param maxForce max force for this motor.
  23462. */
  23463. setMotor(force?: number, maxForce?: number): void;
  23464. /**
  23465. * Set the motor's limits.
  23466. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23467. * @param upperLimit The upper limit of the motor
  23468. * @param lowerLimit The lower limit of the motor
  23469. */
  23470. setLimit(upperLimit: number, lowerLimit?: number): void;
  23471. }
  23472. /**
  23473. * This class represents a single physics Hinge-Joint
  23474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23475. */
  23476. export class HingeJoint extends MotorEnabledJoint {
  23477. /**
  23478. * Initializes the Hinge-Joint
  23479. * @param jointData The joint data for the Hinge-Joint
  23480. */
  23481. constructor(jointData: PhysicsJointData);
  23482. /**
  23483. * Set the motor values.
  23484. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23485. * @param {number} force the force to apply
  23486. * @param {number} maxForce max force for this motor.
  23487. */
  23488. setMotor(force?: number, maxForce?: number): void;
  23489. /**
  23490. * Set the motor's limits.
  23491. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23492. * @param upperLimit The upper limit of the motor
  23493. * @param lowerLimit The lower limit of the motor
  23494. */
  23495. setLimit(upperLimit: number, lowerLimit?: number): void;
  23496. }
  23497. /**
  23498. * This class represents a dual hinge physics joint (same as wheel joint)
  23499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23500. */
  23501. export class Hinge2Joint extends MotorEnabledJoint {
  23502. /**
  23503. * Initializes the Hinge2-Joint
  23504. * @param jointData The joint data for the Hinge2-Joint
  23505. */
  23506. constructor(jointData: PhysicsJointData);
  23507. /**
  23508. * Set the motor values.
  23509. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23510. * @param {number} targetSpeed the speed the motor is to reach
  23511. * @param {number} maxForce max force for this motor.
  23512. * @param {motorIndex} the motor's index, 0 or 1.
  23513. */
  23514. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23515. /**
  23516. * Set the motor limits.
  23517. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23518. * @param {number} upperLimit the upper limit
  23519. * @param {number} lowerLimit lower limit
  23520. * @param {motorIndex} the motor's index, 0 or 1.
  23521. */
  23522. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23523. }
  23524. /**
  23525. * Interface for a motor enabled joint
  23526. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23527. */
  23528. export interface IMotorEnabledJoint {
  23529. /**
  23530. * Physics joint
  23531. */
  23532. physicsJoint: any;
  23533. /**
  23534. * Sets the motor of the motor-enabled joint
  23535. * @param force The force of the motor
  23536. * @param maxForce The maximum force of the motor
  23537. * @param motorIndex The index of the motor
  23538. */
  23539. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23540. /**
  23541. * Sets the limit of the motor
  23542. * @param upperLimit The upper limit of the motor
  23543. * @param lowerLimit The lower limit of the motor
  23544. * @param motorIndex The index of the motor
  23545. */
  23546. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23547. }
  23548. /**
  23549. * Joint data for a Distance-Joint
  23550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23551. */
  23552. export interface DistanceJointData extends PhysicsJointData {
  23553. /**
  23554. * Max distance the 2 joint objects can be apart
  23555. */
  23556. maxDistance: number;
  23557. }
  23558. /**
  23559. * Joint data from a spring joint
  23560. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23561. */
  23562. export interface SpringJointData extends PhysicsJointData {
  23563. /**
  23564. * Length of the spring
  23565. */
  23566. length: number;
  23567. /**
  23568. * Stiffness of the spring
  23569. */
  23570. stiffness: number;
  23571. /**
  23572. * Damping of the spring
  23573. */
  23574. damping: number;
  23575. /** this callback will be called when applying the force to the impostors. */
  23576. forceApplicationCallback: () => void;
  23577. }
  23578. }
  23579. declare module "babylonjs/Physics/physicsRaycastResult" {
  23580. import { Vector3 } from "babylonjs/Maths/math.vector";
  23581. /**
  23582. * Holds the data for the raycast result
  23583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23584. */
  23585. export class PhysicsRaycastResult {
  23586. private _hasHit;
  23587. private _hitDistance;
  23588. private _hitNormalWorld;
  23589. private _hitPointWorld;
  23590. private _rayFromWorld;
  23591. private _rayToWorld;
  23592. /**
  23593. * Gets if there was a hit
  23594. */
  23595. readonly hasHit: boolean;
  23596. /**
  23597. * Gets the distance from the hit
  23598. */
  23599. readonly hitDistance: number;
  23600. /**
  23601. * Gets the hit normal/direction in the world
  23602. */
  23603. readonly hitNormalWorld: Vector3;
  23604. /**
  23605. * Gets the hit point in the world
  23606. */
  23607. readonly hitPointWorld: Vector3;
  23608. /**
  23609. * Gets the ray "start point" of the ray in the world
  23610. */
  23611. readonly rayFromWorld: Vector3;
  23612. /**
  23613. * Gets the ray "end point" of the ray in the world
  23614. */
  23615. readonly rayToWorld: Vector3;
  23616. /**
  23617. * Sets the hit data (normal & point in world space)
  23618. * @param hitNormalWorld defines the normal in world space
  23619. * @param hitPointWorld defines the point in world space
  23620. */
  23621. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23622. /**
  23623. * Sets the distance from the start point to the hit point
  23624. * @param distance
  23625. */
  23626. setHitDistance(distance: number): void;
  23627. /**
  23628. * Calculates the distance manually
  23629. */
  23630. calculateHitDistance(): void;
  23631. /**
  23632. * Resets all the values to default
  23633. * @param from The from point on world space
  23634. * @param to The to point on world space
  23635. */
  23636. reset(from?: Vector3, to?: Vector3): void;
  23637. }
  23638. /**
  23639. * Interface for the size containing width and height
  23640. */
  23641. interface IXYZ {
  23642. /**
  23643. * X
  23644. */
  23645. x: number;
  23646. /**
  23647. * Y
  23648. */
  23649. y: number;
  23650. /**
  23651. * Z
  23652. */
  23653. z: number;
  23654. }
  23655. }
  23656. declare module "babylonjs/Physics/IPhysicsEngine" {
  23657. import { Nullable } from "babylonjs/types";
  23658. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23660. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23661. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23662. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23663. /**
  23664. * Interface used to describe a physics joint
  23665. */
  23666. export interface PhysicsImpostorJoint {
  23667. /** Defines the main impostor to which the joint is linked */
  23668. mainImpostor: PhysicsImpostor;
  23669. /** Defines the impostor that is connected to the main impostor using this joint */
  23670. connectedImpostor: PhysicsImpostor;
  23671. /** Defines the joint itself */
  23672. joint: PhysicsJoint;
  23673. }
  23674. /** @hidden */
  23675. export interface IPhysicsEnginePlugin {
  23676. world: any;
  23677. name: string;
  23678. setGravity(gravity: Vector3): void;
  23679. setTimeStep(timeStep: number): void;
  23680. getTimeStep(): number;
  23681. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23682. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23683. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23684. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23685. removePhysicsBody(impostor: PhysicsImpostor): void;
  23686. generateJoint(joint: PhysicsImpostorJoint): void;
  23687. removeJoint(joint: PhysicsImpostorJoint): void;
  23688. isSupported(): boolean;
  23689. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23690. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23691. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23692. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23693. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23694. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23695. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23696. getBodyMass(impostor: PhysicsImpostor): number;
  23697. getBodyFriction(impostor: PhysicsImpostor): number;
  23698. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23699. getBodyRestitution(impostor: PhysicsImpostor): number;
  23700. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23701. getBodyPressure?(impostor: PhysicsImpostor): number;
  23702. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23703. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23704. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23705. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23706. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23707. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23708. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23709. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23710. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23711. sleepBody(impostor: PhysicsImpostor): void;
  23712. wakeUpBody(impostor: PhysicsImpostor): void;
  23713. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23714. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23715. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23716. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23717. getRadius(impostor: PhysicsImpostor): number;
  23718. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23719. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23720. dispose(): void;
  23721. }
  23722. /**
  23723. * Interface used to define a physics engine
  23724. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23725. */
  23726. export interface IPhysicsEngine {
  23727. /**
  23728. * Gets the gravity vector used by the simulation
  23729. */
  23730. gravity: Vector3;
  23731. /**
  23732. * Sets the gravity vector used by the simulation
  23733. * @param gravity defines the gravity vector to use
  23734. */
  23735. setGravity(gravity: Vector3): void;
  23736. /**
  23737. * Set the time step of the physics engine.
  23738. * Default is 1/60.
  23739. * To slow it down, enter 1/600 for example.
  23740. * To speed it up, 1/30
  23741. * @param newTimeStep the new timestep to apply to this world.
  23742. */
  23743. setTimeStep(newTimeStep: number): void;
  23744. /**
  23745. * Get the time step of the physics engine.
  23746. * @returns the current time step
  23747. */
  23748. getTimeStep(): number;
  23749. /**
  23750. * Release all resources
  23751. */
  23752. dispose(): void;
  23753. /**
  23754. * Gets the name of the current physics plugin
  23755. * @returns the name of the plugin
  23756. */
  23757. getPhysicsPluginName(): string;
  23758. /**
  23759. * Adding a new impostor for the impostor tracking.
  23760. * This will be done by the impostor itself.
  23761. * @param impostor the impostor to add
  23762. */
  23763. addImpostor(impostor: PhysicsImpostor): void;
  23764. /**
  23765. * Remove an impostor from the engine.
  23766. * This impostor and its mesh will not longer be updated by the physics engine.
  23767. * @param impostor the impostor to remove
  23768. */
  23769. removeImpostor(impostor: PhysicsImpostor): void;
  23770. /**
  23771. * Add a joint to the physics engine
  23772. * @param mainImpostor defines the main impostor to which the joint is added.
  23773. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23774. * @param joint defines the joint that will connect both impostors.
  23775. */
  23776. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23777. /**
  23778. * Removes a joint from the simulation
  23779. * @param mainImpostor defines the impostor used with the joint
  23780. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23781. * @param joint defines the joint to remove
  23782. */
  23783. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23784. /**
  23785. * Gets the current plugin used to run the simulation
  23786. * @returns current plugin
  23787. */
  23788. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23789. /**
  23790. * Gets the list of physic impostors
  23791. * @returns an array of PhysicsImpostor
  23792. */
  23793. getImpostors(): Array<PhysicsImpostor>;
  23794. /**
  23795. * Gets the impostor for a physics enabled object
  23796. * @param object defines the object impersonated by the impostor
  23797. * @returns the PhysicsImpostor or null if not found
  23798. */
  23799. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23800. /**
  23801. * Gets the impostor for a physics body object
  23802. * @param body defines physics body used by the impostor
  23803. * @returns the PhysicsImpostor or null if not found
  23804. */
  23805. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23806. /**
  23807. * Does a raycast in the physics world
  23808. * @param from when should the ray start?
  23809. * @param to when should the ray end?
  23810. * @returns PhysicsRaycastResult
  23811. */
  23812. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23813. /**
  23814. * Called by the scene. No need to call it.
  23815. * @param delta defines the timespam between frames
  23816. */
  23817. _step(delta: number): void;
  23818. }
  23819. }
  23820. declare module "babylonjs/Physics/physicsImpostor" {
  23821. import { Nullable, IndicesArray } from "babylonjs/types";
  23822. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23823. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23825. import { Scene } from "babylonjs/scene";
  23826. import { Bone } from "babylonjs/Bones/bone";
  23827. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23828. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23829. import { Space } from "babylonjs/Maths/math.axis";
  23830. /**
  23831. * The interface for the physics imposter parameters
  23832. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23833. */
  23834. export interface PhysicsImpostorParameters {
  23835. /**
  23836. * The mass of the physics imposter
  23837. */
  23838. mass: number;
  23839. /**
  23840. * The friction of the physics imposter
  23841. */
  23842. friction?: number;
  23843. /**
  23844. * The coefficient of restitution of the physics imposter
  23845. */
  23846. restitution?: number;
  23847. /**
  23848. * The native options of the physics imposter
  23849. */
  23850. nativeOptions?: any;
  23851. /**
  23852. * Specifies if the parent should be ignored
  23853. */
  23854. ignoreParent?: boolean;
  23855. /**
  23856. * Specifies if bi-directional transformations should be disabled
  23857. */
  23858. disableBidirectionalTransformation?: boolean;
  23859. /**
  23860. * The pressure inside the physics imposter, soft object only
  23861. */
  23862. pressure?: number;
  23863. /**
  23864. * The stiffness the physics imposter, soft object only
  23865. */
  23866. stiffness?: number;
  23867. /**
  23868. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23869. */
  23870. velocityIterations?: number;
  23871. /**
  23872. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23873. */
  23874. positionIterations?: number;
  23875. /**
  23876. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23877. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23878. * Add to fix multiple points
  23879. */
  23880. fixedPoints?: number;
  23881. /**
  23882. * The collision margin around a soft object
  23883. */
  23884. margin?: number;
  23885. /**
  23886. * The collision margin around a soft object
  23887. */
  23888. damping?: number;
  23889. /**
  23890. * The path for a rope based on an extrusion
  23891. */
  23892. path?: any;
  23893. /**
  23894. * The shape of an extrusion used for a rope based on an extrusion
  23895. */
  23896. shape?: any;
  23897. }
  23898. /**
  23899. * Interface for a physics-enabled object
  23900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23901. */
  23902. export interface IPhysicsEnabledObject {
  23903. /**
  23904. * The position of the physics-enabled object
  23905. */
  23906. position: Vector3;
  23907. /**
  23908. * The rotation of the physics-enabled object
  23909. */
  23910. rotationQuaternion: Nullable<Quaternion>;
  23911. /**
  23912. * The scale of the physics-enabled object
  23913. */
  23914. scaling: Vector3;
  23915. /**
  23916. * The rotation of the physics-enabled object
  23917. */
  23918. rotation?: Vector3;
  23919. /**
  23920. * The parent of the physics-enabled object
  23921. */
  23922. parent?: any;
  23923. /**
  23924. * The bounding info of the physics-enabled object
  23925. * @returns The bounding info of the physics-enabled object
  23926. */
  23927. getBoundingInfo(): BoundingInfo;
  23928. /**
  23929. * Computes the world matrix
  23930. * @param force Specifies if the world matrix should be computed by force
  23931. * @returns A world matrix
  23932. */
  23933. computeWorldMatrix(force: boolean): Matrix;
  23934. /**
  23935. * Gets the world matrix
  23936. * @returns A world matrix
  23937. */
  23938. getWorldMatrix?(): Matrix;
  23939. /**
  23940. * Gets the child meshes
  23941. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23942. * @returns An array of abstract meshes
  23943. */
  23944. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23945. /**
  23946. * Gets the vertex data
  23947. * @param kind The type of vertex data
  23948. * @returns A nullable array of numbers, or a float32 array
  23949. */
  23950. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23951. /**
  23952. * Gets the indices from the mesh
  23953. * @returns A nullable array of index arrays
  23954. */
  23955. getIndices?(): Nullable<IndicesArray>;
  23956. /**
  23957. * Gets the scene from the mesh
  23958. * @returns the indices array or null
  23959. */
  23960. getScene?(): Scene;
  23961. /**
  23962. * Gets the absolute position from the mesh
  23963. * @returns the absolute position
  23964. */
  23965. getAbsolutePosition(): Vector3;
  23966. /**
  23967. * Gets the absolute pivot point from the mesh
  23968. * @returns the absolute pivot point
  23969. */
  23970. getAbsolutePivotPoint(): Vector3;
  23971. /**
  23972. * Rotates the mesh
  23973. * @param axis The axis of rotation
  23974. * @param amount The amount of rotation
  23975. * @param space The space of the rotation
  23976. * @returns The rotation transform node
  23977. */
  23978. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23979. /**
  23980. * Translates the mesh
  23981. * @param axis The axis of translation
  23982. * @param distance The distance of translation
  23983. * @param space The space of the translation
  23984. * @returns The transform node
  23985. */
  23986. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23987. /**
  23988. * Sets the absolute position of the mesh
  23989. * @param absolutePosition The absolute position of the mesh
  23990. * @returns The transform node
  23991. */
  23992. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23993. /**
  23994. * Gets the class name of the mesh
  23995. * @returns The class name
  23996. */
  23997. getClassName(): string;
  23998. }
  23999. /**
  24000. * Represents a physics imposter
  24001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24002. */
  24003. export class PhysicsImpostor {
  24004. /**
  24005. * The physics-enabled object used as the physics imposter
  24006. */
  24007. object: IPhysicsEnabledObject;
  24008. /**
  24009. * The type of the physics imposter
  24010. */
  24011. type: number;
  24012. private _options;
  24013. private _scene?;
  24014. /**
  24015. * The default object size of the imposter
  24016. */
  24017. static DEFAULT_OBJECT_SIZE: Vector3;
  24018. /**
  24019. * The identity quaternion of the imposter
  24020. */
  24021. static IDENTITY_QUATERNION: Quaternion;
  24022. /** @hidden */
  24023. _pluginData: any;
  24024. private _physicsEngine;
  24025. private _physicsBody;
  24026. private _bodyUpdateRequired;
  24027. private _onBeforePhysicsStepCallbacks;
  24028. private _onAfterPhysicsStepCallbacks;
  24029. /** @hidden */
  24030. _onPhysicsCollideCallbacks: Array<{
  24031. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24032. otherImpostors: Array<PhysicsImpostor>;
  24033. }>;
  24034. private _deltaPosition;
  24035. private _deltaRotation;
  24036. private _deltaRotationConjugated;
  24037. /** @hidden */
  24038. _isFromLine: boolean;
  24039. private _parent;
  24040. private _isDisposed;
  24041. private static _tmpVecs;
  24042. private static _tmpQuat;
  24043. /**
  24044. * Specifies if the physics imposter is disposed
  24045. */
  24046. readonly isDisposed: boolean;
  24047. /**
  24048. * Gets the mass of the physics imposter
  24049. */
  24050. mass: number;
  24051. /**
  24052. * Gets the coefficient of friction
  24053. */
  24054. /**
  24055. * Sets the coefficient of friction
  24056. */
  24057. friction: number;
  24058. /**
  24059. * Gets the coefficient of restitution
  24060. */
  24061. /**
  24062. * Sets the coefficient of restitution
  24063. */
  24064. restitution: number;
  24065. /**
  24066. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24067. */
  24068. /**
  24069. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24070. */
  24071. pressure: number;
  24072. /**
  24073. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24074. */
  24075. /**
  24076. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24077. */
  24078. stiffness: number;
  24079. /**
  24080. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24081. */
  24082. /**
  24083. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24084. */
  24085. velocityIterations: number;
  24086. /**
  24087. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24088. */
  24089. /**
  24090. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24091. */
  24092. positionIterations: number;
  24093. /**
  24094. * The unique id of the physics imposter
  24095. * set by the physics engine when adding this impostor to the array
  24096. */
  24097. uniqueId: number;
  24098. /**
  24099. * @hidden
  24100. */
  24101. soft: boolean;
  24102. /**
  24103. * @hidden
  24104. */
  24105. segments: number;
  24106. private _joints;
  24107. /**
  24108. * Initializes the physics imposter
  24109. * @param object The physics-enabled object used as the physics imposter
  24110. * @param type The type of the physics imposter
  24111. * @param _options The options for the physics imposter
  24112. * @param _scene The Babylon scene
  24113. */
  24114. constructor(
  24115. /**
  24116. * The physics-enabled object used as the physics imposter
  24117. */
  24118. object: IPhysicsEnabledObject,
  24119. /**
  24120. * The type of the physics imposter
  24121. */
  24122. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24123. /**
  24124. * This function will completly initialize this impostor.
  24125. * It will create a new body - but only if this mesh has no parent.
  24126. * If it has, this impostor will not be used other than to define the impostor
  24127. * of the child mesh.
  24128. * @hidden
  24129. */
  24130. _init(): void;
  24131. private _getPhysicsParent;
  24132. /**
  24133. * Should a new body be generated.
  24134. * @returns boolean specifying if body initialization is required
  24135. */
  24136. isBodyInitRequired(): boolean;
  24137. /**
  24138. * Sets the updated scaling
  24139. * @param updated Specifies if the scaling is updated
  24140. */
  24141. setScalingUpdated(): void;
  24142. /**
  24143. * Force a regeneration of this or the parent's impostor's body.
  24144. * Use under cautious - This will remove all joints already implemented.
  24145. */
  24146. forceUpdate(): void;
  24147. /**
  24148. * Gets the body that holds this impostor. Either its own, or its parent.
  24149. */
  24150. /**
  24151. * Set the physics body. Used mainly by the physics engine/plugin
  24152. */
  24153. physicsBody: any;
  24154. /**
  24155. * Get the parent of the physics imposter
  24156. * @returns Physics imposter or null
  24157. */
  24158. /**
  24159. * Sets the parent of the physics imposter
  24160. */
  24161. parent: Nullable<PhysicsImpostor>;
  24162. /**
  24163. * Resets the update flags
  24164. */
  24165. resetUpdateFlags(): void;
  24166. /**
  24167. * Gets the object extend size
  24168. * @returns the object extend size
  24169. */
  24170. getObjectExtendSize(): Vector3;
  24171. /**
  24172. * Gets the object center
  24173. * @returns The object center
  24174. */
  24175. getObjectCenter(): Vector3;
  24176. /**
  24177. * Get a specific parametes from the options parameter
  24178. * @param paramName The object parameter name
  24179. * @returns The object parameter
  24180. */
  24181. getParam(paramName: string): any;
  24182. /**
  24183. * Sets a specific parameter in the options given to the physics plugin
  24184. * @param paramName The parameter name
  24185. * @param value The value of the parameter
  24186. */
  24187. setParam(paramName: string, value: number): void;
  24188. /**
  24189. * Specifically change the body's mass option. Won't recreate the physics body object
  24190. * @param mass The mass of the physics imposter
  24191. */
  24192. setMass(mass: number): void;
  24193. /**
  24194. * Gets the linear velocity
  24195. * @returns linear velocity or null
  24196. */
  24197. getLinearVelocity(): Nullable<Vector3>;
  24198. /**
  24199. * Sets the linear velocity
  24200. * @param velocity linear velocity or null
  24201. */
  24202. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24203. /**
  24204. * Gets the angular velocity
  24205. * @returns angular velocity or null
  24206. */
  24207. getAngularVelocity(): Nullable<Vector3>;
  24208. /**
  24209. * Sets the angular velocity
  24210. * @param velocity The velocity or null
  24211. */
  24212. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24213. /**
  24214. * Execute a function with the physics plugin native code
  24215. * Provide a function the will have two variables - the world object and the physics body object
  24216. * @param func The function to execute with the physics plugin native code
  24217. */
  24218. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24219. /**
  24220. * Register a function that will be executed before the physics world is stepping forward
  24221. * @param func The function to execute before the physics world is stepped forward
  24222. */
  24223. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24224. /**
  24225. * Unregister a function that will be executed before the physics world is stepping forward
  24226. * @param func The function to execute before the physics world is stepped forward
  24227. */
  24228. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24229. /**
  24230. * Register a function that will be executed after the physics step
  24231. * @param func The function to execute after physics step
  24232. */
  24233. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24234. /**
  24235. * Unregisters a function that will be executed after the physics step
  24236. * @param func The function to execute after physics step
  24237. */
  24238. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24239. /**
  24240. * register a function that will be executed when this impostor collides against a different body
  24241. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24242. * @param func Callback that is executed on collision
  24243. */
  24244. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24245. /**
  24246. * Unregisters the physics imposter on contact
  24247. * @param collideAgainst The physics object to collide against
  24248. * @param func Callback to execute on collision
  24249. */
  24250. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24251. private _tmpQuat;
  24252. private _tmpQuat2;
  24253. /**
  24254. * Get the parent rotation
  24255. * @returns The parent rotation
  24256. */
  24257. getParentsRotation(): Quaternion;
  24258. /**
  24259. * this function is executed by the physics engine.
  24260. */
  24261. beforeStep: () => void;
  24262. /**
  24263. * this function is executed by the physics engine
  24264. */
  24265. afterStep: () => void;
  24266. /**
  24267. * Legacy collision detection event support
  24268. */
  24269. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24270. /**
  24271. * event and body object due to cannon's event-based architecture.
  24272. */
  24273. onCollide: (e: {
  24274. body: any;
  24275. }) => void;
  24276. /**
  24277. * Apply a force
  24278. * @param force The force to apply
  24279. * @param contactPoint The contact point for the force
  24280. * @returns The physics imposter
  24281. */
  24282. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24283. /**
  24284. * Apply an impulse
  24285. * @param force The impulse force
  24286. * @param contactPoint The contact point for the impulse force
  24287. * @returns The physics imposter
  24288. */
  24289. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24290. /**
  24291. * A help function to create a joint
  24292. * @param otherImpostor A physics imposter used to create a joint
  24293. * @param jointType The type of joint
  24294. * @param jointData The data for the joint
  24295. * @returns The physics imposter
  24296. */
  24297. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24298. /**
  24299. * Add a joint to this impostor with a different impostor
  24300. * @param otherImpostor A physics imposter used to add a joint
  24301. * @param joint The joint to add
  24302. * @returns The physics imposter
  24303. */
  24304. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24305. /**
  24306. * Add an anchor to a cloth impostor
  24307. * @param otherImpostor rigid impostor to anchor to
  24308. * @param width ratio across width from 0 to 1
  24309. * @param height ratio up height from 0 to 1
  24310. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24311. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24312. * @returns impostor the soft imposter
  24313. */
  24314. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24315. /**
  24316. * Add a hook to a rope impostor
  24317. * @param otherImpostor rigid impostor to anchor to
  24318. * @param length ratio across rope from 0 to 1
  24319. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24320. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24321. * @returns impostor the rope imposter
  24322. */
  24323. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24324. /**
  24325. * Will keep this body still, in a sleep mode.
  24326. * @returns the physics imposter
  24327. */
  24328. sleep(): PhysicsImpostor;
  24329. /**
  24330. * Wake the body up.
  24331. * @returns The physics imposter
  24332. */
  24333. wakeUp(): PhysicsImpostor;
  24334. /**
  24335. * Clones the physics imposter
  24336. * @param newObject The physics imposter clones to this physics-enabled object
  24337. * @returns A nullable physics imposter
  24338. */
  24339. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24340. /**
  24341. * Disposes the physics imposter
  24342. */
  24343. dispose(): void;
  24344. /**
  24345. * Sets the delta position
  24346. * @param position The delta position amount
  24347. */
  24348. setDeltaPosition(position: Vector3): void;
  24349. /**
  24350. * Sets the delta rotation
  24351. * @param rotation The delta rotation amount
  24352. */
  24353. setDeltaRotation(rotation: Quaternion): void;
  24354. /**
  24355. * Gets the box size of the physics imposter and stores the result in the input parameter
  24356. * @param result Stores the box size
  24357. * @returns The physics imposter
  24358. */
  24359. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24360. /**
  24361. * Gets the radius of the physics imposter
  24362. * @returns Radius of the physics imposter
  24363. */
  24364. getRadius(): number;
  24365. /**
  24366. * Sync a bone with this impostor
  24367. * @param bone The bone to sync to the impostor.
  24368. * @param boneMesh The mesh that the bone is influencing.
  24369. * @param jointPivot The pivot of the joint / bone in local space.
  24370. * @param distToJoint Optional distance from the impostor to the joint.
  24371. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24372. */
  24373. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24374. /**
  24375. * Sync impostor to a bone
  24376. * @param bone The bone that the impostor will be synced to.
  24377. * @param boneMesh The mesh that the bone is influencing.
  24378. * @param jointPivot The pivot of the joint / bone in local space.
  24379. * @param distToJoint Optional distance from the impostor to the joint.
  24380. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24381. * @param boneAxis Optional vector3 axis the bone is aligned with
  24382. */
  24383. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24384. /**
  24385. * No-Imposter type
  24386. */
  24387. static NoImpostor: number;
  24388. /**
  24389. * Sphere-Imposter type
  24390. */
  24391. static SphereImpostor: number;
  24392. /**
  24393. * Box-Imposter type
  24394. */
  24395. static BoxImpostor: number;
  24396. /**
  24397. * Plane-Imposter type
  24398. */
  24399. static PlaneImpostor: number;
  24400. /**
  24401. * Mesh-imposter type
  24402. */
  24403. static MeshImpostor: number;
  24404. /**
  24405. * Capsule-Impostor type (Ammo.js plugin only)
  24406. */
  24407. static CapsuleImpostor: number;
  24408. /**
  24409. * Cylinder-Imposter type
  24410. */
  24411. static CylinderImpostor: number;
  24412. /**
  24413. * Particle-Imposter type
  24414. */
  24415. static ParticleImpostor: number;
  24416. /**
  24417. * Heightmap-Imposter type
  24418. */
  24419. static HeightmapImpostor: number;
  24420. /**
  24421. * ConvexHull-Impostor type (Ammo.js plugin only)
  24422. */
  24423. static ConvexHullImpostor: number;
  24424. /**
  24425. * Rope-Imposter type
  24426. */
  24427. static RopeImpostor: number;
  24428. /**
  24429. * Cloth-Imposter type
  24430. */
  24431. static ClothImpostor: number;
  24432. /**
  24433. * Softbody-Imposter type
  24434. */
  24435. static SoftbodyImpostor: number;
  24436. }
  24437. }
  24438. declare module "babylonjs/Meshes/mesh" {
  24439. import { Observable } from "babylonjs/Misc/observable";
  24440. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24441. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24442. import { Camera } from "babylonjs/Cameras/camera";
  24443. import { Scene } from "babylonjs/scene";
  24444. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24445. import { Color4 } from "babylonjs/Maths/math.color";
  24446. import { Engine } from "babylonjs/Engines/engine";
  24447. import { Node } from "babylonjs/node";
  24448. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24449. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24450. import { Buffer } from "babylonjs/Meshes/buffer";
  24451. import { Geometry } from "babylonjs/Meshes/geometry";
  24452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24453. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24454. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24455. import { Effect } from "babylonjs/Materials/effect";
  24456. import { Material } from "babylonjs/Materials/material";
  24457. import { Skeleton } from "babylonjs/Bones/skeleton";
  24458. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24459. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24460. import { Path3D } from "babylonjs/Maths/math.path";
  24461. import { Plane } from "babylonjs/Maths/math.plane";
  24462. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24463. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24464. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24465. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24466. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24467. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24468. /**
  24469. * @hidden
  24470. **/
  24471. export class _CreationDataStorage {
  24472. closePath?: boolean;
  24473. closeArray?: boolean;
  24474. idx: number[];
  24475. dashSize: number;
  24476. gapSize: number;
  24477. path3D: Path3D;
  24478. pathArray: Vector3[][];
  24479. arc: number;
  24480. radius: number;
  24481. cap: number;
  24482. tessellation: number;
  24483. }
  24484. /**
  24485. * @hidden
  24486. **/
  24487. class _InstanceDataStorage {
  24488. visibleInstances: any;
  24489. batchCache: _InstancesBatch;
  24490. instancesBufferSize: number;
  24491. instancesBuffer: Nullable<Buffer>;
  24492. instancesData: Float32Array;
  24493. overridenInstanceCount: number;
  24494. isFrozen: boolean;
  24495. previousBatch: Nullable<_InstancesBatch>;
  24496. hardwareInstancedRendering: boolean;
  24497. sideOrientation: number;
  24498. manualUpdate: boolean;
  24499. }
  24500. /**
  24501. * @hidden
  24502. **/
  24503. export class _InstancesBatch {
  24504. mustReturn: boolean;
  24505. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24506. renderSelf: boolean[];
  24507. hardwareInstancedRendering: boolean[];
  24508. }
  24509. /**
  24510. * Class used to represent renderable models
  24511. */
  24512. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24513. /**
  24514. * Mesh side orientation : usually the external or front surface
  24515. */
  24516. static readonly FRONTSIDE: number;
  24517. /**
  24518. * Mesh side orientation : usually the internal or back surface
  24519. */
  24520. static readonly BACKSIDE: number;
  24521. /**
  24522. * Mesh side orientation : both internal and external or front and back surfaces
  24523. */
  24524. static readonly DOUBLESIDE: number;
  24525. /**
  24526. * Mesh side orientation : by default, `FRONTSIDE`
  24527. */
  24528. static readonly DEFAULTSIDE: number;
  24529. /**
  24530. * Mesh cap setting : no cap
  24531. */
  24532. static readonly NO_CAP: number;
  24533. /**
  24534. * Mesh cap setting : one cap at the beginning of the mesh
  24535. */
  24536. static readonly CAP_START: number;
  24537. /**
  24538. * Mesh cap setting : one cap at the end of the mesh
  24539. */
  24540. static readonly CAP_END: number;
  24541. /**
  24542. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24543. */
  24544. static readonly CAP_ALL: number;
  24545. /**
  24546. * Mesh pattern setting : no flip or rotate
  24547. */
  24548. static readonly NO_FLIP: number;
  24549. /**
  24550. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24551. */
  24552. static readonly FLIP_TILE: number;
  24553. /**
  24554. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24555. */
  24556. static readonly ROTATE_TILE: number;
  24557. /**
  24558. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24559. */
  24560. static readonly FLIP_ROW: number;
  24561. /**
  24562. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24563. */
  24564. static readonly ROTATE_ROW: number;
  24565. /**
  24566. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24567. */
  24568. static readonly FLIP_N_ROTATE_TILE: number;
  24569. /**
  24570. * Mesh pattern setting : rotate pattern and rotate
  24571. */
  24572. static readonly FLIP_N_ROTATE_ROW: number;
  24573. /**
  24574. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24575. */
  24576. static readonly CENTER: number;
  24577. /**
  24578. * Mesh tile positioning : part tiles on left
  24579. */
  24580. static readonly LEFT: number;
  24581. /**
  24582. * Mesh tile positioning : part tiles on right
  24583. */
  24584. static readonly RIGHT: number;
  24585. /**
  24586. * Mesh tile positioning : part tiles on top
  24587. */
  24588. static readonly TOP: number;
  24589. /**
  24590. * Mesh tile positioning : part tiles on bottom
  24591. */
  24592. static readonly BOTTOM: number;
  24593. /**
  24594. * Gets the default side orientation.
  24595. * @param orientation the orientation to value to attempt to get
  24596. * @returns the default orientation
  24597. * @hidden
  24598. */
  24599. static _GetDefaultSideOrientation(orientation?: number): number;
  24600. private _internalMeshDataInfo;
  24601. /**
  24602. * An event triggered before rendering the mesh
  24603. */
  24604. readonly onBeforeRenderObservable: Observable<Mesh>;
  24605. /**
  24606. * An event triggered before binding the mesh
  24607. */
  24608. readonly onBeforeBindObservable: Observable<Mesh>;
  24609. /**
  24610. * An event triggered after rendering the mesh
  24611. */
  24612. readonly onAfterRenderObservable: Observable<Mesh>;
  24613. /**
  24614. * An event triggered before drawing the mesh
  24615. */
  24616. readonly onBeforeDrawObservable: Observable<Mesh>;
  24617. private _onBeforeDrawObserver;
  24618. /**
  24619. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24620. */
  24621. onBeforeDraw: () => void;
  24622. readonly hasInstances: boolean;
  24623. /**
  24624. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24625. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24626. */
  24627. delayLoadState: number;
  24628. /**
  24629. * Gets the list of instances created from this mesh
  24630. * it is not supposed to be modified manually.
  24631. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24632. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24633. */
  24634. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24635. /**
  24636. * Gets the file containing delay loading data for this mesh
  24637. */
  24638. delayLoadingFile: string;
  24639. /** @hidden */
  24640. _binaryInfo: any;
  24641. /**
  24642. * User defined function used to change how LOD level selection is done
  24643. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24644. */
  24645. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24646. /**
  24647. * Gets or sets the morph target manager
  24648. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24649. */
  24650. morphTargetManager: Nullable<MorphTargetManager>;
  24651. /** @hidden */
  24652. _creationDataStorage: Nullable<_CreationDataStorage>;
  24653. /** @hidden */
  24654. _geometry: Nullable<Geometry>;
  24655. /** @hidden */
  24656. _delayInfo: Array<string>;
  24657. /** @hidden */
  24658. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24659. /** @hidden */
  24660. _instanceDataStorage: _InstanceDataStorage;
  24661. private _effectiveMaterial;
  24662. /** @hidden */
  24663. _shouldGenerateFlatShading: boolean;
  24664. /** @hidden */
  24665. _originalBuilderSideOrientation: number;
  24666. /**
  24667. * Use this property to change the original side orientation defined at construction time
  24668. */
  24669. overrideMaterialSideOrientation: Nullable<number>;
  24670. /**
  24671. * Gets the source mesh (the one used to clone this one from)
  24672. */
  24673. readonly source: Nullable<Mesh>;
  24674. /**
  24675. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24676. */
  24677. isUnIndexed: boolean;
  24678. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24679. readonly worldMatrixInstancedBuffer: Float32Array;
  24680. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24681. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  24682. /**
  24683. * @constructor
  24684. * @param name The value used by scene.getMeshByName() to do a lookup.
  24685. * @param scene The scene to add this mesh to.
  24686. * @param parent The parent of this mesh, if it has one
  24687. * @param source An optional Mesh from which geometry is shared, cloned.
  24688. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24689. * When false, achieved by calling a clone(), also passing False.
  24690. * This will make creation of children, recursive.
  24691. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24692. */
  24693. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24694. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24695. doNotInstantiate: boolean;
  24696. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24697. /**
  24698. * Gets the class name
  24699. * @returns the string "Mesh".
  24700. */
  24701. getClassName(): string;
  24702. /** @hidden */
  24703. readonly _isMesh: boolean;
  24704. /**
  24705. * Returns a description of this mesh
  24706. * @param fullDetails define if full details about this mesh must be used
  24707. * @returns a descriptive string representing this mesh
  24708. */
  24709. toString(fullDetails?: boolean): string;
  24710. /** @hidden */
  24711. _unBindEffect(): void;
  24712. /**
  24713. * Gets a boolean indicating if this mesh has LOD
  24714. */
  24715. readonly hasLODLevels: boolean;
  24716. /**
  24717. * Gets the list of MeshLODLevel associated with the current mesh
  24718. * @returns an array of MeshLODLevel
  24719. */
  24720. getLODLevels(): MeshLODLevel[];
  24721. private _sortLODLevels;
  24722. /**
  24723. * Add a mesh as LOD level triggered at the given distance.
  24724. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24725. * @param distance The distance from the center of the object to show this level
  24726. * @param mesh The mesh to be added as LOD level (can be null)
  24727. * @return This mesh (for chaining)
  24728. */
  24729. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24730. /**
  24731. * Returns the LOD level mesh at the passed distance or null if not found.
  24732. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24733. * @param distance The distance from the center of the object to show this level
  24734. * @returns a Mesh or `null`
  24735. */
  24736. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24737. /**
  24738. * Remove a mesh from the LOD array
  24739. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24740. * @param mesh defines the mesh to be removed
  24741. * @return This mesh (for chaining)
  24742. */
  24743. removeLODLevel(mesh: Mesh): Mesh;
  24744. /**
  24745. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24746. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24747. * @param camera defines the camera to use to compute distance
  24748. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24749. * @return This mesh (for chaining)
  24750. */
  24751. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24752. /**
  24753. * Gets the mesh internal Geometry object
  24754. */
  24755. readonly geometry: Nullable<Geometry>;
  24756. /**
  24757. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24758. * @returns the total number of vertices
  24759. */
  24760. getTotalVertices(): number;
  24761. /**
  24762. * Returns the content of an associated vertex buffer
  24763. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24764. * - VertexBuffer.PositionKind
  24765. * - VertexBuffer.UVKind
  24766. * - VertexBuffer.UV2Kind
  24767. * - VertexBuffer.UV3Kind
  24768. * - VertexBuffer.UV4Kind
  24769. * - VertexBuffer.UV5Kind
  24770. * - VertexBuffer.UV6Kind
  24771. * - VertexBuffer.ColorKind
  24772. * - VertexBuffer.MatricesIndicesKind
  24773. * - VertexBuffer.MatricesIndicesExtraKind
  24774. * - VertexBuffer.MatricesWeightsKind
  24775. * - VertexBuffer.MatricesWeightsExtraKind
  24776. * @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
  24777. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24778. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24779. */
  24780. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24781. /**
  24782. * Returns the mesh VertexBuffer object from the requested `kind`
  24783. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24784. * - VertexBuffer.PositionKind
  24785. * - VertexBuffer.NormalKind
  24786. * - VertexBuffer.UVKind
  24787. * - VertexBuffer.UV2Kind
  24788. * - VertexBuffer.UV3Kind
  24789. * - VertexBuffer.UV4Kind
  24790. * - VertexBuffer.UV5Kind
  24791. * - VertexBuffer.UV6Kind
  24792. * - VertexBuffer.ColorKind
  24793. * - VertexBuffer.MatricesIndicesKind
  24794. * - VertexBuffer.MatricesIndicesExtraKind
  24795. * - VertexBuffer.MatricesWeightsKind
  24796. * - VertexBuffer.MatricesWeightsExtraKind
  24797. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24798. */
  24799. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24800. /**
  24801. * Tests if a specific vertex buffer is associated with this mesh
  24802. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24803. * - VertexBuffer.PositionKind
  24804. * - VertexBuffer.NormalKind
  24805. * - VertexBuffer.UVKind
  24806. * - VertexBuffer.UV2Kind
  24807. * - VertexBuffer.UV3Kind
  24808. * - VertexBuffer.UV4Kind
  24809. * - VertexBuffer.UV5Kind
  24810. * - VertexBuffer.UV6Kind
  24811. * - VertexBuffer.ColorKind
  24812. * - VertexBuffer.MatricesIndicesKind
  24813. * - VertexBuffer.MatricesIndicesExtraKind
  24814. * - VertexBuffer.MatricesWeightsKind
  24815. * - VertexBuffer.MatricesWeightsExtraKind
  24816. * @returns a boolean
  24817. */
  24818. isVerticesDataPresent(kind: string): boolean;
  24819. /**
  24820. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24821. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24822. * - VertexBuffer.PositionKind
  24823. * - VertexBuffer.UVKind
  24824. * - VertexBuffer.UV2Kind
  24825. * - VertexBuffer.UV3Kind
  24826. * - VertexBuffer.UV4Kind
  24827. * - VertexBuffer.UV5Kind
  24828. * - VertexBuffer.UV6Kind
  24829. * - VertexBuffer.ColorKind
  24830. * - VertexBuffer.MatricesIndicesKind
  24831. * - VertexBuffer.MatricesIndicesExtraKind
  24832. * - VertexBuffer.MatricesWeightsKind
  24833. * - VertexBuffer.MatricesWeightsExtraKind
  24834. * @returns a boolean
  24835. */
  24836. isVertexBufferUpdatable(kind: string): boolean;
  24837. /**
  24838. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24839. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24840. * - VertexBuffer.PositionKind
  24841. * - VertexBuffer.NormalKind
  24842. * - VertexBuffer.UVKind
  24843. * - VertexBuffer.UV2Kind
  24844. * - VertexBuffer.UV3Kind
  24845. * - VertexBuffer.UV4Kind
  24846. * - VertexBuffer.UV5Kind
  24847. * - VertexBuffer.UV6Kind
  24848. * - VertexBuffer.ColorKind
  24849. * - VertexBuffer.MatricesIndicesKind
  24850. * - VertexBuffer.MatricesIndicesExtraKind
  24851. * - VertexBuffer.MatricesWeightsKind
  24852. * - VertexBuffer.MatricesWeightsExtraKind
  24853. * @returns an array of strings
  24854. */
  24855. getVerticesDataKinds(): string[];
  24856. /**
  24857. * Returns a positive integer : the total number of indices in this mesh geometry.
  24858. * @returns the numner of indices or zero if the mesh has no geometry.
  24859. */
  24860. getTotalIndices(): number;
  24861. /**
  24862. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24863. * @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.
  24864. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24865. * @returns the indices array or an empty array if the mesh has no geometry
  24866. */
  24867. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24868. readonly isBlocked: boolean;
  24869. /**
  24870. * Determine if the current mesh is ready to be rendered
  24871. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24872. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24873. * @returns true if all associated assets are ready (material, textures, shaders)
  24874. */
  24875. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24876. /**
  24877. * 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.
  24878. */
  24879. readonly areNormalsFrozen: boolean;
  24880. /**
  24881. * 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.
  24882. * @returns the current mesh
  24883. */
  24884. freezeNormals(): Mesh;
  24885. /**
  24886. * 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
  24887. * @returns the current mesh
  24888. */
  24889. unfreezeNormals(): Mesh;
  24890. /**
  24891. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24892. */
  24893. overridenInstanceCount: number;
  24894. /** @hidden */
  24895. _preActivate(): Mesh;
  24896. /** @hidden */
  24897. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24898. /** @hidden */
  24899. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24900. /**
  24901. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24902. * This means the mesh underlying bounding box and sphere are recomputed.
  24903. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24904. * @returns the current mesh
  24905. */
  24906. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24907. /** @hidden */
  24908. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24909. /**
  24910. * This function will subdivide the mesh into multiple submeshes
  24911. * @param count defines the expected number of submeshes
  24912. */
  24913. subdivide(count: number): void;
  24914. /**
  24915. * Copy a FloatArray into a specific associated vertex buffer
  24916. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24917. * - VertexBuffer.PositionKind
  24918. * - VertexBuffer.UVKind
  24919. * - VertexBuffer.UV2Kind
  24920. * - VertexBuffer.UV3Kind
  24921. * - VertexBuffer.UV4Kind
  24922. * - VertexBuffer.UV5Kind
  24923. * - VertexBuffer.UV6Kind
  24924. * - VertexBuffer.ColorKind
  24925. * - VertexBuffer.MatricesIndicesKind
  24926. * - VertexBuffer.MatricesIndicesExtraKind
  24927. * - VertexBuffer.MatricesWeightsKind
  24928. * - VertexBuffer.MatricesWeightsExtraKind
  24929. * @param data defines the data source
  24930. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24931. * @param stride defines the data stride size (can be null)
  24932. * @returns the current mesh
  24933. */
  24934. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24935. /**
  24936. * Delete a vertex buffer associated with this mesh
  24937. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24938. * - VertexBuffer.PositionKind
  24939. * - VertexBuffer.UVKind
  24940. * - VertexBuffer.UV2Kind
  24941. * - VertexBuffer.UV3Kind
  24942. * - VertexBuffer.UV4Kind
  24943. * - VertexBuffer.UV5Kind
  24944. * - VertexBuffer.UV6Kind
  24945. * - VertexBuffer.ColorKind
  24946. * - VertexBuffer.MatricesIndicesKind
  24947. * - VertexBuffer.MatricesIndicesExtraKind
  24948. * - VertexBuffer.MatricesWeightsKind
  24949. * - VertexBuffer.MatricesWeightsExtraKind
  24950. */
  24951. removeVerticesData(kind: string): void;
  24952. /**
  24953. * Flags an associated vertex buffer as updatable
  24954. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24955. * - VertexBuffer.PositionKind
  24956. * - VertexBuffer.UVKind
  24957. * - VertexBuffer.UV2Kind
  24958. * - VertexBuffer.UV3Kind
  24959. * - VertexBuffer.UV4Kind
  24960. * - VertexBuffer.UV5Kind
  24961. * - VertexBuffer.UV6Kind
  24962. * - VertexBuffer.ColorKind
  24963. * - VertexBuffer.MatricesIndicesKind
  24964. * - VertexBuffer.MatricesIndicesExtraKind
  24965. * - VertexBuffer.MatricesWeightsKind
  24966. * - VertexBuffer.MatricesWeightsExtraKind
  24967. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24968. */
  24969. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24970. /**
  24971. * Sets the mesh global Vertex Buffer
  24972. * @param buffer defines the buffer to use
  24973. * @returns the current mesh
  24974. */
  24975. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24976. /**
  24977. * Update a specific associated vertex buffer
  24978. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24979. * - VertexBuffer.PositionKind
  24980. * - VertexBuffer.UVKind
  24981. * - VertexBuffer.UV2Kind
  24982. * - VertexBuffer.UV3Kind
  24983. * - VertexBuffer.UV4Kind
  24984. * - VertexBuffer.UV5Kind
  24985. * - VertexBuffer.UV6Kind
  24986. * - VertexBuffer.ColorKind
  24987. * - VertexBuffer.MatricesIndicesKind
  24988. * - VertexBuffer.MatricesIndicesExtraKind
  24989. * - VertexBuffer.MatricesWeightsKind
  24990. * - VertexBuffer.MatricesWeightsExtraKind
  24991. * @param data defines the data source
  24992. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24993. * @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)
  24994. * @returns the current mesh
  24995. */
  24996. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24997. /**
  24998. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24999. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25000. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25001. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25002. * @returns the current mesh
  25003. */
  25004. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25005. /**
  25006. * Creates a un-shared specific occurence of the geometry for the mesh.
  25007. * @returns the current mesh
  25008. */
  25009. makeGeometryUnique(): Mesh;
  25010. /**
  25011. * Set the index buffer of this mesh
  25012. * @param indices defines the source data
  25013. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25014. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25015. * @returns the current mesh
  25016. */
  25017. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25018. /**
  25019. * Update the current index buffer
  25020. * @param indices defines the source data
  25021. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25022. * @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)
  25023. * @returns the current mesh
  25024. */
  25025. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25026. /**
  25027. * Invert the geometry to move from a right handed system to a left handed one.
  25028. * @returns the current mesh
  25029. */
  25030. toLeftHanded(): Mesh;
  25031. /** @hidden */
  25032. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25033. /** @hidden */
  25034. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25035. /**
  25036. * Registers for this mesh a javascript function called just before the rendering process
  25037. * @param func defines the function to call before rendering this mesh
  25038. * @returns the current mesh
  25039. */
  25040. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25041. /**
  25042. * Disposes a previously registered javascript function called before the rendering
  25043. * @param func defines the function to remove
  25044. * @returns the current mesh
  25045. */
  25046. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25047. /**
  25048. * Registers for this mesh a javascript function called just after the rendering is complete
  25049. * @param func defines the function to call after rendering this mesh
  25050. * @returns the current mesh
  25051. */
  25052. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25053. /**
  25054. * Disposes a previously registered javascript function called after the rendering.
  25055. * @param func defines the function to remove
  25056. * @returns the current mesh
  25057. */
  25058. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25059. /** @hidden */
  25060. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25061. /** @hidden */
  25062. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25063. /** @hidden */
  25064. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25065. /** @hidden */
  25066. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25067. /** @hidden */
  25068. _rebuild(): void;
  25069. /** @hidden */
  25070. _freeze(): void;
  25071. /** @hidden */
  25072. _unFreeze(): void;
  25073. /**
  25074. * 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
  25075. * @param subMesh defines the subMesh to render
  25076. * @param enableAlphaMode defines if alpha mode can be changed
  25077. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25078. * @returns the current mesh
  25079. */
  25080. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25081. private _onBeforeDraw;
  25082. /**
  25083. * Renormalize the mesh and patch it up if there are no weights
  25084. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25085. * However in the case of zero weights then we set just a single influence to 1.
  25086. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25087. */
  25088. cleanMatrixWeights(): void;
  25089. private normalizeSkinFourWeights;
  25090. private normalizeSkinWeightsAndExtra;
  25091. /**
  25092. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25093. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25094. * the user know there was an issue with importing the mesh
  25095. * @returns a validation object with skinned, valid and report string
  25096. */
  25097. validateSkinning(): {
  25098. skinned: boolean;
  25099. valid: boolean;
  25100. report: string;
  25101. };
  25102. /** @hidden */
  25103. _checkDelayState(): Mesh;
  25104. private _queueLoad;
  25105. /**
  25106. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25107. * A mesh is in the frustum if its bounding box intersects the frustum
  25108. * @param frustumPlanes defines the frustum to test
  25109. * @returns true if the mesh is in the frustum planes
  25110. */
  25111. isInFrustum(frustumPlanes: Plane[]): boolean;
  25112. /**
  25113. * Sets the mesh material by the material or multiMaterial `id` property
  25114. * @param id is a string identifying the material or the multiMaterial
  25115. * @returns the current mesh
  25116. */
  25117. setMaterialByID(id: string): Mesh;
  25118. /**
  25119. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25120. * @returns an array of IAnimatable
  25121. */
  25122. getAnimatables(): IAnimatable[];
  25123. /**
  25124. * Modifies the mesh geometry according to the passed transformation matrix.
  25125. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25126. * The mesh normals are modified using the same transformation.
  25127. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25128. * @param transform defines the transform matrix to use
  25129. * @see http://doc.babylonjs.com/resources/baking_transformations
  25130. * @returns the current mesh
  25131. */
  25132. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25133. /**
  25134. * Modifies the mesh geometry according to its own current World Matrix.
  25135. * The mesh World Matrix is then reset.
  25136. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25137. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25138. * @see http://doc.babylonjs.com/resources/baking_transformations
  25139. * @returns the current mesh
  25140. */
  25141. bakeCurrentTransformIntoVertices(): Mesh;
  25142. /** @hidden */
  25143. readonly _positions: Nullable<Vector3[]>;
  25144. /** @hidden */
  25145. _resetPointsArrayCache(): Mesh;
  25146. /** @hidden */
  25147. _generatePointsArray(): boolean;
  25148. /**
  25149. * Returns a new Mesh object generated from the current mesh properties.
  25150. * This method must not get confused with createInstance()
  25151. * @param name is a string, the name given to the new mesh
  25152. * @param newParent can be any Node object (default `null`)
  25153. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25154. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25155. * @returns a new mesh
  25156. */
  25157. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25158. /**
  25159. * Releases resources associated with this mesh.
  25160. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25161. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25162. */
  25163. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25164. /** @hidden */
  25165. _disposeInstanceSpecificData(): void;
  25166. /**
  25167. * Modifies the mesh geometry according to a displacement map.
  25168. * 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.
  25169. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25170. * @param url is a string, the URL from the image file is to be downloaded.
  25171. * @param minHeight is the lower limit of the displacement.
  25172. * @param maxHeight is the upper limit of the displacement.
  25173. * @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.
  25174. * @param uvOffset is an optional vector2 used to offset UV.
  25175. * @param uvScale is an optional vector2 used to scale UV.
  25176. * @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.
  25177. * @returns the Mesh.
  25178. */
  25179. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25180. /**
  25181. * Modifies the mesh geometry according to a displacementMap buffer.
  25182. * 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.
  25183. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25184. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25185. * @param heightMapWidth is the width of the buffer image.
  25186. * @param heightMapHeight is the height of the buffer image.
  25187. * @param minHeight is the lower limit of the displacement.
  25188. * @param maxHeight is the upper limit of the displacement.
  25189. * @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.
  25190. * @param uvOffset is an optional vector2 used to offset UV.
  25191. * @param uvScale is an optional vector2 used to scale UV.
  25192. * @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.
  25193. * @returns the Mesh.
  25194. */
  25195. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25196. /**
  25197. * Modify the mesh to get a flat shading rendering.
  25198. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25199. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25200. * @returns current mesh
  25201. */
  25202. convertToFlatShadedMesh(): Mesh;
  25203. /**
  25204. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25205. * In other words, more vertices, no more indices and a single bigger VBO.
  25206. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25207. * @returns current mesh
  25208. */
  25209. convertToUnIndexedMesh(): Mesh;
  25210. /**
  25211. * Inverses facet orientations.
  25212. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25213. * @param flipNormals will also inverts the normals
  25214. * @returns current mesh
  25215. */
  25216. flipFaces(flipNormals?: boolean): Mesh;
  25217. /**
  25218. * Increase the number of facets and hence vertices in a mesh
  25219. * Vertex normals are interpolated from existing vertex normals
  25220. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25221. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25222. */
  25223. increaseVertices(numberPerEdge: number): void;
  25224. /**
  25225. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25226. * This will undo any application of covertToFlatShadedMesh
  25227. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25228. */
  25229. forceSharedVertices(): void;
  25230. /** @hidden */
  25231. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25232. /** @hidden */
  25233. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25234. /**
  25235. * Creates a new InstancedMesh object from the mesh model.
  25236. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25237. * @param name defines the name of the new instance
  25238. * @returns a new InstancedMesh
  25239. */
  25240. createInstance(name: string): InstancedMesh;
  25241. /**
  25242. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25243. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25244. * @returns the current mesh
  25245. */
  25246. synchronizeInstances(): Mesh;
  25247. /**
  25248. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25249. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25250. * This should be used together with the simplification to avoid disappearing triangles.
  25251. * @param successCallback an optional success callback to be called after the optimization finished.
  25252. * @returns the current mesh
  25253. */
  25254. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25255. /**
  25256. * Serialize current mesh
  25257. * @param serializationObject defines the object which will receive the serialization data
  25258. */
  25259. serialize(serializationObject: any): void;
  25260. /** @hidden */
  25261. _syncGeometryWithMorphTargetManager(): void;
  25262. /** @hidden */
  25263. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25264. /**
  25265. * Returns a new Mesh object parsed from the source provided.
  25266. * @param parsedMesh is the source
  25267. * @param scene defines the hosting scene
  25268. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25269. * @returns a new Mesh
  25270. */
  25271. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25272. /**
  25273. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25274. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25275. * @param name defines the name of the mesh to create
  25276. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25277. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25278. * @param closePath creates a seam between the first and the last points of each path of the path array
  25279. * @param offset is taken in account only if the `pathArray` is containing a single path
  25280. * @param scene defines the hosting scene
  25281. * @param updatable defines if the mesh must be flagged as updatable
  25282. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25283. * @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)
  25284. * @returns a new Mesh
  25285. */
  25286. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25287. /**
  25288. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25289. * @param name defines the name of the mesh to create
  25290. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25291. * @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
  25292. * @param scene defines the hosting scene
  25293. * @param updatable defines if the mesh must be flagged as updatable
  25294. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25295. * @returns a new Mesh
  25296. */
  25297. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25298. /**
  25299. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25300. * @param name defines the name of the mesh to create
  25301. * @param size sets the size (float) of each box side (default 1)
  25302. * @param scene defines the hosting scene
  25303. * @param updatable defines if the mesh must be flagged as updatable
  25304. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25305. * @returns a new Mesh
  25306. */
  25307. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25308. /**
  25309. * Creates a sphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25312. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25313. * @param scene defines the hosting scene
  25314. * @param updatable defines if the mesh must be flagged as updatable
  25315. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25316. * @returns a new Mesh
  25317. */
  25318. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25319. /**
  25320. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25321. * @param name defines the name of the mesh to create
  25322. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25323. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25324. * @param scene defines the hosting scene
  25325. * @returns a new Mesh
  25326. */
  25327. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25328. /**
  25329. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25330. * @param name defines the name of the mesh to create
  25331. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25332. * @param diameterTop set the top cap diameter (floats, default 1)
  25333. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25334. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25335. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25336. * @param scene defines the hosting scene
  25337. * @param updatable defines if the mesh must be flagged as updatable
  25338. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25339. * @returns a new Mesh
  25340. */
  25341. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25342. /**
  25343. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25344. * @param name defines the name of the mesh to create
  25345. * @param diameter sets the diameter size (float) of the torus (default 1)
  25346. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25347. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25348. * @param scene defines the hosting scene
  25349. * @param updatable defines if the mesh must be flagged as updatable
  25350. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25351. * @returns a new Mesh
  25352. */
  25353. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25354. /**
  25355. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25356. * @param name defines the name of the mesh to create
  25357. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25358. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25359. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25360. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25361. * @param p the number of windings on X axis (positive integers, default 2)
  25362. * @param q the number of windings on Y axis (positive integers, default 3)
  25363. * @param scene defines the hosting scene
  25364. * @param updatable defines if the mesh must be flagged as updatable
  25365. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25366. * @returns a new Mesh
  25367. */
  25368. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25369. /**
  25370. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25371. * @param name defines the name of the mesh to create
  25372. * @param points is an array successive Vector3
  25373. * @param scene defines the hosting scene
  25374. * @param updatable defines if the mesh must be flagged as updatable
  25375. * @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).
  25376. * @returns a new Mesh
  25377. */
  25378. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25379. /**
  25380. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25381. * @param name defines the name of the mesh to create
  25382. * @param points is an array successive Vector3
  25383. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25384. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25385. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25386. * @param scene defines the hosting scene
  25387. * @param updatable defines if the mesh must be flagged as updatable
  25388. * @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)
  25389. * @returns a new Mesh
  25390. */
  25391. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25392. /**
  25393. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25394. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25395. * 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.
  25396. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25397. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25398. * Remember you can only change the shape positions, not their number when updating a polygon.
  25399. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25400. * @param name defines the name of the mesh to create
  25401. * @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
  25402. * @param scene defines the hosting scene
  25403. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25404. * @param updatable defines if the mesh must be flagged as updatable
  25405. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25406. * @param earcutInjection can be used to inject your own earcut reference
  25407. * @returns a new Mesh
  25408. */
  25409. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25410. /**
  25411. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25412. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25413. * @param name defines the name of the mesh to create
  25414. * @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
  25415. * @param depth defines the height of extrusion
  25416. * @param scene defines the hosting scene
  25417. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25418. * @param updatable defines if the mesh must be flagged as updatable
  25419. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25420. * @param earcutInjection can be used to inject your own earcut reference
  25421. * @returns a new Mesh
  25422. */
  25423. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25424. /**
  25425. * Creates an extruded shape mesh.
  25426. * 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
  25427. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25428. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25429. * @param name defines the name of the mesh to create
  25430. * @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
  25431. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25432. * @param scale is the value to scale the shape
  25433. * @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
  25434. * @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
  25435. * @param scene defines the hosting scene
  25436. * @param updatable defines if the mesh must be flagged as updatable
  25437. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25438. * @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)
  25439. * @returns a new Mesh
  25440. */
  25441. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25442. /**
  25443. * Creates an custom extruded shape mesh.
  25444. * The custom extrusion is a parametric shape.
  25445. * It has no predefined shape. Its final shape will depend on the input parameters.
  25446. * Please consider using the same method from the MeshBuilder class instead
  25447. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25448. * @param name defines the name of the mesh to create
  25449. * @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
  25450. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25451. * @param scaleFunction is a custom Javascript function called on each path point
  25452. * @param rotationFunction is a custom Javascript function called on each path point
  25453. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25454. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25455. * @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
  25456. * @param scene defines the hosting scene
  25457. * @param updatable defines if the mesh must be flagged as updatable
  25458. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25459. * @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)
  25460. * @returns a new Mesh
  25461. */
  25462. 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;
  25463. /**
  25464. * Creates lathe mesh.
  25465. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25466. * Please consider using the same method from the MeshBuilder class instead
  25467. * @param name defines the name of the mesh to create
  25468. * @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
  25469. * @param radius is the radius value of the lathe
  25470. * @param tessellation is the side number of the lathe.
  25471. * @param scene defines the hosting scene
  25472. * @param updatable defines if the mesh must be flagged as updatable
  25473. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25474. * @returns a new Mesh
  25475. */
  25476. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25477. /**
  25478. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25479. * @param name defines the name of the mesh to create
  25480. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25481. * @param scene defines the hosting scene
  25482. * @param updatable defines if the mesh must be flagged as updatable
  25483. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25484. * @returns a new Mesh
  25485. */
  25486. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25487. /**
  25488. * Creates a ground mesh.
  25489. * Please consider using the same method from the MeshBuilder class instead
  25490. * @param name defines the name of the mesh to create
  25491. * @param width set the width of the ground
  25492. * @param height set the height of the ground
  25493. * @param subdivisions sets the number of subdivisions per side
  25494. * @param scene defines the hosting scene
  25495. * @param updatable defines if the mesh must be flagged as updatable
  25496. * @returns a new Mesh
  25497. */
  25498. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25499. /**
  25500. * Creates a tiled ground mesh.
  25501. * Please consider using the same method from the MeshBuilder class instead
  25502. * @param name defines the name of the mesh to create
  25503. * @param xmin set the ground minimum X coordinate
  25504. * @param zmin set the ground minimum Y coordinate
  25505. * @param xmax set the ground maximum X coordinate
  25506. * @param zmax set the ground maximum Z coordinate
  25507. * @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
  25508. * @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
  25509. * @param scene defines the hosting scene
  25510. * @param updatable defines if the mesh must be flagged as updatable
  25511. * @returns a new Mesh
  25512. */
  25513. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25514. w: number;
  25515. h: number;
  25516. }, precision: {
  25517. w: number;
  25518. h: number;
  25519. }, scene: Scene, updatable?: boolean): Mesh;
  25520. /**
  25521. * Creates a ground mesh from a height map.
  25522. * Please consider using the same method from the MeshBuilder class instead
  25523. * @see http://doc.babylonjs.com/babylon101/height_map
  25524. * @param name defines the name of the mesh to create
  25525. * @param url sets the URL of the height map image resource
  25526. * @param width set the ground width size
  25527. * @param height set the ground height size
  25528. * @param subdivisions sets the number of subdivision per side
  25529. * @param minHeight is the minimum altitude on the ground
  25530. * @param maxHeight is the maximum altitude on the ground
  25531. * @param scene defines the hosting scene
  25532. * @param updatable defines if the mesh must be flagged as updatable
  25533. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25534. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25535. * @returns a new Mesh
  25536. */
  25537. 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;
  25538. /**
  25539. * Creates a tube mesh.
  25540. * The tube is a parametric shape.
  25541. * It has no predefined shape. Its final shape will depend on the input parameters.
  25542. * Please consider using the same method from the MeshBuilder class instead
  25543. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25544. * @param name defines the name of the mesh to create
  25545. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25546. * @param radius sets the tube radius size
  25547. * @param tessellation is the number of sides on the tubular surface
  25548. * @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
  25549. * @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
  25550. * @param scene defines the hosting scene
  25551. * @param updatable defines if the mesh must be flagged as updatable
  25552. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25553. * @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)
  25554. * @returns a new Mesh
  25555. */
  25556. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25557. (i: number, distance: number): number;
  25558. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25559. /**
  25560. * Creates a polyhedron mesh.
  25561. * Please consider using the same method from the MeshBuilder class instead.
  25562. * * 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
  25563. * * The parameter `size` (positive float, default 1) sets the polygon size
  25564. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25565. * * 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`
  25566. * * 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
  25567. * * 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)`)
  25568. * * 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
  25569. * * 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
  25570. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25571. * * If you create a double-sided mesh, you can choose what parts of 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
  25572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25573. * @param name defines the name of the mesh to create
  25574. * @param options defines the options used to create the mesh
  25575. * @param scene defines the hosting scene
  25576. * @returns a new Mesh
  25577. */
  25578. static CreatePolyhedron(name: string, options: {
  25579. type?: number;
  25580. size?: number;
  25581. sizeX?: number;
  25582. sizeY?: number;
  25583. sizeZ?: number;
  25584. custom?: any;
  25585. faceUV?: Vector4[];
  25586. faceColors?: Color4[];
  25587. updatable?: boolean;
  25588. sideOrientation?: number;
  25589. }, scene: Scene): Mesh;
  25590. /**
  25591. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25592. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25593. * * 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`)
  25594. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25595. * * 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
  25596. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25597. * * If you create a double-sided mesh, you can choose what parts of 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
  25598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25599. * @param name defines the name of the mesh
  25600. * @param options defines the options used to create the mesh
  25601. * @param scene defines the hosting scene
  25602. * @returns a new Mesh
  25603. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25604. */
  25605. static CreateIcoSphere(name: string, options: {
  25606. radius?: number;
  25607. flat?: boolean;
  25608. subdivisions?: number;
  25609. sideOrientation?: number;
  25610. updatable?: boolean;
  25611. }, scene: Scene): Mesh;
  25612. /**
  25613. * Creates a decal mesh.
  25614. * Please consider using the same method from the MeshBuilder class instead.
  25615. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25616. * @param name defines the name of the mesh
  25617. * @param sourceMesh defines the mesh receiving the decal
  25618. * @param position sets the position of the decal in world coordinates
  25619. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25620. * @param size sets the decal scaling
  25621. * @param angle sets the angle to rotate the decal
  25622. * @returns a new Mesh
  25623. */
  25624. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25625. /**
  25626. * Prepare internal position array for software CPU skinning
  25627. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25628. */
  25629. setPositionsForCPUSkinning(): Float32Array;
  25630. /**
  25631. * Prepare internal normal array for software CPU skinning
  25632. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25633. */
  25634. setNormalsForCPUSkinning(): Float32Array;
  25635. /**
  25636. * Updates the vertex buffer by applying transformation from the bones
  25637. * @param skeleton defines the skeleton to apply to current mesh
  25638. * @returns the current mesh
  25639. */
  25640. applySkeleton(skeleton: Skeleton): Mesh;
  25641. /**
  25642. * 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
  25643. * @param meshes defines the list of meshes to scan
  25644. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25645. */
  25646. static MinMax(meshes: AbstractMesh[]): {
  25647. min: Vector3;
  25648. max: Vector3;
  25649. };
  25650. /**
  25651. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25652. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25653. * @returns a vector3
  25654. */
  25655. static Center(meshesOrMinMaxVector: {
  25656. min: Vector3;
  25657. max: Vector3;
  25658. } | AbstractMesh[]): Vector3;
  25659. /**
  25660. * Merge the array of meshes into a single mesh for performance reasons.
  25661. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25662. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25663. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25664. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25665. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25666. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25667. * @returns a new mesh
  25668. */
  25669. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25670. /** @hidden */
  25671. addInstance(instance: InstancedMesh): void;
  25672. /** @hidden */
  25673. removeInstance(instance: InstancedMesh): void;
  25674. }
  25675. }
  25676. declare module "babylonjs/Cameras/camera" {
  25677. import { SmartArray } from "babylonjs/Misc/smartArray";
  25678. import { Observable } from "babylonjs/Misc/observable";
  25679. import { Nullable } from "babylonjs/types";
  25680. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25681. import { Scene } from "babylonjs/scene";
  25682. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25683. import { Node } from "babylonjs/node";
  25684. import { Mesh } from "babylonjs/Meshes/mesh";
  25685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25686. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25687. import { Viewport } from "babylonjs/Maths/math.viewport";
  25688. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25689. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25690. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25691. import { Ray } from "babylonjs/Culling/ray";
  25692. /**
  25693. * This is the base class of all the camera used in the application.
  25694. * @see http://doc.babylonjs.com/features/cameras
  25695. */
  25696. export class Camera extends Node {
  25697. /** @hidden */
  25698. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25699. /**
  25700. * This is the default projection mode used by the cameras.
  25701. * It helps recreating a feeling of perspective and better appreciate depth.
  25702. * This is the best way to simulate real life cameras.
  25703. */
  25704. static readonly PERSPECTIVE_CAMERA: number;
  25705. /**
  25706. * This helps creating camera with an orthographic mode.
  25707. * 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.
  25708. */
  25709. static readonly ORTHOGRAPHIC_CAMERA: number;
  25710. /**
  25711. * This is the default FOV mode for perspective cameras.
  25712. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25713. */
  25714. static readonly FOVMODE_VERTICAL_FIXED: number;
  25715. /**
  25716. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25717. */
  25718. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25719. /**
  25720. * This specifies ther is no need for a camera rig.
  25721. * Basically only one eye is rendered corresponding to the camera.
  25722. */
  25723. static readonly RIG_MODE_NONE: number;
  25724. /**
  25725. * Simulates a camera Rig with one blue eye and one red eye.
  25726. * This can be use with 3d blue and red glasses.
  25727. */
  25728. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25729. /**
  25730. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25731. */
  25732. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25733. /**
  25734. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25735. */
  25736. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25737. /**
  25738. * Defines that both eyes of the camera will be rendered over under each other.
  25739. */
  25740. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25741. /**
  25742. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25743. */
  25744. static readonly RIG_MODE_VR: number;
  25745. /**
  25746. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25747. */
  25748. static readonly RIG_MODE_WEBVR: number;
  25749. /**
  25750. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25751. */
  25752. static readonly RIG_MODE_CUSTOM: number;
  25753. /**
  25754. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25755. */
  25756. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25757. /**
  25758. * Define the input manager associated with the camera.
  25759. */
  25760. inputs: CameraInputsManager<Camera>;
  25761. /** @hidden */
  25762. _position: Vector3;
  25763. /**
  25764. * Define the current local position of the camera in the scene
  25765. */
  25766. position: Vector3;
  25767. /**
  25768. * The vector the camera should consider as up.
  25769. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25770. */
  25771. upVector: Vector3;
  25772. /**
  25773. * Define the current limit on the left side for an orthographic camera
  25774. * In scene unit
  25775. */
  25776. orthoLeft: Nullable<number>;
  25777. /**
  25778. * Define the current limit on the right side for an orthographic camera
  25779. * In scene unit
  25780. */
  25781. orthoRight: Nullable<number>;
  25782. /**
  25783. * Define the current limit on the bottom side for an orthographic camera
  25784. * In scene unit
  25785. */
  25786. orthoBottom: Nullable<number>;
  25787. /**
  25788. * Define the current limit on the top side for an orthographic camera
  25789. * In scene unit
  25790. */
  25791. orthoTop: Nullable<number>;
  25792. /**
  25793. * Field Of View is set in Radians. (default is 0.8)
  25794. */
  25795. fov: number;
  25796. /**
  25797. * Define the minimum distance the camera can see from.
  25798. * This is important to note that the depth buffer are not infinite and the closer it starts
  25799. * the more your scene might encounter depth fighting issue.
  25800. */
  25801. minZ: number;
  25802. /**
  25803. * Define the maximum distance the camera can see to.
  25804. * This is important to note that the depth buffer are not infinite and the further it end
  25805. * the more your scene might encounter depth fighting issue.
  25806. */
  25807. maxZ: number;
  25808. /**
  25809. * Define the default inertia of the camera.
  25810. * This helps giving a smooth feeling to the camera movement.
  25811. */
  25812. inertia: number;
  25813. /**
  25814. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25815. */
  25816. mode: number;
  25817. /**
  25818. * Define wether the camera is intermediate.
  25819. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25820. */
  25821. isIntermediate: boolean;
  25822. /**
  25823. * Define the viewport of the camera.
  25824. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25825. */
  25826. viewport: Viewport;
  25827. /**
  25828. * Restricts the camera to viewing objects with the same layerMask.
  25829. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25830. */
  25831. layerMask: number;
  25832. /**
  25833. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25834. */
  25835. fovMode: number;
  25836. /**
  25837. * Rig mode of the camera.
  25838. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25839. * This is normally controlled byt the camera themselves as internal use.
  25840. */
  25841. cameraRigMode: number;
  25842. /**
  25843. * Defines the distance between both "eyes" in case of a RIG
  25844. */
  25845. interaxialDistance: number;
  25846. /**
  25847. * Defines if stereoscopic rendering is done side by side or over under.
  25848. */
  25849. isStereoscopicSideBySide: boolean;
  25850. /**
  25851. * 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
  25852. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25853. * else in the scene. (Eg. security camera)
  25854. *
  25855. * 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)
  25856. */
  25857. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25858. /**
  25859. * When set, the camera will render to this render target instead of the default canvas
  25860. *
  25861. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25862. */
  25863. outputRenderTarget: Nullable<RenderTargetTexture>;
  25864. /**
  25865. * Observable triggered when the camera view matrix has changed.
  25866. */
  25867. onViewMatrixChangedObservable: Observable<Camera>;
  25868. /**
  25869. * Observable triggered when the camera Projection matrix has changed.
  25870. */
  25871. onProjectionMatrixChangedObservable: Observable<Camera>;
  25872. /**
  25873. * Observable triggered when the inputs have been processed.
  25874. */
  25875. onAfterCheckInputsObservable: Observable<Camera>;
  25876. /**
  25877. * Observable triggered when reset has been called and applied to the camera.
  25878. */
  25879. onRestoreStateObservable: Observable<Camera>;
  25880. /** @hidden */
  25881. _cameraRigParams: any;
  25882. /** @hidden */
  25883. _rigCameras: Camera[];
  25884. /** @hidden */
  25885. _rigPostProcess: Nullable<PostProcess>;
  25886. protected _webvrViewMatrix: Matrix;
  25887. /** @hidden */
  25888. _skipRendering: boolean;
  25889. /** @hidden */
  25890. _projectionMatrix: Matrix;
  25891. /** @hidden */
  25892. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25893. /** @hidden */
  25894. _activeMeshes: SmartArray<AbstractMesh>;
  25895. protected _globalPosition: Vector3;
  25896. /** @hidden */
  25897. _computedViewMatrix: Matrix;
  25898. private _doNotComputeProjectionMatrix;
  25899. private _transformMatrix;
  25900. private _frustumPlanes;
  25901. private _refreshFrustumPlanes;
  25902. private _storedFov;
  25903. private _stateStored;
  25904. /**
  25905. * Instantiates a new camera object.
  25906. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25907. * @see http://doc.babylonjs.com/features/cameras
  25908. * @param name Defines the name of the camera in the scene
  25909. * @param position Defines the position of the camera
  25910. * @param scene Defines the scene the camera belongs too
  25911. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25912. */
  25913. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25914. /**
  25915. * Store current camera state (fov, position, etc..)
  25916. * @returns the camera
  25917. */
  25918. storeState(): Camera;
  25919. /**
  25920. * Restores the camera state values if it has been stored. You must call storeState() first
  25921. */
  25922. protected _restoreStateValues(): boolean;
  25923. /**
  25924. * Restored camera state. You must call storeState() first.
  25925. * @returns true if restored and false otherwise
  25926. */
  25927. restoreState(): boolean;
  25928. /**
  25929. * Gets the class name of the camera.
  25930. * @returns the class name
  25931. */
  25932. getClassName(): string;
  25933. /** @hidden */
  25934. readonly _isCamera: boolean;
  25935. /**
  25936. * Gets a string representation of the camera useful for debug purpose.
  25937. * @param fullDetails Defines that a more verboe level of logging is required
  25938. * @returns the string representation
  25939. */
  25940. toString(fullDetails?: boolean): string;
  25941. /**
  25942. * Gets the current world space position of the camera.
  25943. */
  25944. readonly globalPosition: Vector3;
  25945. /**
  25946. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25947. * @returns the active meshe list
  25948. */
  25949. getActiveMeshes(): SmartArray<AbstractMesh>;
  25950. /**
  25951. * Check wether a mesh is part of the current active mesh list of the camera
  25952. * @param mesh Defines the mesh to check
  25953. * @returns true if active, false otherwise
  25954. */
  25955. isActiveMesh(mesh: Mesh): boolean;
  25956. /**
  25957. * Is this camera ready to be used/rendered
  25958. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25959. * @return true if the camera is ready
  25960. */
  25961. isReady(completeCheck?: boolean): boolean;
  25962. /** @hidden */
  25963. _initCache(): void;
  25964. /** @hidden */
  25965. _updateCache(ignoreParentClass?: boolean): void;
  25966. /** @hidden */
  25967. _isSynchronized(): boolean;
  25968. /** @hidden */
  25969. _isSynchronizedViewMatrix(): boolean;
  25970. /** @hidden */
  25971. _isSynchronizedProjectionMatrix(): boolean;
  25972. /**
  25973. * Attach the input controls to a specific dom element to get the input from.
  25974. * @param element Defines the element the controls should be listened from
  25975. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25976. */
  25977. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25978. /**
  25979. * Detach the current controls from the specified dom element.
  25980. * @param element Defines the element to stop listening the inputs from
  25981. */
  25982. detachControl(element: HTMLElement): void;
  25983. /**
  25984. * Update the camera state according to the different inputs gathered during the frame.
  25985. */
  25986. update(): void;
  25987. /** @hidden */
  25988. _checkInputs(): void;
  25989. /** @hidden */
  25990. readonly rigCameras: Camera[];
  25991. /**
  25992. * Gets the post process used by the rig cameras
  25993. */
  25994. readonly rigPostProcess: Nullable<PostProcess>;
  25995. /**
  25996. * Internal, gets the first post proces.
  25997. * @returns the first post process to be run on this camera.
  25998. */
  25999. _getFirstPostProcess(): Nullable<PostProcess>;
  26000. private _cascadePostProcessesToRigCams;
  26001. /**
  26002. * Attach a post process to the camera.
  26003. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26004. * @param postProcess The post process to attach to the camera
  26005. * @param insertAt The position of the post process in case several of them are in use in the scene
  26006. * @returns the position the post process has been inserted at
  26007. */
  26008. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26009. /**
  26010. * Detach a post process to the camera.
  26011. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26012. * @param postProcess The post process to detach from the camera
  26013. */
  26014. detachPostProcess(postProcess: PostProcess): void;
  26015. /**
  26016. * Gets the current world matrix of the camera
  26017. */
  26018. getWorldMatrix(): Matrix;
  26019. /** @hidden */
  26020. _getViewMatrix(): Matrix;
  26021. /**
  26022. * Gets the current view matrix of the camera.
  26023. * @param force forces the camera to recompute the matrix without looking at the cached state
  26024. * @returns the view matrix
  26025. */
  26026. getViewMatrix(force?: boolean): Matrix;
  26027. /**
  26028. * Freeze the projection matrix.
  26029. * It will prevent the cache check of the camera projection compute and can speed up perf
  26030. * if no parameter of the camera are meant to change
  26031. * @param projection Defines manually a projection if necessary
  26032. */
  26033. freezeProjectionMatrix(projection?: Matrix): void;
  26034. /**
  26035. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26036. */
  26037. unfreezeProjectionMatrix(): void;
  26038. /**
  26039. * Gets the current projection matrix of the camera.
  26040. * @param force forces the camera to recompute the matrix without looking at the cached state
  26041. * @returns the projection matrix
  26042. */
  26043. getProjectionMatrix(force?: boolean): Matrix;
  26044. /**
  26045. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26046. * @returns a Matrix
  26047. */
  26048. getTransformationMatrix(): Matrix;
  26049. private _updateFrustumPlanes;
  26050. /**
  26051. * Checks if a cullable object (mesh...) is in the camera frustum
  26052. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26053. * @param target The object to check
  26054. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26055. * @returns true if the object is in frustum otherwise false
  26056. */
  26057. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26058. /**
  26059. * Checks if a cullable object (mesh...) is in the camera frustum
  26060. * Unlike isInFrustum this cheks the full bounding box
  26061. * @param target The object to check
  26062. * @returns true if the object is in frustum otherwise false
  26063. */
  26064. isCompletelyInFrustum(target: ICullable): boolean;
  26065. /**
  26066. * Gets a ray in the forward direction from the camera.
  26067. * @param length Defines the length of the ray to create
  26068. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26069. * @param origin Defines the start point of the ray which defaults to the camera position
  26070. * @returns the forward ray
  26071. */
  26072. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26073. /**
  26074. * Releases resources associated with this node.
  26075. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26076. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26077. */
  26078. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26079. /** @hidden */
  26080. _isLeftCamera: boolean;
  26081. /**
  26082. * Gets the left camera of a rig setup in case of Rigged Camera
  26083. */
  26084. readonly isLeftCamera: boolean;
  26085. /** @hidden */
  26086. _isRightCamera: boolean;
  26087. /**
  26088. * Gets the right camera of a rig setup in case of Rigged Camera
  26089. */
  26090. readonly isRightCamera: boolean;
  26091. /**
  26092. * Gets the left camera of a rig setup in case of Rigged Camera
  26093. */
  26094. readonly leftCamera: Nullable<FreeCamera>;
  26095. /**
  26096. * Gets the right camera of a rig setup in case of Rigged Camera
  26097. */
  26098. readonly rightCamera: Nullable<FreeCamera>;
  26099. /**
  26100. * Gets the left camera target of a rig setup in case of Rigged Camera
  26101. * @returns the target position
  26102. */
  26103. getLeftTarget(): Nullable<Vector3>;
  26104. /**
  26105. * Gets the right camera target of a rig setup in case of Rigged Camera
  26106. * @returns the target position
  26107. */
  26108. getRightTarget(): Nullable<Vector3>;
  26109. /**
  26110. * @hidden
  26111. */
  26112. setCameraRigMode(mode: number, rigParams: any): void;
  26113. /** @hidden */
  26114. static _setStereoscopicRigMode(camera: Camera): void;
  26115. /** @hidden */
  26116. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26117. /** @hidden */
  26118. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26119. /** @hidden */
  26120. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26121. /** @hidden */
  26122. _getVRProjectionMatrix(): Matrix;
  26123. protected _updateCameraRotationMatrix(): void;
  26124. protected _updateWebVRCameraRotationMatrix(): void;
  26125. /**
  26126. * This function MUST be overwritten by the different WebVR cameras available.
  26127. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26128. * @hidden
  26129. */
  26130. _getWebVRProjectionMatrix(): Matrix;
  26131. /**
  26132. * This function MUST be overwritten by the different WebVR cameras available.
  26133. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26134. * @hidden
  26135. */
  26136. _getWebVRViewMatrix(): Matrix;
  26137. /** @hidden */
  26138. setCameraRigParameter(name: string, value: any): void;
  26139. /**
  26140. * needs to be overridden by children so sub has required properties to be copied
  26141. * @hidden
  26142. */
  26143. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26144. /**
  26145. * May need to be overridden by children
  26146. * @hidden
  26147. */
  26148. _updateRigCameras(): void;
  26149. /** @hidden */
  26150. _setupInputs(): void;
  26151. /**
  26152. * Serialiaze the camera setup to a json represention
  26153. * @returns the JSON representation
  26154. */
  26155. serialize(): any;
  26156. /**
  26157. * Clones the current camera.
  26158. * @param name The cloned camera name
  26159. * @returns the cloned camera
  26160. */
  26161. clone(name: string): Camera;
  26162. /**
  26163. * Gets the direction of the camera relative to a given local axis.
  26164. * @param localAxis Defines the reference axis to provide a relative direction.
  26165. * @return the direction
  26166. */
  26167. getDirection(localAxis: Vector3): Vector3;
  26168. /**
  26169. * Returns the current camera absolute rotation
  26170. */
  26171. readonly absoluteRotation: Quaternion;
  26172. /**
  26173. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26174. * @param localAxis Defines the reference axis to provide a relative direction.
  26175. * @param result Defines the vector to store the result in
  26176. */
  26177. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26178. /**
  26179. * Gets a camera constructor for a given camera type
  26180. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26181. * @param name The name of the camera the result will be able to instantiate
  26182. * @param scene The scene the result will construct the camera in
  26183. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26184. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26185. * @returns a factory method to construc the camera
  26186. */
  26187. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26188. /**
  26189. * Compute the world matrix of the camera.
  26190. * @returns the camera world matrix
  26191. */
  26192. computeWorldMatrix(): Matrix;
  26193. /**
  26194. * Parse a JSON and creates the camera from the parsed information
  26195. * @param parsedCamera The JSON to parse
  26196. * @param scene The scene to instantiate the camera in
  26197. * @returns the newly constructed camera
  26198. */
  26199. static Parse(parsedCamera: any, scene: Scene): Camera;
  26200. }
  26201. }
  26202. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26203. import { Nullable } from "babylonjs/types";
  26204. import { Scene } from "babylonjs/scene";
  26205. import { Vector4 } from "babylonjs/Maths/math.vector";
  26206. import { Mesh } from "babylonjs/Meshes/mesh";
  26207. /**
  26208. * Class containing static functions to help procedurally build meshes
  26209. */
  26210. export class DiscBuilder {
  26211. /**
  26212. * Creates a plane polygonal mesh. By default, this is a disc
  26213. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26214. * * 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
  26215. * * 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
  26216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26219. * @param name defines the name of the mesh
  26220. * @param options defines the options used to create the mesh
  26221. * @param scene defines the hosting scene
  26222. * @returns the plane polygonal mesh
  26223. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26224. */
  26225. static CreateDisc(name: string, options: {
  26226. radius?: number;
  26227. tessellation?: number;
  26228. arc?: number;
  26229. updatable?: boolean;
  26230. sideOrientation?: number;
  26231. frontUVs?: Vector4;
  26232. backUVs?: Vector4;
  26233. }, scene?: Nullable<Scene>): Mesh;
  26234. }
  26235. }
  26236. declare module "babylonjs/Particles/solidParticleSystem" {
  26237. import { Nullable } from "babylonjs/types";
  26238. import { Vector3 } from "babylonjs/Maths/math.vector";
  26239. import { Mesh } from "babylonjs/Meshes/mesh";
  26240. import { Scene, IDisposable } from "babylonjs/scene";
  26241. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26242. /**
  26243. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26244. *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.
  26245. * The SPS is also a particle system. It provides some methods to manage the particles.
  26246. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26247. *
  26248. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26249. */
  26250. export class SolidParticleSystem implements IDisposable {
  26251. /**
  26252. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26253. * Example : var p = SPS.particles[i];
  26254. */
  26255. particles: SolidParticle[];
  26256. /**
  26257. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26258. */
  26259. nbParticles: number;
  26260. /**
  26261. * If the particles must ever face the camera (default false). Useful for planar particles.
  26262. */
  26263. billboard: boolean;
  26264. /**
  26265. * Recompute normals when adding a shape
  26266. */
  26267. recomputeNormals: boolean;
  26268. /**
  26269. * This a counter ofr your own usage. It's not set by any SPS functions.
  26270. */
  26271. counter: number;
  26272. /**
  26273. * The SPS name. This name is also given to the underlying mesh.
  26274. */
  26275. name: string;
  26276. /**
  26277. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26278. */
  26279. mesh: Mesh;
  26280. /**
  26281. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26282. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26283. */
  26284. vars: any;
  26285. /**
  26286. * This array is populated when the SPS is set as 'pickable'.
  26287. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26288. * Each element of this array is an object `{idx: int, faceId: int}`.
  26289. * `idx` is the picked particle index in the `SPS.particles` array
  26290. * `faceId` is the picked face index counted within this particle.
  26291. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26292. */
  26293. pickedParticles: {
  26294. idx: number;
  26295. faceId: number;
  26296. }[];
  26297. /**
  26298. * This array is populated when `enableDepthSort` is set to true.
  26299. * Each element of this array is an instance of the class DepthSortedParticle.
  26300. */
  26301. depthSortedParticles: DepthSortedParticle[];
  26302. /**
  26303. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26304. * @hidden
  26305. */
  26306. _bSphereOnly: boolean;
  26307. /**
  26308. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26309. * @hidden
  26310. */
  26311. _bSphereRadiusFactor: number;
  26312. private _scene;
  26313. private _positions;
  26314. private _indices;
  26315. private _normals;
  26316. private _colors;
  26317. private _uvs;
  26318. private _indices32;
  26319. private _positions32;
  26320. private _normals32;
  26321. private _fixedNormal32;
  26322. private _colors32;
  26323. private _uvs32;
  26324. private _index;
  26325. private _updatable;
  26326. private _pickable;
  26327. private _isVisibilityBoxLocked;
  26328. private _alwaysVisible;
  26329. private _depthSort;
  26330. private _expandable;
  26331. private _shapeCounter;
  26332. private _copy;
  26333. private _color;
  26334. private _computeParticleColor;
  26335. private _computeParticleTexture;
  26336. private _computeParticleRotation;
  26337. private _computeParticleVertex;
  26338. private _computeBoundingBox;
  26339. private _depthSortParticles;
  26340. private _camera;
  26341. private _mustUnrotateFixedNormals;
  26342. private _particlesIntersect;
  26343. private _needs32Bits;
  26344. private _isNotBuilt;
  26345. private _lastParticleId;
  26346. private _idxOfId;
  26347. /**
  26348. * Creates a SPS (Solid Particle System) object.
  26349. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26350. * @param scene (Scene) is the scene in which the SPS is added.
  26351. * @param options defines the options of the sps e.g.
  26352. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26353. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26354. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26355. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26356. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26357. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26358. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26359. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26360. */
  26361. constructor(name: string, scene: Scene, options?: {
  26362. updatable?: boolean;
  26363. isPickable?: boolean;
  26364. enableDepthSort?: boolean;
  26365. particleIntersection?: boolean;
  26366. boundingSphereOnly?: boolean;
  26367. bSphereRadiusFactor?: number;
  26368. expandable?: boolean;
  26369. });
  26370. /**
  26371. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26372. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26373. * @returns the created mesh
  26374. */
  26375. buildMesh(): Mesh;
  26376. /**
  26377. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26378. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26379. * Thus the particles generated from `digest()` have their property `position` set yet.
  26380. * @param mesh ( Mesh ) is the mesh to be digested
  26381. * @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
  26382. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26383. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26384. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26385. * @returns the current SPS
  26386. */
  26387. digest(mesh: Mesh, options?: {
  26388. facetNb?: number;
  26389. number?: number;
  26390. delta?: number;
  26391. storage?: [];
  26392. }): SolidParticleSystem;
  26393. /**
  26394. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26395. * @hidden
  26396. */
  26397. private _unrotateFixedNormals;
  26398. /**
  26399. * Resets the temporary working copy particle
  26400. * @hidden
  26401. */
  26402. private _resetCopy;
  26403. /**
  26404. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26405. * @param p the current index in the positions array to be updated
  26406. * @param shape a Vector3 array, the shape geometry
  26407. * @param positions the positions array to be updated
  26408. * @param meshInd the shape indices array
  26409. * @param indices the indices array to be updated
  26410. * @param meshUV the shape uv array
  26411. * @param uvs the uv array to be updated
  26412. * @param meshCol the shape color array
  26413. * @param colors the color array to be updated
  26414. * @param meshNor the shape normals array
  26415. * @param normals the normals array to be updated
  26416. * @param idx the particle index
  26417. * @param idxInShape the particle index in its shape
  26418. * @param options the addShape() method passed options
  26419. * @hidden
  26420. */
  26421. private _meshBuilder;
  26422. /**
  26423. * Returns a shape Vector3 array from positions float array
  26424. * @param positions float array
  26425. * @returns a vector3 array
  26426. * @hidden
  26427. */
  26428. private _posToShape;
  26429. /**
  26430. * Returns a shapeUV array from a float uvs (array deep copy)
  26431. * @param uvs as a float array
  26432. * @returns a shapeUV array
  26433. * @hidden
  26434. */
  26435. private _uvsToShapeUV;
  26436. /**
  26437. * Adds a new particle object in the particles array
  26438. * @param idx particle index in particles array
  26439. * @param id particle id
  26440. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26441. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26442. * @param model particle ModelShape object
  26443. * @param shapeId model shape identifier
  26444. * @param idxInShape index of the particle in the current model
  26445. * @param bInfo model bounding info object
  26446. * @param storage target storage array, if any
  26447. * @hidden
  26448. */
  26449. private _addParticle;
  26450. /**
  26451. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26452. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26453. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26454. * @param nb (positive integer) the number of particles to be created from this model
  26455. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26456. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26457. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26458. * @returns the number of shapes in the system
  26459. */
  26460. addShape(mesh: Mesh, nb: number, options?: {
  26461. positionFunction?: any;
  26462. vertexFunction?: any;
  26463. storage?: [];
  26464. }): number;
  26465. /**
  26466. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26467. * @hidden
  26468. */
  26469. private _rebuildParticle;
  26470. /**
  26471. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26472. * @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.
  26473. * @returns the SPS.
  26474. */
  26475. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26476. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26477. * Returns an array with the removed particles.
  26478. * 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.
  26479. * The SPS can't be empty so at least one particle needs to remain in place.
  26480. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26481. * @param start index of the first particle to remove
  26482. * @param end index of the last particle to remove (included)
  26483. * @returns an array populated with the removed particles
  26484. */
  26485. removeParticles(start: number, end: number): SolidParticle[];
  26486. /**
  26487. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26488. * @param solidParticleArray an array populated with Solid Particles objects
  26489. * @returns the SPS
  26490. */
  26491. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  26492. /**
  26493. * Creates a new particle and modifies the SPS mesh geometry :
  26494. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  26495. * - calls _addParticle() to populate the particle array
  26496. * factorized code from addShape() and insertParticlesFromArray()
  26497. * @param idx particle index in the particles array
  26498. * @param i particle index in its shape
  26499. * @param modelShape particle ModelShape object
  26500. * @param shape shape vertex array
  26501. * @param meshInd shape indices array
  26502. * @param meshUV shape uv array
  26503. * @param meshCol shape color array
  26504. * @param meshNor shape normals array
  26505. * @param bbInfo shape bounding info
  26506. * @param storage target particle storage
  26507. * @options addShape() passed options
  26508. * @hidden
  26509. */
  26510. private _insertNewParticle;
  26511. /**
  26512. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26513. * This method calls `updateParticle()` for each particle of the SPS.
  26514. * For an animated SPS, it is usually called within the render loop.
  26515. * 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.
  26516. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26517. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26518. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26519. * @returns the SPS.
  26520. */
  26521. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26522. /**
  26523. * Disposes the SPS.
  26524. */
  26525. dispose(): void;
  26526. /**
  26527. * Returns a SolidParticle object from its identifier : particle.id
  26528. * @param id (integer) the particle Id
  26529. * @returns the searched particle or null if not found in the SPS.
  26530. */
  26531. getParticleById(id: number): Nullable<SolidParticle>;
  26532. /**
  26533. * Returns a new array populated with the particles having the passed shapeId.
  26534. * @param shapeId (integer) the shape identifier
  26535. * @returns a new solid particle array
  26536. */
  26537. getParticlesByShapeId(shapeId: number): SolidParticle[];
  26538. /**
  26539. * Populates the passed array "ref" with the particles having the passed shapeId.
  26540. * @param shapeId the shape identifier
  26541. * @returns the SPS
  26542. * @param ref
  26543. */
  26544. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  26545. /**
  26546. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26547. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26548. * @returns the SPS.
  26549. */
  26550. refreshVisibleSize(): SolidParticleSystem;
  26551. /**
  26552. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26553. * @param size the size (float) of the visibility box
  26554. * note : this doesn't lock the SPS mesh bounding box.
  26555. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26556. */
  26557. setVisibilityBox(size: number): void;
  26558. /**
  26559. * Gets whether the SPS as always visible or not
  26560. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26561. */
  26562. /**
  26563. * Sets the SPS as always visible or not
  26564. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26565. */
  26566. isAlwaysVisible: boolean;
  26567. /**
  26568. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26569. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26570. */
  26571. /**
  26572. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26573. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26574. */
  26575. isVisibilityBoxLocked: boolean;
  26576. /**
  26577. * Tells to `setParticles()` to compute the particle rotations or not.
  26578. * Default value : true. The SPS is faster when it's set to false.
  26579. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26580. */
  26581. /**
  26582. * Gets if `setParticles()` computes the particle rotations or not.
  26583. * Default value : true. The SPS is faster when it's set to false.
  26584. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26585. */
  26586. computeParticleRotation: boolean;
  26587. /**
  26588. * Tells to `setParticles()` to compute the particle colors or not.
  26589. * Default value : true. The SPS is faster when it's set to false.
  26590. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26591. */
  26592. /**
  26593. * Gets if `setParticles()` computes the particle colors or not.
  26594. * Default value : true. The SPS is faster when it's set to false.
  26595. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26596. */
  26597. computeParticleColor: boolean;
  26598. /**
  26599. * Gets if `setParticles()` computes the particle textures or not.
  26600. * Default value : true. The SPS is faster when it's set to false.
  26601. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26602. */
  26603. computeParticleTexture: boolean;
  26604. /**
  26605. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26606. * Default value : false. The SPS is faster when it's set to false.
  26607. * Note : the particle custom vertex positions aren't stored values.
  26608. */
  26609. /**
  26610. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26611. * Default value : false. The SPS is faster when it's set to false.
  26612. * Note : the particle custom vertex positions aren't stored values.
  26613. */
  26614. computeParticleVertex: boolean;
  26615. /**
  26616. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26617. */
  26618. /**
  26619. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26620. */
  26621. computeBoundingBox: boolean;
  26622. /**
  26623. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26624. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26625. * Default : `true`
  26626. */
  26627. /**
  26628. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26629. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26630. * Default : `true`
  26631. */
  26632. depthSortParticles: boolean;
  26633. /**
  26634. * Gets if the SPS is created as expandable at construction time.
  26635. * Default : `false`
  26636. */
  26637. readonly expandable: boolean;
  26638. /**
  26639. * This function does nothing. It may be overwritten to set all the particle first values.
  26640. * The SPS doesn't call this function, you may have to call it by your own.
  26641. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26642. */
  26643. initParticles(): void;
  26644. /**
  26645. * This function does nothing. It may be overwritten to recycle a particle.
  26646. * The SPS doesn't call this function, you may have to call it by your own.
  26647. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26648. * @param particle The particle to recycle
  26649. * @returns the recycled particle
  26650. */
  26651. recycleParticle(particle: SolidParticle): SolidParticle;
  26652. /**
  26653. * Updates a particle : this function should be overwritten by the user.
  26654. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26655. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26656. * @example : just set a particle position or velocity and recycle conditions
  26657. * @param particle The particle to update
  26658. * @returns the updated particle
  26659. */
  26660. updateParticle(particle: SolidParticle): SolidParticle;
  26661. /**
  26662. * Updates a vertex of a particle : it can be overwritten by the user.
  26663. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26664. * @param particle the current particle
  26665. * @param vertex the current index of the current particle
  26666. * @param pt the index of the current vertex in the particle shape
  26667. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26668. * @example : just set a vertex particle position
  26669. * @returns the updated vertex
  26670. */
  26671. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26672. /**
  26673. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26674. * This does nothing and may be overwritten by the user.
  26675. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26676. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26677. * @param update the boolean update value actually passed to setParticles()
  26678. */
  26679. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26680. /**
  26681. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26682. * This will be passed three parameters.
  26683. * This does nothing and may be overwritten by the user.
  26684. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26685. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26686. * @param update the boolean update value actually passed to setParticles()
  26687. */
  26688. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26689. }
  26690. }
  26691. declare module "babylonjs/Particles/solidParticle" {
  26692. import { Nullable } from "babylonjs/types";
  26693. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26694. import { Color4 } from "babylonjs/Maths/math.color";
  26695. import { Mesh } from "babylonjs/Meshes/mesh";
  26696. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26697. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26698. import { Plane } from "babylonjs/Maths/math.plane";
  26699. /**
  26700. * Represents one particle of a solid particle system.
  26701. */
  26702. export class SolidParticle {
  26703. /**
  26704. * particle global index
  26705. */
  26706. idx: number;
  26707. /**
  26708. * particle identifier
  26709. */
  26710. id: number;
  26711. /**
  26712. * The color of the particle
  26713. */
  26714. color: Nullable<Color4>;
  26715. /**
  26716. * The world space position of the particle.
  26717. */
  26718. position: Vector3;
  26719. /**
  26720. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26721. */
  26722. rotation: Vector3;
  26723. /**
  26724. * The world space rotation quaternion of the particle.
  26725. */
  26726. rotationQuaternion: Nullable<Quaternion>;
  26727. /**
  26728. * The scaling of the particle.
  26729. */
  26730. scaling: Vector3;
  26731. /**
  26732. * The uvs of the particle.
  26733. */
  26734. uvs: Vector4;
  26735. /**
  26736. * The current speed of the particle.
  26737. */
  26738. velocity: Vector3;
  26739. /**
  26740. * The pivot point in the particle local space.
  26741. */
  26742. pivot: Vector3;
  26743. /**
  26744. * Must the particle be translated from its pivot point in its local space ?
  26745. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26746. * Default : false
  26747. */
  26748. translateFromPivot: boolean;
  26749. /**
  26750. * Is the particle active or not ?
  26751. */
  26752. alive: boolean;
  26753. /**
  26754. * Is the particle visible or not ?
  26755. */
  26756. isVisible: boolean;
  26757. /**
  26758. * Index of this particle in the global "positions" array (Internal use)
  26759. * @hidden
  26760. */
  26761. _pos: number;
  26762. /**
  26763. * @hidden Index of this particle in the global "indices" array (Internal use)
  26764. */
  26765. _ind: number;
  26766. /**
  26767. * @hidden ModelShape of this particle (Internal use)
  26768. */
  26769. _model: ModelShape;
  26770. /**
  26771. * ModelShape id of this particle
  26772. */
  26773. shapeId: number;
  26774. /**
  26775. * Index of the particle in its shape id
  26776. */
  26777. idxInShape: number;
  26778. /**
  26779. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26780. */
  26781. _modelBoundingInfo: BoundingInfo;
  26782. /**
  26783. * @hidden Particle BoundingInfo object (Internal use)
  26784. */
  26785. _boundingInfo: BoundingInfo;
  26786. /**
  26787. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26788. */
  26789. _sps: SolidParticleSystem;
  26790. /**
  26791. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26792. */
  26793. _stillInvisible: boolean;
  26794. /**
  26795. * @hidden Last computed particle rotation matrix
  26796. */
  26797. _rotationMatrix: number[];
  26798. /**
  26799. * Parent particle Id, if any.
  26800. * Default null.
  26801. */
  26802. parentId: Nullable<number>;
  26803. /**
  26804. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26805. * The possible values are :
  26806. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26807. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26808. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26809. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26810. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26811. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26812. * */
  26813. cullingStrategy: number;
  26814. /**
  26815. * @hidden Internal global position in the SPS.
  26816. */
  26817. _globalPosition: Vector3;
  26818. /**
  26819. * Creates a Solid Particle object.
  26820. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26821. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  26822. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  26823. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26824. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26825. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26826. * @param shapeId (integer) is the model shape identifier in the SPS.
  26827. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26828. * @param sps defines the sps it is associated to
  26829. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26830. */
  26831. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26832. /**
  26833. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  26834. * @param target the particle target
  26835. * @returns the current particle
  26836. */
  26837. copyToRef(target: SolidParticle): SolidParticle;
  26838. /**
  26839. * Legacy support, changed scale to scaling
  26840. */
  26841. /**
  26842. * Legacy support, changed scale to scaling
  26843. */
  26844. scale: Vector3;
  26845. /**
  26846. * Legacy support, changed quaternion to rotationQuaternion
  26847. */
  26848. /**
  26849. * Legacy support, changed quaternion to rotationQuaternion
  26850. */
  26851. quaternion: Nullable<Quaternion>;
  26852. /**
  26853. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26854. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26855. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26856. * @returns true if it intersects
  26857. */
  26858. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26859. /**
  26860. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26861. * A particle is in the frustum if its bounding box intersects the frustum
  26862. * @param frustumPlanes defines the frustum to test
  26863. * @returns true if the particle is in the frustum planes
  26864. */
  26865. isInFrustum(frustumPlanes: Plane[]): boolean;
  26866. /**
  26867. * get the rotation matrix of the particle
  26868. * @hidden
  26869. */
  26870. getRotationMatrix(m: Matrix): void;
  26871. }
  26872. /**
  26873. * Represents the shape of the model used by one particle of a solid particle system.
  26874. * SPS internal tool, don't use it manually.
  26875. */
  26876. export class ModelShape {
  26877. /**
  26878. * The shape id
  26879. * @hidden
  26880. */
  26881. shapeID: number;
  26882. /**
  26883. * flat array of model positions (internal use)
  26884. * @hidden
  26885. */
  26886. _shape: Vector3[];
  26887. /**
  26888. * flat array of model UVs (internal use)
  26889. * @hidden
  26890. */
  26891. _shapeUV: number[];
  26892. /**
  26893. * color array of the model
  26894. * @hidden
  26895. */
  26896. _shapeColors: number[];
  26897. /**
  26898. * indices array of the model
  26899. * @hidden
  26900. */
  26901. _indices: number[];
  26902. /**
  26903. * normals array of the model
  26904. * @hidden
  26905. */
  26906. _normals: number[];
  26907. /**
  26908. * length of the shape in the model indices array (internal use)
  26909. * @hidden
  26910. */
  26911. _indicesLength: number;
  26912. /**
  26913. * Custom position function (internal use)
  26914. * @hidden
  26915. */
  26916. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26917. /**
  26918. * Custom vertex function (internal use)
  26919. * @hidden
  26920. */
  26921. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26922. /**
  26923. * 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.
  26924. * SPS internal tool, don't use it manually.
  26925. * @hidden
  26926. */
  26927. 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>);
  26928. }
  26929. /**
  26930. * Represents a Depth Sorted Particle in the solid particle system.
  26931. */
  26932. export class DepthSortedParticle {
  26933. /**
  26934. * Index of the particle in the "indices" array
  26935. */
  26936. ind: number;
  26937. /**
  26938. * Length of the particle shape in the "indices" array
  26939. */
  26940. indicesLength: number;
  26941. /**
  26942. * Squared distance from the particle to the camera
  26943. */
  26944. sqDistance: number;
  26945. }
  26946. }
  26947. declare module "babylonjs/Collisions/meshCollisionData" {
  26948. import { Collider } from "babylonjs/Collisions/collider";
  26949. import { Vector3 } from "babylonjs/Maths/math.vector";
  26950. import { Nullable } from "babylonjs/types";
  26951. import { Observer } from "babylonjs/Misc/observable";
  26952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26953. /**
  26954. * @hidden
  26955. */
  26956. export class _MeshCollisionData {
  26957. _checkCollisions: boolean;
  26958. _collisionMask: number;
  26959. _collisionGroup: number;
  26960. _collider: Nullable<Collider>;
  26961. _oldPositionForCollisions: Vector3;
  26962. _diffPositionForCollisions: Vector3;
  26963. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26964. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26965. }
  26966. }
  26967. declare module "babylonjs/Meshes/abstractMesh" {
  26968. import { Observable } from "babylonjs/Misc/observable";
  26969. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26970. import { Camera } from "babylonjs/Cameras/camera";
  26971. import { Scene, IDisposable } from "babylonjs/scene";
  26972. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26973. import { Node } from "babylonjs/node";
  26974. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26975. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26976. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26977. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26978. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26979. import { Material } from "babylonjs/Materials/material";
  26980. import { Light } from "babylonjs/Lights/light";
  26981. import { Skeleton } from "babylonjs/Bones/skeleton";
  26982. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26983. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26984. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26985. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26986. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26987. import { Plane } from "babylonjs/Maths/math.plane";
  26988. import { Ray } from "babylonjs/Culling/ray";
  26989. import { Collider } from "babylonjs/Collisions/collider";
  26990. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26991. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26992. /** @hidden */
  26993. class _FacetDataStorage {
  26994. facetPositions: Vector3[];
  26995. facetNormals: Vector3[];
  26996. facetPartitioning: number[][];
  26997. facetNb: number;
  26998. partitioningSubdivisions: number;
  26999. partitioningBBoxRatio: number;
  27000. facetDataEnabled: boolean;
  27001. facetParameters: any;
  27002. bbSize: Vector3;
  27003. subDiv: {
  27004. max: number;
  27005. X: number;
  27006. Y: number;
  27007. Z: number;
  27008. };
  27009. facetDepthSort: boolean;
  27010. facetDepthSortEnabled: boolean;
  27011. depthSortedIndices: IndicesArray;
  27012. depthSortedFacets: {
  27013. ind: number;
  27014. sqDistance: number;
  27015. }[];
  27016. facetDepthSortFunction: (f1: {
  27017. ind: number;
  27018. sqDistance: number;
  27019. }, f2: {
  27020. ind: number;
  27021. sqDistance: number;
  27022. }) => number;
  27023. facetDepthSortFrom: Vector3;
  27024. facetDepthSortOrigin: Vector3;
  27025. invertedMatrix: Matrix;
  27026. }
  27027. /**
  27028. * @hidden
  27029. **/
  27030. class _InternalAbstractMeshDataInfo {
  27031. _hasVertexAlpha: boolean;
  27032. _useVertexColors: boolean;
  27033. _numBoneInfluencers: number;
  27034. _applyFog: boolean;
  27035. _receiveShadows: boolean;
  27036. _facetData: _FacetDataStorage;
  27037. _visibility: number;
  27038. _skeleton: Nullable<Skeleton>;
  27039. _layerMask: number;
  27040. _computeBonesUsingShaders: boolean;
  27041. _isActive: boolean;
  27042. _onlyForInstances: boolean;
  27043. _isActiveIntermediate: boolean;
  27044. _onlyForInstancesIntermediate: boolean;
  27045. _actAsRegularMesh: boolean;
  27046. }
  27047. /**
  27048. * Class used to store all common mesh properties
  27049. */
  27050. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27051. /** No occlusion */
  27052. static OCCLUSION_TYPE_NONE: number;
  27053. /** Occlusion set to optimisitic */
  27054. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27055. /** Occlusion set to strict */
  27056. static OCCLUSION_TYPE_STRICT: number;
  27057. /** Use an accurante occlusion algorithm */
  27058. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27059. /** Use a conservative occlusion algorithm */
  27060. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27061. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27062. * Test order :
  27063. * Is the bounding sphere outside the frustum ?
  27064. * If not, are the bounding box vertices outside the frustum ?
  27065. * It not, then the cullable object is in the frustum.
  27066. */
  27067. static readonly CULLINGSTRATEGY_STANDARD: number;
  27068. /** Culling strategy : Bounding Sphere Only.
  27069. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27070. * It's also less accurate than the standard because some not visible objects can still be selected.
  27071. * Test : is the bounding sphere outside the frustum ?
  27072. * If not, then the cullable object is in the frustum.
  27073. */
  27074. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27075. /** Culling strategy : Optimistic Inclusion.
  27076. * This in an inclusion test first, then the standard exclusion test.
  27077. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27078. * 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.
  27079. * Anyway, it's as accurate as the standard strategy.
  27080. * Test :
  27081. * Is the cullable object bounding sphere center in the frustum ?
  27082. * If not, apply the default culling strategy.
  27083. */
  27084. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27085. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27086. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27087. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27088. * 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.
  27089. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27090. * Test :
  27091. * Is the cullable object bounding sphere center in the frustum ?
  27092. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27093. */
  27094. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27095. /**
  27096. * No billboard
  27097. */
  27098. static readonly BILLBOARDMODE_NONE: number;
  27099. /** Billboard on X axis */
  27100. static readonly BILLBOARDMODE_X: number;
  27101. /** Billboard on Y axis */
  27102. static readonly BILLBOARDMODE_Y: number;
  27103. /** Billboard on Z axis */
  27104. static readonly BILLBOARDMODE_Z: number;
  27105. /** Billboard on all axes */
  27106. static readonly BILLBOARDMODE_ALL: number;
  27107. /** Billboard on using position instead of orientation */
  27108. static readonly BILLBOARDMODE_USE_POSITION: number;
  27109. /** @hidden */
  27110. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27111. /**
  27112. * The culling strategy to use to check whether the mesh must be rendered or not.
  27113. * This value can be changed at any time and will be used on the next render mesh selection.
  27114. * The possible values are :
  27115. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27116. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27117. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27118. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27119. * Please read each static variable documentation to get details about the culling process.
  27120. * */
  27121. cullingStrategy: number;
  27122. /**
  27123. * Gets the number of facets in the mesh
  27124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27125. */
  27126. readonly facetNb: number;
  27127. /**
  27128. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27129. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27130. */
  27131. partitioningSubdivisions: number;
  27132. /**
  27133. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27134. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27136. */
  27137. partitioningBBoxRatio: number;
  27138. /**
  27139. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27140. * Works only for updatable meshes.
  27141. * Doesn't work with multi-materials
  27142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27143. */
  27144. mustDepthSortFacets: boolean;
  27145. /**
  27146. * The location (Vector3) where the facet depth sort must be computed from.
  27147. * By default, the active camera position.
  27148. * Used only when facet depth sort is enabled
  27149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27150. */
  27151. facetDepthSortFrom: Vector3;
  27152. /**
  27153. * gets a boolean indicating if facetData is enabled
  27154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27155. */
  27156. readonly isFacetDataEnabled: boolean;
  27157. /** @hidden */
  27158. _updateNonUniformScalingState(value: boolean): boolean;
  27159. /**
  27160. * An event triggered when this mesh collides with another one
  27161. */
  27162. onCollideObservable: Observable<AbstractMesh>;
  27163. /** Set a function to call when this mesh collides with another one */
  27164. onCollide: () => void;
  27165. /**
  27166. * An event triggered when the collision's position changes
  27167. */
  27168. onCollisionPositionChangeObservable: Observable<Vector3>;
  27169. /** Set a function to call when the collision's position changes */
  27170. onCollisionPositionChange: () => void;
  27171. /**
  27172. * An event triggered when material is changed
  27173. */
  27174. onMaterialChangedObservable: Observable<AbstractMesh>;
  27175. /**
  27176. * Gets or sets the orientation for POV movement & rotation
  27177. */
  27178. definedFacingForward: boolean;
  27179. /** @hidden */
  27180. _occlusionQuery: Nullable<WebGLQuery>;
  27181. /** @hidden */
  27182. _renderingGroup: Nullable<RenderingGroup>;
  27183. /**
  27184. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27185. */
  27186. /**
  27187. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27188. */
  27189. visibility: number;
  27190. /** Gets or sets the alpha index used to sort transparent meshes
  27191. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27192. */
  27193. alphaIndex: number;
  27194. /**
  27195. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27196. */
  27197. isVisible: boolean;
  27198. /**
  27199. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27200. */
  27201. isPickable: boolean;
  27202. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27203. showSubMeshesBoundingBox: boolean;
  27204. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27205. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27206. */
  27207. isBlocker: boolean;
  27208. /**
  27209. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27210. */
  27211. enablePointerMoveEvents: boolean;
  27212. /**
  27213. * Specifies the rendering group id for this mesh (0 by default)
  27214. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27215. */
  27216. renderingGroupId: number;
  27217. private _material;
  27218. /** Gets or sets current material */
  27219. material: Nullable<Material>;
  27220. /**
  27221. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27222. * @see http://doc.babylonjs.com/babylon101/shadows
  27223. */
  27224. receiveShadows: boolean;
  27225. /** Defines color to use when rendering outline */
  27226. outlineColor: Color3;
  27227. /** Define width to use when rendering outline */
  27228. outlineWidth: number;
  27229. /** Defines color to use when rendering overlay */
  27230. overlayColor: Color3;
  27231. /** Defines alpha to use when rendering overlay */
  27232. overlayAlpha: number;
  27233. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27234. hasVertexAlpha: boolean;
  27235. /** 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) */
  27236. useVertexColors: boolean;
  27237. /**
  27238. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27239. */
  27240. computeBonesUsingShaders: boolean;
  27241. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27242. numBoneInfluencers: number;
  27243. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27244. applyFog: boolean;
  27245. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27246. useOctreeForRenderingSelection: boolean;
  27247. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27248. useOctreeForPicking: boolean;
  27249. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27250. useOctreeForCollisions: boolean;
  27251. /**
  27252. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27253. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27254. */
  27255. layerMask: number;
  27256. /**
  27257. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27258. */
  27259. alwaysSelectAsActiveMesh: boolean;
  27260. /**
  27261. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27262. */
  27263. doNotSyncBoundingInfo: boolean;
  27264. /**
  27265. * Gets or sets the current action manager
  27266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27267. */
  27268. actionManager: Nullable<AbstractActionManager>;
  27269. private _meshCollisionData;
  27270. /**
  27271. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27272. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27273. */
  27274. ellipsoid: Vector3;
  27275. /**
  27276. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27277. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27278. */
  27279. ellipsoidOffset: Vector3;
  27280. /**
  27281. * Gets or sets a collision mask used to mask collisions (default is -1).
  27282. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27283. */
  27284. collisionMask: number;
  27285. /**
  27286. * Gets or sets the current collision group mask (-1 by default).
  27287. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27288. */
  27289. collisionGroup: number;
  27290. /**
  27291. * Defines edge width used when edgesRenderer is enabled
  27292. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27293. */
  27294. edgesWidth: number;
  27295. /**
  27296. * Defines edge color used when edgesRenderer is enabled
  27297. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27298. */
  27299. edgesColor: Color4;
  27300. /** @hidden */
  27301. _edgesRenderer: Nullable<IEdgesRenderer>;
  27302. /** @hidden */
  27303. _masterMesh: Nullable<AbstractMesh>;
  27304. /** @hidden */
  27305. _boundingInfo: Nullable<BoundingInfo>;
  27306. /** @hidden */
  27307. _renderId: number;
  27308. /**
  27309. * Gets or sets the list of subMeshes
  27310. * @see http://doc.babylonjs.com/how_to/multi_materials
  27311. */
  27312. subMeshes: SubMesh[];
  27313. /** @hidden */
  27314. _intersectionsInProgress: AbstractMesh[];
  27315. /** @hidden */
  27316. _unIndexed: boolean;
  27317. /** @hidden */
  27318. _lightSources: Light[];
  27319. /** Gets the list of lights affecting that mesh */
  27320. readonly lightSources: Light[];
  27321. /** @hidden */
  27322. readonly _positions: Nullable<Vector3[]>;
  27323. /** @hidden */
  27324. _waitingData: {
  27325. lods: Nullable<any>;
  27326. actions: Nullable<any>;
  27327. freezeWorldMatrix: Nullable<boolean>;
  27328. };
  27329. /** @hidden */
  27330. _bonesTransformMatrices: Nullable<Float32Array>;
  27331. /** @hidden */
  27332. _transformMatrixTexture: Nullable<RawTexture>;
  27333. /**
  27334. * Gets or sets a skeleton to apply skining transformations
  27335. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27336. */
  27337. skeleton: Nullable<Skeleton>;
  27338. /**
  27339. * An event triggered when the mesh is rebuilt.
  27340. */
  27341. onRebuildObservable: Observable<AbstractMesh>;
  27342. /**
  27343. * Creates a new AbstractMesh
  27344. * @param name defines the name of the mesh
  27345. * @param scene defines the hosting scene
  27346. */
  27347. constructor(name: string, scene?: Nullable<Scene>);
  27348. /**
  27349. * Returns the string "AbstractMesh"
  27350. * @returns "AbstractMesh"
  27351. */
  27352. getClassName(): string;
  27353. /**
  27354. * Gets a string representation of the current mesh
  27355. * @param fullDetails defines a boolean indicating if full details must be included
  27356. * @returns a string representation of the current mesh
  27357. */
  27358. toString(fullDetails?: boolean): string;
  27359. /**
  27360. * @hidden
  27361. */
  27362. protected _getEffectiveParent(): Nullable<Node>;
  27363. /** @hidden */
  27364. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27365. /** @hidden */
  27366. _rebuild(): void;
  27367. /** @hidden */
  27368. _resyncLightSources(): void;
  27369. /** @hidden */
  27370. _resyncLighSource(light: Light): void;
  27371. /** @hidden */
  27372. _unBindEffect(): void;
  27373. /** @hidden */
  27374. _removeLightSource(light: Light, dispose: boolean): void;
  27375. private _markSubMeshesAsDirty;
  27376. /** @hidden */
  27377. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27378. /** @hidden */
  27379. _markSubMeshesAsAttributesDirty(): void;
  27380. /** @hidden */
  27381. _markSubMeshesAsMiscDirty(): void;
  27382. /**
  27383. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27384. */
  27385. scaling: Vector3;
  27386. /**
  27387. * Returns true if the mesh is blocked. Implemented by child classes
  27388. */
  27389. readonly isBlocked: boolean;
  27390. /**
  27391. * Returns the mesh itself by default. Implemented by child classes
  27392. * @param camera defines the camera to use to pick the right LOD level
  27393. * @returns the currentAbstractMesh
  27394. */
  27395. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27396. /**
  27397. * Returns 0 by default. Implemented by child classes
  27398. * @returns an integer
  27399. */
  27400. getTotalVertices(): number;
  27401. /**
  27402. * Returns a positive integer : the total number of indices in this mesh geometry.
  27403. * @returns the numner of indices or zero if the mesh has no geometry.
  27404. */
  27405. getTotalIndices(): number;
  27406. /**
  27407. * Returns null by default. Implemented by child classes
  27408. * @returns null
  27409. */
  27410. getIndices(): Nullable<IndicesArray>;
  27411. /**
  27412. * Returns the array of the requested vertex data kind. Implemented by child classes
  27413. * @param kind defines the vertex data kind to use
  27414. * @returns null
  27415. */
  27416. getVerticesData(kind: string): Nullable<FloatArray>;
  27417. /**
  27418. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27419. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27420. * Note that a new underlying VertexBuffer object is created each call.
  27421. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27422. * @param kind defines vertex data kind:
  27423. * * VertexBuffer.PositionKind
  27424. * * VertexBuffer.UVKind
  27425. * * VertexBuffer.UV2Kind
  27426. * * VertexBuffer.UV3Kind
  27427. * * VertexBuffer.UV4Kind
  27428. * * VertexBuffer.UV5Kind
  27429. * * VertexBuffer.UV6Kind
  27430. * * VertexBuffer.ColorKind
  27431. * * VertexBuffer.MatricesIndicesKind
  27432. * * VertexBuffer.MatricesIndicesExtraKind
  27433. * * VertexBuffer.MatricesWeightsKind
  27434. * * VertexBuffer.MatricesWeightsExtraKind
  27435. * @param data defines the data source
  27436. * @param updatable defines if the data must be flagged as updatable (or static)
  27437. * @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
  27438. * @returns the current mesh
  27439. */
  27440. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27441. /**
  27442. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27443. * If the mesh has no geometry, it is simply returned as it is.
  27444. * @param kind defines vertex data kind:
  27445. * * VertexBuffer.PositionKind
  27446. * * VertexBuffer.UVKind
  27447. * * VertexBuffer.UV2Kind
  27448. * * VertexBuffer.UV3Kind
  27449. * * VertexBuffer.UV4Kind
  27450. * * VertexBuffer.UV5Kind
  27451. * * VertexBuffer.UV6Kind
  27452. * * VertexBuffer.ColorKind
  27453. * * VertexBuffer.MatricesIndicesKind
  27454. * * VertexBuffer.MatricesIndicesExtraKind
  27455. * * VertexBuffer.MatricesWeightsKind
  27456. * * VertexBuffer.MatricesWeightsExtraKind
  27457. * @param data defines the data source
  27458. * @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
  27459. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27460. * @returns the current mesh
  27461. */
  27462. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27463. /**
  27464. * Sets the mesh indices,
  27465. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27466. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27467. * @param totalVertices Defines the total number of vertices
  27468. * @returns the current mesh
  27469. */
  27470. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27471. /**
  27472. * Gets a boolean indicating if specific vertex data is present
  27473. * @param kind defines the vertex data kind to use
  27474. * @returns true is data kind is present
  27475. */
  27476. isVerticesDataPresent(kind: string): boolean;
  27477. /**
  27478. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27479. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27480. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27481. * @returns a BoundingInfo
  27482. */
  27483. getBoundingInfo(): BoundingInfo;
  27484. /**
  27485. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27486. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27487. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27488. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27489. * @returns the current mesh
  27490. */
  27491. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27492. /**
  27493. * Overwrite the current bounding info
  27494. * @param boundingInfo defines the new bounding info
  27495. * @returns the current mesh
  27496. */
  27497. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27498. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27499. readonly useBones: boolean;
  27500. /** @hidden */
  27501. _preActivate(): void;
  27502. /** @hidden */
  27503. _preActivateForIntermediateRendering(renderId: number): void;
  27504. /** @hidden */
  27505. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27506. /** @hidden */
  27507. _postActivate(): void;
  27508. /** @hidden */
  27509. _freeze(): void;
  27510. /** @hidden */
  27511. _unFreeze(): void;
  27512. /**
  27513. * Gets the current world matrix
  27514. * @returns a Matrix
  27515. */
  27516. getWorldMatrix(): Matrix;
  27517. /** @hidden */
  27518. _getWorldMatrixDeterminant(): number;
  27519. /**
  27520. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27521. */
  27522. readonly isAnInstance: boolean;
  27523. /**
  27524. * Gets a boolean indicating if this mesh has instances
  27525. */
  27526. readonly hasInstances: boolean;
  27527. /**
  27528. * Perform relative position change from the point of view of behind the front of the mesh.
  27529. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27530. * Supports definition of mesh facing forward or backward
  27531. * @param amountRight defines the distance on the right axis
  27532. * @param amountUp defines the distance on the up axis
  27533. * @param amountForward defines the distance on the forward axis
  27534. * @returns the current mesh
  27535. */
  27536. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27537. /**
  27538. * Calculate relative position change from the point of view of behind the front of the mesh.
  27539. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27540. * Supports definition of mesh facing forward or backward
  27541. * @param amountRight defines the distance on the right axis
  27542. * @param amountUp defines the distance on the up axis
  27543. * @param amountForward defines the distance on the forward axis
  27544. * @returns the new displacement vector
  27545. */
  27546. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27547. /**
  27548. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27549. * Supports definition of mesh facing forward or backward
  27550. * @param flipBack defines the flip
  27551. * @param twirlClockwise defines the twirl
  27552. * @param tiltRight defines the tilt
  27553. * @returns the current mesh
  27554. */
  27555. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27556. /**
  27557. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27558. * Supports definition of mesh facing forward or backward.
  27559. * @param flipBack defines the flip
  27560. * @param twirlClockwise defines the twirl
  27561. * @param tiltRight defines the tilt
  27562. * @returns the new rotation vector
  27563. */
  27564. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27565. /**
  27566. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27567. * This means the mesh underlying bounding box and sphere are recomputed.
  27568. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27569. * @returns the current mesh
  27570. */
  27571. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27572. /** @hidden */
  27573. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27574. /** @hidden */
  27575. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27576. /** @hidden */
  27577. _updateBoundingInfo(): AbstractMesh;
  27578. /** @hidden */
  27579. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27580. /** @hidden */
  27581. protected _afterComputeWorldMatrix(): void;
  27582. /** @hidden */
  27583. readonly _effectiveMesh: AbstractMesh;
  27584. /**
  27585. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27586. * A mesh is in the frustum if its bounding box intersects the frustum
  27587. * @param frustumPlanes defines the frustum to test
  27588. * @returns true if the mesh is in the frustum planes
  27589. */
  27590. isInFrustum(frustumPlanes: Plane[]): boolean;
  27591. /**
  27592. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27593. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27594. * @param frustumPlanes defines the frustum to test
  27595. * @returns true if the mesh is completely in the frustum planes
  27596. */
  27597. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27598. /**
  27599. * True if the mesh intersects another mesh or a SolidParticle object
  27600. * @param mesh defines a target mesh or SolidParticle to test
  27601. * @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)
  27602. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27603. * @returns true if there is an intersection
  27604. */
  27605. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27606. /**
  27607. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27608. * @param point defines the point to test
  27609. * @returns true if there is an intersection
  27610. */
  27611. intersectsPoint(point: Vector3): boolean;
  27612. /**
  27613. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27614. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27615. */
  27616. checkCollisions: boolean;
  27617. /**
  27618. * Gets Collider object used to compute collisions (not physics)
  27619. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27620. */
  27621. readonly collider: Nullable<Collider>;
  27622. /**
  27623. * Move the mesh using collision engine
  27624. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27625. * @param displacement defines the requested displacement vector
  27626. * @returns the current mesh
  27627. */
  27628. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27629. private _onCollisionPositionChange;
  27630. /** @hidden */
  27631. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27632. /** @hidden */
  27633. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27634. /** @hidden */
  27635. _checkCollision(collider: Collider): AbstractMesh;
  27636. /** @hidden */
  27637. _generatePointsArray(): boolean;
  27638. /**
  27639. * Checks if the passed Ray intersects with the mesh
  27640. * @param ray defines the ray to use
  27641. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27642. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27643. * @returns the picking info
  27644. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27645. */
  27646. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27647. /**
  27648. * Clones the current mesh
  27649. * @param name defines the mesh name
  27650. * @param newParent defines the new mesh parent
  27651. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27652. * @returns the new mesh
  27653. */
  27654. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27655. /**
  27656. * Disposes all the submeshes of the current meshnp
  27657. * @returns the current mesh
  27658. */
  27659. releaseSubMeshes(): AbstractMesh;
  27660. /**
  27661. * Releases resources associated with this abstract mesh.
  27662. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27663. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27664. */
  27665. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27666. /**
  27667. * Adds the passed mesh as a child to the current mesh
  27668. * @param mesh defines the child mesh
  27669. * @returns the current mesh
  27670. */
  27671. addChild(mesh: AbstractMesh): AbstractMesh;
  27672. /**
  27673. * Removes the passed mesh from the current mesh children list
  27674. * @param mesh defines the child mesh
  27675. * @returns the current mesh
  27676. */
  27677. removeChild(mesh: AbstractMesh): AbstractMesh;
  27678. /** @hidden */
  27679. private _initFacetData;
  27680. /**
  27681. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27682. * This method can be called within the render loop.
  27683. * 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
  27684. * @returns the current mesh
  27685. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27686. */
  27687. updateFacetData(): AbstractMesh;
  27688. /**
  27689. * Returns the facetLocalNormals array.
  27690. * The normals are expressed in the mesh local spac
  27691. * @returns an array of Vector3
  27692. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27693. */
  27694. getFacetLocalNormals(): Vector3[];
  27695. /**
  27696. * Returns the facetLocalPositions array.
  27697. * The facet positions are expressed in the mesh local space
  27698. * @returns an array of Vector3
  27699. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27700. */
  27701. getFacetLocalPositions(): Vector3[];
  27702. /**
  27703. * Returns the facetLocalPartioning array
  27704. * @returns an array of array of numbers
  27705. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27706. */
  27707. getFacetLocalPartitioning(): number[][];
  27708. /**
  27709. * Returns the i-th facet position in the world system.
  27710. * This method allocates a new Vector3 per call
  27711. * @param i defines the facet index
  27712. * @returns a new Vector3
  27713. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27714. */
  27715. getFacetPosition(i: number): Vector3;
  27716. /**
  27717. * Sets the reference Vector3 with the i-th facet position in the world system
  27718. * @param i defines the facet index
  27719. * @param ref defines the target vector
  27720. * @returns the current mesh
  27721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27722. */
  27723. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27724. /**
  27725. * Returns the i-th facet normal in the world system.
  27726. * This method allocates a new Vector3 per call
  27727. * @param i defines the facet index
  27728. * @returns a new Vector3
  27729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27730. */
  27731. getFacetNormal(i: number): Vector3;
  27732. /**
  27733. * Sets the reference Vector3 with the i-th facet normal in the world system
  27734. * @param i defines the facet index
  27735. * @param ref defines the target vector
  27736. * @returns the current mesh
  27737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27738. */
  27739. getFacetNormalToRef(i: number, ref: Vector3): this;
  27740. /**
  27741. * 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)
  27742. * @param x defines x coordinate
  27743. * @param y defines y coordinate
  27744. * @param z defines z coordinate
  27745. * @returns the array of facet indexes
  27746. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27747. */
  27748. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27749. /**
  27750. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27751. * @param projected sets as the (x,y,z) world projection on the facet
  27752. * @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
  27753. * @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
  27754. * @param x defines x coordinate
  27755. * @param y defines y coordinate
  27756. * @param z defines z coordinate
  27757. * @returns the face index if found (or null instead)
  27758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27759. */
  27760. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27761. /**
  27762. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27763. * @param projected sets as the (x,y,z) local projection on the facet
  27764. * @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
  27765. * @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
  27766. * @param x defines x coordinate
  27767. * @param y defines y coordinate
  27768. * @param z defines z coordinate
  27769. * @returns the face index if found (or null instead)
  27770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27771. */
  27772. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27773. /**
  27774. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27775. * @returns the parameters
  27776. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27777. */
  27778. getFacetDataParameters(): any;
  27779. /**
  27780. * Disables the feature FacetData and frees the related memory
  27781. * @returns the current mesh
  27782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27783. */
  27784. disableFacetData(): AbstractMesh;
  27785. /**
  27786. * Updates the AbstractMesh indices array
  27787. * @param indices defines the data source
  27788. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27789. * @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)
  27790. * @returns the current mesh
  27791. */
  27792. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27793. /**
  27794. * Creates new normals data for the mesh
  27795. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27796. * @returns the current mesh
  27797. */
  27798. createNormals(updatable: boolean): AbstractMesh;
  27799. /**
  27800. * Align the mesh with a normal
  27801. * @param normal defines the normal to use
  27802. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27803. * @returns the current mesh
  27804. */
  27805. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27806. /** @hidden */
  27807. _checkOcclusionQuery(): boolean;
  27808. /**
  27809. * Disables the mesh edge rendering mode
  27810. * @returns the currentAbstractMesh
  27811. */
  27812. disableEdgesRendering(): AbstractMesh;
  27813. /**
  27814. * Enables the edge rendering mode on the mesh.
  27815. * This mode makes the mesh edges visible
  27816. * @param epsilon defines the maximal distance between two angles to detect a face
  27817. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27818. * @returns the currentAbstractMesh
  27819. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27820. */
  27821. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27822. }
  27823. }
  27824. declare module "babylonjs/Actions/actionEvent" {
  27825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27826. import { Nullable } from "babylonjs/types";
  27827. import { Sprite } from "babylonjs/Sprites/sprite";
  27828. import { Scene } from "babylonjs/scene";
  27829. import { Vector2 } from "babylonjs/Maths/math.vector";
  27830. /**
  27831. * Interface used to define ActionEvent
  27832. */
  27833. export interface IActionEvent {
  27834. /** The mesh or sprite that triggered the action */
  27835. source: any;
  27836. /** The X mouse cursor position at the time of the event */
  27837. pointerX: number;
  27838. /** The Y mouse cursor position at the time of the event */
  27839. pointerY: number;
  27840. /** The mesh that is currently pointed at (can be null) */
  27841. meshUnderPointer: Nullable<AbstractMesh>;
  27842. /** the original (browser) event that triggered the ActionEvent */
  27843. sourceEvent?: any;
  27844. /** additional data for the event */
  27845. additionalData?: any;
  27846. }
  27847. /**
  27848. * ActionEvent is the event being sent when an action is triggered.
  27849. */
  27850. export class ActionEvent implements IActionEvent {
  27851. /** The mesh or sprite that triggered the action */
  27852. source: any;
  27853. /** The X mouse cursor position at the time of the event */
  27854. pointerX: number;
  27855. /** The Y mouse cursor position at the time of the event */
  27856. pointerY: number;
  27857. /** The mesh that is currently pointed at (can be null) */
  27858. meshUnderPointer: Nullable<AbstractMesh>;
  27859. /** the original (browser) event that triggered the ActionEvent */
  27860. sourceEvent?: any;
  27861. /** additional data for the event */
  27862. additionalData?: any;
  27863. /**
  27864. * Creates a new ActionEvent
  27865. * @param source The mesh or sprite that triggered the action
  27866. * @param pointerX The X mouse cursor position at the time of the event
  27867. * @param pointerY The Y mouse cursor position at the time of the event
  27868. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27869. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27870. * @param additionalData additional data for the event
  27871. */
  27872. constructor(
  27873. /** The mesh or sprite that triggered the action */
  27874. source: any,
  27875. /** The X mouse cursor position at the time of the event */
  27876. pointerX: number,
  27877. /** The Y mouse cursor position at the time of the event */
  27878. pointerY: number,
  27879. /** The mesh that is currently pointed at (can be null) */
  27880. meshUnderPointer: Nullable<AbstractMesh>,
  27881. /** the original (browser) event that triggered the ActionEvent */
  27882. sourceEvent?: any,
  27883. /** additional data for the event */
  27884. additionalData?: any);
  27885. /**
  27886. * Helper function to auto-create an ActionEvent from a source mesh.
  27887. * @param source The source mesh that triggered the event
  27888. * @param evt The original (browser) event
  27889. * @param additionalData additional data for the event
  27890. * @returns the new ActionEvent
  27891. */
  27892. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27893. /**
  27894. * Helper function to auto-create an ActionEvent from a source sprite
  27895. * @param source The source sprite that triggered the event
  27896. * @param scene Scene associated with the sprite
  27897. * @param evt The original (browser) event
  27898. * @param additionalData additional data for the event
  27899. * @returns the new ActionEvent
  27900. */
  27901. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27902. /**
  27903. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27904. * @param scene the scene where the event occurred
  27905. * @param evt The original (browser) event
  27906. * @returns the new ActionEvent
  27907. */
  27908. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27909. /**
  27910. * Helper function to auto-create an ActionEvent from a primitive
  27911. * @param prim defines the target primitive
  27912. * @param pointerPos defines the pointer position
  27913. * @param evt The original (browser) event
  27914. * @param additionalData additional data for the event
  27915. * @returns the new ActionEvent
  27916. */
  27917. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27918. }
  27919. }
  27920. declare module "babylonjs/Actions/abstractActionManager" {
  27921. import { IDisposable } from "babylonjs/scene";
  27922. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27923. import { IAction } from "babylonjs/Actions/action";
  27924. import { Nullable } from "babylonjs/types";
  27925. /**
  27926. * Abstract class used to decouple action Manager from scene and meshes.
  27927. * Do not instantiate.
  27928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27929. */
  27930. export abstract class AbstractActionManager implements IDisposable {
  27931. /** Gets the list of active triggers */
  27932. static Triggers: {
  27933. [key: string]: number;
  27934. };
  27935. /** Gets the cursor to use when hovering items */
  27936. hoverCursor: string;
  27937. /** Gets the list of actions */
  27938. actions: IAction[];
  27939. /**
  27940. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27941. */
  27942. isRecursive: boolean;
  27943. /**
  27944. * Releases all associated resources
  27945. */
  27946. abstract dispose(): void;
  27947. /**
  27948. * Does this action manager has pointer triggers
  27949. */
  27950. abstract readonly hasPointerTriggers: boolean;
  27951. /**
  27952. * Does this action manager has pick triggers
  27953. */
  27954. abstract readonly hasPickTriggers: boolean;
  27955. /**
  27956. * Process a specific trigger
  27957. * @param trigger defines the trigger to process
  27958. * @param evt defines the event details to be processed
  27959. */
  27960. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27961. /**
  27962. * Does this action manager handles actions of any of the given triggers
  27963. * @param triggers defines the triggers to be tested
  27964. * @return a boolean indicating whether one (or more) of the triggers is handled
  27965. */
  27966. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27967. /**
  27968. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27969. * speed.
  27970. * @param triggerA defines the trigger to be tested
  27971. * @param triggerB defines the trigger to be tested
  27972. * @return a boolean indicating whether one (or more) of the triggers is handled
  27973. */
  27974. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27975. /**
  27976. * Does this action manager handles actions of a given trigger
  27977. * @param trigger defines the trigger to be tested
  27978. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27979. * @return whether the trigger is handled
  27980. */
  27981. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27982. /**
  27983. * Serialize this manager to a JSON object
  27984. * @param name defines the property name to store this manager
  27985. * @returns a JSON representation of this manager
  27986. */
  27987. abstract serialize(name: string): any;
  27988. /**
  27989. * Registers an action to this action manager
  27990. * @param action defines the action to be registered
  27991. * @return the action amended (prepared) after registration
  27992. */
  27993. abstract registerAction(action: IAction): Nullable<IAction>;
  27994. /**
  27995. * Unregisters an action to this action manager
  27996. * @param action defines the action to be unregistered
  27997. * @return a boolean indicating whether the action has been unregistered
  27998. */
  27999. abstract unregisterAction(action: IAction): Boolean;
  28000. /**
  28001. * Does exist one action manager with at least one trigger
  28002. **/
  28003. static readonly HasTriggers: boolean;
  28004. /**
  28005. * Does exist one action manager with at least one pick trigger
  28006. **/
  28007. static readonly HasPickTriggers: boolean;
  28008. /**
  28009. * Does exist one action manager that handles actions of a given trigger
  28010. * @param trigger defines the trigger to be tested
  28011. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28012. **/
  28013. static HasSpecificTrigger(trigger: number): boolean;
  28014. }
  28015. }
  28016. declare module "babylonjs/node" {
  28017. import { Scene } from "babylonjs/scene";
  28018. import { Nullable } from "babylonjs/types";
  28019. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  28020. import { Engine } from "babylonjs/Engines/engine";
  28021. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  28022. import { Observable } from "babylonjs/Misc/observable";
  28023. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28024. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28025. import { Animatable } from "babylonjs/Animations/animatable";
  28026. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  28027. import { Animation } from "babylonjs/Animations/animation";
  28028. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28030. /**
  28031. * Defines how a node can be built from a string name.
  28032. */
  28033. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28034. /**
  28035. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28036. */
  28037. export class Node implements IBehaviorAware<Node> {
  28038. /** @hidden */
  28039. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  28040. private static _NodeConstructors;
  28041. /**
  28042. * Add a new node constructor
  28043. * @param type defines the type name of the node to construct
  28044. * @param constructorFunc defines the constructor function
  28045. */
  28046. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28047. /**
  28048. * Returns a node constructor based on type name
  28049. * @param type defines the type name
  28050. * @param name defines the new node name
  28051. * @param scene defines the hosting scene
  28052. * @param options defines optional options to transmit to constructors
  28053. * @returns the new constructor or null
  28054. */
  28055. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28056. /**
  28057. * Gets or sets the name of the node
  28058. */
  28059. name: string;
  28060. /**
  28061. * Gets or sets the id of the node
  28062. */
  28063. id: string;
  28064. /**
  28065. * Gets or sets the unique id of the node
  28066. */
  28067. uniqueId: number;
  28068. /**
  28069. * Gets or sets a string used to store user defined state for the node
  28070. */
  28071. state: string;
  28072. /**
  28073. * Gets or sets an object used to store user defined information for the node
  28074. */
  28075. metadata: any;
  28076. /**
  28077. * For internal use only. Please do not use.
  28078. */
  28079. reservedDataStore: any;
  28080. /**
  28081. * List of inspectable custom properties (used by the Inspector)
  28082. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28083. */
  28084. inspectableCustomProperties: IInspectable[];
  28085. private _doNotSerialize;
  28086. /**
  28087. * Gets or sets a boolean used to define if the node must be serialized
  28088. */
  28089. doNotSerialize: boolean;
  28090. /** @hidden */
  28091. _isDisposed: boolean;
  28092. /**
  28093. * Gets a list of Animations associated with the node
  28094. */
  28095. animations: import("babylonjs/Animations/animation").Animation[];
  28096. protected _ranges: {
  28097. [name: string]: Nullable<AnimationRange>;
  28098. };
  28099. /**
  28100. * Callback raised when the node is ready to be used
  28101. */
  28102. onReady: Nullable<(node: Node) => void>;
  28103. private _isEnabled;
  28104. private _isParentEnabled;
  28105. private _isReady;
  28106. /** @hidden */
  28107. _currentRenderId: number;
  28108. private _parentUpdateId;
  28109. /** @hidden */
  28110. _childUpdateId: number;
  28111. /** @hidden */
  28112. _waitingParentId: Nullable<string>;
  28113. /** @hidden */
  28114. _scene: Scene;
  28115. /** @hidden */
  28116. _cache: any;
  28117. private _parentNode;
  28118. private _children;
  28119. /** @hidden */
  28120. _worldMatrix: Matrix;
  28121. /** @hidden */
  28122. _worldMatrixDeterminant: number;
  28123. /** @hidden */
  28124. _worldMatrixDeterminantIsDirty: boolean;
  28125. /** @hidden */
  28126. private _sceneRootNodesIndex;
  28127. /**
  28128. * Gets a boolean indicating if the node has been disposed
  28129. * @returns true if the node was disposed
  28130. */
  28131. isDisposed(): boolean;
  28132. /**
  28133. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28134. * @see https://doc.babylonjs.com/how_to/parenting
  28135. */
  28136. parent: Nullable<Node>;
  28137. /** @hidden */
  28138. _addToSceneRootNodes(): void;
  28139. /** @hidden */
  28140. _removeFromSceneRootNodes(): void;
  28141. private _animationPropertiesOverride;
  28142. /**
  28143. * Gets or sets the animation properties override
  28144. */
  28145. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  28146. /**
  28147. * Gets a string idenfifying the name of the class
  28148. * @returns "Node" string
  28149. */
  28150. getClassName(): string;
  28151. /** @hidden */
  28152. readonly _isNode: boolean;
  28153. /**
  28154. * An event triggered when the mesh is disposed
  28155. */
  28156. onDisposeObservable: Observable<Node>;
  28157. private _onDisposeObserver;
  28158. /**
  28159. * Sets a callback that will be raised when the node will be disposed
  28160. */
  28161. onDispose: () => void;
  28162. /**
  28163. * Creates a new Node
  28164. * @param name the name and id to be given to this node
  28165. * @param scene the scene this node will be added to
  28166. */
  28167. constructor(name: string, scene?: Nullable<Scene>);
  28168. /**
  28169. * Gets the scene of the node
  28170. * @returns a scene
  28171. */
  28172. getScene(): Scene;
  28173. /**
  28174. * Gets the engine of the node
  28175. * @returns a Engine
  28176. */
  28177. getEngine(): Engine;
  28178. private _behaviors;
  28179. /**
  28180. * Attach a behavior to the node
  28181. * @see http://doc.babylonjs.com/features/behaviour
  28182. * @param behavior defines the behavior to attach
  28183. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28184. * @returns the current Node
  28185. */
  28186. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28187. /**
  28188. * Remove an attached behavior
  28189. * @see http://doc.babylonjs.com/features/behaviour
  28190. * @param behavior defines the behavior to attach
  28191. * @returns the current Node
  28192. */
  28193. removeBehavior(behavior: Behavior<Node>): Node;
  28194. /**
  28195. * Gets the list of attached behaviors
  28196. * @see http://doc.babylonjs.com/features/behaviour
  28197. */
  28198. readonly behaviors: Behavior<Node>[];
  28199. /**
  28200. * Gets an attached behavior by name
  28201. * @param name defines the name of the behavior to look for
  28202. * @see http://doc.babylonjs.com/features/behaviour
  28203. * @returns null if behavior was not found else the requested behavior
  28204. */
  28205. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28206. /**
  28207. * Returns the latest update of the World matrix
  28208. * @returns a Matrix
  28209. */
  28210. getWorldMatrix(): Matrix;
  28211. /** @hidden */
  28212. _getWorldMatrixDeterminant(): number;
  28213. /**
  28214. * Returns directly the latest state of the mesh World matrix.
  28215. * A Matrix is returned.
  28216. */
  28217. readonly worldMatrixFromCache: Matrix;
  28218. /** @hidden */
  28219. _initCache(): void;
  28220. /** @hidden */
  28221. updateCache(force?: boolean): void;
  28222. /** @hidden */
  28223. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28224. /** @hidden */
  28225. _updateCache(ignoreParentClass?: boolean): void;
  28226. /** @hidden */
  28227. _isSynchronized(): boolean;
  28228. /** @hidden */
  28229. _markSyncedWithParent(): void;
  28230. /** @hidden */
  28231. isSynchronizedWithParent(): boolean;
  28232. /** @hidden */
  28233. isSynchronized(): boolean;
  28234. /**
  28235. * Is this node ready to be used/rendered
  28236. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28237. * @return true if the node is ready
  28238. */
  28239. isReady(completeCheck?: boolean): boolean;
  28240. /**
  28241. * Is this node enabled?
  28242. * 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
  28243. * @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
  28244. * @return whether this node (and its parent) is enabled
  28245. */
  28246. isEnabled(checkAncestors?: boolean): boolean;
  28247. /** @hidden */
  28248. protected _syncParentEnabledState(): void;
  28249. /**
  28250. * Set the enabled state of this node
  28251. * @param value defines the new enabled state
  28252. */
  28253. setEnabled(value: boolean): void;
  28254. /**
  28255. * Is this node a descendant of the given node?
  28256. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28257. * @param ancestor defines the parent node to inspect
  28258. * @returns a boolean indicating if this node is a descendant of the given node
  28259. */
  28260. isDescendantOf(ancestor: Node): boolean;
  28261. /** @hidden */
  28262. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28263. /**
  28264. * Will return all nodes that have this node as ascendant
  28265. * @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
  28266. * @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
  28267. * @return all children nodes of all types
  28268. */
  28269. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28270. /**
  28271. * Get all child-meshes of this node
  28272. * @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)
  28273. * @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
  28274. * @returns an array of AbstractMesh
  28275. */
  28276. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28277. /**
  28278. * Get all direct children of this node
  28279. * @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
  28280. * @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)
  28281. * @returns an array of Node
  28282. */
  28283. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28284. /** @hidden */
  28285. _setReady(state: boolean): void;
  28286. /**
  28287. * Get an animation by name
  28288. * @param name defines the name of the animation to look for
  28289. * @returns null if not found else the requested animation
  28290. */
  28291. getAnimationByName(name: string): Nullable<Animation>;
  28292. /**
  28293. * Creates an animation range for this node
  28294. * @param name defines the name of the range
  28295. * @param from defines the starting key
  28296. * @param to defines the end key
  28297. */
  28298. createAnimationRange(name: string, from: number, to: number): void;
  28299. /**
  28300. * Delete a specific animation range
  28301. * @param name defines the name of the range to delete
  28302. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28303. */
  28304. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28305. /**
  28306. * Get an animation range by name
  28307. * @param name defines the name of the animation range to look for
  28308. * @returns null if not found else the requested animation range
  28309. */
  28310. getAnimationRange(name: string): Nullable<AnimationRange>;
  28311. /**
  28312. * Gets the list of all animation ranges defined on this node
  28313. * @returns an array
  28314. */
  28315. getAnimationRanges(): Nullable<AnimationRange>[];
  28316. /**
  28317. * Will start the animation sequence
  28318. * @param name defines the range frames for animation sequence
  28319. * @param loop defines if the animation should loop (false by default)
  28320. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28321. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28322. * @returns the object created for this animation. If range does not exist, it will return null
  28323. */
  28324. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28325. /**
  28326. * Serialize animation ranges into a JSON compatible object
  28327. * @returns serialization object
  28328. */
  28329. serializeAnimationRanges(): any;
  28330. /**
  28331. * Computes the world matrix of the node
  28332. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28333. * @returns the world matrix
  28334. */
  28335. computeWorldMatrix(force?: boolean): Matrix;
  28336. /**
  28337. * Releases resources associated with this node.
  28338. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28339. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28340. */
  28341. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28342. /**
  28343. * Parse animation range data from a serialization object and store them into a given node
  28344. * @param node defines where to store the animation ranges
  28345. * @param parsedNode defines the serialization object to read data from
  28346. * @param scene defines the hosting scene
  28347. */
  28348. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28349. /**
  28350. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28351. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28352. * @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
  28353. * @returns the new bounding vectors
  28354. */
  28355. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28356. min: Vector3;
  28357. max: Vector3;
  28358. };
  28359. }
  28360. }
  28361. declare module "babylonjs/Animations/animation" {
  28362. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  28363. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  28364. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28365. import { Nullable } from "babylonjs/types";
  28366. import { Scene } from "babylonjs/scene";
  28367. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  28368. import { AnimationRange } from "babylonjs/Animations/animationRange";
  28369. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  28370. import { Node } from "babylonjs/node";
  28371. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28372. import { Size } from "babylonjs/Maths/math.size";
  28373. import { Animatable } from "babylonjs/Animations/animatable";
  28374. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  28375. /**
  28376. * @hidden
  28377. */
  28378. export class _IAnimationState {
  28379. key: number;
  28380. repeatCount: number;
  28381. workValue?: any;
  28382. loopMode?: number;
  28383. offsetValue?: any;
  28384. highLimitValue?: any;
  28385. }
  28386. /**
  28387. * Class used to store any kind of animation
  28388. */
  28389. export class Animation {
  28390. /**Name of the animation */
  28391. name: string;
  28392. /**Property to animate */
  28393. targetProperty: string;
  28394. /**The frames per second of the animation */
  28395. framePerSecond: number;
  28396. /**The data type of the animation */
  28397. dataType: number;
  28398. /**The loop mode of the animation */
  28399. loopMode?: number | undefined;
  28400. /**Specifies if blending should be enabled */
  28401. enableBlending?: boolean | undefined;
  28402. /**
  28403. * Use matrix interpolation instead of using direct key value when animating matrices
  28404. */
  28405. static AllowMatricesInterpolation: boolean;
  28406. /**
  28407. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28408. */
  28409. static AllowMatrixDecomposeForInterpolation: boolean;
  28410. /**
  28411. * Stores the key frames of the animation
  28412. */
  28413. private _keys;
  28414. /**
  28415. * Stores the easing function of the animation
  28416. */
  28417. private _easingFunction;
  28418. /**
  28419. * @hidden Internal use only
  28420. */
  28421. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28422. /**
  28423. * The set of event that will be linked to this animation
  28424. */
  28425. private _events;
  28426. /**
  28427. * Stores an array of target property paths
  28428. */
  28429. targetPropertyPath: string[];
  28430. /**
  28431. * Stores the blending speed of the animation
  28432. */
  28433. blendingSpeed: number;
  28434. /**
  28435. * Stores the animation ranges for the animation
  28436. */
  28437. private _ranges;
  28438. /**
  28439. * @hidden Internal use
  28440. */
  28441. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28442. /**
  28443. * Sets up an animation
  28444. * @param property The property to animate
  28445. * @param animationType The animation type to apply
  28446. * @param framePerSecond The frames per second of the animation
  28447. * @param easingFunction The easing function used in the animation
  28448. * @returns The created animation
  28449. */
  28450. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28451. /**
  28452. * Create and start an animation on a node
  28453. * @param name defines the name of the global animation that will be run on all nodes
  28454. * @param node defines the root node where the animation will take place
  28455. * @param targetProperty defines property to animate
  28456. * @param framePerSecond defines the number of frame per second yo use
  28457. * @param totalFrame defines the number of frames in total
  28458. * @param from defines the initial value
  28459. * @param to defines the final value
  28460. * @param loopMode defines which loop mode you want to use (off by default)
  28461. * @param easingFunction defines the easing function to use (linear by default)
  28462. * @param onAnimationEnd defines the callback to call when animation end
  28463. * @returns the animatable created for this animation
  28464. */
  28465. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28466. /**
  28467. * Create and start an animation on a node and its descendants
  28468. * @param name defines the name of the global animation that will be run on all nodes
  28469. * @param node defines the root node where the animation will take place
  28470. * @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
  28471. * @param targetProperty defines property to animate
  28472. * @param framePerSecond defines the number of frame per second to use
  28473. * @param totalFrame defines the number of frames in total
  28474. * @param from defines the initial value
  28475. * @param to defines the final value
  28476. * @param loopMode defines which loop mode you want to use (off by default)
  28477. * @param easingFunction defines the easing function to use (linear by default)
  28478. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28479. * @returns the list of animatables created for all nodes
  28480. * @example https://www.babylonjs-playground.com/#MH0VLI
  28481. */
  28482. 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[]>;
  28483. /**
  28484. * Creates a new animation, merges it with the existing animations and starts it
  28485. * @param name Name of the animation
  28486. * @param node Node which contains the scene that begins the animations
  28487. * @param targetProperty Specifies which property to animate
  28488. * @param framePerSecond The frames per second of the animation
  28489. * @param totalFrame The total number of frames
  28490. * @param from The frame at the beginning of the animation
  28491. * @param to The frame at the end of the animation
  28492. * @param loopMode Specifies the loop mode of the animation
  28493. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28494. * @param onAnimationEnd Callback to run once the animation is complete
  28495. * @returns Nullable animation
  28496. */
  28497. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28498. /**
  28499. * Transition property of an host to the target Value
  28500. * @param property The property to transition
  28501. * @param targetValue The target Value of the property
  28502. * @param host The object where the property to animate belongs
  28503. * @param scene Scene used to run the animation
  28504. * @param frameRate Framerate (in frame/s) to use
  28505. * @param transition The transition type we want to use
  28506. * @param duration The duration of the animation, in milliseconds
  28507. * @param onAnimationEnd Callback trigger at the end of the animation
  28508. * @returns Nullable animation
  28509. */
  28510. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28511. /**
  28512. * Return the array of runtime animations currently using this animation
  28513. */
  28514. readonly runtimeAnimations: RuntimeAnimation[];
  28515. /**
  28516. * Specifies if any of the runtime animations are currently running
  28517. */
  28518. readonly hasRunningRuntimeAnimations: boolean;
  28519. /**
  28520. * Initializes the animation
  28521. * @param name Name of the animation
  28522. * @param targetProperty Property to animate
  28523. * @param framePerSecond The frames per second of the animation
  28524. * @param dataType The data type of the animation
  28525. * @param loopMode The loop mode of the animation
  28526. * @param enableBlending Specifies if blending should be enabled
  28527. */
  28528. constructor(
  28529. /**Name of the animation */
  28530. name: string,
  28531. /**Property to animate */
  28532. targetProperty: string,
  28533. /**The frames per second of the animation */
  28534. framePerSecond: number,
  28535. /**The data type of the animation */
  28536. dataType: number,
  28537. /**The loop mode of the animation */
  28538. loopMode?: number | undefined,
  28539. /**Specifies if blending should be enabled */
  28540. enableBlending?: boolean | undefined);
  28541. /**
  28542. * Converts the animation to a string
  28543. * @param fullDetails support for multiple levels of logging within scene loading
  28544. * @returns String form of the animation
  28545. */
  28546. toString(fullDetails?: boolean): string;
  28547. /**
  28548. * Add an event to this animation
  28549. * @param event Event to add
  28550. */
  28551. addEvent(event: AnimationEvent): void;
  28552. /**
  28553. * Remove all events found at the given frame
  28554. * @param frame The frame to remove events from
  28555. */
  28556. removeEvents(frame: number): void;
  28557. /**
  28558. * Retrieves all the events from the animation
  28559. * @returns Events from the animation
  28560. */
  28561. getEvents(): AnimationEvent[];
  28562. /**
  28563. * Creates an animation range
  28564. * @param name Name of the animation range
  28565. * @param from Starting frame of the animation range
  28566. * @param to Ending frame of the animation
  28567. */
  28568. createRange(name: string, from: number, to: number): void;
  28569. /**
  28570. * Deletes an animation range by name
  28571. * @param name Name of the animation range to delete
  28572. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28573. */
  28574. deleteRange(name: string, deleteFrames?: boolean): void;
  28575. /**
  28576. * Gets the animation range by name, or null if not defined
  28577. * @param name Name of the animation range
  28578. * @returns Nullable animation range
  28579. */
  28580. getRange(name: string): Nullable<AnimationRange>;
  28581. /**
  28582. * Gets the key frames from the animation
  28583. * @returns The key frames of the animation
  28584. */
  28585. getKeys(): Array<IAnimationKey>;
  28586. /**
  28587. * Gets the highest frame rate of the animation
  28588. * @returns Highest frame rate of the animation
  28589. */
  28590. getHighestFrame(): number;
  28591. /**
  28592. * Gets the easing function of the animation
  28593. * @returns Easing function of the animation
  28594. */
  28595. getEasingFunction(): IEasingFunction;
  28596. /**
  28597. * Sets the easing function of the animation
  28598. * @param easingFunction A custom mathematical formula for animation
  28599. */
  28600. setEasingFunction(easingFunction: EasingFunction): void;
  28601. /**
  28602. * Interpolates a scalar linearly
  28603. * @param startValue Start value of the animation curve
  28604. * @param endValue End value of the animation curve
  28605. * @param gradient Scalar amount to interpolate
  28606. * @returns Interpolated scalar value
  28607. */
  28608. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28609. /**
  28610. * Interpolates a scalar cubically
  28611. * @param startValue Start value of the animation curve
  28612. * @param outTangent End tangent of the animation
  28613. * @param endValue End value of the animation curve
  28614. * @param inTangent Start tangent of the animation curve
  28615. * @param gradient Scalar amount to interpolate
  28616. * @returns Interpolated scalar value
  28617. */
  28618. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28619. /**
  28620. * Interpolates a quaternion using a spherical linear interpolation
  28621. * @param startValue Start value of the animation curve
  28622. * @param endValue End value of the animation curve
  28623. * @param gradient Scalar amount to interpolate
  28624. * @returns Interpolated quaternion value
  28625. */
  28626. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28627. /**
  28628. * Interpolates a quaternion cubically
  28629. * @param startValue Start value of the animation curve
  28630. * @param outTangent End tangent of the animation curve
  28631. * @param endValue End value of the animation curve
  28632. * @param inTangent Start tangent of the animation curve
  28633. * @param gradient Scalar amount to interpolate
  28634. * @returns Interpolated quaternion value
  28635. */
  28636. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28637. /**
  28638. * Interpolates a Vector3 linearl
  28639. * @param startValue Start value of the animation curve
  28640. * @param endValue End value of the animation curve
  28641. * @param gradient Scalar amount to interpolate
  28642. * @returns Interpolated scalar value
  28643. */
  28644. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28645. /**
  28646. * Interpolates a Vector3 cubically
  28647. * @param startValue Start value of the animation curve
  28648. * @param outTangent End tangent of the animation
  28649. * @param endValue End value of the animation curve
  28650. * @param inTangent Start tangent of the animation curve
  28651. * @param gradient Scalar amount to interpolate
  28652. * @returns InterpolatedVector3 value
  28653. */
  28654. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28655. /**
  28656. * Interpolates a Vector2 linearly
  28657. * @param startValue Start value of the animation curve
  28658. * @param endValue End value of the animation curve
  28659. * @param gradient Scalar amount to interpolate
  28660. * @returns Interpolated Vector2 value
  28661. */
  28662. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28663. /**
  28664. * Interpolates a Vector2 cubically
  28665. * @param startValue Start value of the animation curve
  28666. * @param outTangent End tangent of the animation
  28667. * @param endValue End value of the animation curve
  28668. * @param inTangent Start tangent of the animation curve
  28669. * @param gradient Scalar amount to interpolate
  28670. * @returns Interpolated Vector2 value
  28671. */
  28672. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28673. /**
  28674. * Interpolates a size linearly
  28675. * @param startValue Start value of the animation curve
  28676. * @param endValue End value of the animation curve
  28677. * @param gradient Scalar amount to interpolate
  28678. * @returns Interpolated Size value
  28679. */
  28680. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28681. /**
  28682. * Interpolates a Color3 linearly
  28683. * @param startValue Start value of the animation curve
  28684. * @param endValue End value of the animation curve
  28685. * @param gradient Scalar amount to interpolate
  28686. * @returns Interpolated Color3 value
  28687. */
  28688. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28689. /**
  28690. * Interpolates a Color4 linearly
  28691. * @param startValue Start value of the animation curve
  28692. * @param endValue End value of the animation curve
  28693. * @param gradient Scalar amount to interpolate
  28694. * @returns Interpolated Color3 value
  28695. */
  28696. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  28697. /**
  28698. * @hidden Internal use only
  28699. */
  28700. _getKeyValue(value: any): any;
  28701. /**
  28702. * @hidden Internal use only
  28703. */
  28704. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28705. /**
  28706. * Defines the function to use to interpolate matrices
  28707. * @param startValue defines the start matrix
  28708. * @param endValue defines the end matrix
  28709. * @param gradient defines the gradient between both matrices
  28710. * @param result defines an optional target matrix where to store the interpolation
  28711. * @returns the interpolated matrix
  28712. */
  28713. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28714. /**
  28715. * Makes a copy of the animation
  28716. * @returns Cloned animation
  28717. */
  28718. clone(): Animation;
  28719. /**
  28720. * Sets the key frames of the animation
  28721. * @param values The animation key frames to set
  28722. */
  28723. setKeys(values: Array<IAnimationKey>): void;
  28724. /**
  28725. * Serializes the animation to an object
  28726. * @returns Serialized object
  28727. */
  28728. serialize(): any;
  28729. /**
  28730. * Float animation type
  28731. */
  28732. static readonly ANIMATIONTYPE_FLOAT: number;
  28733. /**
  28734. * Vector3 animation type
  28735. */
  28736. static readonly ANIMATIONTYPE_VECTOR3: number;
  28737. /**
  28738. * Quaternion animation type
  28739. */
  28740. static readonly ANIMATIONTYPE_QUATERNION: number;
  28741. /**
  28742. * Matrix animation type
  28743. */
  28744. static readonly ANIMATIONTYPE_MATRIX: number;
  28745. /**
  28746. * Color3 animation type
  28747. */
  28748. static readonly ANIMATIONTYPE_COLOR3: number;
  28749. /**
  28750. * Color3 animation type
  28751. */
  28752. static readonly ANIMATIONTYPE_COLOR4: number;
  28753. /**
  28754. * Vector2 animation type
  28755. */
  28756. static readonly ANIMATIONTYPE_VECTOR2: number;
  28757. /**
  28758. * Size animation type
  28759. */
  28760. static readonly ANIMATIONTYPE_SIZE: number;
  28761. /**
  28762. * Relative Loop Mode
  28763. */
  28764. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28765. /**
  28766. * Cycle Loop Mode
  28767. */
  28768. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28769. /**
  28770. * Constant Loop Mode
  28771. */
  28772. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28773. /** @hidden */
  28774. static _UniversalLerp(left: any, right: any, amount: number): any;
  28775. /**
  28776. * Parses an animation object and creates an animation
  28777. * @param parsedAnimation Parsed animation object
  28778. * @returns Animation object
  28779. */
  28780. static Parse(parsedAnimation: any): Animation;
  28781. /**
  28782. * Appends the serialized animations from the source animations
  28783. * @param source Source containing the animations
  28784. * @param destination Target to store the animations
  28785. */
  28786. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28787. }
  28788. }
  28789. declare module "babylonjs/Animations/animatable.interface" {
  28790. import { Nullable } from "babylonjs/types";
  28791. import { Animation } from "babylonjs/Animations/animation";
  28792. /**
  28793. * Interface containing an array of animations
  28794. */
  28795. export interface IAnimatable {
  28796. /**
  28797. * Array of animations
  28798. */
  28799. animations: Nullable<Array<Animation>>;
  28800. }
  28801. }
  28802. declare module "babylonjs/Materials/fresnelParameters" {
  28803. import { Color3 } from "babylonjs/Maths/math.color";
  28804. /**
  28805. * This represents all the required information to add a fresnel effect on a material:
  28806. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28807. */
  28808. export class FresnelParameters {
  28809. private _isEnabled;
  28810. /**
  28811. * Define if the fresnel effect is enable or not.
  28812. */
  28813. isEnabled: boolean;
  28814. /**
  28815. * Define the color used on edges (grazing angle)
  28816. */
  28817. leftColor: Color3;
  28818. /**
  28819. * Define the color used on center
  28820. */
  28821. rightColor: Color3;
  28822. /**
  28823. * Define bias applied to computed fresnel term
  28824. */
  28825. bias: number;
  28826. /**
  28827. * Defined the power exponent applied to fresnel term
  28828. */
  28829. power: number;
  28830. /**
  28831. * Clones the current fresnel and its valuues
  28832. * @returns a clone fresnel configuration
  28833. */
  28834. clone(): FresnelParameters;
  28835. /**
  28836. * Serializes the current fresnel parameters to a JSON representation.
  28837. * @return the JSON serialization
  28838. */
  28839. serialize(): any;
  28840. /**
  28841. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28842. * @param parsedFresnelParameters Define the JSON representation
  28843. * @returns the parsed parameters
  28844. */
  28845. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28846. }
  28847. }
  28848. declare module "babylonjs/Misc/decorators" {
  28849. import { Nullable } from "babylonjs/types";
  28850. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28851. import { Scene } from "babylonjs/scene";
  28852. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28853. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28854. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28855. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28856. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28857. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28858. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28859. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28860. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28861. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28862. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28863. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28864. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28865. /**
  28866. * Decorator used to define property that can be serialized as reference to a camera
  28867. * @param sourceName defines the name of the property to decorate
  28868. */
  28869. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28870. /**
  28871. * Class used to help serialization objects
  28872. */
  28873. export class SerializationHelper {
  28874. /** @hidden */
  28875. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28876. /** @hidden */
  28877. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28878. /** @hidden */
  28879. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28880. /** @hidden */
  28881. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28882. /**
  28883. * Appends the serialized animations from the source animations
  28884. * @param source Source containing the animations
  28885. * @param destination Target to store the animations
  28886. */
  28887. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28888. /**
  28889. * Static function used to serialized a specific entity
  28890. * @param entity defines the entity to serialize
  28891. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28892. * @returns a JSON compatible object representing the serialization of the entity
  28893. */
  28894. static Serialize<T>(entity: T, serializationObject?: any): any;
  28895. /**
  28896. * Creates a new entity from a serialization data object
  28897. * @param creationFunction defines a function used to instanciated the new entity
  28898. * @param source defines the source serialization data
  28899. * @param scene defines the hosting scene
  28900. * @param rootUrl defines the root url for resources
  28901. * @returns a new entity
  28902. */
  28903. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28904. /**
  28905. * Clones an object
  28906. * @param creationFunction defines the function used to instanciate the new object
  28907. * @param source defines the source object
  28908. * @returns the cloned object
  28909. */
  28910. static Clone<T>(creationFunction: () => T, source: T): T;
  28911. /**
  28912. * Instanciates a new object based on a source one (some data will be shared between both object)
  28913. * @param creationFunction defines the function used to instanciate the new object
  28914. * @param source defines the source object
  28915. * @returns the new object
  28916. */
  28917. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28918. }
  28919. }
  28920. declare module "babylonjs/Misc/guid" {
  28921. /**
  28922. * Class used to manipulate GUIDs
  28923. */
  28924. export class GUID {
  28925. /**
  28926. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28927. * Be aware Math.random() could cause collisions, but:
  28928. * "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"
  28929. * @returns a pseudo random id
  28930. */
  28931. static RandomId(): string;
  28932. }
  28933. }
  28934. declare module "babylonjs/Materials/Textures/baseTexture" {
  28935. import { Observable } from "babylonjs/Misc/observable";
  28936. import { Nullable } from "babylonjs/types";
  28937. import { Scene } from "babylonjs/scene";
  28938. import { Matrix } from "babylonjs/Maths/math.vector";
  28939. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28940. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28941. import { ISize } from "babylonjs/Maths/math.size";
  28942. /**
  28943. * Base class of all the textures in babylon.
  28944. * It groups all the common properties the materials, post process, lights... might need
  28945. * in order to make a correct use of the texture.
  28946. */
  28947. export class BaseTexture implements IAnimatable {
  28948. /**
  28949. * Default anisotropic filtering level for the application.
  28950. * It is set to 4 as a good tradeoff between perf and quality.
  28951. */
  28952. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28953. /**
  28954. * Gets or sets the unique id of the texture
  28955. */
  28956. uniqueId: number;
  28957. /**
  28958. * Define the name of the texture.
  28959. */
  28960. name: string;
  28961. /**
  28962. * Gets or sets an object used to store user defined information.
  28963. */
  28964. metadata: any;
  28965. /**
  28966. * For internal use only. Please do not use.
  28967. */
  28968. reservedDataStore: any;
  28969. private _hasAlpha;
  28970. /**
  28971. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28972. */
  28973. hasAlpha: boolean;
  28974. /**
  28975. * Defines if the alpha value should be determined via the rgb values.
  28976. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28977. */
  28978. getAlphaFromRGB: boolean;
  28979. /**
  28980. * Intensity or strength of the texture.
  28981. * It is commonly used by materials to fine tune the intensity of the texture
  28982. */
  28983. level: number;
  28984. /**
  28985. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28986. * This is part of the texture as textures usually maps to one uv set.
  28987. */
  28988. coordinatesIndex: number;
  28989. private _coordinatesMode;
  28990. /**
  28991. * How a texture is mapped.
  28992. *
  28993. * | Value | Type | Description |
  28994. * | ----- | ----------------------------------- | ----------- |
  28995. * | 0 | EXPLICIT_MODE | |
  28996. * | 1 | SPHERICAL_MODE | |
  28997. * | 2 | PLANAR_MODE | |
  28998. * | 3 | CUBIC_MODE | |
  28999. * | 4 | PROJECTION_MODE | |
  29000. * | 5 | SKYBOX_MODE | |
  29001. * | 6 | INVCUBIC_MODE | |
  29002. * | 7 | EQUIRECTANGULAR_MODE | |
  29003. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29004. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29005. */
  29006. coordinatesMode: number;
  29007. /**
  29008. * | Value | Type | Description |
  29009. * | ----- | ------------------ | ----------- |
  29010. * | 0 | CLAMP_ADDRESSMODE | |
  29011. * | 1 | WRAP_ADDRESSMODE | |
  29012. * | 2 | MIRROR_ADDRESSMODE | |
  29013. */
  29014. wrapU: number;
  29015. /**
  29016. * | Value | Type | Description |
  29017. * | ----- | ------------------ | ----------- |
  29018. * | 0 | CLAMP_ADDRESSMODE | |
  29019. * | 1 | WRAP_ADDRESSMODE | |
  29020. * | 2 | MIRROR_ADDRESSMODE | |
  29021. */
  29022. wrapV: number;
  29023. /**
  29024. * | Value | Type | Description |
  29025. * | ----- | ------------------ | ----------- |
  29026. * | 0 | CLAMP_ADDRESSMODE | |
  29027. * | 1 | WRAP_ADDRESSMODE | |
  29028. * | 2 | MIRROR_ADDRESSMODE | |
  29029. */
  29030. wrapR: number;
  29031. /**
  29032. * With compliant hardware and browser (supporting anisotropic filtering)
  29033. * this defines the level of anisotropic filtering in the texture.
  29034. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29035. */
  29036. anisotropicFilteringLevel: number;
  29037. /**
  29038. * Define if the texture is a cube texture or if false a 2d texture.
  29039. */
  29040. isCube: boolean;
  29041. /**
  29042. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29043. */
  29044. is3D: boolean;
  29045. /**
  29046. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29047. */
  29048. is2DArray: boolean;
  29049. /**
  29050. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29051. * HDR texture are usually stored in linear space.
  29052. * This only impacts the PBR and Background materials
  29053. */
  29054. gammaSpace: boolean;
  29055. /**
  29056. * Gets or sets whether or not the texture contains RGBD data.
  29057. */
  29058. isRGBD: boolean;
  29059. /**
  29060. * Is Z inverted in the texture (useful in a cube texture).
  29061. */
  29062. invertZ: boolean;
  29063. /**
  29064. * Are mip maps generated for this texture or not.
  29065. */
  29066. readonly noMipmap: boolean;
  29067. /**
  29068. * @hidden
  29069. */
  29070. lodLevelInAlpha: boolean;
  29071. /**
  29072. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29073. */
  29074. lodGenerationOffset: number;
  29075. /**
  29076. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29077. */
  29078. lodGenerationScale: number;
  29079. /**
  29080. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29081. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29082. * average roughness values.
  29083. */
  29084. linearSpecularLOD: boolean;
  29085. /**
  29086. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29087. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29088. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29089. */
  29090. irradianceTexture: Nullable<BaseTexture>;
  29091. /**
  29092. * Define if the texture is a render target.
  29093. */
  29094. isRenderTarget: boolean;
  29095. /**
  29096. * Define the unique id of the texture in the scene.
  29097. */
  29098. readonly uid: string;
  29099. /**
  29100. * Return a string representation of the texture.
  29101. * @returns the texture as a string
  29102. */
  29103. toString(): string;
  29104. /**
  29105. * Get the class name of the texture.
  29106. * @returns "BaseTexture"
  29107. */
  29108. getClassName(): string;
  29109. /**
  29110. * Define the list of animation attached to the texture.
  29111. */
  29112. animations: import("babylonjs/Animations/animation").Animation[];
  29113. /**
  29114. * An event triggered when the texture is disposed.
  29115. */
  29116. onDisposeObservable: Observable<BaseTexture>;
  29117. private _onDisposeObserver;
  29118. /**
  29119. * Callback triggered when the texture has been disposed.
  29120. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29121. */
  29122. onDispose: () => void;
  29123. /**
  29124. * Define the current state of the loading sequence when in delayed load mode.
  29125. */
  29126. delayLoadState: number;
  29127. private _scene;
  29128. /** @hidden */
  29129. _texture: Nullable<InternalTexture>;
  29130. private _uid;
  29131. /**
  29132. * Define if the texture is preventinga material to render or not.
  29133. * If not and the texture is not ready, the engine will use a default black texture instead.
  29134. */
  29135. readonly isBlocking: boolean;
  29136. /**
  29137. * Instantiates a new BaseTexture.
  29138. * Base class of all the textures in babylon.
  29139. * It groups all the common properties the materials, post process, lights... might need
  29140. * in order to make a correct use of the texture.
  29141. * @param scene Define the scene the texture blongs to
  29142. */
  29143. constructor(scene: Nullable<Scene>);
  29144. /**
  29145. * Get the scene the texture belongs to.
  29146. * @returns the scene or null if undefined
  29147. */
  29148. getScene(): Nullable<Scene>;
  29149. /**
  29150. * Get the texture transform matrix used to offset tile the texture for istance.
  29151. * @returns the transformation matrix
  29152. */
  29153. getTextureMatrix(): Matrix;
  29154. /**
  29155. * Get the texture reflection matrix used to rotate/transform the reflection.
  29156. * @returns the reflection matrix
  29157. */
  29158. getReflectionTextureMatrix(): Matrix;
  29159. /**
  29160. * Get the underlying lower level texture from Babylon.
  29161. * @returns the insternal texture
  29162. */
  29163. getInternalTexture(): Nullable<InternalTexture>;
  29164. /**
  29165. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29166. * @returns true if ready or not blocking
  29167. */
  29168. isReadyOrNotBlocking(): boolean;
  29169. /**
  29170. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29171. * @returns true if fully ready
  29172. */
  29173. isReady(): boolean;
  29174. private _cachedSize;
  29175. /**
  29176. * Get the size of the texture.
  29177. * @returns the texture size.
  29178. */
  29179. getSize(): ISize;
  29180. /**
  29181. * Get the base size of the texture.
  29182. * It can be different from the size if the texture has been resized for POT for instance
  29183. * @returns the base size
  29184. */
  29185. getBaseSize(): ISize;
  29186. /**
  29187. * Update the sampling mode of the texture.
  29188. * Default is Trilinear mode.
  29189. *
  29190. * | Value | Type | Description |
  29191. * | ----- | ------------------ | ----------- |
  29192. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29193. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29194. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29195. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29196. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29197. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29198. * | 7 | NEAREST_LINEAR | |
  29199. * | 8 | NEAREST_NEAREST | |
  29200. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29201. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29202. * | 11 | LINEAR_LINEAR | |
  29203. * | 12 | LINEAR_NEAREST | |
  29204. *
  29205. * > _mag_: magnification filter (close to the viewer)
  29206. * > _min_: minification filter (far from the viewer)
  29207. * > _mip_: filter used between mip map levels
  29208. *@param samplingMode Define the new sampling mode of the texture
  29209. */
  29210. updateSamplingMode(samplingMode: number): void;
  29211. /**
  29212. * Scales the texture if is `canRescale()`
  29213. * @param ratio the resize factor we want to use to rescale
  29214. */
  29215. scale(ratio: number): void;
  29216. /**
  29217. * Get if the texture can rescale.
  29218. */
  29219. readonly canRescale: boolean;
  29220. /** @hidden */
  29221. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29222. /** @hidden */
  29223. _rebuild(): void;
  29224. /**
  29225. * Triggers the load sequence in delayed load mode.
  29226. */
  29227. delayLoad(): void;
  29228. /**
  29229. * Clones the texture.
  29230. * @returns the cloned texture
  29231. */
  29232. clone(): Nullable<BaseTexture>;
  29233. /**
  29234. * Get the texture underlying type (INT, FLOAT...)
  29235. */
  29236. readonly textureType: number;
  29237. /**
  29238. * Get the texture underlying format (RGB, RGBA...)
  29239. */
  29240. readonly textureFormat: number;
  29241. /**
  29242. * Indicates that textures need to be re-calculated for all materials
  29243. */
  29244. protected _markAllSubMeshesAsTexturesDirty(): void;
  29245. /**
  29246. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29247. * This will returns an RGBA array buffer containing either in values (0-255) or
  29248. * float values (0-1) depending of the underlying buffer type.
  29249. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29250. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29251. * @param buffer defines a user defined buffer to fill with data (can be null)
  29252. * @returns The Array buffer containing the pixels data.
  29253. */
  29254. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29255. /**
  29256. * Release and destroy the underlying lower level texture aka internalTexture.
  29257. */
  29258. releaseInternalTexture(): void;
  29259. /** @hidden */
  29260. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29261. /** @hidden */
  29262. readonly _lodTextureMid: Nullable<BaseTexture>;
  29263. /** @hidden */
  29264. readonly _lodTextureLow: Nullable<BaseTexture>;
  29265. /**
  29266. * Dispose the texture and release its associated resources.
  29267. */
  29268. dispose(): void;
  29269. /**
  29270. * Serialize the texture into a JSON representation that can be parsed later on.
  29271. * @returns the JSON representation of the texture
  29272. */
  29273. serialize(): any;
  29274. /**
  29275. * Helper function to be called back once a list of texture contains only ready textures.
  29276. * @param textures Define the list of textures to wait for
  29277. * @param callback Define the callback triggered once the entire list will be ready
  29278. */
  29279. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29280. }
  29281. }
  29282. declare module "babylonjs/Materials/effect" {
  29283. import { Observable } from "babylonjs/Misc/observable";
  29284. import { Nullable } from "babylonjs/types";
  29285. import { IDisposable } from "babylonjs/scene";
  29286. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29287. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29288. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29289. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29290. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29291. import { Engine } from "babylonjs/Engines/engine";
  29292. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29293. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29294. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29295. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29296. /**
  29297. * Options to be used when creating an effect.
  29298. */
  29299. export interface IEffectCreationOptions {
  29300. /**
  29301. * Atrributes that will be used in the shader.
  29302. */
  29303. attributes: string[];
  29304. /**
  29305. * Uniform varible names that will be set in the shader.
  29306. */
  29307. uniformsNames: string[];
  29308. /**
  29309. * Uniform buffer variable names that will be set in the shader.
  29310. */
  29311. uniformBuffersNames: string[];
  29312. /**
  29313. * Sampler texture variable names that will be set in the shader.
  29314. */
  29315. samplers: string[];
  29316. /**
  29317. * Define statements that will be set in the shader.
  29318. */
  29319. defines: any;
  29320. /**
  29321. * Possible fallbacks for this effect to improve performance when needed.
  29322. */
  29323. fallbacks: Nullable<IEffectFallbacks>;
  29324. /**
  29325. * Callback that will be called when the shader is compiled.
  29326. */
  29327. onCompiled: Nullable<(effect: Effect) => void>;
  29328. /**
  29329. * Callback that will be called if an error occurs during shader compilation.
  29330. */
  29331. onError: Nullable<(effect: Effect, errors: string) => void>;
  29332. /**
  29333. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29334. */
  29335. indexParameters?: any;
  29336. /**
  29337. * Max number of lights that can be used in the shader.
  29338. */
  29339. maxSimultaneousLights?: number;
  29340. /**
  29341. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29342. */
  29343. transformFeedbackVaryings?: Nullable<string[]>;
  29344. }
  29345. /**
  29346. * Effect containing vertex and fragment shader that can be executed on an object.
  29347. */
  29348. export class Effect implements IDisposable {
  29349. /**
  29350. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29351. */
  29352. static ShadersRepository: string;
  29353. /**
  29354. * Name of the effect.
  29355. */
  29356. name: any;
  29357. /**
  29358. * String container all the define statements that should be set on the shader.
  29359. */
  29360. defines: string;
  29361. /**
  29362. * Callback that will be called when the shader is compiled.
  29363. */
  29364. onCompiled: Nullable<(effect: Effect) => void>;
  29365. /**
  29366. * Callback that will be called if an error occurs during shader compilation.
  29367. */
  29368. onError: Nullable<(effect: Effect, errors: string) => void>;
  29369. /**
  29370. * Callback that will be called when effect is bound.
  29371. */
  29372. onBind: Nullable<(effect: Effect) => void>;
  29373. /**
  29374. * Unique ID of the effect.
  29375. */
  29376. uniqueId: number;
  29377. /**
  29378. * Observable that will be called when the shader is compiled.
  29379. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29380. */
  29381. onCompileObservable: Observable<Effect>;
  29382. /**
  29383. * Observable that will be called if an error occurs during shader compilation.
  29384. */
  29385. onErrorObservable: Observable<Effect>;
  29386. /** @hidden */
  29387. _onBindObservable: Nullable<Observable<Effect>>;
  29388. /**
  29389. * Observable that will be called when effect is bound.
  29390. */
  29391. readonly onBindObservable: Observable<Effect>;
  29392. /** @hidden */
  29393. _bonesComputationForcedToCPU: boolean;
  29394. private static _uniqueIdSeed;
  29395. private _engine;
  29396. private _uniformBuffersNames;
  29397. private _uniformsNames;
  29398. private _samplerList;
  29399. private _samplers;
  29400. private _isReady;
  29401. private _compilationError;
  29402. private _allFallbacksProcessed;
  29403. private _attributesNames;
  29404. private _attributes;
  29405. private _uniforms;
  29406. /**
  29407. * Key for the effect.
  29408. * @hidden
  29409. */
  29410. _key: string;
  29411. private _indexParameters;
  29412. private _fallbacks;
  29413. private _vertexSourceCode;
  29414. private _fragmentSourceCode;
  29415. private _vertexSourceCodeOverride;
  29416. private _fragmentSourceCodeOverride;
  29417. private _transformFeedbackVaryings;
  29418. /**
  29419. * Compiled shader to webGL program.
  29420. * @hidden
  29421. */
  29422. _pipelineContext: Nullable<IPipelineContext>;
  29423. private _valueCache;
  29424. private static _baseCache;
  29425. /**
  29426. * Instantiates an effect.
  29427. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29428. * @param baseName Name of the effect.
  29429. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29430. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29431. * @param samplers List of sampler variables that will be passed to the shader.
  29432. * @param engine Engine to be used to render the effect
  29433. * @param defines Define statements to be added to the shader.
  29434. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29435. * @param onCompiled Callback that will be called when the shader is compiled.
  29436. * @param onError Callback that will be called if an error occurs during shader compilation.
  29437. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29438. */
  29439. 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);
  29440. private _useFinalCode;
  29441. /**
  29442. * Unique key for this effect
  29443. */
  29444. readonly key: string;
  29445. /**
  29446. * If the effect has been compiled and prepared.
  29447. * @returns if the effect is compiled and prepared.
  29448. */
  29449. isReady(): boolean;
  29450. private _isReadyInternal;
  29451. /**
  29452. * The engine the effect was initialized with.
  29453. * @returns the engine.
  29454. */
  29455. getEngine(): Engine;
  29456. /**
  29457. * The pipeline context for this effect
  29458. * @returns the associated pipeline context
  29459. */
  29460. getPipelineContext(): Nullable<IPipelineContext>;
  29461. /**
  29462. * The set of names of attribute variables for the shader.
  29463. * @returns An array of attribute names.
  29464. */
  29465. getAttributesNames(): string[];
  29466. /**
  29467. * Returns the attribute at the given index.
  29468. * @param index The index of the attribute.
  29469. * @returns The location of the attribute.
  29470. */
  29471. getAttributeLocation(index: number): number;
  29472. /**
  29473. * Returns the attribute based on the name of the variable.
  29474. * @param name of the attribute to look up.
  29475. * @returns the attribute location.
  29476. */
  29477. getAttributeLocationByName(name: string): number;
  29478. /**
  29479. * The number of attributes.
  29480. * @returns the numnber of attributes.
  29481. */
  29482. getAttributesCount(): number;
  29483. /**
  29484. * Gets the index of a uniform variable.
  29485. * @param uniformName of the uniform to look up.
  29486. * @returns the index.
  29487. */
  29488. getUniformIndex(uniformName: string): number;
  29489. /**
  29490. * Returns the attribute based on the name of the variable.
  29491. * @param uniformName of the uniform to look up.
  29492. * @returns the location of the uniform.
  29493. */
  29494. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29495. /**
  29496. * Returns an array of sampler variable names
  29497. * @returns The array of sampler variable neames.
  29498. */
  29499. getSamplers(): string[];
  29500. /**
  29501. * The error from the last compilation.
  29502. * @returns the error string.
  29503. */
  29504. getCompilationError(): string;
  29505. /**
  29506. * Gets a boolean indicating that all fallbacks were used during compilation
  29507. * @returns true if all fallbacks were used
  29508. */
  29509. allFallbacksProcessed(): boolean;
  29510. /**
  29511. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29512. * @param func The callback to be used.
  29513. */
  29514. executeWhenCompiled(func: (effect: Effect) => void): void;
  29515. private _checkIsReady;
  29516. private _loadShader;
  29517. /**
  29518. * Recompiles the webGL program
  29519. * @param vertexSourceCode The source code for the vertex shader.
  29520. * @param fragmentSourceCode The source code for the fragment shader.
  29521. * @param onCompiled Callback called when completed.
  29522. * @param onError Callback called on error.
  29523. * @hidden
  29524. */
  29525. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29526. /**
  29527. * Prepares the effect
  29528. * @hidden
  29529. */
  29530. _prepareEffect(): void;
  29531. private _processCompilationErrors;
  29532. /**
  29533. * Checks if the effect is supported. (Must be called after compilation)
  29534. */
  29535. readonly isSupported: boolean;
  29536. /**
  29537. * Binds a texture to the engine to be used as output of the shader.
  29538. * @param channel Name of the output variable.
  29539. * @param texture Texture to bind.
  29540. * @hidden
  29541. */
  29542. _bindTexture(channel: string, texture: InternalTexture): void;
  29543. /**
  29544. * Sets a texture on the engine to be used in the shader.
  29545. * @param channel Name of the sampler variable.
  29546. * @param texture Texture to set.
  29547. */
  29548. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29549. /**
  29550. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29551. * @param channel Name of the sampler variable.
  29552. * @param texture Texture to set.
  29553. */
  29554. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29555. /**
  29556. * Sets an array of textures on the engine to be used in the shader.
  29557. * @param channel Name of the variable.
  29558. * @param textures Textures to set.
  29559. */
  29560. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29561. /**
  29562. * 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)
  29563. * @param channel Name of the sampler variable.
  29564. * @param postProcess Post process to get the input texture from.
  29565. */
  29566. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29567. /**
  29568. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29569. * 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)
  29570. * @param channel Name of the sampler variable.
  29571. * @param postProcess Post process to get the output texture from.
  29572. */
  29573. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29574. /** @hidden */
  29575. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29576. /** @hidden */
  29577. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29578. /** @hidden */
  29579. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29580. /** @hidden */
  29581. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29582. /**
  29583. * Binds a buffer to a uniform.
  29584. * @param buffer Buffer to bind.
  29585. * @param name Name of the uniform variable to bind to.
  29586. */
  29587. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29588. /**
  29589. * Binds block to a uniform.
  29590. * @param blockName Name of the block to bind.
  29591. * @param index Index to bind.
  29592. */
  29593. bindUniformBlock(blockName: string, index: number): void;
  29594. /**
  29595. * Sets an interger value on a uniform variable.
  29596. * @param uniformName Name of the variable.
  29597. * @param value Value to be set.
  29598. * @returns this effect.
  29599. */
  29600. setInt(uniformName: string, value: number): Effect;
  29601. /**
  29602. * Sets an int array on a uniform variable.
  29603. * @param uniformName Name of the variable.
  29604. * @param array array to be set.
  29605. * @returns this effect.
  29606. */
  29607. setIntArray(uniformName: string, array: Int32Array): Effect;
  29608. /**
  29609. * 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)
  29610. * @param uniformName Name of the variable.
  29611. * @param array array to be set.
  29612. * @returns this effect.
  29613. */
  29614. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29615. /**
  29616. * 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)
  29617. * @param uniformName Name of the variable.
  29618. * @param array array to be set.
  29619. * @returns this effect.
  29620. */
  29621. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29622. /**
  29623. * 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)
  29624. * @param uniformName Name of the variable.
  29625. * @param array array to be set.
  29626. * @returns this effect.
  29627. */
  29628. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29629. /**
  29630. * Sets an float array on a uniform variable.
  29631. * @param uniformName Name of the variable.
  29632. * @param array array to be set.
  29633. * @returns this effect.
  29634. */
  29635. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29636. /**
  29637. * 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)
  29638. * @param uniformName Name of the variable.
  29639. * @param array array to be set.
  29640. * @returns this effect.
  29641. */
  29642. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29643. /**
  29644. * 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)
  29645. * @param uniformName Name of the variable.
  29646. * @param array array to be set.
  29647. * @returns this effect.
  29648. */
  29649. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29650. /**
  29651. * 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)
  29652. * @param uniformName Name of the variable.
  29653. * @param array array to be set.
  29654. * @returns this effect.
  29655. */
  29656. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29657. /**
  29658. * Sets an array on a uniform variable.
  29659. * @param uniformName Name of the variable.
  29660. * @param array array to be set.
  29661. * @returns this effect.
  29662. */
  29663. setArray(uniformName: string, array: number[]): Effect;
  29664. /**
  29665. * 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)
  29666. * @param uniformName Name of the variable.
  29667. * @param array array to be set.
  29668. * @returns this effect.
  29669. */
  29670. setArray2(uniformName: string, array: number[]): Effect;
  29671. /**
  29672. * 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)
  29673. * @param uniformName Name of the variable.
  29674. * @param array array to be set.
  29675. * @returns this effect.
  29676. */
  29677. setArray3(uniformName: string, array: number[]): Effect;
  29678. /**
  29679. * 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)
  29680. * @param uniformName Name of the variable.
  29681. * @param array array to be set.
  29682. * @returns this effect.
  29683. */
  29684. setArray4(uniformName: string, array: number[]): Effect;
  29685. /**
  29686. * Sets matrices on a uniform variable.
  29687. * @param uniformName Name of the variable.
  29688. * @param matrices matrices to be set.
  29689. * @returns this effect.
  29690. */
  29691. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29692. /**
  29693. * Sets matrix on a uniform variable.
  29694. * @param uniformName Name of the variable.
  29695. * @param matrix matrix to be set.
  29696. * @returns this effect.
  29697. */
  29698. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29699. /**
  29700. * 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)
  29701. * @param uniformName Name of the variable.
  29702. * @param matrix matrix to be set.
  29703. * @returns this effect.
  29704. */
  29705. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29706. /**
  29707. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29708. * @param uniformName Name of the variable.
  29709. * @param matrix matrix to be set.
  29710. * @returns this effect.
  29711. */
  29712. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29713. /**
  29714. * Sets a float on a uniform variable.
  29715. * @param uniformName Name of the variable.
  29716. * @param value value to be set.
  29717. * @returns this effect.
  29718. */
  29719. setFloat(uniformName: string, value: number): Effect;
  29720. /**
  29721. * Sets a boolean on a uniform variable.
  29722. * @param uniformName Name of the variable.
  29723. * @param bool value to be set.
  29724. * @returns this effect.
  29725. */
  29726. setBool(uniformName: string, bool: boolean): Effect;
  29727. /**
  29728. * Sets a Vector2 on a uniform variable.
  29729. * @param uniformName Name of the variable.
  29730. * @param vector2 vector2 to be set.
  29731. * @returns this effect.
  29732. */
  29733. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29734. /**
  29735. * Sets a float2 on a uniform variable.
  29736. * @param uniformName Name of the variable.
  29737. * @param x First float in float2.
  29738. * @param y Second float in float2.
  29739. * @returns this effect.
  29740. */
  29741. setFloat2(uniformName: string, x: number, y: number): Effect;
  29742. /**
  29743. * Sets a Vector3 on a uniform variable.
  29744. * @param uniformName Name of the variable.
  29745. * @param vector3 Value to be set.
  29746. * @returns this effect.
  29747. */
  29748. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29749. /**
  29750. * Sets a float3 on a uniform variable.
  29751. * @param uniformName Name of the variable.
  29752. * @param x First float in float3.
  29753. * @param y Second float in float3.
  29754. * @param z Third float in float3.
  29755. * @returns this effect.
  29756. */
  29757. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29758. /**
  29759. * Sets a Vector4 on a uniform variable.
  29760. * @param uniformName Name of the variable.
  29761. * @param vector4 Value to be set.
  29762. * @returns this effect.
  29763. */
  29764. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29765. /**
  29766. * Sets a float4 on a uniform variable.
  29767. * @param uniformName Name of the variable.
  29768. * @param x First float in float4.
  29769. * @param y Second float in float4.
  29770. * @param z Third float in float4.
  29771. * @param w Fourth float in float4.
  29772. * @returns this effect.
  29773. */
  29774. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29775. /**
  29776. * Sets a Color3 on a uniform variable.
  29777. * @param uniformName Name of the variable.
  29778. * @param color3 Value to be set.
  29779. * @returns this effect.
  29780. */
  29781. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29782. /**
  29783. * Sets a Color4 on a uniform variable.
  29784. * @param uniformName Name of the variable.
  29785. * @param color3 Value to be set.
  29786. * @param alpha Alpha value to be set.
  29787. * @returns this effect.
  29788. */
  29789. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29790. /**
  29791. * Sets a Color4 on a uniform variable
  29792. * @param uniformName defines the name of the variable
  29793. * @param color4 defines the value to be set
  29794. * @returns this effect.
  29795. */
  29796. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29797. /** Release all associated resources */
  29798. dispose(): void;
  29799. /**
  29800. * This function will add a new shader to the shader store
  29801. * @param name the name of the shader
  29802. * @param pixelShader optional pixel shader content
  29803. * @param vertexShader optional vertex shader content
  29804. */
  29805. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29806. /**
  29807. * Store of each shader (The can be looked up using effect.key)
  29808. */
  29809. static ShadersStore: {
  29810. [key: string]: string;
  29811. };
  29812. /**
  29813. * Store of each included file for a shader (The can be looked up using effect.key)
  29814. */
  29815. static IncludesShadersStore: {
  29816. [key: string]: string;
  29817. };
  29818. /**
  29819. * Resets the cache of effects.
  29820. */
  29821. static ResetCache(): void;
  29822. }
  29823. }
  29824. declare module "babylonjs/Engines/engineCapabilities" {
  29825. /**
  29826. * Interface used to describe the capabilities of the engine relatively to the current browser
  29827. */
  29828. export interface EngineCapabilities {
  29829. /** Maximum textures units per fragment shader */
  29830. maxTexturesImageUnits: number;
  29831. /** Maximum texture units per vertex shader */
  29832. maxVertexTextureImageUnits: number;
  29833. /** Maximum textures units in the entire pipeline */
  29834. maxCombinedTexturesImageUnits: number;
  29835. /** Maximum texture size */
  29836. maxTextureSize: number;
  29837. /** Maximum texture samples */
  29838. maxSamples?: number;
  29839. /** Maximum cube texture size */
  29840. maxCubemapTextureSize: number;
  29841. /** Maximum render texture size */
  29842. maxRenderTextureSize: number;
  29843. /** Maximum number of vertex attributes */
  29844. maxVertexAttribs: number;
  29845. /** Maximum number of varyings */
  29846. maxVaryingVectors: number;
  29847. /** Maximum number of uniforms per vertex shader */
  29848. maxVertexUniformVectors: number;
  29849. /** Maximum number of uniforms per fragment shader */
  29850. maxFragmentUniformVectors: number;
  29851. /** Defines if standard derivates (dx/dy) are supported */
  29852. standardDerivatives: boolean;
  29853. /** Defines if s3tc texture compression is supported */
  29854. s3tc?: WEBGL_compressed_texture_s3tc;
  29855. /** Defines if pvrtc texture compression is supported */
  29856. pvrtc: any;
  29857. /** Defines if etc1 texture compression is supported */
  29858. etc1: any;
  29859. /** Defines if etc2 texture compression is supported */
  29860. etc2: any;
  29861. /** Defines if astc texture compression is supported */
  29862. astc: any;
  29863. /** Defines if float textures are supported */
  29864. textureFloat: boolean;
  29865. /** Defines if vertex array objects are supported */
  29866. vertexArrayObject: boolean;
  29867. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29868. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  29869. /** Gets the maximum level of anisotropy supported */
  29870. maxAnisotropy: number;
  29871. /** Defines if instancing is supported */
  29872. instancedArrays: boolean;
  29873. /** Defines if 32 bits indices are supported */
  29874. uintIndices: boolean;
  29875. /** Defines if high precision shaders are supported */
  29876. highPrecisionShaderSupported: boolean;
  29877. /** Defines if depth reading in the fragment shader is supported */
  29878. fragmentDepthSupported: boolean;
  29879. /** Defines if float texture linear filtering is supported*/
  29880. textureFloatLinearFiltering: boolean;
  29881. /** Defines if rendering to float textures is supported */
  29882. textureFloatRender: boolean;
  29883. /** Defines if half float textures are supported*/
  29884. textureHalfFloat: boolean;
  29885. /** Defines if half float texture linear filtering is supported*/
  29886. textureHalfFloatLinearFiltering: boolean;
  29887. /** Defines if rendering to half float textures is supported */
  29888. textureHalfFloatRender: boolean;
  29889. /** Defines if textureLOD shader command is supported */
  29890. textureLOD: boolean;
  29891. /** Defines if draw buffers extension is supported */
  29892. drawBuffersExtension: boolean;
  29893. /** Defines if depth textures are supported */
  29894. depthTextureExtension: boolean;
  29895. /** Defines if float color buffer are supported */
  29896. colorBufferFloat: boolean;
  29897. /** Gets disjoint timer query extension (null if not supported) */
  29898. timerQuery?: EXT_disjoint_timer_query;
  29899. /** Defines if timestamp can be used with timer query */
  29900. canUseTimestampForTimerQuery: boolean;
  29901. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29902. multiview?: any;
  29903. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  29904. oculusMultiview?: any;
  29905. /** Function used to let the system compiles shaders in background */
  29906. parallelShaderCompile?: {
  29907. COMPLETION_STATUS_KHR: number;
  29908. };
  29909. /** Max number of texture samples for MSAA */
  29910. maxMSAASamples: number;
  29911. /** Defines if the blend min max extension is supported */
  29912. blendMinMax: boolean;
  29913. }
  29914. }
  29915. declare module "babylonjs/States/depthCullingState" {
  29916. import { Nullable } from "babylonjs/types";
  29917. /**
  29918. * @hidden
  29919. **/
  29920. export class DepthCullingState {
  29921. private _isDepthTestDirty;
  29922. private _isDepthMaskDirty;
  29923. private _isDepthFuncDirty;
  29924. private _isCullFaceDirty;
  29925. private _isCullDirty;
  29926. private _isZOffsetDirty;
  29927. private _isFrontFaceDirty;
  29928. private _depthTest;
  29929. private _depthMask;
  29930. private _depthFunc;
  29931. private _cull;
  29932. private _cullFace;
  29933. private _zOffset;
  29934. private _frontFace;
  29935. /**
  29936. * Initializes the state.
  29937. */
  29938. constructor();
  29939. readonly isDirty: boolean;
  29940. zOffset: number;
  29941. cullFace: Nullable<number>;
  29942. cull: Nullable<boolean>;
  29943. depthFunc: Nullable<number>;
  29944. depthMask: boolean;
  29945. depthTest: boolean;
  29946. frontFace: Nullable<number>;
  29947. reset(): void;
  29948. apply(gl: WebGLRenderingContext): void;
  29949. }
  29950. }
  29951. declare module "babylonjs/States/stencilState" {
  29952. /**
  29953. * @hidden
  29954. **/
  29955. export class StencilState {
  29956. /** 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 */
  29957. static readonly ALWAYS: number;
  29958. /** Passed to stencilOperation to specify that stencil value must be kept */
  29959. static readonly KEEP: number;
  29960. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29961. static readonly REPLACE: number;
  29962. private _isStencilTestDirty;
  29963. private _isStencilMaskDirty;
  29964. private _isStencilFuncDirty;
  29965. private _isStencilOpDirty;
  29966. private _stencilTest;
  29967. private _stencilMask;
  29968. private _stencilFunc;
  29969. private _stencilFuncRef;
  29970. private _stencilFuncMask;
  29971. private _stencilOpStencilFail;
  29972. private _stencilOpDepthFail;
  29973. private _stencilOpStencilDepthPass;
  29974. readonly isDirty: boolean;
  29975. stencilFunc: number;
  29976. stencilFuncRef: number;
  29977. stencilFuncMask: number;
  29978. stencilOpStencilFail: number;
  29979. stencilOpDepthFail: number;
  29980. stencilOpStencilDepthPass: number;
  29981. stencilMask: number;
  29982. stencilTest: boolean;
  29983. constructor();
  29984. reset(): void;
  29985. apply(gl: WebGLRenderingContext): void;
  29986. }
  29987. }
  29988. declare module "babylonjs/States/alphaCullingState" {
  29989. /**
  29990. * @hidden
  29991. **/
  29992. export class AlphaState {
  29993. private _isAlphaBlendDirty;
  29994. private _isBlendFunctionParametersDirty;
  29995. private _isBlendEquationParametersDirty;
  29996. private _isBlendConstantsDirty;
  29997. private _alphaBlend;
  29998. private _blendFunctionParameters;
  29999. private _blendEquationParameters;
  30000. private _blendConstants;
  30001. /**
  30002. * Initializes the state.
  30003. */
  30004. constructor();
  30005. readonly isDirty: boolean;
  30006. alphaBlend: boolean;
  30007. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30008. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30009. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30010. reset(): void;
  30011. apply(gl: WebGLRenderingContext): void;
  30012. }
  30013. }
  30014. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30015. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30016. /** @hidden */
  30017. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30018. attributeProcessor(attribute: string): string;
  30019. varyingProcessor(varying: string, isFragment: boolean): string;
  30020. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30021. }
  30022. }
  30023. declare module "babylonjs/Engines/instancingAttributeInfo" {
  30024. /**
  30025. * Interface for attribute information associated with buffer instanciation
  30026. */
  30027. export interface InstancingAttributeInfo {
  30028. /**
  30029. * Index/offset of the attribute in the vertex shader
  30030. */
  30031. index: number;
  30032. /**
  30033. * size of the attribute, 1, 2, 3 or 4
  30034. */
  30035. attributeSize: number;
  30036. /**
  30037. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30038. * default is FLOAT
  30039. */
  30040. attributeType: number;
  30041. /**
  30042. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30043. */
  30044. normalized: boolean;
  30045. /**
  30046. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30047. */
  30048. offset: number;
  30049. /**
  30050. * Name of the GLSL attribute, for debugging purpose only
  30051. */
  30052. attributeName: string;
  30053. }
  30054. }
  30055. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  30056. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30057. import { Nullable } from "babylonjs/types";
  30058. module "babylonjs/Engines/thinEngine" {
  30059. interface ThinEngine {
  30060. /**
  30061. * Update a video texture
  30062. * @param texture defines the texture to update
  30063. * @param video defines the video element to use
  30064. * @param invertY defines if data must be stored with Y axis inverted
  30065. */
  30066. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30067. }
  30068. }
  30069. }
  30070. declare module "babylonjs/Materials/Textures/videoTexture" {
  30071. import { Observable } from "babylonjs/Misc/observable";
  30072. import { Nullable } from "babylonjs/types";
  30073. import { Scene } from "babylonjs/scene";
  30074. import { Texture } from "babylonjs/Materials/Textures/texture";
  30075. import "babylonjs/Engines/Extensions/engine.videoTexture";
  30076. /**
  30077. * Settings for finer control over video usage
  30078. */
  30079. export interface VideoTextureSettings {
  30080. /**
  30081. * Applies `autoplay` to video, if specified
  30082. */
  30083. autoPlay?: boolean;
  30084. /**
  30085. * Applies `loop` to video, if specified
  30086. */
  30087. loop?: boolean;
  30088. /**
  30089. * Automatically updates internal texture from video at every frame in the render loop
  30090. */
  30091. autoUpdateTexture: boolean;
  30092. /**
  30093. * Image src displayed during the video loading or until the user interacts with the video.
  30094. */
  30095. poster?: string;
  30096. }
  30097. /**
  30098. * If you want to display a video in your scene, this is the special texture for that.
  30099. * This special texture works similar to other textures, with the exception of a few parameters.
  30100. * @see https://doc.babylonjs.com/how_to/video_texture
  30101. */
  30102. export class VideoTexture extends Texture {
  30103. /**
  30104. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30105. */
  30106. readonly autoUpdateTexture: boolean;
  30107. /**
  30108. * The video instance used by the texture internally
  30109. */
  30110. readonly video: HTMLVideoElement;
  30111. private _onUserActionRequestedObservable;
  30112. /**
  30113. * Event triggerd when a dom action is required by the user to play the video.
  30114. * This happens due to recent changes in browser policies preventing video to auto start.
  30115. */
  30116. readonly onUserActionRequestedObservable: Observable<Texture>;
  30117. private _generateMipMaps;
  30118. private _engine;
  30119. private _stillImageCaptured;
  30120. private _displayingPosterTexture;
  30121. private _settings;
  30122. private _createInternalTextureOnEvent;
  30123. private _frameId;
  30124. /**
  30125. * Creates a video texture.
  30126. * If you want to display a video in your scene, this is the special texture for that.
  30127. * This special texture works similar to other textures, with the exception of a few parameters.
  30128. * @see https://doc.babylonjs.com/how_to/video_texture
  30129. * @param name optional name, will detect from video source, if not defined
  30130. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30131. * @param scene is obviously the current scene.
  30132. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30133. * @param invertY is false by default but can be used to invert video on Y axis
  30134. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30135. * @param settings allows finer control over video usage
  30136. */
  30137. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30138. private _getName;
  30139. private _getVideo;
  30140. private _createInternalTexture;
  30141. private reset;
  30142. /**
  30143. * @hidden Internal method to initiate `update`.
  30144. */
  30145. _rebuild(): void;
  30146. /**
  30147. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30148. */
  30149. update(): void;
  30150. /**
  30151. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30152. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30153. */
  30154. updateTexture(isVisible: boolean): void;
  30155. protected _updateInternalTexture: () => void;
  30156. /**
  30157. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30158. * @param url New url.
  30159. */
  30160. updateURL(url: string): void;
  30161. /**
  30162. * Dispose the texture and release its associated resources.
  30163. */
  30164. dispose(): void;
  30165. /**
  30166. * Creates a video texture straight from a stream.
  30167. * @param scene Define the scene the texture should be created in
  30168. * @param stream Define the stream the texture should be created from
  30169. * @returns The created video texture as a promise
  30170. */
  30171. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30172. /**
  30173. * Creates a video texture straight from your WebCam video feed.
  30174. * @param scene Define the scene the texture should be created in
  30175. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30176. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30177. * @returns The created video texture as a promise
  30178. */
  30179. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30180. minWidth: number;
  30181. maxWidth: number;
  30182. minHeight: number;
  30183. maxHeight: number;
  30184. deviceId: string;
  30185. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30186. /**
  30187. * Creates a video texture straight from your WebCam video feed.
  30188. * @param scene Define the scene the texture should be created in
  30189. * @param onReady Define a callback to triggered once the texture will be ready
  30190. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30191. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30192. */
  30193. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30194. minWidth: number;
  30195. maxWidth: number;
  30196. minHeight: number;
  30197. maxHeight: number;
  30198. deviceId: string;
  30199. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30200. }
  30201. }
  30202. declare module "babylonjs/Engines/thinEngine" {
  30203. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30204. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  30205. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30206. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30207. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30208. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30209. import { Observable } from "babylonjs/Misc/observable";
  30210. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30211. import { StencilState } from "babylonjs/States/stencilState";
  30212. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30213. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30214. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30215. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30216. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30217. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30218. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30219. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30220. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30221. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30222. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30223. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30224. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  30225. /**
  30226. * Defines the interface used by objects working like Scene
  30227. * @hidden
  30228. */
  30229. interface ISceneLike {
  30230. _addPendingData(data: any): void;
  30231. _removePendingData(data: any): void;
  30232. offlineProvider: IOfflineProvider;
  30233. }
  30234. /** Interface defining initialization parameters for Engine class */
  30235. export interface EngineOptions extends WebGLContextAttributes {
  30236. /**
  30237. * Defines if the engine should no exceed a specified device ratio
  30238. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30239. */
  30240. limitDeviceRatio?: number;
  30241. /**
  30242. * Defines if webvr should be enabled automatically
  30243. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30244. */
  30245. autoEnableWebVR?: boolean;
  30246. /**
  30247. * Defines if webgl2 should be turned off even if supported
  30248. * @see http://doc.babylonjs.com/features/webgl2
  30249. */
  30250. disableWebGL2Support?: boolean;
  30251. /**
  30252. * Defines if webaudio should be initialized as well
  30253. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30254. */
  30255. audioEngine?: boolean;
  30256. /**
  30257. * Defines if animations should run using a deterministic lock step
  30258. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30259. */
  30260. deterministicLockstep?: boolean;
  30261. /** Defines the maximum steps to use with deterministic lock step mode */
  30262. lockstepMaxSteps?: number;
  30263. /**
  30264. * Defines that engine should ignore context lost events
  30265. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30266. */
  30267. doNotHandleContextLost?: boolean;
  30268. /**
  30269. * Defines that engine should ignore modifying touch action attribute and style
  30270. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30271. */
  30272. doNotHandleTouchAction?: boolean;
  30273. /**
  30274. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30275. */
  30276. useHighPrecisionFloats?: boolean;
  30277. }
  30278. /**
  30279. * The base engine class (root of all engines)
  30280. */
  30281. export class ThinEngine {
  30282. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30283. static ExceptionList: ({
  30284. key: string;
  30285. capture: string;
  30286. captureConstraint: number;
  30287. targets: string[];
  30288. } | {
  30289. key: string;
  30290. capture: null;
  30291. captureConstraint: null;
  30292. targets: string[];
  30293. })[];
  30294. /** @hidden */
  30295. static _TextureLoaders: IInternalTextureLoader[];
  30296. /**
  30297. * Returns the current npm package of the sdk
  30298. */
  30299. static readonly NpmPackage: string;
  30300. /**
  30301. * Returns the current version of the framework
  30302. */
  30303. static readonly Version: string;
  30304. /**
  30305. * Returns a string describing the current engine
  30306. */
  30307. readonly description: string;
  30308. /**
  30309. * Gets or sets the epsilon value used by collision engine
  30310. */
  30311. static CollisionsEpsilon: number;
  30312. /**
  30313. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30314. */
  30315. static ShadersRepository: string;
  30316. /** @hidden */
  30317. _shaderProcessor: IShaderProcessor;
  30318. /**
  30319. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30320. */
  30321. forcePOTTextures: boolean;
  30322. /**
  30323. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30324. */
  30325. isFullscreen: boolean;
  30326. /**
  30327. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30328. */
  30329. cullBackFaces: boolean;
  30330. /**
  30331. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30332. */
  30333. renderEvenInBackground: boolean;
  30334. /**
  30335. * Gets or sets a boolean indicating that cache can be kept between frames
  30336. */
  30337. preventCacheWipeBetweenFrames: boolean;
  30338. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30339. validateShaderPrograms: boolean;
  30340. /**
  30341. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30342. * This can provide greater z depth for distant objects.
  30343. */
  30344. useReverseDepthBuffer: boolean;
  30345. /**
  30346. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30347. */
  30348. disableUniformBuffers: boolean;
  30349. /** @hidden */
  30350. _uniformBuffers: UniformBuffer[];
  30351. /**
  30352. * Gets a boolean indicating that the engine supports uniform buffers
  30353. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30354. */
  30355. readonly supportsUniformBuffers: boolean;
  30356. /** @hidden */
  30357. _gl: WebGLRenderingContext;
  30358. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30359. protected _windowIsBackground: boolean;
  30360. protected _webGLVersion: number;
  30361. protected _creationOptions: EngineOptions;
  30362. protected _highPrecisionShadersAllowed: boolean;
  30363. /** @hidden */
  30364. readonly _shouldUseHighPrecisionShader: boolean;
  30365. /**
  30366. * Gets a boolean indicating that only power of 2 textures are supported
  30367. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30368. */
  30369. readonly needPOTTextures: boolean;
  30370. /** @hidden */
  30371. _badOS: boolean;
  30372. /** @hidden */
  30373. _badDesktopOS: boolean;
  30374. private _hardwareScalingLevel;
  30375. /** @hidden */
  30376. _caps: EngineCapabilities;
  30377. private _isStencilEnable;
  30378. protected _colorWrite: boolean;
  30379. private _glVersion;
  30380. private _glRenderer;
  30381. private _glVendor;
  30382. /** @hidden */
  30383. _videoTextureSupported: boolean;
  30384. protected _renderingQueueLaunched: boolean;
  30385. protected _activeRenderLoops: (() => void)[];
  30386. /**
  30387. * Observable signaled when a context lost event is raised
  30388. */
  30389. onContextLostObservable: Observable<ThinEngine>;
  30390. /**
  30391. * Observable signaled when a context restored event is raised
  30392. */
  30393. onContextRestoredObservable: Observable<ThinEngine>;
  30394. private _onContextLost;
  30395. private _onContextRestored;
  30396. protected _contextWasLost: boolean;
  30397. /** @hidden */
  30398. _doNotHandleContextLost: boolean;
  30399. /**
  30400. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30401. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30402. */
  30403. doNotHandleContextLost: boolean;
  30404. /**
  30405. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30406. */
  30407. disableVertexArrayObjects: boolean;
  30408. /** @hidden */
  30409. protected _depthCullingState: DepthCullingState;
  30410. /** @hidden */
  30411. protected _stencilState: StencilState;
  30412. /** @hidden */
  30413. protected _alphaState: AlphaState;
  30414. /** @hidden */
  30415. _internalTexturesCache: InternalTexture[];
  30416. /** @hidden */
  30417. protected _activeChannel: number;
  30418. private _currentTextureChannel;
  30419. /** @hidden */
  30420. protected _boundTexturesCache: {
  30421. [key: string]: Nullable<InternalTexture>;
  30422. };
  30423. /** @hidden */
  30424. protected _currentEffect: Nullable<Effect>;
  30425. /** @hidden */
  30426. protected _currentProgram: Nullable<WebGLProgram>;
  30427. private _compiledEffects;
  30428. private _vertexAttribArraysEnabled;
  30429. /** @hidden */
  30430. protected _cachedViewport: Nullable<IViewportLike>;
  30431. private _cachedVertexArrayObject;
  30432. /** @hidden */
  30433. protected _cachedVertexBuffers: any;
  30434. /** @hidden */
  30435. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30436. /** @hidden */
  30437. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30438. /** @hidden */
  30439. _currentRenderTarget: Nullable<InternalTexture>;
  30440. private _uintIndicesCurrentlySet;
  30441. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30442. /** @hidden */
  30443. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30444. private _currentBufferPointers;
  30445. private _currentInstanceLocations;
  30446. private _currentInstanceBuffers;
  30447. private _textureUnits;
  30448. /** @hidden */
  30449. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30450. /** @hidden */
  30451. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30452. /** @hidden */
  30453. _boundRenderFunction: any;
  30454. private _vaoRecordInProgress;
  30455. private _mustWipeVertexAttributes;
  30456. private _emptyTexture;
  30457. private _emptyCubeTexture;
  30458. private _emptyTexture3D;
  30459. private _emptyTexture2DArray;
  30460. /** @hidden */
  30461. _frameHandler: number;
  30462. private _nextFreeTextureSlots;
  30463. private _maxSimultaneousTextures;
  30464. private _activeRequests;
  30465. protected _texturesSupported: string[];
  30466. /** @hidden */
  30467. _textureFormatInUse: Nullable<string>;
  30468. protected readonly _supportsHardwareTextureRescaling: boolean;
  30469. /**
  30470. * Gets the list of texture formats supported
  30471. */
  30472. readonly texturesSupported: Array<string>;
  30473. /**
  30474. * Gets the list of texture formats in use
  30475. */
  30476. readonly textureFormatInUse: Nullable<string>;
  30477. /**
  30478. * Gets the current viewport
  30479. */
  30480. readonly currentViewport: Nullable<IViewportLike>;
  30481. /**
  30482. * Gets the default empty texture
  30483. */
  30484. readonly emptyTexture: InternalTexture;
  30485. /**
  30486. * Gets the default empty 3D texture
  30487. */
  30488. readonly emptyTexture3D: InternalTexture;
  30489. /**
  30490. * Gets the default empty 2D array texture
  30491. */
  30492. readonly emptyTexture2DArray: InternalTexture;
  30493. /**
  30494. * Gets the default empty cube texture
  30495. */
  30496. readonly emptyCubeTexture: InternalTexture;
  30497. /**
  30498. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30499. */
  30500. readonly premultipliedAlpha: boolean;
  30501. /**
  30502. * Observable event triggered before each texture is initialized
  30503. */
  30504. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30505. /**
  30506. * Creates a new engine
  30507. * @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
  30508. * @param antialias defines enable antialiasing (default: false)
  30509. * @param options defines further options to be sent to the getContext() function
  30510. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30511. */
  30512. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30513. private _rebuildInternalTextures;
  30514. private _rebuildEffects;
  30515. /**
  30516. * Gets a boolean indicating if all created effects are ready
  30517. * @returns true if all effects are ready
  30518. */
  30519. areAllEffectsReady(): boolean;
  30520. protected _rebuildBuffers(): void;
  30521. private _initGLContext;
  30522. /**
  30523. * Gets version of the current webGL context
  30524. */
  30525. readonly webGLVersion: number;
  30526. /**
  30527. * Gets a string idenfifying the name of the class
  30528. * @returns "Engine" string
  30529. */
  30530. getClassName(): string;
  30531. /**
  30532. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30533. */
  30534. readonly isStencilEnable: boolean;
  30535. /** @hidden */
  30536. _prepareWorkingCanvas(): void;
  30537. /**
  30538. * Reset the texture cache to empty state
  30539. */
  30540. resetTextureCache(): void;
  30541. /**
  30542. * Gets an object containing information about the current webGL context
  30543. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30544. */
  30545. getGlInfo(): {
  30546. vendor: string;
  30547. renderer: string;
  30548. version: string;
  30549. };
  30550. /**
  30551. * Defines the hardware scaling level.
  30552. * By default the hardware scaling level is computed from the window device ratio.
  30553. * 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.
  30554. * @param level defines the level to use
  30555. */
  30556. setHardwareScalingLevel(level: number): void;
  30557. /**
  30558. * Gets the current hardware scaling level.
  30559. * By default the hardware scaling level is computed from the window device ratio.
  30560. * 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.
  30561. * @returns a number indicating the current hardware scaling level
  30562. */
  30563. getHardwareScalingLevel(): number;
  30564. /**
  30565. * Gets the list of loaded textures
  30566. * @returns an array containing all loaded textures
  30567. */
  30568. getLoadedTexturesCache(): InternalTexture[];
  30569. /**
  30570. * Gets the object containing all engine capabilities
  30571. * @returns the EngineCapabilities object
  30572. */
  30573. getCaps(): EngineCapabilities;
  30574. /**
  30575. * stop executing a render loop function and remove it from the execution array
  30576. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30577. */
  30578. stopRenderLoop(renderFunction?: () => void): void;
  30579. /** @hidden */
  30580. _renderLoop(): void;
  30581. /**
  30582. * Gets the HTML canvas attached with the current webGL context
  30583. * @returns a HTML canvas
  30584. */
  30585. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30586. /**
  30587. * Gets host window
  30588. * @returns the host window object
  30589. */
  30590. getHostWindow(): Nullable<Window>;
  30591. /**
  30592. * Gets the current render width
  30593. * @param useScreen defines if screen size must be used (or the current render target if any)
  30594. * @returns a number defining the current render width
  30595. */
  30596. getRenderWidth(useScreen?: boolean): number;
  30597. /**
  30598. * Gets the current render height
  30599. * @param useScreen defines if screen size must be used (or the current render target if any)
  30600. * @returns a number defining the current render height
  30601. */
  30602. getRenderHeight(useScreen?: boolean): number;
  30603. /**
  30604. * Can be used to override the current requestAnimationFrame requester.
  30605. * @hidden
  30606. */
  30607. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30608. /**
  30609. * Register and execute a render loop. The engine can have more than one render function
  30610. * @param renderFunction defines the function to continuously execute
  30611. */
  30612. runRenderLoop(renderFunction: () => void): void;
  30613. /**
  30614. * Clear the current render buffer or the current render target (if any is set up)
  30615. * @param color defines the color to use
  30616. * @param backBuffer defines if the back buffer must be cleared
  30617. * @param depth defines if the depth buffer must be cleared
  30618. * @param stencil defines if the stencil buffer must be cleared
  30619. */
  30620. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30621. private _viewportCached;
  30622. /** @hidden */
  30623. _viewport(x: number, y: number, width: number, height: number): void;
  30624. /**
  30625. * Set the WebGL's viewport
  30626. * @param viewport defines the viewport element to be used
  30627. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30628. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30629. */
  30630. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30631. /**
  30632. * Begin a new frame
  30633. */
  30634. beginFrame(): void;
  30635. /**
  30636. * Enf the current frame
  30637. */
  30638. endFrame(): void;
  30639. /**
  30640. * Resize the view according to the canvas' size
  30641. */
  30642. resize(): void;
  30643. /**
  30644. * Force a specific size of the canvas
  30645. * @param width defines the new canvas' width
  30646. * @param height defines the new canvas' height
  30647. */
  30648. setSize(width: number, height: number): void;
  30649. /**
  30650. * Binds the frame buffer to the specified texture.
  30651. * @param texture The texture to render to or null for the default canvas
  30652. * @param faceIndex The face of the texture to render to in case of cube texture
  30653. * @param requiredWidth The width of the target to render to
  30654. * @param requiredHeight The height of the target to render to
  30655. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30656. * @param depthStencilTexture The depth stencil texture to use to render
  30657. * @param lodLevel defines le lod level to bind to the frame buffer
  30658. */
  30659. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30660. /** @hidden */
  30661. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30662. /**
  30663. * Unbind the current render target texture from the webGL context
  30664. * @param texture defines the render target texture to unbind
  30665. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30666. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30667. */
  30668. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30669. /**
  30670. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30671. */
  30672. flushFramebuffer(): void;
  30673. /**
  30674. * Unbind the current render target and bind the default framebuffer
  30675. */
  30676. restoreDefaultFramebuffer(): void;
  30677. /** @hidden */
  30678. protected _resetVertexBufferBinding(): void;
  30679. /**
  30680. * Creates a vertex buffer
  30681. * @param data the data for the vertex buffer
  30682. * @returns the new WebGL static buffer
  30683. */
  30684. createVertexBuffer(data: DataArray): DataBuffer;
  30685. private _createVertexBuffer;
  30686. /**
  30687. * Creates a dynamic vertex buffer
  30688. * @param data the data for the dynamic vertex buffer
  30689. * @returns the new WebGL dynamic buffer
  30690. */
  30691. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30692. protected _resetIndexBufferBinding(): void;
  30693. /**
  30694. * Creates a new index buffer
  30695. * @param indices defines the content of the index buffer
  30696. * @param updatable defines if the index buffer must be updatable
  30697. * @returns a new webGL buffer
  30698. */
  30699. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30700. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30701. /**
  30702. * Bind a webGL buffer to the webGL context
  30703. * @param buffer defines the buffer to bind
  30704. */
  30705. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30706. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30707. private bindBuffer;
  30708. /**
  30709. * update the bound buffer with the given data
  30710. * @param data defines the data to update
  30711. */
  30712. updateArrayBuffer(data: Float32Array): void;
  30713. private _vertexAttribPointer;
  30714. private _bindIndexBufferWithCache;
  30715. private _bindVertexBuffersAttributes;
  30716. /**
  30717. * Records a vertex array object
  30718. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30719. * @param vertexBuffers defines the list of vertex buffers to store
  30720. * @param indexBuffer defines the index buffer to store
  30721. * @param effect defines the effect to store
  30722. * @returns the new vertex array object
  30723. */
  30724. recordVertexArrayObject(vertexBuffers: {
  30725. [key: string]: VertexBuffer;
  30726. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30727. /**
  30728. * Bind a specific vertex array object
  30729. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30730. * @param vertexArrayObject defines the vertex array object to bind
  30731. * @param indexBuffer defines the index buffer to bind
  30732. */
  30733. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30734. /**
  30735. * Bind webGl buffers directly to the webGL context
  30736. * @param vertexBuffer defines the vertex buffer to bind
  30737. * @param indexBuffer defines the index buffer to bind
  30738. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30739. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30740. * @param effect defines the effect associated with the vertex buffer
  30741. */
  30742. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30743. private _unbindVertexArrayObject;
  30744. /**
  30745. * Bind a list of vertex buffers to the webGL context
  30746. * @param vertexBuffers defines the list of vertex buffers to bind
  30747. * @param indexBuffer defines the index buffer to bind
  30748. * @param effect defines the effect associated with the vertex buffers
  30749. */
  30750. bindBuffers(vertexBuffers: {
  30751. [key: string]: Nullable<VertexBuffer>;
  30752. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30753. /**
  30754. * Unbind all instance attributes
  30755. */
  30756. unbindInstanceAttributes(): void;
  30757. /**
  30758. * Release and free the memory of a vertex array object
  30759. * @param vao defines the vertex array object to delete
  30760. */
  30761. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30762. /** @hidden */
  30763. _releaseBuffer(buffer: DataBuffer): boolean;
  30764. protected _deleteBuffer(buffer: DataBuffer): void;
  30765. /**
  30766. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30767. * @param instancesBuffer defines the webGL buffer to update and bind
  30768. * @param data defines the data to store in the buffer
  30769. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30770. */
  30771. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30772. /**
  30773. * Apply all cached states (depth, culling, stencil and alpha)
  30774. */
  30775. applyStates(): void;
  30776. /**
  30777. * Send a draw order
  30778. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30779. * @param indexStart defines the starting index
  30780. * @param indexCount defines the number of index to draw
  30781. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30782. */
  30783. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30784. /**
  30785. * Draw a list of points
  30786. * @param verticesStart defines the index of first vertex to draw
  30787. * @param verticesCount defines the count of vertices to draw
  30788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30789. */
  30790. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30791. /**
  30792. * Draw a list of unindexed primitives
  30793. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30794. * @param verticesStart defines the index of first vertex to draw
  30795. * @param verticesCount defines the count of vertices to draw
  30796. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30797. */
  30798. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30799. /**
  30800. * Draw a list of indexed primitives
  30801. * @param fillMode defines the primitive to use
  30802. * @param indexStart defines the starting index
  30803. * @param indexCount defines the number of index to draw
  30804. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30805. */
  30806. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30807. /**
  30808. * Draw a list of unindexed primitives
  30809. * @param fillMode defines the primitive to use
  30810. * @param verticesStart defines the index of first vertex to draw
  30811. * @param verticesCount defines the count of vertices to draw
  30812. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30813. */
  30814. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30815. private _drawMode;
  30816. /** @hidden */
  30817. protected _reportDrawCall(): void;
  30818. /** @hidden */
  30819. _releaseEffect(effect: Effect): void;
  30820. /** @hidden */
  30821. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30822. /**
  30823. * Create a new effect (used to store vertex/fragment shaders)
  30824. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30825. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30826. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30827. * @param samplers defines an array of string used to represent textures
  30828. * @param defines defines the string containing the defines to use to compile the shaders
  30829. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30830. * @param onCompiled defines a function to call when the effect creation is successful
  30831. * @param onError defines a function to call when the effect creation has failed
  30832. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30833. * @returns the new Effect
  30834. */
  30835. 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;
  30836. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30837. private _compileShader;
  30838. private _compileRawShader;
  30839. /**
  30840. * Directly creates a webGL program
  30841. * @param pipelineContext defines the pipeline context to attach to
  30842. * @param vertexCode defines the vertex shader code to use
  30843. * @param fragmentCode defines the fragment shader code to use
  30844. * @param context defines the webGL context to use (if not set, the current one will be used)
  30845. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30846. * @returns the new webGL program
  30847. */
  30848. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30849. /**
  30850. * Creates a webGL program
  30851. * @param pipelineContext defines the pipeline context to attach to
  30852. * @param vertexCode defines the vertex shader code to use
  30853. * @param fragmentCode defines the fragment shader code to use
  30854. * @param defines defines the string containing the defines to use to compile the shaders
  30855. * @param context defines the webGL context to use (if not set, the current one will be used)
  30856. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30857. * @returns the new webGL program
  30858. */
  30859. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30860. /**
  30861. * Creates a new pipeline context
  30862. * @returns the new pipeline
  30863. */
  30864. createPipelineContext(): IPipelineContext;
  30865. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30866. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30867. /** @hidden */
  30868. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30869. /** @hidden */
  30870. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30871. /** @hidden */
  30872. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30873. /**
  30874. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30875. * @param pipelineContext defines the pipeline context to use
  30876. * @param uniformsNames defines the list of uniform names
  30877. * @returns an array of webGL uniform locations
  30878. */
  30879. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30880. /**
  30881. * Gets the lsit of active attributes for a given webGL program
  30882. * @param pipelineContext defines the pipeline context to use
  30883. * @param attributesNames defines the list of attribute names to get
  30884. * @returns an array of indices indicating the offset of each attribute
  30885. */
  30886. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30887. /**
  30888. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30889. * @param effect defines the effect to activate
  30890. */
  30891. enableEffect(effect: Nullable<Effect>): void;
  30892. /**
  30893. * Set the value of an uniform to a number (int)
  30894. * @param uniform defines the webGL uniform location where to store the value
  30895. * @param value defines the int number to store
  30896. */
  30897. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30898. /**
  30899. * Set the value of an uniform to an array of int32
  30900. * @param uniform defines the webGL uniform location where to store the value
  30901. * @param array defines the array of int32 to store
  30902. */
  30903. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30904. /**
  30905. * Set the value of an uniform to an array of int32 (stored as vec2)
  30906. * @param uniform defines the webGL uniform location where to store the value
  30907. * @param array defines the array of int32 to store
  30908. */
  30909. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30910. /**
  30911. * Set the value of an uniform to an array of int32 (stored as vec3)
  30912. * @param uniform defines the webGL uniform location where to store the value
  30913. * @param array defines the array of int32 to store
  30914. */
  30915. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30916. /**
  30917. * Set the value of an uniform to an array of int32 (stored as vec4)
  30918. * @param uniform defines the webGL uniform location where to store the value
  30919. * @param array defines the array of int32 to store
  30920. */
  30921. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30922. /**
  30923. * Set the value of an uniform to an array of number
  30924. * @param uniform defines the webGL uniform location where to store the value
  30925. * @param array defines the array of number to store
  30926. */
  30927. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30928. /**
  30929. * Set the value of an uniform to an array of number (stored as vec2)
  30930. * @param uniform defines the webGL uniform location where to store the value
  30931. * @param array defines the array of number to store
  30932. */
  30933. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30934. /**
  30935. * Set the value of an uniform to an array of number (stored as vec3)
  30936. * @param uniform defines the webGL uniform location where to store the value
  30937. * @param array defines the array of number to store
  30938. */
  30939. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30940. /**
  30941. * Set the value of an uniform to an array of number (stored as vec4)
  30942. * @param uniform defines the webGL uniform location where to store the value
  30943. * @param array defines the array of number to store
  30944. */
  30945. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  30946. /**
  30947. * Set the value of an uniform to an array of float32 (stored as matrices)
  30948. * @param uniform defines the webGL uniform location where to store the value
  30949. * @param matrices defines the array of float32 to store
  30950. */
  30951. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30952. /**
  30953. * Set the value of an uniform to a matrix (3x3)
  30954. * @param uniform defines the webGL uniform location where to store the value
  30955. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30956. */
  30957. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30958. /**
  30959. * Set the value of an uniform to a matrix (2x2)
  30960. * @param uniform defines the webGL uniform location where to store the value
  30961. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30962. */
  30963. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30964. /**
  30965. * Set the value of an uniform to a number (float)
  30966. * @param uniform defines the webGL uniform location where to store the value
  30967. * @param value defines the float number to store
  30968. */
  30969. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30970. /**
  30971. * Set the value of an uniform to a vec2
  30972. * @param uniform defines the webGL uniform location where to store the value
  30973. * @param x defines the 1st component of the value
  30974. * @param y defines the 2nd component of the value
  30975. */
  30976. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30977. /**
  30978. * Set the value of an uniform to a vec3
  30979. * @param uniform defines the webGL uniform location where to store the value
  30980. * @param x defines the 1st component of the value
  30981. * @param y defines the 2nd component of the value
  30982. * @param z defines the 3rd component of the value
  30983. */
  30984. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30985. /**
  30986. * Set the value of an uniform to a vec4
  30987. * @param uniform defines the webGL uniform location where to store the value
  30988. * @param x defines the 1st component of the value
  30989. * @param y defines the 2nd component of the value
  30990. * @param z defines the 3rd component of the value
  30991. * @param w defines the 4th component of the value
  30992. */
  30993. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30994. /**
  30995. * Gets the depth culling state manager
  30996. */
  30997. readonly depthCullingState: DepthCullingState;
  30998. /**
  30999. * Gets the alpha state manager
  31000. */
  31001. readonly alphaState: AlphaState;
  31002. /**
  31003. * Gets the stencil state manager
  31004. */
  31005. readonly stencilState: StencilState;
  31006. /**
  31007. * Clears the list of texture accessible through engine.
  31008. * This can help preventing texture load conflict due to name collision.
  31009. */
  31010. clearInternalTexturesCache(): void;
  31011. /**
  31012. * Force the entire cache to be cleared
  31013. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31014. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31015. */
  31016. wipeCaches(bruteForce?: boolean): void;
  31017. /** @hidden */
  31018. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31019. min: number;
  31020. mag: number;
  31021. };
  31022. /** @hidden */
  31023. _createTexture(): WebGLTexture;
  31024. /**
  31025. * Usually called from Texture.ts.
  31026. * Passed information to create a WebGLTexture
  31027. * @param urlArg defines a value which contains one of the following:
  31028. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31029. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31030. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31031. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31032. * @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)
  31033. * @param scene needed for loading to the correct scene
  31034. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31035. * @param onLoad optional callback to be called upon successful completion
  31036. * @param onError optional callback to be called upon failure
  31037. * @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
  31038. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31039. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31040. * @param forcedExtension defines the extension to use to pick the right loader
  31041. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31042. * @param mimeType defines an optional mime type
  31043. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31044. */
  31045. 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;
  31046. /**
  31047. * @hidden
  31048. */
  31049. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31050. /**
  31051. * Creates a raw texture
  31052. * @param data defines the data to store in the texture
  31053. * @param width defines the width of the texture
  31054. * @param height defines the height of the texture
  31055. * @param format defines the format of the data
  31056. * @param generateMipMaps defines if the engine should generate the mip levels
  31057. * @param invertY defines if data must be stored with Y axis inverted
  31058. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31059. * @param compression defines the compression used (null by default)
  31060. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31061. * @returns the raw texture inside an InternalTexture
  31062. */
  31063. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31064. /**
  31065. * Creates a new raw cube texture
  31066. * @param data defines the array of data to use to create each face
  31067. * @param size defines the size of the textures
  31068. * @param format defines the format of the data
  31069. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31070. * @param generateMipMaps defines if the engine should generate the mip levels
  31071. * @param invertY defines if data must be stored with Y axis inverted
  31072. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31073. * @param compression defines the compression used (null by default)
  31074. * @returns the cube texture as an InternalTexture
  31075. */
  31076. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31077. /**
  31078. * Creates a new raw 3D texture
  31079. * @param data defines the data used to create the texture
  31080. * @param width defines the width of the texture
  31081. * @param height defines the height of the texture
  31082. * @param depth defines the depth of the texture
  31083. * @param format defines the format of the texture
  31084. * @param generateMipMaps defines if the engine must generate mip levels
  31085. * @param invertY defines if data must be stored with Y axis inverted
  31086. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31087. * @param compression defines the compressed used (can be null)
  31088. * @param textureType defines the compressed used (can be null)
  31089. * @returns a new raw 3D texture (stored in an InternalTexture)
  31090. */
  31091. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31092. /**
  31093. * Creates a new raw 2D array texture
  31094. * @param data defines the data used to create the texture
  31095. * @param width defines the width of the texture
  31096. * @param height defines the height of the texture
  31097. * @param depth defines the number of layers of the texture
  31098. * @param format defines the format of the texture
  31099. * @param generateMipMaps defines if the engine must generate mip levels
  31100. * @param invertY defines if data must be stored with Y axis inverted
  31101. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31102. * @param compression defines the compressed used (can be null)
  31103. * @param textureType defines the compressed used (can be null)
  31104. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31105. */
  31106. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31107. private _unpackFlipYCached;
  31108. /**
  31109. * In case you are sharing the context with other applications, it might
  31110. * be interested to not cache the unpack flip y state to ensure a consistent
  31111. * value would be set.
  31112. */
  31113. enableUnpackFlipYCached: boolean;
  31114. /** @hidden */
  31115. _unpackFlipY(value: boolean): void;
  31116. /** @hidden */
  31117. _getUnpackAlignement(): number;
  31118. /**
  31119. * Update the sampling mode of a given texture
  31120. * @param samplingMode defines the required sampling mode
  31121. * @param texture defines the texture to update
  31122. */
  31123. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  31124. /** @hidden */
  31125. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31126. width: number;
  31127. height: number;
  31128. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31129. /** @hidden */
  31130. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31131. /** @hidden */
  31132. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31133. /** @hidden */
  31134. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31135. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31136. private _prepareWebGLTexture;
  31137. /** @hidden */
  31138. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31139. /** @hidden */
  31140. _releaseFramebufferObjects(texture: InternalTexture): void;
  31141. /** @hidden */
  31142. _releaseTexture(texture: InternalTexture): void;
  31143. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31144. protected _setProgram(program: WebGLProgram): void;
  31145. protected _boundUniforms: {
  31146. [key: number]: WebGLUniformLocation;
  31147. };
  31148. /**
  31149. * Binds an effect to the webGL context
  31150. * @param effect defines the effect to bind
  31151. */
  31152. bindSamplers(effect: Effect): void;
  31153. private _activateCurrentTexture;
  31154. /** @hidden */
  31155. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31156. /** @hidden */
  31157. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31158. /**
  31159. * Unbind all textures from the webGL context
  31160. */
  31161. unbindAllTextures(): void;
  31162. /**
  31163. * Sets a texture to the according uniform.
  31164. * @param channel The texture channel
  31165. * @param uniform The uniform to set
  31166. * @param texture The texture to apply
  31167. */
  31168. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31169. private _bindSamplerUniformToChannel;
  31170. private _getTextureWrapMode;
  31171. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31172. /**
  31173. * Sets an array of texture to the webGL context
  31174. * @param channel defines the channel where the texture array must be set
  31175. * @param uniform defines the associated uniform location
  31176. * @param textures defines the array of textures to bind
  31177. */
  31178. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31179. /** @hidden */
  31180. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31181. private _setTextureParameterFloat;
  31182. private _setTextureParameterInteger;
  31183. /**
  31184. * Unbind all vertex attributes from the webGL context
  31185. */
  31186. unbindAllAttributes(): void;
  31187. /**
  31188. * 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
  31189. */
  31190. releaseEffects(): void;
  31191. /**
  31192. * Dispose and release all associated resources
  31193. */
  31194. dispose(): void;
  31195. /**
  31196. * Attach a new callback raised when context lost event is fired
  31197. * @param callback defines the callback to call
  31198. */
  31199. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31200. /**
  31201. * Attach a new callback raised when context restored event is fired
  31202. * @param callback defines the callback to call
  31203. */
  31204. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31205. /**
  31206. * Get the current error code of the webGL context
  31207. * @returns the error code
  31208. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31209. */
  31210. getError(): number;
  31211. private _canRenderToFloatFramebuffer;
  31212. private _canRenderToHalfFloatFramebuffer;
  31213. private _canRenderToFramebuffer;
  31214. /** @hidden */
  31215. _getWebGLTextureType(type: number): number;
  31216. /** @hidden */
  31217. _getInternalFormat(format: number): number;
  31218. /** @hidden */
  31219. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31220. /** @hidden */
  31221. _getRGBAMultiSampleBufferFormat(type: number): number;
  31222. /** @hidden */
  31223. _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;
  31224. /**
  31225. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31226. * @returns true if the engine can be created
  31227. * @ignorenaming
  31228. */
  31229. static isSupported(): boolean;
  31230. /**
  31231. * Find the next highest power of two.
  31232. * @param x Number to start search from.
  31233. * @return Next highest power of two.
  31234. */
  31235. static CeilingPOT(x: number): number;
  31236. /**
  31237. * Find the next lowest power of two.
  31238. * @param x Number to start search from.
  31239. * @return Next lowest power of two.
  31240. */
  31241. static FloorPOT(x: number): number;
  31242. /**
  31243. * Find the nearest power of two.
  31244. * @param x Number to start search from.
  31245. * @return Next nearest power of two.
  31246. */
  31247. static NearestPOT(x: number): number;
  31248. /**
  31249. * Get the closest exponent of two
  31250. * @param value defines the value to approximate
  31251. * @param max defines the maximum value to return
  31252. * @param mode defines how to define the closest value
  31253. * @returns closest exponent of two of the given value
  31254. */
  31255. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31256. /**
  31257. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31258. * @param func - the function to be called
  31259. * @param requester - the object that will request the next frame. Falls back to window.
  31260. * @returns frame number
  31261. */
  31262. static QueueNewFrame(func: () => void, requester?: any): number;
  31263. }
  31264. }
  31265. declare module "babylonjs/Maths/sphericalPolynomial" {
  31266. import { Vector3 } from "babylonjs/Maths/math.vector";
  31267. import { Color3 } from "babylonjs/Maths/math.color";
  31268. /**
  31269. * Class representing spherical harmonics coefficients to the 3rd degree
  31270. */
  31271. export class SphericalHarmonics {
  31272. /**
  31273. * Defines whether or not the harmonics have been prescaled for rendering.
  31274. */
  31275. preScaled: boolean;
  31276. /**
  31277. * The l0,0 coefficients of the spherical harmonics
  31278. */
  31279. l00: Vector3;
  31280. /**
  31281. * The l1,-1 coefficients of the spherical harmonics
  31282. */
  31283. l1_1: Vector3;
  31284. /**
  31285. * The l1,0 coefficients of the spherical harmonics
  31286. */
  31287. l10: Vector3;
  31288. /**
  31289. * The l1,1 coefficients of the spherical harmonics
  31290. */
  31291. l11: Vector3;
  31292. /**
  31293. * The l2,-2 coefficients of the spherical harmonics
  31294. */
  31295. l2_2: Vector3;
  31296. /**
  31297. * The l2,-1 coefficients of the spherical harmonics
  31298. */
  31299. l2_1: Vector3;
  31300. /**
  31301. * The l2,0 coefficients of the spherical harmonics
  31302. */
  31303. l20: Vector3;
  31304. /**
  31305. * The l2,1 coefficients of the spherical harmonics
  31306. */
  31307. l21: Vector3;
  31308. /**
  31309. * The l2,2 coefficients of the spherical harmonics
  31310. */
  31311. l22: Vector3;
  31312. /**
  31313. * Adds a light to the spherical harmonics
  31314. * @param direction the direction of the light
  31315. * @param color the color of the light
  31316. * @param deltaSolidAngle the delta solid angle of the light
  31317. */
  31318. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31319. /**
  31320. * Scales the spherical harmonics by the given amount
  31321. * @param scale the amount to scale
  31322. */
  31323. scaleInPlace(scale: number): void;
  31324. /**
  31325. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31326. *
  31327. * ```
  31328. * E_lm = A_l * L_lm
  31329. * ```
  31330. *
  31331. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31332. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31333. * the scaling factors are given in equation 9.
  31334. */
  31335. convertIncidentRadianceToIrradiance(): void;
  31336. /**
  31337. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31338. *
  31339. * ```
  31340. * L = (1/pi) * E * rho
  31341. * ```
  31342. *
  31343. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31344. */
  31345. convertIrradianceToLambertianRadiance(): void;
  31346. /**
  31347. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31348. * required operations at run time.
  31349. *
  31350. * This is simply done by scaling back the SH with Ylm constants parameter.
  31351. * The trigonometric part being applied by the shader at run time.
  31352. */
  31353. preScaleForRendering(): void;
  31354. /**
  31355. * Constructs a spherical harmonics from an array.
  31356. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31357. * @returns the spherical harmonics
  31358. */
  31359. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31360. /**
  31361. * Gets the spherical harmonics from polynomial
  31362. * @param polynomial the spherical polynomial
  31363. * @returns the spherical harmonics
  31364. */
  31365. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31366. }
  31367. /**
  31368. * Class representing spherical polynomial coefficients to the 3rd degree
  31369. */
  31370. export class SphericalPolynomial {
  31371. private _harmonics;
  31372. /**
  31373. * The spherical harmonics used to create the polynomials.
  31374. */
  31375. readonly preScaledHarmonics: SphericalHarmonics;
  31376. /**
  31377. * The x coefficients of the spherical polynomial
  31378. */
  31379. x: Vector3;
  31380. /**
  31381. * The y coefficients of the spherical polynomial
  31382. */
  31383. y: Vector3;
  31384. /**
  31385. * The z coefficients of the spherical polynomial
  31386. */
  31387. z: Vector3;
  31388. /**
  31389. * The xx coefficients of the spherical polynomial
  31390. */
  31391. xx: Vector3;
  31392. /**
  31393. * The yy coefficients of the spherical polynomial
  31394. */
  31395. yy: Vector3;
  31396. /**
  31397. * The zz coefficients of the spherical polynomial
  31398. */
  31399. zz: Vector3;
  31400. /**
  31401. * The xy coefficients of the spherical polynomial
  31402. */
  31403. xy: Vector3;
  31404. /**
  31405. * The yz coefficients of the spherical polynomial
  31406. */
  31407. yz: Vector3;
  31408. /**
  31409. * The zx coefficients of the spherical polynomial
  31410. */
  31411. zx: Vector3;
  31412. /**
  31413. * Adds an ambient color to the spherical polynomial
  31414. * @param color the color to add
  31415. */
  31416. addAmbient(color: Color3): void;
  31417. /**
  31418. * Scales the spherical polynomial by the given amount
  31419. * @param scale the amount to scale
  31420. */
  31421. scaleInPlace(scale: number): void;
  31422. /**
  31423. * Gets the spherical polynomial from harmonics
  31424. * @param harmonics the spherical harmonics
  31425. * @returns the spherical polynomial
  31426. */
  31427. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  31428. /**
  31429. * Constructs a spherical polynomial from an array.
  31430. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  31431. * @returns the spherical polynomial
  31432. */
  31433. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  31434. }
  31435. }
  31436. declare module "babylonjs/Materials/Textures/internalTexture" {
  31437. import { Observable } from "babylonjs/Misc/observable";
  31438. import { Nullable, int } from "babylonjs/types";
  31439. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31440. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31441. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31442. /**
  31443. * Defines the source of the internal texture
  31444. */
  31445. export enum InternalTextureSource {
  31446. /**
  31447. * The source of the texture data is unknown
  31448. */
  31449. Unknown = 0,
  31450. /**
  31451. * Texture data comes from an URL
  31452. */
  31453. Url = 1,
  31454. /**
  31455. * Texture data is only used for temporary storage
  31456. */
  31457. Temp = 2,
  31458. /**
  31459. * Texture data comes from raw data (ArrayBuffer)
  31460. */
  31461. Raw = 3,
  31462. /**
  31463. * Texture content is dynamic (video or dynamic texture)
  31464. */
  31465. Dynamic = 4,
  31466. /**
  31467. * Texture content is generated by rendering to it
  31468. */
  31469. RenderTarget = 5,
  31470. /**
  31471. * Texture content is part of a multi render target process
  31472. */
  31473. MultiRenderTarget = 6,
  31474. /**
  31475. * Texture data comes from a cube data file
  31476. */
  31477. Cube = 7,
  31478. /**
  31479. * Texture data comes from a raw cube data
  31480. */
  31481. CubeRaw = 8,
  31482. /**
  31483. * Texture data come from a prefiltered cube data file
  31484. */
  31485. CubePrefiltered = 9,
  31486. /**
  31487. * Texture content is raw 3D data
  31488. */
  31489. Raw3D = 10,
  31490. /**
  31491. * Texture content is raw 2D array data
  31492. */
  31493. Raw2DArray = 11,
  31494. /**
  31495. * Texture content is a depth texture
  31496. */
  31497. Depth = 12,
  31498. /**
  31499. * Texture data comes from a raw cube data encoded with RGBD
  31500. */
  31501. CubeRawRGBD = 13
  31502. }
  31503. /**
  31504. * Class used to store data associated with WebGL texture data for the engine
  31505. * This class should not be used directly
  31506. */
  31507. export class InternalTexture {
  31508. /** @hidden */
  31509. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31510. /**
  31511. * Defines if the texture is ready
  31512. */
  31513. isReady: boolean;
  31514. /**
  31515. * Defines if the texture is a cube texture
  31516. */
  31517. isCube: boolean;
  31518. /**
  31519. * Defines if the texture contains 3D data
  31520. */
  31521. is3D: boolean;
  31522. /**
  31523. * Defines if the texture contains 2D array data
  31524. */
  31525. is2DArray: boolean;
  31526. /**
  31527. * Defines if the texture contains multiview data
  31528. */
  31529. isMultiview: boolean;
  31530. /**
  31531. * Gets the URL used to load this texture
  31532. */
  31533. url: string;
  31534. /**
  31535. * Gets the sampling mode of the texture
  31536. */
  31537. samplingMode: number;
  31538. /**
  31539. * Gets a boolean indicating if the texture needs mipmaps generation
  31540. */
  31541. generateMipMaps: boolean;
  31542. /**
  31543. * Gets the number of samples used by the texture (WebGL2+ only)
  31544. */
  31545. samples: number;
  31546. /**
  31547. * Gets the type of the texture (int, float...)
  31548. */
  31549. type: number;
  31550. /**
  31551. * Gets the format of the texture (RGB, RGBA...)
  31552. */
  31553. format: number;
  31554. /**
  31555. * Observable called when the texture is loaded
  31556. */
  31557. onLoadedObservable: Observable<InternalTexture>;
  31558. /**
  31559. * Gets the width of the texture
  31560. */
  31561. width: number;
  31562. /**
  31563. * Gets the height of the texture
  31564. */
  31565. height: number;
  31566. /**
  31567. * Gets the depth of the texture
  31568. */
  31569. depth: number;
  31570. /**
  31571. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31572. */
  31573. baseWidth: number;
  31574. /**
  31575. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31576. */
  31577. baseHeight: number;
  31578. /**
  31579. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31580. */
  31581. baseDepth: number;
  31582. /**
  31583. * Gets a boolean indicating if the texture is inverted on Y axis
  31584. */
  31585. invertY: boolean;
  31586. /** @hidden */
  31587. _invertVScale: boolean;
  31588. /** @hidden */
  31589. _associatedChannel: number;
  31590. /** @hidden */
  31591. _source: InternalTextureSource;
  31592. /** @hidden */
  31593. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  31594. /** @hidden */
  31595. _bufferView: Nullable<ArrayBufferView>;
  31596. /** @hidden */
  31597. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31598. /** @hidden */
  31599. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31600. /** @hidden */
  31601. _size: number;
  31602. /** @hidden */
  31603. _extension: string;
  31604. /** @hidden */
  31605. _files: Nullable<string[]>;
  31606. /** @hidden */
  31607. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31608. /** @hidden */
  31609. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31610. /** @hidden */
  31611. _framebuffer: Nullable<WebGLFramebuffer>;
  31612. /** @hidden */
  31613. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31614. /** @hidden */
  31615. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31616. /** @hidden */
  31617. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31618. /** @hidden */
  31619. _attachments: Nullable<number[]>;
  31620. /** @hidden */
  31621. _cachedCoordinatesMode: Nullable<number>;
  31622. /** @hidden */
  31623. _cachedWrapU: Nullable<number>;
  31624. /** @hidden */
  31625. _cachedWrapV: Nullable<number>;
  31626. /** @hidden */
  31627. _cachedWrapR: Nullable<number>;
  31628. /** @hidden */
  31629. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31630. /** @hidden */
  31631. _isDisabled: boolean;
  31632. /** @hidden */
  31633. _compression: Nullable<string>;
  31634. /** @hidden */
  31635. _generateStencilBuffer: boolean;
  31636. /** @hidden */
  31637. _generateDepthBuffer: boolean;
  31638. /** @hidden */
  31639. _comparisonFunction: number;
  31640. /** @hidden */
  31641. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31642. /** @hidden */
  31643. _lodGenerationScale: number;
  31644. /** @hidden */
  31645. _lodGenerationOffset: number;
  31646. /** @hidden */
  31647. _colorTextureArray: Nullable<WebGLTexture>;
  31648. /** @hidden */
  31649. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31650. /** @hidden */
  31651. _lodTextureHigh: Nullable<BaseTexture>;
  31652. /** @hidden */
  31653. _lodTextureMid: Nullable<BaseTexture>;
  31654. /** @hidden */
  31655. _lodTextureLow: Nullable<BaseTexture>;
  31656. /** @hidden */
  31657. _isRGBD: boolean;
  31658. /** @hidden */
  31659. _linearSpecularLOD: boolean;
  31660. /** @hidden */
  31661. _irradianceTexture: Nullable<BaseTexture>;
  31662. /** @hidden */
  31663. _webGLTexture: Nullable<WebGLTexture>;
  31664. /** @hidden */
  31665. _references: number;
  31666. private _engine;
  31667. /**
  31668. * Gets the Engine the texture belongs to.
  31669. * @returns The babylon engine
  31670. */
  31671. getEngine(): ThinEngine;
  31672. /**
  31673. * Gets the data source type of the texture
  31674. */
  31675. readonly source: InternalTextureSource;
  31676. /**
  31677. * Creates a new InternalTexture
  31678. * @param engine defines the engine to use
  31679. * @param source defines the type of data that will be used
  31680. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31681. */
  31682. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31683. /**
  31684. * Increments the number of references (ie. the number of Texture that point to it)
  31685. */
  31686. incrementReferences(): void;
  31687. /**
  31688. * Change the size of the texture (not the size of the content)
  31689. * @param width defines the new width
  31690. * @param height defines the new height
  31691. * @param depth defines the new depth (1 by default)
  31692. */
  31693. updateSize(width: int, height: int, depth?: int): void;
  31694. /** @hidden */
  31695. _rebuild(): void;
  31696. /** @hidden */
  31697. _swapAndDie(target: InternalTexture): void;
  31698. /**
  31699. * Dispose the current allocated resources
  31700. */
  31701. dispose(): void;
  31702. }
  31703. }
  31704. declare module "babylonjs/Audio/analyser" {
  31705. import { Scene } from "babylonjs/scene";
  31706. /**
  31707. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31709. */
  31710. export class Analyser {
  31711. /**
  31712. * Gets or sets the smoothing
  31713. * @ignorenaming
  31714. */
  31715. SMOOTHING: number;
  31716. /**
  31717. * Gets or sets the FFT table size
  31718. * @ignorenaming
  31719. */
  31720. FFT_SIZE: number;
  31721. /**
  31722. * Gets or sets the bar graph amplitude
  31723. * @ignorenaming
  31724. */
  31725. BARGRAPHAMPLITUDE: number;
  31726. /**
  31727. * Gets or sets the position of the debug canvas
  31728. * @ignorenaming
  31729. */
  31730. DEBUGCANVASPOS: {
  31731. x: number;
  31732. y: number;
  31733. };
  31734. /**
  31735. * Gets or sets the debug canvas size
  31736. * @ignorenaming
  31737. */
  31738. DEBUGCANVASSIZE: {
  31739. width: number;
  31740. height: number;
  31741. };
  31742. private _byteFreqs;
  31743. private _byteTime;
  31744. private _floatFreqs;
  31745. private _webAudioAnalyser;
  31746. private _debugCanvas;
  31747. private _debugCanvasContext;
  31748. private _scene;
  31749. private _registerFunc;
  31750. private _audioEngine;
  31751. /**
  31752. * Creates a new analyser
  31753. * @param scene defines hosting scene
  31754. */
  31755. constructor(scene: Scene);
  31756. /**
  31757. * Get the number of data values you will have to play with for the visualization
  31758. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31759. * @returns a number
  31760. */
  31761. getFrequencyBinCount(): number;
  31762. /**
  31763. * Gets the current frequency data as a byte array
  31764. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31765. * @returns a Uint8Array
  31766. */
  31767. getByteFrequencyData(): Uint8Array;
  31768. /**
  31769. * Gets the current waveform as a byte array
  31770. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31771. * @returns a Uint8Array
  31772. */
  31773. getByteTimeDomainData(): Uint8Array;
  31774. /**
  31775. * Gets the current frequency data as a float array
  31776. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31777. * @returns a Float32Array
  31778. */
  31779. getFloatFrequencyData(): Float32Array;
  31780. /**
  31781. * Renders the debug canvas
  31782. */
  31783. drawDebugCanvas(): void;
  31784. /**
  31785. * Stops rendering the debug canvas and removes it
  31786. */
  31787. stopDebugCanvas(): void;
  31788. /**
  31789. * Connects two audio nodes
  31790. * @param inputAudioNode defines first node to connect
  31791. * @param outputAudioNode defines second node to connect
  31792. */
  31793. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31794. /**
  31795. * Releases all associated resources
  31796. */
  31797. dispose(): void;
  31798. }
  31799. }
  31800. declare module "babylonjs/Audio/audioEngine" {
  31801. import { IDisposable } from "babylonjs/scene";
  31802. import { Analyser } from "babylonjs/Audio/analyser";
  31803. import { Nullable } from "babylonjs/types";
  31804. import { Observable } from "babylonjs/Misc/observable";
  31805. /**
  31806. * This represents an audio engine and it is responsible
  31807. * to play, synchronize and analyse sounds throughout the application.
  31808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31809. */
  31810. export interface IAudioEngine extends IDisposable {
  31811. /**
  31812. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31813. */
  31814. readonly canUseWebAudio: boolean;
  31815. /**
  31816. * Gets the current AudioContext if available.
  31817. */
  31818. readonly audioContext: Nullable<AudioContext>;
  31819. /**
  31820. * The master gain node defines the global audio volume of your audio engine.
  31821. */
  31822. readonly masterGain: GainNode;
  31823. /**
  31824. * Gets whether or not mp3 are supported by your browser.
  31825. */
  31826. readonly isMP3supported: boolean;
  31827. /**
  31828. * Gets whether or not ogg are supported by your browser.
  31829. */
  31830. readonly isOGGsupported: boolean;
  31831. /**
  31832. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31833. * @ignoreNaming
  31834. */
  31835. WarnedWebAudioUnsupported: boolean;
  31836. /**
  31837. * Defines if the audio engine relies on a custom unlocked button.
  31838. * In this case, the embedded button will not be displayed.
  31839. */
  31840. useCustomUnlockedButton: boolean;
  31841. /**
  31842. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31843. */
  31844. readonly unlocked: boolean;
  31845. /**
  31846. * Event raised when audio has been unlocked on the browser.
  31847. */
  31848. onAudioUnlockedObservable: Observable<AudioEngine>;
  31849. /**
  31850. * Event raised when audio has been locked on the browser.
  31851. */
  31852. onAudioLockedObservable: Observable<AudioEngine>;
  31853. /**
  31854. * Flags the audio engine in Locked state.
  31855. * This happens due to new browser policies preventing audio to autoplay.
  31856. */
  31857. lock(): void;
  31858. /**
  31859. * Unlocks the audio engine once a user action has been done on the dom.
  31860. * This is helpful to resume play once browser policies have been satisfied.
  31861. */
  31862. unlock(): void;
  31863. }
  31864. /**
  31865. * This represents the default audio engine used in babylon.
  31866. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31868. */
  31869. export class AudioEngine implements IAudioEngine {
  31870. private _audioContext;
  31871. private _audioContextInitialized;
  31872. private _muteButton;
  31873. private _hostElement;
  31874. /**
  31875. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31876. */
  31877. canUseWebAudio: boolean;
  31878. /**
  31879. * The master gain node defines the global audio volume of your audio engine.
  31880. */
  31881. masterGain: GainNode;
  31882. /**
  31883. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31884. * @ignoreNaming
  31885. */
  31886. WarnedWebAudioUnsupported: boolean;
  31887. /**
  31888. * Gets whether or not mp3 are supported by your browser.
  31889. */
  31890. isMP3supported: boolean;
  31891. /**
  31892. * Gets whether or not ogg are supported by your browser.
  31893. */
  31894. isOGGsupported: boolean;
  31895. /**
  31896. * Gets whether audio has been unlocked on the device.
  31897. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31898. * a user interaction has happened.
  31899. */
  31900. unlocked: boolean;
  31901. /**
  31902. * Defines if the audio engine relies on a custom unlocked button.
  31903. * In this case, the embedded button will not be displayed.
  31904. */
  31905. useCustomUnlockedButton: boolean;
  31906. /**
  31907. * Event raised when audio has been unlocked on the browser.
  31908. */
  31909. onAudioUnlockedObservable: Observable<AudioEngine>;
  31910. /**
  31911. * Event raised when audio has been locked on the browser.
  31912. */
  31913. onAudioLockedObservable: Observable<AudioEngine>;
  31914. /**
  31915. * Gets the current AudioContext if available.
  31916. */
  31917. readonly audioContext: Nullable<AudioContext>;
  31918. private _connectedAnalyser;
  31919. /**
  31920. * Instantiates a new audio engine.
  31921. *
  31922. * There should be only one per page as some browsers restrict the number
  31923. * of audio contexts you can create.
  31924. * @param hostElement defines the host element where to display the mute icon if necessary
  31925. */
  31926. constructor(hostElement?: Nullable<HTMLElement>);
  31927. /**
  31928. * Flags the audio engine in Locked state.
  31929. * This happens due to new browser policies preventing audio to autoplay.
  31930. */
  31931. lock(): void;
  31932. /**
  31933. * Unlocks the audio engine once a user action has been done on the dom.
  31934. * This is helpful to resume play once browser policies have been satisfied.
  31935. */
  31936. unlock(): void;
  31937. private _resumeAudioContext;
  31938. private _initializeAudioContext;
  31939. private _tryToRun;
  31940. private _triggerRunningState;
  31941. private _triggerSuspendedState;
  31942. private _displayMuteButton;
  31943. private _moveButtonToTopLeft;
  31944. private _onResize;
  31945. private _hideMuteButton;
  31946. /**
  31947. * Destroy and release the resources associated with the audio ccontext.
  31948. */
  31949. dispose(): void;
  31950. /**
  31951. * Gets the global volume sets on the master gain.
  31952. * @returns the global volume if set or -1 otherwise
  31953. */
  31954. getGlobalVolume(): number;
  31955. /**
  31956. * Sets the global volume of your experience (sets on the master gain).
  31957. * @param newVolume Defines the new global volume of the application
  31958. */
  31959. setGlobalVolume(newVolume: number): void;
  31960. /**
  31961. * Connect the audio engine to an audio analyser allowing some amazing
  31962. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31964. * @param analyser The analyser to connect to the engine
  31965. */
  31966. connectToAnalyser(analyser: Analyser): void;
  31967. }
  31968. }
  31969. declare module "babylonjs/Loading/loadingScreen" {
  31970. /**
  31971. * Interface used to present a loading screen while loading a scene
  31972. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31973. */
  31974. export interface ILoadingScreen {
  31975. /**
  31976. * Function called to display the loading screen
  31977. */
  31978. displayLoadingUI: () => void;
  31979. /**
  31980. * Function called to hide the loading screen
  31981. */
  31982. hideLoadingUI: () => void;
  31983. /**
  31984. * Gets or sets the color to use for the background
  31985. */
  31986. loadingUIBackgroundColor: string;
  31987. /**
  31988. * Gets or sets the text to display while loading
  31989. */
  31990. loadingUIText: string;
  31991. }
  31992. /**
  31993. * Class used for the default loading screen
  31994. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31995. */
  31996. export class DefaultLoadingScreen implements ILoadingScreen {
  31997. private _renderingCanvas;
  31998. private _loadingText;
  31999. private _loadingDivBackgroundColor;
  32000. private _loadingDiv;
  32001. private _loadingTextDiv;
  32002. /** Gets or sets the logo url to use for the default loading screen */
  32003. static DefaultLogoUrl: string;
  32004. /** Gets or sets the spinner url to use for the default loading screen */
  32005. static DefaultSpinnerUrl: string;
  32006. /**
  32007. * Creates a new default loading screen
  32008. * @param _renderingCanvas defines the canvas used to render the scene
  32009. * @param _loadingText defines the default text to display
  32010. * @param _loadingDivBackgroundColor defines the default background color
  32011. */
  32012. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32013. /**
  32014. * Function called to display the loading screen
  32015. */
  32016. displayLoadingUI(): void;
  32017. /**
  32018. * Function called to hide the loading screen
  32019. */
  32020. hideLoadingUI(): void;
  32021. /**
  32022. * Gets or sets the text to display while loading
  32023. */
  32024. loadingUIText: string;
  32025. /**
  32026. * Gets or sets the color to use for the background
  32027. */
  32028. loadingUIBackgroundColor: string;
  32029. private _resizeLoadingUI;
  32030. }
  32031. }
  32032. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  32033. /**
  32034. * Interface for any object that can request an animation frame
  32035. */
  32036. export interface ICustomAnimationFrameRequester {
  32037. /**
  32038. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32039. */
  32040. renderFunction?: Function;
  32041. /**
  32042. * Called to request the next frame to render to
  32043. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32044. */
  32045. requestAnimationFrame: Function;
  32046. /**
  32047. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32048. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32049. */
  32050. requestID?: number;
  32051. }
  32052. }
  32053. declare module "babylonjs/Misc/performanceMonitor" {
  32054. /**
  32055. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32056. */
  32057. export class PerformanceMonitor {
  32058. private _enabled;
  32059. private _rollingFrameTime;
  32060. private _lastFrameTimeMs;
  32061. /**
  32062. * constructor
  32063. * @param frameSampleSize The number of samples required to saturate the sliding window
  32064. */
  32065. constructor(frameSampleSize?: number);
  32066. /**
  32067. * Samples current frame
  32068. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32069. */
  32070. sampleFrame(timeMs?: number): void;
  32071. /**
  32072. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32073. */
  32074. readonly averageFrameTime: number;
  32075. /**
  32076. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32077. */
  32078. readonly averageFrameTimeVariance: number;
  32079. /**
  32080. * Returns the frame time of the most recent frame
  32081. */
  32082. readonly instantaneousFrameTime: number;
  32083. /**
  32084. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32085. */
  32086. readonly averageFPS: number;
  32087. /**
  32088. * Returns the average framerate in frames per second using the most recent frame time
  32089. */
  32090. readonly instantaneousFPS: number;
  32091. /**
  32092. * Returns true if enough samples have been taken to completely fill the sliding window
  32093. */
  32094. readonly isSaturated: boolean;
  32095. /**
  32096. * Enables contributions to the sliding window sample set
  32097. */
  32098. enable(): void;
  32099. /**
  32100. * Disables contributions to the sliding window sample set
  32101. * Samples will not be interpolated over the disabled period
  32102. */
  32103. disable(): void;
  32104. /**
  32105. * Returns true if sampling is enabled
  32106. */
  32107. readonly isEnabled: boolean;
  32108. /**
  32109. * Resets performance monitor
  32110. */
  32111. reset(): void;
  32112. }
  32113. /**
  32114. * RollingAverage
  32115. *
  32116. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32117. */
  32118. export class RollingAverage {
  32119. /**
  32120. * Current average
  32121. */
  32122. average: number;
  32123. /**
  32124. * Current variance
  32125. */
  32126. variance: number;
  32127. protected _samples: Array<number>;
  32128. protected _sampleCount: number;
  32129. protected _pos: number;
  32130. protected _m2: number;
  32131. /**
  32132. * constructor
  32133. * @param length The number of samples required to saturate the sliding window
  32134. */
  32135. constructor(length: number);
  32136. /**
  32137. * Adds a sample to the sample set
  32138. * @param v The sample value
  32139. */
  32140. add(v: number): void;
  32141. /**
  32142. * Returns previously added values or null if outside of history or outside the sliding window domain
  32143. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32144. * @return Value previously recorded with add() or null if outside of range
  32145. */
  32146. history(i: number): number;
  32147. /**
  32148. * Returns true if enough samples have been taken to completely fill the sliding window
  32149. * @return true if sample-set saturated
  32150. */
  32151. isSaturated(): boolean;
  32152. /**
  32153. * Resets the rolling average (equivalent to 0 samples taken so far)
  32154. */
  32155. reset(): void;
  32156. /**
  32157. * Wraps a value around the sample range boundaries
  32158. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32159. * @return Wrapped position in sample range
  32160. */
  32161. protected _wrapPosition(i: number): number;
  32162. }
  32163. }
  32164. declare module "babylonjs/Misc/perfCounter" {
  32165. /**
  32166. * This class is used to track a performance counter which is number based.
  32167. * The user has access to many properties which give statistics of different nature.
  32168. *
  32169. * The implementer can track two kinds of Performance Counter: time and count.
  32170. * 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.
  32171. * 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.
  32172. */
  32173. export class PerfCounter {
  32174. /**
  32175. * Gets or sets a global boolean to turn on and off all the counters
  32176. */
  32177. static Enabled: boolean;
  32178. /**
  32179. * Returns the smallest value ever
  32180. */
  32181. readonly min: number;
  32182. /**
  32183. * Returns the biggest value ever
  32184. */
  32185. readonly max: number;
  32186. /**
  32187. * Returns the average value since the performance counter is running
  32188. */
  32189. readonly average: number;
  32190. /**
  32191. * Returns the average value of the last second the counter was monitored
  32192. */
  32193. readonly lastSecAverage: number;
  32194. /**
  32195. * Returns the current value
  32196. */
  32197. readonly current: number;
  32198. /**
  32199. * Gets the accumulated total
  32200. */
  32201. readonly total: number;
  32202. /**
  32203. * Gets the total value count
  32204. */
  32205. readonly count: number;
  32206. /**
  32207. * Creates a new counter
  32208. */
  32209. constructor();
  32210. /**
  32211. * Call this method to start monitoring a new frame.
  32212. * 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.
  32213. */
  32214. fetchNewFrame(): void;
  32215. /**
  32216. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32217. * @param newCount the count value to add to the monitored count
  32218. * @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.
  32219. */
  32220. addCount(newCount: number, fetchResult: boolean): void;
  32221. /**
  32222. * Start monitoring this performance counter
  32223. */
  32224. beginMonitoring(): void;
  32225. /**
  32226. * Compute the time lapsed since the previous beginMonitoring() call.
  32227. * @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
  32228. */
  32229. endMonitoring(newFrame?: boolean): void;
  32230. private _fetchResult;
  32231. private _startMonitoringTime;
  32232. private _min;
  32233. private _max;
  32234. private _average;
  32235. private _current;
  32236. private _totalValueCount;
  32237. private _totalAccumulated;
  32238. private _lastSecAverage;
  32239. private _lastSecAccumulated;
  32240. private _lastSecTime;
  32241. private _lastSecValueCount;
  32242. }
  32243. }
  32244. declare module "babylonjs/Engines/engine" {
  32245. import { Observable } from "babylonjs/Misc/observable";
  32246. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  32247. import { Scene } from "babylonjs/scene";
  32248. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32249. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  32250. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32251. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  32252. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32253. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32254. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  32255. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  32256. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32257. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32258. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  32259. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32260. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  32261. import { Material } from "babylonjs/Materials/material";
  32262. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32263. /**
  32264. * Defines the interface used by display changed events
  32265. */
  32266. export interface IDisplayChangedEventArgs {
  32267. /** Gets the vrDisplay object (if any) */
  32268. vrDisplay: Nullable<any>;
  32269. /** Gets a boolean indicating if webVR is supported */
  32270. vrSupported: boolean;
  32271. }
  32272. /**
  32273. * Defines the interface used by objects containing a viewport (like a camera)
  32274. */
  32275. interface IViewportOwnerLike {
  32276. /**
  32277. * Gets or sets the viewport
  32278. */
  32279. viewport: IViewportLike;
  32280. }
  32281. /**
  32282. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32283. */
  32284. export class Engine extends ThinEngine {
  32285. /** Defines that alpha blending is disabled */
  32286. static readonly ALPHA_DISABLE: number;
  32287. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32288. static readonly ALPHA_ADD: number;
  32289. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32290. static readonly ALPHA_COMBINE: number;
  32291. /** Defines that alpha blending to DEST - SRC * DEST */
  32292. static readonly ALPHA_SUBTRACT: number;
  32293. /** Defines that alpha blending to SRC * DEST */
  32294. static readonly ALPHA_MULTIPLY: number;
  32295. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32296. static readonly ALPHA_MAXIMIZED: number;
  32297. /** Defines that alpha blending to SRC + DEST */
  32298. static readonly ALPHA_ONEONE: number;
  32299. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32300. static readonly ALPHA_PREMULTIPLIED: number;
  32301. /**
  32302. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32303. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32304. */
  32305. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32306. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32307. static readonly ALPHA_INTERPOLATE: number;
  32308. /**
  32309. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32310. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32311. */
  32312. static readonly ALPHA_SCREENMODE: number;
  32313. /** Defines that the ressource is not delayed*/
  32314. static readonly DELAYLOADSTATE_NONE: number;
  32315. /** Defines that the ressource was successfully delay loaded */
  32316. static readonly DELAYLOADSTATE_LOADED: number;
  32317. /** Defines that the ressource is currently delay loading */
  32318. static readonly DELAYLOADSTATE_LOADING: number;
  32319. /** Defines that the ressource is delayed and has not started loading */
  32320. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32321. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32322. static readonly NEVER: number;
  32323. /** 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 */
  32324. static readonly ALWAYS: number;
  32325. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32326. static readonly LESS: number;
  32327. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32328. static readonly EQUAL: number;
  32329. /** 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 */
  32330. static readonly LEQUAL: number;
  32331. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32332. static readonly GREATER: number;
  32333. /** 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 */
  32334. static readonly GEQUAL: number;
  32335. /** 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 */
  32336. static readonly NOTEQUAL: number;
  32337. /** Passed to stencilOperation to specify that stencil value must be kept */
  32338. static readonly KEEP: number;
  32339. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32340. static readonly REPLACE: number;
  32341. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32342. static readonly INCR: number;
  32343. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32344. static readonly DECR: number;
  32345. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32346. static readonly INVERT: number;
  32347. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32348. static readonly INCR_WRAP: number;
  32349. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32350. static readonly DECR_WRAP: number;
  32351. /** Texture is not repeating outside of 0..1 UVs */
  32352. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32353. /** Texture is repeating outside of 0..1 UVs */
  32354. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32355. /** Texture is repeating and mirrored */
  32356. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32357. /** ALPHA */
  32358. static readonly TEXTUREFORMAT_ALPHA: number;
  32359. /** LUMINANCE */
  32360. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32361. /** LUMINANCE_ALPHA */
  32362. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32363. /** RGB */
  32364. static readonly TEXTUREFORMAT_RGB: number;
  32365. /** RGBA */
  32366. static readonly TEXTUREFORMAT_RGBA: number;
  32367. /** RED */
  32368. static readonly TEXTUREFORMAT_RED: number;
  32369. /** RED (2nd reference) */
  32370. static readonly TEXTUREFORMAT_R: number;
  32371. /** RG */
  32372. static readonly TEXTUREFORMAT_RG: number;
  32373. /** RED_INTEGER */
  32374. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32375. /** RED_INTEGER (2nd reference) */
  32376. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32377. /** RG_INTEGER */
  32378. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32379. /** RGB_INTEGER */
  32380. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32381. /** RGBA_INTEGER */
  32382. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32383. /** UNSIGNED_BYTE */
  32384. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32385. /** UNSIGNED_BYTE (2nd reference) */
  32386. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32387. /** FLOAT */
  32388. static readonly TEXTURETYPE_FLOAT: number;
  32389. /** HALF_FLOAT */
  32390. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32391. /** BYTE */
  32392. static readonly TEXTURETYPE_BYTE: number;
  32393. /** SHORT */
  32394. static readonly TEXTURETYPE_SHORT: number;
  32395. /** UNSIGNED_SHORT */
  32396. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32397. /** INT */
  32398. static readonly TEXTURETYPE_INT: number;
  32399. /** UNSIGNED_INT */
  32400. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32401. /** UNSIGNED_SHORT_4_4_4_4 */
  32402. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32403. /** UNSIGNED_SHORT_5_5_5_1 */
  32404. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32405. /** UNSIGNED_SHORT_5_6_5 */
  32406. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32407. /** UNSIGNED_INT_2_10_10_10_REV */
  32408. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32409. /** UNSIGNED_INT_24_8 */
  32410. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32411. /** UNSIGNED_INT_10F_11F_11F_REV */
  32412. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32413. /** UNSIGNED_INT_5_9_9_9_REV */
  32414. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32415. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32416. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32417. /** nearest is mag = nearest and min = nearest and mip = linear */
  32418. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32419. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32420. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32421. /** Trilinear is mag = linear and min = linear and mip = linear */
  32422. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32423. /** nearest is mag = nearest and min = nearest and mip = linear */
  32424. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32425. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32426. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32427. /** Trilinear is mag = linear and min = linear and mip = linear */
  32428. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32429. /** mag = nearest and min = nearest and mip = nearest */
  32430. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32431. /** mag = nearest and min = linear and mip = nearest */
  32432. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32433. /** mag = nearest and min = linear and mip = linear */
  32434. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32435. /** mag = nearest and min = linear and mip = none */
  32436. static readonly TEXTURE_NEAREST_LINEAR: number;
  32437. /** mag = nearest and min = nearest and mip = none */
  32438. static readonly TEXTURE_NEAREST_NEAREST: number;
  32439. /** mag = linear and min = nearest and mip = nearest */
  32440. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32441. /** mag = linear and min = nearest and mip = linear */
  32442. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32443. /** mag = linear and min = linear and mip = none */
  32444. static readonly TEXTURE_LINEAR_LINEAR: number;
  32445. /** mag = linear and min = nearest and mip = none */
  32446. static readonly TEXTURE_LINEAR_NEAREST: number;
  32447. /** Explicit coordinates mode */
  32448. static readonly TEXTURE_EXPLICIT_MODE: number;
  32449. /** Spherical coordinates mode */
  32450. static readonly TEXTURE_SPHERICAL_MODE: number;
  32451. /** Planar coordinates mode */
  32452. static readonly TEXTURE_PLANAR_MODE: number;
  32453. /** Cubic coordinates mode */
  32454. static readonly TEXTURE_CUBIC_MODE: number;
  32455. /** Projection coordinates mode */
  32456. static readonly TEXTURE_PROJECTION_MODE: number;
  32457. /** Skybox coordinates mode */
  32458. static readonly TEXTURE_SKYBOX_MODE: number;
  32459. /** Inverse Cubic coordinates mode */
  32460. static readonly TEXTURE_INVCUBIC_MODE: number;
  32461. /** Equirectangular coordinates mode */
  32462. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32463. /** Equirectangular Fixed coordinates mode */
  32464. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32465. /** Equirectangular Fixed Mirrored coordinates mode */
  32466. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32467. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32468. static readonly SCALEMODE_FLOOR: number;
  32469. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32470. static readonly SCALEMODE_NEAREST: number;
  32471. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32472. static readonly SCALEMODE_CEILING: number;
  32473. /**
  32474. * Returns the current npm package of the sdk
  32475. */
  32476. static readonly NpmPackage: string;
  32477. /**
  32478. * Returns the current version of the framework
  32479. */
  32480. static readonly Version: string;
  32481. /** Gets the list of created engines */
  32482. static readonly Instances: Engine[];
  32483. /**
  32484. * Gets the latest created engine
  32485. */
  32486. static readonly LastCreatedEngine: Nullable<Engine>;
  32487. /**
  32488. * Gets the latest created scene
  32489. */
  32490. static readonly LastCreatedScene: Nullable<Scene>;
  32491. /**
  32492. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32493. * @param flag defines which part of the materials must be marked as dirty
  32494. * @param predicate defines a predicate used to filter which materials should be affected
  32495. */
  32496. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32497. /**
  32498. * Method called to create the default loading screen.
  32499. * This can be overriden in your own app.
  32500. * @param canvas The rendering canvas element
  32501. * @returns The loading screen
  32502. */
  32503. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32504. /**
  32505. * Method called to create the default rescale post process on each engine.
  32506. */
  32507. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32508. /**
  32509. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32510. **/
  32511. enableOfflineSupport: boolean;
  32512. /**
  32513. * 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)
  32514. **/
  32515. disableManifestCheck: boolean;
  32516. /**
  32517. * Gets the list of created scenes
  32518. */
  32519. scenes: Scene[];
  32520. /**
  32521. * Event raised when a new scene is created
  32522. */
  32523. onNewSceneAddedObservable: Observable<Scene>;
  32524. /**
  32525. * Gets the list of created postprocesses
  32526. */
  32527. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32528. /**
  32529. * Gets a boolean indicating if the pointer is currently locked
  32530. */
  32531. isPointerLock: boolean;
  32532. /**
  32533. * Observable event triggered each time the rendering canvas is resized
  32534. */
  32535. onResizeObservable: Observable<Engine>;
  32536. /**
  32537. * Observable event triggered each time the canvas loses focus
  32538. */
  32539. onCanvasBlurObservable: Observable<Engine>;
  32540. /**
  32541. * Observable event triggered each time the canvas gains focus
  32542. */
  32543. onCanvasFocusObservable: Observable<Engine>;
  32544. /**
  32545. * Observable event triggered each time the canvas receives pointerout event
  32546. */
  32547. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32548. /**
  32549. * Observable raised when the engine begins a new frame
  32550. */
  32551. onBeginFrameObservable: Observable<Engine>;
  32552. /**
  32553. * If set, will be used to request the next animation frame for the render loop
  32554. */
  32555. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32556. /**
  32557. * Observable raised when the engine ends the current frame
  32558. */
  32559. onEndFrameObservable: Observable<Engine>;
  32560. /**
  32561. * Observable raised when the engine is about to compile a shader
  32562. */
  32563. onBeforeShaderCompilationObservable: Observable<Engine>;
  32564. /**
  32565. * Observable raised when the engine has jsut compiled a shader
  32566. */
  32567. onAfterShaderCompilationObservable: Observable<Engine>;
  32568. /**
  32569. * Gets the audio engine
  32570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32571. * @ignorenaming
  32572. */
  32573. static audioEngine: IAudioEngine;
  32574. /**
  32575. * Default AudioEngine factory responsible of creating the Audio Engine.
  32576. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32577. */
  32578. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32579. /**
  32580. * Default offline support factory responsible of creating a tool used to store data locally.
  32581. * By default, this will create a Database object if the workload has been embedded.
  32582. */
  32583. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32584. private _loadingScreen;
  32585. private _pointerLockRequested;
  32586. private _dummyFramebuffer;
  32587. private _rescalePostProcess;
  32588. /** @hidden */
  32589. protected _alphaMode: number;
  32590. /** @hidden */
  32591. protected _alphaEquation: number;
  32592. private _deterministicLockstep;
  32593. private _lockstepMaxSteps;
  32594. protected readonly _supportsHardwareTextureRescaling: boolean;
  32595. private _fps;
  32596. private _deltaTime;
  32597. /** @hidden */
  32598. _drawCalls: PerfCounter;
  32599. /**
  32600. * Turn this value on if you want to pause FPS computation when in background
  32601. */
  32602. disablePerformanceMonitorInBackground: boolean;
  32603. private _performanceMonitor;
  32604. /**
  32605. * Gets the performance monitor attached to this engine
  32606. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32607. */
  32608. readonly performanceMonitor: PerformanceMonitor;
  32609. private _onFocus;
  32610. private _onBlur;
  32611. private _onCanvasPointerOut;
  32612. private _onCanvasBlur;
  32613. private _onCanvasFocus;
  32614. private _onFullscreenChange;
  32615. private _onPointerLockChange;
  32616. /**
  32617. * Gets the HTML element used to attach event listeners
  32618. * @returns a HTML element
  32619. */
  32620. getInputElement(): Nullable<HTMLElement>;
  32621. /**
  32622. * Creates a new engine
  32623. * @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
  32624. * @param antialias defines enable antialiasing (default: false)
  32625. * @param options defines further options to be sent to the getContext() function
  32626. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32627. */
  32628. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32629. /**
  32630. * Gets current aspect ratio
  32631. * @param viewportOwner defines the camera to use to get the aspect ratio
  32632. * @param useScreen defines if screen size must be used (or the current render target if any)
  32633. * @returns a number defining the aspect ratio
  32634. */
  32635. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32636. /**
  32637. * Gets current screen aspect ratio
  32638. * @returns a number defining the aspect ratio
  32639. */
  32640. getScreenAspectRatio(): number;
  32641. /**
  32642. * Gets host document
  32643. * @returns the host document object
  32644. */
  32645. getHostDocument(): Document;
  32646. /**
  32647. * Gets the client rect of the HTML canvas attached with the current webGL context
  32648. * @returns a client rectanglee
  32649. */
  32650. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32651. /**
  32652. * Gets the client rect of the HTML element used for events
  32653. * @returns a client rectanglee
  32654. */
  32655. getInputElementClientRect(): Nullable<ClientRect>;
  32656. /**
  32657. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32658. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32659. * @returns true if engine is in deterministic lock step mode
  32660. */
  32661. isDeterministicLockStep(): boolean;
  32662. /**
  32663. * Gets the max steps when engine is running in deterministic lock step
  32664. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32665. * @returns the max steps
  32666. */
  32667. getLockstepMaxSteps(): number;
  32668. /**
  32669. * Force the mipmap generation for the given render target texture
  32670. * @param texture defines the render target texture to use
  32671. */
  32672. generateMipMapsForCubemap(texture: InternalTexture): void;
  32673. /** States */
  32674. /**
  32675. * Set various states to the webGL context
  32676. * @param culling defines backface culling state
  32677. * @param zOffset defines the value to apply to zOffset (0 by default)
  32678. * @param force defines if states must be applied even if cache is up to date
  32679. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32680. */
  32681. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32682. /**
  32683. * Set the z offset to apply to current rendering
  32684. * @param value defines the offset to apply
  32685. */
  32686. setZOffset(value: number): void;
  32687. /**
  32688. * Gets the current value of the zOffset
  32689. * @returns the current zOffset state
  32690. */
  32691. getZOffset(): number;
  32692. /**
  32693. * Enable or disable depth buffering
  32694. * @param enable defines the state to set
  32695. */
  32696. setDepthBuffer(enable: boolean): void;
  32697. /**
  32698. * Gets a boolean indicating if depth writing is enabled
  32699. * @returns the current depth writing state
  32700. */
  32701. getDepthWrite(): boolean;
  32702. /**
  32703. * Enable or disable depth writing
  32704. * @param enable defines the state to set
  32705. */
  32706. setDepthWrite(enable: boolean): void;
  32707. /**
  32708. * Enable or disable color writing
  32709. * @param enable defines the state to set
  32710. */
  32711. setColorWrite(enable: boolean): void;
  32712. /**
  32713. * Gets a boolean indicating if color writing is enabled
  32714. * @returns the current color writing state
  32715. */
  32716. getColorWrite(): boolean;
  32717. /**
  32718. * Sets alpha constants used by some alpha blending modes
  32719. * @param r defines the red component
  32720. * @param g defines the green component
  32721. * @param b defines the blue component
  32722. * @param a defines the alpha component
  32723. */
  32724. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32725. /**
  32726. * Sets the current alpha mode
  32727. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32728. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32729. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32730. */
  32731. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32732. /**
  32733. * Gets the current alpha mode
  32734. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32735. * @returns the current alpha mode
  32736. */
  32737. getAlphaMode(): number;
  32738. /**
  32739. * Sets the current alpha equation
  32740. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32741. */
  32742. setAlphaEquation(equation: number): void;
  32743. /**
  32744. * Gets the current alpha equation.
  32745. * @returns the current alpha equation
  32746. */
  32747. getAlphaEquation(): number;
  32748. /**
  32749. * Gets a boolean indicating if stencil buffer is enabled
  32750. * @returns the current stencil buffer state
  32751. */
  32752. getStencilBuffer(): boolean;
  32753. /**
  32754. * Enable or disable the stencil buffer
  32755. * @param enable defines if the stencil buffer must be enabled or disabled
  32756. */
  32757. setStencilBuffer(enable: boolean): void;
  32758. /**
  32759. * Gets the current stencil mask
  32760. * @returns a number defining the new stencil mask to use
  32761. */
  32762. getStencilMask(): number;
  32763. /**
  32764. * Sets the current stencil mask
  32765. * @param mask defines the new stencil mask to use
  32766. */
  32767. setStencilMask(mask: number): void;
  32768. /**
  32769. * Gets the current stencil function
  32770. * @returns a number defining the stencil function to use
  32771. */
  32772. getStencilFunction(): number;
  32773. /**
  32774. * Gets the current stencil reference value
  32775. * @returns a number defining the stencil reference value to use
  32776. */
  32777. getStencilFunctionReference(): number;
  32778. /**
  32779. * Gets the current stencil mask
  32780. * @returns a number defining the stencil mask to use
  32781. */
  32782. getStencilFunctionMask(): number;
  32783. /**
  32784. * Sets the current stencil function
  32785. * @param stencilFunc defines the new stencil function to use
  32786. */
  32787. setStencilFunction(stencilFunc: number): void;
  32788. /**
  32789. * Sets the current stencil reference
  32790. * @param reference defines the new stencil reference to use
  32791. */
  32792. setStencilFunctionReference(reference: number): void;
  32793. /**
  32794. * Sets the current stencil mask
  32795. * @param mask defines the new stencil mask to use
  32796. */
  32797. setStencilFunctionMask(mask: number): void;
  32798. /**
  32799. * Gets the current stencil operation when stencil fails
  32800. * @returns a number defining stencil operation to use when stencil fails
  32801. */
  32802. getStencilOperationFail(): number;
  32803. /**
  32804. * Gets the current stencil operation when depth fails
  32805. * @returns a number defining stencil operation to use when depth fails
  32806. */
  32807. getStencilOperationDepthFail(): number;
  32808. /**
  32809. * Gets the current stencil operation when stencil passes
  32810. * @returns a number defining stencil operation to use when stencil passes
  32811. */
  32812. getStencilOperationPass(): number;
  32813. /**
  32814. * Sets the stencil operation to use when stencil fails
  32815. * @param operation defines the stencil operation to use when stencil fails
  32816. */
  32817. setStencilOperationFail(operation: number): void;
  32818. /**
  32819. * Sets the stencil operation to use when depth fails
  32820. * @param operation defines the stencil operation to use when depth fails
  32821. */
  32822. setStencilOperationDepthFail(operation: number): void;
  32823. /**
  32824. * Sets the stencil operation to use when stencil passes
  32825. * @param operation defines the stencil operation to use when stencil passes
  32826. */
  32827. setStencilOperationPass(operation: number): void;
  32828. /**
  32829. * Sets a boolean indicating if the dithering state is enabled or disabled
  32830. * @param value defines the dithering state
  32831. */
  32832. setDitheringState(value: boolean): void;
  32833. /**
  32834. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32835. * @param value defines the rasterizer state
  32836. */
  32837. setRasterizerState(value: boolean): void;
  32838. /**
  32839. * Gets the current depth function
  32840. * @returns a number defining the depth function
  32841. */
  32842. getDepthFunction(): Nullable<number>;
  32843. /**
  32844. * Sets the current depth function
  32845. * @param depthFunc defines the function to use
  32846. */
  32847. setDepthFunction(depthFunc: number): void;
  32848. /**
  32849. * Sets the current depth function to GREATER
  32850. */
  32851. setDepthFunctionToGreater(): void;
  32852. /**
  32853. * Sets the current depth function to GEQUAL
  32854. */
  32855. setDepthFunctionToGreaterOrEqual(): void;
  32856. /**
  32857. * Sets the current depth function to LESS
  32858. */
  32859. setDepthFunctionToLess(): void;
  32860. /**
  32861. * Sets the current depth function to LEQUAL
  32862. */
  32863. setDepthFunctionToLessOrEqual(): void;
  32864. private _cachedStencilBuffer;
  32865. private _cachedStencilFunction;
  32866. private _cachedStencilMask;
  32867. private _cachedStencilOperationPass;
  32868. private _cachedStencilOperationFail;
  32869. private _cachedStencilOperationDepthFail;
  32870. private _cachedStencilReference;
  32871. /**
  32872. * Caches the the state of the stencil buffer
  32873. */
  32874. cacheStencilState(): void;
  32875. /**
  32876. * Restores the state of the stencil buffer
  32877. */
  32878. restoreStencilState(): void;
  32879. /**
  32880. * Directly set the WebGL Viewport
  32881. * @param x defines the x coordinate of the viewport (in screen space)
  32882. * @param y defines the y coordinate of the viewport (in screen space)
  32883. * @param width defines the width of the viewport (in screen space)
  32884. * @param height defines the height of the viewport (in screen space)
  32885. * @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
  32886. */
  32887. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32888. /**
  32889. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32890. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32891. * @param y defines the y-coordinate of the corner of the clear rectangle
  32892. * @param width defines the width of the clear rectangle
  32893. * @param height defines the height of the clear rectangle
  32894. * @param clearColor defines the clear color
  32895. */
  32896. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32897. /**
  32898. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32899. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32900. * @param y defines the y-coordinate of the corner of the clear rectangle
  32901. * @param width defines the width of the clear rectangle
  32902. * @param height defines the height of the clear rectangle
  32903. */
  32904. enableScissor(x: number, y: number, width: number, height: number): void;
  32905. /**
  32906. * Disable previously set scissor test rectangle
  32907. */
  32908. disableScissor(): void;
  32909. protected _reportDrawCall(): void;
  32910. /**
  32911. * Initializes a webVR display and starts listening to display change events
  32912. * The onVRDisplayChangedObservable will be notified upon these changes
  32913. * @returns The onVRDisplayChangedObservable
  32914. */
  32915. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32916. /** @hidden */
  32917. _prepareVRComponent(): void;
  32918. /** @hidden */
  32919. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32920. /** @hidden */
  32921. _submitVRFrame(): void;
  32922. /**
  32923. * Call this function to leave webVR mode
  32924. * Will do nothing if webVR is not supported or if there is no webVR device
  32925. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32926. */
  32927. disableVR(): void;
  32928. /**
  32929. * Gets a boolean indicating that the system is in VR mode and is presenting
  32930. * @returns true if VR mode is engaged
  32931. */
  32932. isVRPresenting(): boolean;
  32933. /** @hidden */
  32934. _requestVRFrame(): void;
  32935. /** @hidden */
  32936. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32937. /**
  32938. * Gets the source code of the vertex shader associated with a specific webGL program
  32939. * @param program defines the program to use
  32940. * @returns a string containing the source code of the vertex shader associated with the program
  32941. */
  32942. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32943. /**
  32944. * Gets the source code of the fragment shader associated with a specific webGL program
  32945. * @param program defines the program to use
  32946. * @returns a string containing the source code of the fragment shader associated with the program
  32947. */
  32948. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32949. /**
  32950. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32951. * @param x defines the x coordinate of the rectangle where pixels must be read
  32952. * @param y defines the y coordinate of the rectangle where pixels must be read
  32953. * @param width defines the width of the rectangle where pixels must be read
  32954. * @param height defines the height of the rectangle where pixels must be read
  32955. * @returns a Uint8Array containing RGBA colors
  32956. */
  32957. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32958. /**
  32959. * Sets a depth stencil texture from a render target to the according uniform.
  32960. * @param channel The texture channel
  32961. * @param uniform The uniform to set
  32962. * @param texture The render target texture containing the depth stencil texture to apply
  32963. */
  32964. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32965. /**
  32966. * Sets a texture to the webGL context from a postprocess
  32967. * @param channel defines the channel to use
  32968. * @param postProcess defines the source postprocess
  32969. */
  32970. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32971. /**
  32972. * Binds the output of the passed in post process to the texture channel specified
  32973. * @param channel The channel the texture should be bound to
  32974. * @param postProcess The post process which's output should be bound
  32975. */
  32976. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32977. /** @hidden */
  32978. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32979. protected _rebuildBuffers(): void;
  32980. /** @hidden */
  32981. _renderFrame(): void;
  32982. _renderLoop(): void;
  32983. /** @hidden */
  32984. _renderViews(): boolean;
  32985. /**
  32986. * Toggle full screen mode
  32987. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32988. */
  32989. switchFullscreen(requestPointerLock: boolean): void;
  32990. /**
  32991. * Enters full screen mode
  32992. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32993. */
  32994. enterFullscreen(requestPointerLock: boolean): void;
  32995. /**
  32996. * Exits full screen mode
  32997. */
  32998. exitFullscreen(): void;
  32999. /**
  33000. * Enters Pointerlock mode
  33001. */
  33002. enterPointerlock(): void;
  33003. /**
  33004. * Exits Pointerlock mode
  33005. */
  33006. exitPointerlock(): void;
  33007. /**
  33008. * Begin a new frame
  33009. */
  33010. beginFrame(): void;
  33011. /**
  33012. * Enf the current frame
  33013. */
  33014. endFrame(): void;
  33015. resize(): void;
  33016. /**
  33017. * Set the compressed texture format to use, based on the formats you have, and the formats
  33018. * supported by the hardware / browser.
  33019. *
  33020. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33021. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33022. * to API arguments needed to compressed textures. This puts the burden on the container
  33023. * generator to house the arcane code for determining these for current & future formats.
  33024. *
  33025. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33026. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33027. *
  33028. * Note: The result of this call is not taken into account when a texture is base64.
  33029. *
  33030. * @param formatsAvailable defines the list of those format families you have created
  33031. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33032. *
  33033. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33034. * @returns The extension selected.
  33035. */
  33036. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33037. /**
  33038. * Force a specific size of the canvas
  33039. * @param width defines the new canvas' width
  33040. * @param height defines the new canvas' height
  33041. */
  33042. setSize(width: number, height: number): void;
  33043. /**
  33044. * Updates a dynamic vertex buffer.
  33045. * @param vertexBuffer the vertex buffer to update
  33046. * @param data the data used to update the vertex buffer
  33047. * @param byteOffset the byte offset of the data
  33048. * @param byteLength the byte length of the data
  33049. */
  33050. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33051. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33052. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33053. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33054. _releaseTexture(texture: InternalTexture): void;
  33055. /**
  33056. * @hidden
  33057. * Rescales a texture
  33058. * @param source input texutre
  33059. * @param destination destination texture
  33060. * @param scene scene to use to render the resize
  33061. * @param internalFormat format to use when resizing
  33062. * @param onComplete callback to be called when resize has completed
  33063. */
  33064. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33065. /**
  33066. * Gets the current framerate
  33067. * @returns a number representing the framerate
  33068. */
  33069. getFps(): number;
  33070. /**
  33071. * Gets the time spent between current and previous frame
  33072. * @returns a number representing the delta time in ms
  33073. */
  33074. getDeltaTime(): number;
  33075. private _measureFps;
  33076. /** @hidden */
  33077. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33078. /**
  33079. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  33080. * @param renderTarget The render target to set the frame buffer for
  33081. */
  33082. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  33083. /**
  33084. * Update a dynamic index buffer
  33085. * @param indexBuffer defines the target index buffer
  33086. * @param indices defines the data to update
  33087. * @param offset defines the offset in the target index buffer where update should start
  33088. */
  33089. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33090. /**
  33091. * Updates the sample count of a render target texture
  33092. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33093. * @param texture defines the texture to update
  33094. * @param samples defines the sample count to set
  33095. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33096. */
  33097. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33098. /**
  33099. * Updates a depth texture Comparison Mode and Function.
  33100. * If the comparison Function is equal to 0, the mode will be set to none.
  33101. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33102. * @param texture The texture to set the comparison function for
  33103. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33104. */
  33105. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33106. /**
  33107. * Creates a webGL buffer to use with instanciation
  33108. * @param capacity defines the size of the buffer
  33109. * @returns the webGL buffer
  33110. */
  33111. createInstancesBuffer(capacity: number): DataBuffer;
  33112. /**
  33113. * Delete a webGL buffer used with instanciation
  33114. * @param buffer defines the webGL buffer to delete
  33115. */
  33116. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33117. /** @hidden */
  33118. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33119. dispose(): void;
  33120. private _disableTouchAction;
  33121. /**
  33122. * Display the loading screen
  33123. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33124. */
  33125. displayLoadingUI(): void;
  33126. /**
  33127. * Hide the loading screen
  33128. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33129. */
  33130. hideLoadingUI(): void;
  33131. /**
  33132. * Gets the current loading screen object
  33133. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33134. */
  33135. /**
  33136. * Sets the current loading screen object
  33137. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33138. */
  33139. loadingScreen: ILoadingScreen;
  33140. /**
  33141. * Sets the current loading screen text
  33142. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33143. */
  33144. loadingUIText: string;
  33145. /**
  33146. * Sets the current loading screen background color
  33147. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33148. */
  33149. loadingUIBackgroundColor: string;
  33150. /** Pointerlock and fullscreen */
  33151. /**
  33152. * Ask the browser to promote the current element to pointerlock mode
  33153. * @param element defines the DOM element to promote
  33154. */
  33155. static _RequestPointerlock(element: HTMLElement): void;
  33156. /**
  33157. * Asks the browser to exit pointerlock mode
  33158. */
  33159. static _ExitPointerlock(): void;
  33160. /**
  33161. * Ask the browser to promote the current element to fullscreen rendering mode
  33162. * @param element defines the DOM element to promote
  33163. */
  33164. static _RequestFullscreen(element: HTMLElement): void;
  33165. /**
  33166. * Asks the browser to exit fullscreen mode
  33167. */
  33168. static _ExitFullscreen(): void;
  33169. }
  33170. }
  33171. declare module "babylonjs/Engines/engineStore" {
  33172. import { Nullable } from "babylonjs/types";
  33173. import { Engine } from "babylonjs/Engines/engine";
  33174. import { Scene } from "babylonjs/scene";
  33175. /**
  33176. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33177. * during the life time of the application.
  33178. */
  33179. export class EngineStore {
  33180. /** Gets the list of created engines */
  33181. static Instances: import("babylonjs/Engines/engine").Engine[];
  33182. /** @hidden */
  33183. static _LastCreatedScene: Nullable<Scene>;
  33184. /**
  33185. * Gets the latest created engine
  33186. */
  33187. static readonly LastCreatedEngine: Nullable<Engine>;
  33188. /**
  33189. * Gets the latest created scene
  33190. */
  33191. static readonly LastCreatedScene: Nullable<Scene>;
  33192. /**
  33193. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33194. * @ignorenaming
  33195. */
  33196. static UseFallbackTexture: boolean;
  33197. /**
  33198. * Texture content used if a texture cannot loaded
  33199. * @ignorenaming
  33200. */
  33201. static FallbackTexture: string;
  33202. }
  33203. }
  33204. declare module "babylonjs/Misc/promise" {
  33205. /**
  33206. * Helper class that provides a small promise polyfill
  33207. */
  33208. export class PromisePolyfill {
  33209. /**
  33210. * Static function used to check if the polyfill is required
  33211. * If this is the case then the function will inject the polyfill to window.Promise
  33212. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33213. */
  33214. static Apply(force?: boolean): void;
  33215. }
  33216. }
  33217. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  33218. /**
  33219. * Interface for screenshot methods with describe argument called `size` as object with options
  33220. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33221. */
  33222. export interface IScreenshotSize {
  33223. /**
  33224. * number in pixels for canvas height
  33225. */
  33226. height?: number;
  33227. /**
  33228. * multiplier allowing render at a higher or lower resolution
  33229. * If value is defined then height and width will be ignored and taken from camera
  33230. */
  33231. precision?: number;
  33232. /**
  33233. * number in pixels for canvas width
  33234. */
  33235. width?: number;
  33236. }
  33237. }
  33238. declare module "babylonjs/Misc/tools" {
  33239. import { Nullable, float } from "babylonjs/types";
  33240. import { DomManagement } from "babylonjs/Misc/domManagement";
  33241. import { WebRequest } from "babylonjs/Misc/webRequest";
  33242. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33243. import { ReadFileError } from "babylonjs/Misc/fileTools";
  33244. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33245. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  33246. import { Camera } from "babylonjs/Cameras/camera";
  33247. import { Engine } from "babylonjs/Engines/engine";
  33248. interface IColor4Like {
  33249. r: float;
  33250. g: float;
  33251. b: float;
  33252. a: float;
  33253. }
  33254. /**
  33255. * Class containing a set of static utilities functions
  33256. */
  33257. export class Tools {
  33258. /**
  33259. * Gets or sets the base URL to use to load assets
  33260. */
  33261. static BaseUrl: string;
  33262. /**
  33263. * Enable/Disable Custom HTTP Request Headers globally.
  33264. * default = false
  33265. * @see CustomRequestHeaders
  33266. */
  33267. static UseCustomRequestHeaders: boolean;
  33268. /**
  33269. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33270. * i.e. when loading files, where the server/service expects an Authorization header
  33271. */
  33272. static CustomRequestHeaders: {
  33273. [key: string]: string;
  33274. };
  33275. /**
  33276. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33277. */
  33278. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  33279. /**
  33280. * Default behaviour for cors in the application.
  33281. * It can be a string if the expected behavior is identical in the entire app.
  33282. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33283. */
  33284. static CorsBehavior: string | ((url: string | string[]) => string);
  33285. /**
  33286. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33287. * @ignorenaming
  33288. */
  33289. static UseFallbackTexture: boolean;
  33290. /**
  33291. * Use this object to register external classes like custom textures or material
  33292. * to allow the laoders to instantiate them
  33293. */
  33294. static RegisteredExternalClasses: {
  33295. [key: string]: Object;
  33296. };
  33297. /**
  33298. * Texture content used if a texture cannot loaded
  33299. * @ignorenaming
  33300. */
  33301. static fallbackTexture: string;
  33302. /**
  33303. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33304. * @param u defines the coordinate on X axis
  33305. * @param v defines the coordinate on Y axis
  33306. * @param width defines the width of the source data
  33307. * @param height defines the height of the source data
  33308. * @param pixels defines the source byte array
  33309. * @param color defines the output color
  33310. */
  33311. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33312. /**
  33313. * Interpolates between a and b via alpha
  33314. * @param a The lower value (returned when alpha = 0)
  33315. * @param b The upper value (returned when alpha = 1)
  33316. * @param alpha The interpolation-factor
  33317. * @return The mixed value
  33318. */
  33319. static Mix(a: number, b: number, alpha: number): number;
  33320. /**
  33321. * Tries to instantiate a new object from a given class name
  33322. * @param className defines the class name to instantiate
  33323. * @returns the new object or null if the system was not able to do the instantiation
  33324. */
  33325. static Instantiate(className: string): any;
  33326. /**
  33327. * Provides a slice function that will work even on IE
  33328. * @param data defines the array to slice
  33329. * @param start defines the start of the data (optional)
  33330. * @param end defines the end of the data (optional)
  33331. * @returns the new sliced array
  33332. */
  33333. static Slice<T>(data: T, start?: number, end?: number): T;
  33334. /**
  33335. * Polyfill for setImmediate
  33336. * @param action defines the action to execute after the current execution block
  33337. */
  33338. static SetImmediate(action: () => void): void;
  33339. /**
  33340. * Function indicating if a number is an exponent of 2
  33341. * @param value defines the value to test
  33342. * @returns true if the value is an exponent of 2
  33343. */
  33344. static IsExponentOfTwo(value: number): boolean;
  33345. private static _tmpFloatArray;
  33346. /**
  33347. * Returns the nearest 32-bit single precision float representation of a Number
  33348. * @param value A Number. If the parameter is of a different type, it will get converted
  33349. * to a number or to NaN if it cannot be converted
  33350. * @returns number
  33351. */
  33352. static FloatRound(value: number): number;
  33353. /**
  33354. * Extracts the filename from a path
  33355. * @param path defines the path to use
  33356. * @returns the filename
  33357. */
  33358. static GetFilename(path: string): string;
  33359. /**
  33360. * Extracts the "folder" part of a path (everything before the filename).
  33361. * @param uri The URI to extract the info from
  33362. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33363. * @returns The "folder" part of the path
  33364. */
  33365. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33366. /**
  33367. * Extracts text content from a DOM element hierarchy
  33368. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33369. */
  33370. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33371. /**
  33372. * Convert an angle in radians to degrees
  33373. * @param angle defines the angle to convert
  33374. * @returns the angle in degrees
  33375. */
  33376. static ToDegrees(angle: number): number;
  33377. /**
  33378. * Convert an angle in degrees to radians
  33379. * @param angle defines the angle to convert
  33380. * @returns the angle in radians
  33381. */
  33382. static ToRadians(angle: number): number;
  33383. /**
  33384. * Returns an array if obj is not an array
  33385. * @param obj defines the object to evaluate as an array
  33386. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33387. * @returns either obj directly if obj is an array or a new array containing obj
  33388. */
  33389. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33390. /**
  33391. * Gets the pointer prefix to use
  33392. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33393. */
  33394. static GetPointerPrefix(): string;
  33395. /**
  33396. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33397. * @param url define the url we are trying
  33398. * @param element define the dom element where to configure the cors policy
  33399. */
  33400. static SetCorsBehavior(url: string | string[], element: {
  33401. crossOrigin: string | null;
  33402. }): void;
  33403. /**
  33404. * Removes unwanted characters from an url
  33405. * @param url defines the url to clean
  33406. * @returns the cleaned url
  33407. */
  33408. static CleanUrl(url: string): string;
  33409. /**
  33410. * Gets or sets a function used to pre-process url before using them to load assets
  33411. */
  33412. static PreprocessUrl: (url: string) => string;
  33413. /**
  33414. * Loads an image as an HTMLImageElement.
  33415. * @param input url string, ArrayBuffer, or Blob to load
  33416. * @param onLoad callback called when the image successfully loads
  33417. * @param onError callback called when the image fails to load
  33418. * @param offlineProvider offline provider for caching
  33419. * @param mimeType optional mime type
  33420. * @returns the HTMLImageElement of the loaded image
  33421. */
  33422. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33423. /**
  33424. * Loads a file from a url
  33425. * @param url url string, ArrayBuffer, or Blob to load
  33426. * @param onSuccess callback called when the file successfully loads
  33427. * @param onProgress callback called while file is loading (if the server supports this mode)
  33428. * @param offlineProvider defines the offline provider for caching
  33429. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33430. * @param onError callback called when the file fails to load
  33431. * @returns a file request object
  33432. */
  33433. 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;
  33434. /**
  33435. * Loads a file from a url
  33436. * @param url the file url to load
  33437. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33438. */
  33439. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33440. /**
  33441. * Load a script (identified by an url). When the url returns, the
  33442. * content of this file is added into a new script element, attached to the DOM (body element)
  33443. * @param scriptUrl defines the url of the script to laod
  33444. * @param onSuccess defines the callback called when the script is loaded
  33445. * @param onError defines the callback to call if an error occurs
  33446. * @param scriptId defines the id of the script element
  33447. */
  33448. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33449. /**
  33450. * Load an asynchronous script (identified by an url). When the url returns, the
  33451. * content of this file is added into a new script element, attached to the DOM (body element)
  33452. * @param scriptUrl defines the url of the script to laod
  33453. * @param scriptId defines the id of the script element
  33454. * @returns a promise request object
  33455. */
  33456. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33457. /**
  33458. * Loads a file from a blob
  33459. * @param fileToLoad defines the blob to use
  33460. * @param callback defines the callback to call when data is loaded
  33461. * @param progressCallback defines the callback to call during loading process
  33462. * @returns a file request object
  33463. */
  33464. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33465. /**
  33466. * Reads a file from a File object
  33467. * @param file defines the file to load
  33468. * @param onSuccess defines the callback to call when data is loaded
  33469. * @param onProgress defines the callback to call during loading process
  33470. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33471. * @param onError defines the callback to call when an error occurs
  33472. * @returns a file request object
  33473. */
  33474. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  33475. /**
  33476. * Creates a data url from a given string content
  33477. * @param content defines the content to convert
  33478. * @returns the new data url link
  33479. */
  33480. static FileAsURL(content: string): string;
  33481. /**
  33482. * Format the given number to a specific decimal format
  33483. * @param value defines the number to format
  33484. * @param decimals defines the number of decimals to use
  33485. * @returns the formatted string
  33486. */
  33487. static Format(value: number, decimals?: number): string;
  33488. /**
  33489. * Tries to copy an object by duplicating every property
  33490. * @param source defines the source object
  33491. * @param destination defines the target object
  33492. * @param doNotCopyList defines a list of properties to avoid
  33493. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33494. */
  33495. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33496. /**
  33497. * Gets a boolean indicating if the given object has no own property
  33498. * @param obj defines the object to test
  33499. * @returns true if object has no own property
  33500. */
  33501. static IsEmpty(obj: any): boolean;
  33502. /**
  33503. * Function used to register events at window level
  33504. * @param windowElement defines the Window object to use
  33505. * @param events defines the events to register
  33506. */
  33507. static RegisterTopRootEvents(windowElement: Window, events: {
  33508. name: string;
  33509. handler: Nullable<(e: FocusEvent) => any>;
  33510. }[]): void;
  33511. /**
  33512. * Function used to unregister events from window level
  33513. * @param windowElement defines the Window object to use
  33514. * @param events defines the events to unregister
  33515. */
  33516. static UnregisterTopRootEvents(windowElement: Window, events: {
  33517. name: string;
  33518. handler: Nullable<(e: FocusEvent) => any>;
  33519. }[]): void;
  33520. /**
  33521. * @ignore
  33522. */
  33523. static _ScreenshotCanvas: HTMLCanvasElement;
  33524. /**
  33525. * Dumps the current bound framebuffer
  33526. * @param width defines the rendering width
  33527. * @param height defines the rendering height
  33528. * @param engine defines the hosting engine
  33529. * @param successCallback defines the callback triggered once the data are available
  33530. * @param mimeType defines the mime type of the result
  33531. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33532. */
  33533. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33534. /**
  33535. * Converts the canvas data to blob.
  33536. * This acts as a polyfill for browsers not supporting the to blob function.
  33537. * @param canvas Defines the canvas to extract the data from
  33538. * @param successCallback Defines the callback triggered once the data are available
  33539. * @param mimeType Defines the mime type of the result
  33540. */
  33541. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33542. /**
  33543. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33544. * @param successCallback defines the callback triggered once the data are available
  33545. * @param mimeType defines the mime type of the result
  33546. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33547. */
  33548. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33549. /**
  33550. * Downloads a blob in the browser
  33551. * @param blob defines the blob to download
  33552. * @param fileName defines the name of the downloaded file
  33553. */
  33554. static Download(blob: Blob, fileName: string): void;
  33555. /**
  33556. * Captures a screenshot of the current rendering
  33557. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33558. * @param engine defines the rendering engine
  33559. * @param camera defines the source camera
  33560. * @param size This parameter can be set to a single number or to an object with the
  33561. * following (optional) properties: precision, width, height. If a single number is passed,
  33562. * it will be used for both width and height. If an object is passed, the screenshot size
  33563. * will be derived from the parameters. The precision property is a multiplier allowing
  33564. * rendering at a higher or lower resolution
  33565. * @param successCallback defines the callback receives a single parameter which contains the
  33566. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33567. * src parameter of an <img> to display it
  33568. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33569. * Check your browser for supported MIME types
  33570. */
  33571. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33572. /**
  33573. * Captures a screenshot of the current rendering
  33574. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33575. * @param engine defines the rendering engine
  33576. * @param camera defines the source camera
  33577. * @param size This parameter can be set to a single number or to an object with the
  33578. * following (optional) properties: precision, width, height. If a single number is passed,
  33579. * it will be used for both width and height. If an object is passed, the screenshot size
  33580. * will be derived from the parameters. The precision property is a multiplier allowing
  33581. * rendering at a higher or lower resolution
  33582. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33583. * Check your browser for supported MIME types
  33584. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33585. * to the src parameter of an <img> to display it
  33586. */
  33587. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33588. /**
  33589. * Generates an image screenshot from the specified camera.
  33590. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33591. * @param engine The engine to use for rendering
  33592. * @param camera The camera to use for rendering
  33593. * @param size This parameter can be set to a single number or to an object with the
  33594. * following (optional) properties: precision, width, height. If a single number is passed,
  33595. * it will be used for both width and height. If an object is passed, the screenshot size
  33596. * will be derived from the parameters. The precision property is a multiplier allowing
  33597. * rendering at a higher or lower resolution
  33598. * @param successCallback The callback receives a single parameter which contains the
  33599. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33600. * src parameter of an <img> to display it
  33601. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33602. * Check your browser for supported MIME types
  33603. * @param samples Texture samples (default: 1)
  33604. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33605. * @param fileName A name for for the downloaded file.
  33606. */
  33607. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33608. /**
  33609. * Generates an image screenshot from the specified camera.
  33610. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33611. * @param engine The engine to use for rendering
  33612. * @param camera The camera to use for rendering
  33613. * @param size This parameter can be set to a single number or to an object with the
  33614. * following (optional) properties: precision, width, height. If a single number is passed,
  33615. * it will be used for both width and height. If an object is passed, the screenshot size
  33616. * will be derived from the parameters. The precision property is a multiplier allowing
  33617. * rendering at a higher or lower resolution
  33618. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33619. * Check your browser for supported MIME types
  33620. * @param samples Texture samples (default: 1)
  33621. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33622. * @param fileName A name for for the downloaded file.
  33623. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33624. * to the src parameter of an <img> to display it
  33625. */
  33626. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33627. /**
  33628. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33629. * Be aware Math.random() could cause collisions, but:
  33630. * "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"
  33631. * @returns a pseudo random id
  33632. */
  33633. static RandomId(): string;
  33634. /**
  33635. * Test if the given uri is a base64 string
  33636. * @param uri The uri to test
  33637. * @return True if the uri is a base64 string or false otherwise
  33638. */
  33639. static IsBase64(uri: string): boolean;
  33640. /**
  33641. * Decode the given base64 uri.
  33642. * @param uri The uri to decode
  33643. * @return The decoded base64 data.
  33644. */
  33645. static DecodeBase64(uri: string): ArrayBuffer;
  33646. /**
  33647. * Gets the absolute url.
  33648. * @param url the input url
  33649. * @return the absolute url
  33650. */
  33651. static GetAbsoluteUrl(url: string): string;
  33652. /**
  33653. * No log
  33654. */
  33655. static readonly NoneLogLevel: number;
  33656. /**
  33657. * Only message logs
  33658. */
  33659. static readonly MessageLogLevel: number;
  33660. /**
  33661. * Only warning logs
  33662. */
  33663. static readonly WarningLogLevel: number;
  33664. /**
  33665. * Only error logs
  33666. */
  33667. static readonly ErrorLogLevel: number;
  33668. /**
  33669. * All logs
  33670. */
  33671. static readonly AllLogLevel: number;
  33672. /**
  33673. * Gets a value indicating the number of loading errors
  33674. * @ignorenaming
  33675. */
  33676. static readonly errorsCount: number;
  33677. /**
  33678. * Callback called when a new log is added
  33679. */
  33680. static OnNewCacheEntry: (entry: string) => void;
  33681. /**
  33682. * Log a message to the console
  33683. * @param message defines the message to log
  33684. */
  33685. static Log(message: string): void;
  33686. /**
  33687. * Write a warning message to the console
  33688. * @param message defines the message to log
  33689. */
  33690. static Warn(message: string): void;
  33691. /**
  33692. * Write an error message to the console
  33693. * @param message defines the message to log
  33694. */
  33695. static Error(message: string): void;
  33696. /**
  33697. * Gets current log cache (list of logs)
  33698. */
  33699. static readonly LogCache: string;
  33700. /**
  33701. * Clears the log cache
  33702. */
  33703. static ClearLogCache(): void;
  33704. /**
  33705. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33706. */
  33707. static LogLevels: number;
  33708. /**
  33709. * Checks if the window object exists
  33710. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33711. */
  33712. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33713. /**
  33714. * No performance log
  33715. */
  33716. static readonly PerformanceNoneLogLevel: number;
  33717. /**
  33718. * Use user marks to log performance
  33719. */
  33720. static readonly PerformanceUserMarkLogLevel: number;
  33721. /**
  33722. * Log performance to the console
  33723. */
  33724. static readonly PerformanceConsoleLogLevel: number;
  33725. private static _performance;
  33726. /**
  33727. * Sets the current performance log level
  33728. */
  33729. static PerformanceLogLevel: number;
  33730. private static _StartPerformanceCounterDisabled;
  33731. private static _EndPerformanceCounterDisabled;
  33732. private static _StartUserMark;
  33733. private static _EndUserMark;
  33734. private static _StartPerformanceConsole;
  33735. private static _EndPerformanceConsole;
  33736. /**
  33737. * Starts a performance counter
  33738. */
  33739. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33740. /**
  33741. * Ends a specific performance coutner
  33742. */
  33743. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33744. /**
  33745. * Gets either window.performance.now() if supported or Date.now() else
  33746. */
  33747. static readonly Now: number;
  33748. /**
  33749. * This method will return the name of the class used to create the instance of the given object.
  33750. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33751. * @param object the object to get the class name from
  33752. * @param isType defines if the object is actually a type
  33753. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33754. */
  33755. static GetClassName(object: any, isType?: boolean): string;
  33756. /**
  33757. * Gets the first element of an array satisfying a given predicate
  33758. * @param array defines the array to browse
  33759. * @param predicate defines the predicate to use
  33760. * @returns null if not found or the element
  33761. */
  33762. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33763. /**
  33764. * This method will return the name of the full name of the class, including its owning module (if any).
  33765. * 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).
  33766. * @param object the object to get the class name from
  33767. * @param isType defines if the object is actually a type
  33768. * @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.
  33769. * @ignorenaming
  33770. */
  33771. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33772. /**
  33773. * Returns a promise that resolves after the given amount of time.
  33774. * @param delay Number of milliseconds to delay
  33775. * @returns Promise that resolves after the given amount of time
  33776. */
  33777. static DelayAsync(delay: number): Promise<void>;
  33778. }
  33779. /**
  33780. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33781. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33782. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33783. * @param name The name of the class, case should be preserved
  33784. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33785. */
  33786. export function className(name: string, module?: string): (target: Object) => void;
  33787. /**
  33788. * An implementation of a loop for asynchronous functions.
  33789. */
  33790. export class AsyncLoop {
  33791. /**
  33792. * Defines the number of iterations for the loop
  33793. */
  33794. iterations: number;
  33795. /**
  33796. * Defines the current index of the loop.
  33797. */
  33798. index: number;
  33799. private _done;
  33800. private _fn;
  33801. private _successCallback;
  33802. /**
  33803. * Constructor.
  33804. * @param iterations the number of iterations.
  33805. * @param func the function to run each iteration
  33806. * @param successCallback the callback that will be called upon succesful execution
  33807. * @param offset starting offset.
  33808. */
  33809. constructor(
  33810. /**
  33811. * Defines the number of iterations for the loop
  33812. */
  33813. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33814. /**
  33815. * Execute the next iteration. Must be called after the last iteration was finished.
  33816. */
  33817. executeNext(): void;
  33818. /**
  33819. * Break the loop and run the success callback.
  33820. */
  33821. breakLoop(): void;
  33822. /**
  33823. * Create and run an async loop.
  33824. * @param iterations the number of iterations.
  33825. * @param fn the function to run each iteration
  33826. * @param successCallback the callback that will be called upon succesful execution
  33827. * @param offset starting offset.
  33828. * @returns the created async loop object
  33829. */
  33830. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33831. /**
  33832. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33833. * @param iterations total number of iterations
  33834. * @param syncedIterations number of synchronous iterations in each async iteration.
  33835. * @param fn the function to call each iteration.
  33836. * @param callback a success call back that will be called when iterating stops.
  33837. * @param breakFunction a break condition (optional)
  33838. * @param timeout timeout settings for the setTimeout function. default - 0.
  33839. * @returns the created async loop object
  33840. */
  33841. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33842. }
  33843. }
  33844. declare module "babylonjs/Misc/stringDictionary" {
  33845. import { Nullable } from "babylonjs/types";
  33846. /**
  33847. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33848. * The underlying implementation relies on an associative array to ensure the best performances.
  33849. * The value can be anything including 'null' but except 'undefined'
  33850. */
  33851. export class StringDictionary<T> {
  33852. /**
  33853. * This will clear this dictionary and copy the content from the 'source' one.
  33854. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33855. * @param source the dictionary to take the content from and copy to this dictionary
  33856. */
  33857. copyFrom(source: StringDictionary<T>): void;
  33858. /**
  33859. * Get a value based from its key
  33860. * @param key the given key to get the matching value from
  33861. * @return the value if found, otherwise undefined is returned
  33862. */
  33863. get(key: string): T | undefined;
  33864. /**
  33865. * Get a value from its key or add it if it doesn't exist.
  33866. * This method will ensure you that a given key/data will be present in the dictionary.
  33867. * @param key the given key to get the matching value from
  33868. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33869. * The factory will only be invoked if there's no data for the given key.
  33870. * @return the value corresponding to the key.
  33871. */
  33872. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33873. /**
  33874. * Get a value from its key if present in the dictionary otherwise add it
  33875. * @param key the key to get the value from
  33876. * @param val if there's no such key/value pair in the dictionary add it with this value
  33877. * @return the value corresponding to the key
  33878. */
  33879. getOrAdd(key: string, val: T): T;
  33880. /**
  33881. * Check if there's a given key in the dictionary
  33882. * @param key the key to check for
  33883. * @return true if the key is present, false otherwise
  33884. */
  33885. contains(key: string): boolean;
  33886. /**
  33887. * Add a new key and its corresponding value
  33888. * @param key the key to add
  33889. * @param value the value corresponding to the key
  33890. * @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
  33891. */
  33892. add(key: string, value: T): boolean;
  33893. /**
  33894. * Update a specific value associated to a key
  33895. * @param key defines the key to use
  33896. * @param value defines the value to store
  33897. * @returns true if the value was updated (or false if the key was not found)
  33898. */
  33899. set(key: string, value: T): boolean;
  33900. /**
  33901. * Get the element of the given key and remove it from the dictionary
  33902. * @param key defines the key to search
  33903. * @returns the value associated with the key or null if not found
  33904. */
  33905. getAndRemove(key: string): Nullable<T>;
  33906. /**
  33907. * Remove a key/value from the dictionary.
  33908. * @param key the key to remove
  33909. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33910. */
  33911. remove(key: string): boolean;
  33912. /**
  33913. * Clear the whole content of the dictionary
  33914. */
  33915. clear(): void;
  33916. /**
  33917. * Gets the current count
  33918. */
  33919. readonly count: number;
  33920. /**
  33921. * Execute a callback on each key/val of the dictionary.
  33922. * Note that you can remove any element in this dictionary in the callback implementation
  33923. * @param callback the callback to execute on a given key/value pair
  33924. */
  33925. forEach(callback: (key: string, val: T) => void): void;
  33926. /**
  33927. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33928. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33929. * Note that you can remove any element in this dictionary in the callback implementation
  33930. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33931. * @returns the first item
  33932. */
  33933. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33934. private _count;
  33935. private _data;
  33936. }
  33937. }
  33938. declare module "babylonjs/Collisions/collisionCoordinator" {
  33939. import { Nullable } from "babylonjs/types";
  33940. import { Scene } from "babylonjs/scene";
  33941. import { Vector3 } from "babylonjs/Maths/math.vector";
  33942. import { Collider } from "babylonjs/Collisions/collider";
  33943. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33944. /** @hidden */
  33945. export interface ICollisionCoordinator {
  33946. createCollider(): Collider;
  33947. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33948. init(scene: Scene): void;
  33949. }
  33950. /** @hidden */
  33951. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33952. private _scene;
  33953. private _scaledPosition;
  33954. private _scaledVelocity;
  33955. private _finalPosition;
  33956. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33957. createCollider(): Collider;
  33958. init(scene: Scene): void;
  33959. private _collideWithWorld;
  33960. }
  33961. }
  33962. declare module "babylonjs/Inputs/scene.inputManager" {
  33963. import { Nullable } from "babylonjs/types";
  33964. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33965. import { Vector2 } from "babylonjs/Maths/math.vector";
  33966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33967. import { Scene } from "babylonjs/scene";
  33968. /**
  33969. * Class used to manage all inputs for the scene.
  33970. */
  33971. export class InputManager {
  33972. /** The distance in pixel that you have to move to prevent some events */
  33973. static DragMovementThreshold: number;
  33974. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33975. static LongPressDelay: number;
  33976. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33977. static DoubleClickDelay: number;
  33978. /** If you need to check double click without raising a single click at first click, enable this flag */
  33979. static ExclusiveDoubleClickMode: boolean;
  33980. private _wheelEventName;
  33981. private _onPointerMove;
  33982. private _onPointerDown;
  33983. private _onPointerUp;
  33984. private _initClickEvent;
  33985. private _initActionManager;
  33986. private _delayedSimpleClick;
  33987. private _delayedSimpleClickTimeout;
  33988. private _previousDelayedSimpleClickTimeout;
  33989. private _meshPickProceed;
  33990. private _previousButtonPressed;
  33991. private _currentPickResult;
  33992. private _previousPickResult;
  33993. private _totalPointersPressed;
  33994. private _doubleClickOccured;
  33995. private _pointerOverMesh;
  33996. private _pickedDownMesh;
  33997. private _pickedUpMesh;
  33998. private _pointerX;
  33999. private _pointerY;
  34000. private _unTranslatedPointerX;
  34001. private _unTranslatedPointerY;
  34002. private _startingPointerPosition;
  34003. private _previousStartingPointerPosition;
  34004. private _startingPointerTime;
  34005. private _previousStartingPointerTime;
  34006. private _pointerCaptures;
  34007. private _onKeyDown;
  34008. private _onKeyUp;
  34009. private _onCanvasFocusObserver;
  34010. private _onCanvasBlurObserver;
  34011. private _scene;
  34012. /**
  34013. * Creates a new InputManager
  34014. * @param scene defines the hosting scene
  34015. */
  34016. constructor(scene: Scene);
  34017. /**
  34018. * Gets the mesh that is currently under the pointer
  34019. */
  34020. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34021. /**
  34022. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34023. */
  34024. readonly unTranslatedPointer: Vector2;
  34025. /**
  34026. * Gets or sets the current on-screen X position of the pointer
  34027. */
  34028. pointerX: number;
  34029. /**
  34030. * Gets or sets the current on-screen Y position of the pointer
  34031. */
  34032. pointerY: number;
  34033. private _updatePointerPosition;
  34034. private _processPointerMove;
  34035. private _setRayOnPointerInfo;
  34036. private _checkPrePointerObservable;
  34037. /**
  34038. * Use this method to simulate a pointer move on a mesh
  34039. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34040. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34041. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34042. */
  34043. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34044. /**
  34045. * Use this method to simulate a pointer down on a mesh
  34046. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34047. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34048. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34049. */
  34050. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34051. private _processPointerDown;
  34052. /** @hidden */
  34053. _isPointerSwiping(): boolean;
  34054. /**
  34055. * Use this method to simulate a pointer up on a mesh
  34056. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34057. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34058. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34059. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34060. */
  34061. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34062. private _processPointerUp;
  34063. /**
  34064. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34065. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34066. * @returns true if the pointer was captured
  34067. */
  34068. isPointerCaptured(pointerId?: number): boolean;
  34069. /**
  34070. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34071. * @param attachUp defines if you want to attach events to pointerup
  34072. * @param attachDown defines if you want to attach events to pointerdown
  34073. * @param attachMove defines if you want to attach events to pointermove
  34074. */
  34075. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34076. /**
  34077. * Detaches all event handlers
  34078. */
  34079. detachControl(): void;
  34080. /**
  34081. * Force the value of meshUnderPointer
  34082. * @param mesh defines the mesh to use
  34083. */
  34084. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34085. /**
  34086. * Gets the mesh under the pointer
  34087. * @returns a Mesh or null if no mesh is under the pointer
  34088. */
  34089. getPointerOverMesh(): Nullable<AbstractMesh>;
  34090. }
  34091. }
  34092. declare module "babylonjs/Misc/uniqueIdGenerator" {
  34093. /**
  34094. * Helper class used to generate session unique ID
  34095. */
  34096. export class UniqueIdGenerator {
  34097. private static _UniqueIdCounter;
  34098. /**
  34099. * Gets an unique (relatively to the current scene) Id
  34100. */
  34101. static readonly UniqueId: number;
  34102. }
  34103. }
  34104. declare module "babylonjs/Animations/animationGroup" {
  34105. import { Animatable } from "babylonjs/Animations/animatable";
  34106. import { Animation } from "babylonjs/Animations/animation";
  34107. import { Scene, IDisposable } from "babylonjs/scene";
  34108. import { Observable } from "babylonjs/Misc/observable";
  34109. import { Nullable } from "babylonjs/types";
  34110. import "babylonjs/Animations/animatable";
  34111. /**
  34112. * This class defines the direct association between an animation and a target
  34113. */
  34114. export class TargetedAnimation {
  34115. /**
  34116. * Animation to perform
  34117. */
  34118. animation: Animation;
  34119. /**
  34120. * Target to animate
  34121. */
  34122. target: any;
  34123. /**
  34124. * Serialize the object
  34125. * @returns the JSON object representing the current entity
  34126. */
  34127. serialize(): any;
  34128. }
  34129. /**
  34130. * Use this class to create coordinated animations on multiple targets
  34131. */
  34132. export class AnimationGroup implements IDisposable {
  34133. /** The name of the animation group */
  34134. name: string;
  34135. private _scene;
  34136. private _targetedAnimations;
  34137. private _animatables;
  34138. private _from;
  34139. private _to;
  34140. private _isStarted;
  34141. private _isPaused;
  34142. private _speedRatio;
  34143. private _loopAnimation;
  34144. /**
  34145. * Gets or sets the unique id of the node
  34146. */
  34147. uniqueId: number;
  34148. /**
  34149. * This observable will notify when one animation have ended
  34150. */
  34151. onAnimationEndObservable: Observable<TargetedAnimation>;
  34152. /**
  34153. * Observer raised when one animation loops
  34154. */
  34155. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34156. /**
  34157. * Observer raised when all animations have looped
  34158. */
  34159. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34160. /**
  34161. * This observable will notify when all animations have ended.
  34162. */
  34163. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34164. /**
  34165. * This observable will notify when all animations have paused.
  34166. */
  34167. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34168. /**
  34169. * This observable will notify when all animations are playing.
  34170. */
  34171. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34172. /**
  34173. * Gets the first frame
  34174. */
  34175. readonly from: number;
  34176. /**
  34177. * Gets the last frame
  34178. */
  34179. readonly to: number;
  34180. /**
  34181. * Define if the animations are started
  34182. */
  34183. readonly isStarted: boolean;
  34184. /**
  34185. * Gets a value indicating that the current group is playing
  34186. */
  34187. readonly isPlaying: boolean;
  34188. /**
  34189. * Gets or sets the speed ratio to use for all animations
  34190. */
  34191. /**
  34192. * Gets or sets the speed ratio to use for all animations
  34193. */
  34194. speedRatio: number;
  34195. /**
  34196. * Gets or sets if all animations should loop or not
  34197. */
  34198. loopAnimation: boolean;
  34199. /**
  34200. * Gets the targeted animations for this animation group
  34201. */
  34202. readonly targetedAnimations: Array<TargetedAnimation>;
  34203. /**
  34204. * returning the list of animatables controlled by this animation group.
  34205. */
  34206. readonly animatables: Array<Animatable>;
  34207. /**
  34208. * Instantiates a new Animation Group.
  34209. * This helps managing several animations at once.
  34210. * @see http://doc.babylonjs.com/how_to/group
  34211. * @param name Defines the name of the group
  34212. * @param scene Defines the scene the group belongs to
  34213. */
  34214. constructor(
  34215. /** The name of the animation group */
  34216. name: string, scene?: Nullable<Scene>);
  34217. /**
  34218. * Add an animation (with its target) in the group
  34219. * @param animation defines the animation we want to add
  34220. * @param target defines the target of the animation
  34221. * @returns the TargetedAnimation object
  34222. */
  34223. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34224. /**
  34225. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34226. * It can add constant keys at begin or end
  34227. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34228. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34229. * @returns the animation group
  34230. */
  34231. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34232. private _animationLoopCount;
  34233. private _animationLoopFlags;
  34234. private _processLoop;
  34235. /**
  34236. * Start all animations on given targets
  34237. * @param loop defines if animations must loop
  34238. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34239. * @param from defines the from key (optional)
  34240. * @param to defines the to key (optional)
  34241. * @returns the current animation group
  34242. */
  34243. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34244. /**
  34245. * Pause all animations
  34246. * @returns the animation group
  34247. */
  34248. pause(): AnimationGroup;
  34249. /**
  34250. * Play all animations to initial state
  34251. * This function will start() the animations if they were not started or will restart() them if they were paused
  34252. * @param loop defines if animations must loop
  34253. * @returns the animation group
  34254. */
  34255. play(loop?: boolean): AnimationGroup;
  34256. /**
  34257. * Reset all animations to initial state
  34258. * @returns the animation group
  34259. */
  34260. reset(): AnimationGroup;
  34261. /**
  34262. * Restart animations from key 0
  34263. * @returns the animation group
  34264. */
  34265. restart(): AnimationGroup;
  34266. /**
  34267. * Stop all animations
  34268. * @returns the animation group
  34269. */
  34270. stop(): AnimationGroup;
  34271. /**
  34272. * Set animation weight for all animatables
  34273. * @param weight defines the weight to use
  34274. * @return the animationGroup
  34275. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34276. */
  34277. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34278. /**
  34279. * Synchronize and normalize all animatables with a source animatable
  34280. * @param root defines the root animatable to synchronize with
  34281. * @return the animationGroup
  34282. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34283. */
  34284. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34285. /**
  34286. * Goes to a specific frame in this animation group
  34287. * @param frame the frame number to go to
  34288. * @return the animationGroup
  34289. */
  34290. goToFrame(frame: number): AnimationGroup;
  34291. /**
  34292. * Dispose all associated resources
  34293. */
  34294. dispose(): void;
  34295. private _checkAnimationGroupEnded;
  34296. /**
  34297. * Clone the current animation group and returns a copy
  34298. * @param newName defines the name of the new group
  34299. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34300. * @returns the new aniamtion group
  34301. */
  34302. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34303. /**
  34304. * Serializes the animationGroup to an object
  34305. * @returns Serialized object
  34306. */
  34307. serialize(): any;
  34308. /**
  34309. * Returns a new AnimationGroup object parsed from the source provided.
  34310. * @param parsedAnimationGroup defines the source
  34311. * @param scene defines the scene that will receive the animationGroup
  34312. * @returns a new AnimationGroup
  34313. */
  34314. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34315. /**
  34316. * Returns the string "AnimationGroup"
  34317. * @returns "AnimationGroup"
  34318. */
  34319. getClassName(): string;
  34320. /**
  34321. * Creates a detailled string about the object
  34322. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34323. * @returns a string representing the object
  34324. */
  34325. toString(fullDetails?: boolean): string;
  34326. }
  34327. }
  34328. declare module "babylonjs/scene" {
  34329. import { Nullable } from "babylonjs/types";
  34330. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34331. import { Observable } from "babylonjs/Misc/observable";
  34332. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  34333. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  34334. import { Geometry } from "babylonjs/Meshes/geometry";
  34335. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34336. import { SubMesh } from "babylonjs/Meshes/subMesh";
  34337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34338. import { Mesh } from "babylonjs/Meshes/mesh";
  34339. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34340. import { Bone } from "babylonjs/Bones/bone";
  34341. import { Skeleton } from "babylonjs/Bones/skeleton";
  34342. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34343. import { Camera } from "babylonjs/Cameras/camera";
  34344. import { AbstractScene } from "babylonjs/abstractScene";
  34345. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34346. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34347. import { Material } from "babylonjs/Materials/material";
  34348. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  34349. import { Effect } from "babylonjs/Materials/effect";
  34350. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  34351. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34352. import { Light } from "babylonjs/Lights/light";
  34353. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  34354. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  34355. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  34356. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  34357. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34358. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  34359. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34360. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  34361. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  34362. import { Engine } from "babylonjs/Engines/engine";
  34363. import { Node } from "babylonjs/node";
  34364. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  34365. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34366. import { WebRequest } from "babylonjs/Misc/webRequest";
  34367. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  34368. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34369. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34370. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34371. import { Plane } from "babylonjs/Maths/math.plane";
  34372. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  34373. import { Ray } from "babylonjs/Culling/ray";
  34374. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  34375. import { Animation } from "babylonjs/Animations/animation";
  34376. import { Animatable } from "babylonjs/Animations/animatable";
  34377. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34378. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34379. import { Collider } from "babylonjs/Collisions/collider";
  34380. /**
  34381. * Define an interface for all classes that will hold resources
  34382. */
  34383. export interface IDisposable {
  34384. /**
  34385. * Releases all held resources
  34386. */
  34387. dispose(): void;
  34388. }
  34389. /** Interface defining initialization parameters for Scene class */
  34390. export interface SceneOptions {
  34391. /**
  34392. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34393. * It will improve performance when the number of geometries becomes important.
  34394. */
  34395. useGeometryUniqueIdsMap?: boolean;
  34396. /**
  34397. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34398. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34399. */
  34400. useMaterialMeshMap?: boolean;
  34401. /**
  34402. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34403. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34404. */
  34405. useClonedMeshhMap?: boolean;
  34406. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34407. virtual?: boolean;
  34408. }
  34409. /**
  34410. * Represents a scene to be rendered by the engine.
  34411. * @see http://doc.babylonjs.com/features/scene
  34412. */
  34413. export class Scene extends AbstractScene implements IAnimatable {
  34414. /** The fog is deactivated */
  34415. static readonly FOGMODE_NONE: number;
  34416. /** The fog density is following an exponential function */
  34417. static readonly FOGMODE_EXP: number;
  34418. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34419. static readonly FOGMODE_EXP2: number;
  34420. /** The fog density is following a linear function. */
  34421. static readonly FOGMODE_LINEAR: number;
  34422. /**
  34423. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34424. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34425. */
  34426. static MinDeltaTime: number;
  34427. /**
  34428. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34429. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34430. */
  34431. static MaxDeltaTime: number;
  34432. /**
  34433. * Factory used to create the default material.
  34434. * @param name The name of the material to create
  34435. * @param scene The scene to create the material for
  34436. * @returns The default material
  34437. */
  34438. static DefaultMaterialFactory(scene: Scene): Material;
  34439. /**
  34440. * Factory used to create the a collision coordinator.
  34441. * @returns The collision coordinator
  34442. */
  34443. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34444. /** @hidden */
  34445. _inputManager: InputManager;
  34446. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34447. cameraToUseForPointers: Nullable<Camera>;
  34448. /** @hidden */
  34449. readonly _isScene: boolean;
  34450. /**
  34451. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34452. */
  34453. autoClear: boolean;
  34454. /**
  34455. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34456. */
  34457. autoClearDepthAndStencil: boolean;
  34458. /**
  34459. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34460. */
  34461. clearColor: Color4;
  34462. /**
  34463. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34464. */
  34465. ambientColor: Color3;
  34466. /**
  34467. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34468. * It should only be one of the following (if not the default embedded one):
  34469. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34470. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34471. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34472. * The material properties need to be setup according to the type of texture in use.
  34473. */
  34474. environmentBRDFTexture: BaseTexture;
  34475. /** @hidden */
  34476. protected _environmentTexture: Nullable<BaseTexture>;
  34477. /**
  34478. * Texture used in all pbr material as the reflection texture.
  34479. * As in the majority of the scene they are the same (exception for multi room and so on),
  34480. * this is easier to reference from here than from all the materials.
  34481. */
  34482. /**
  34483. * Texture used in all pbr material as the reflection texture.
  34484. * As in the majority of the scene they are the same (exception for multi room and so on),
  34485. * this is easier to set here than in all the materials.
  34486. */
  34487. environmentTexture: Nullable<BaseTexture>;
  34488. /** @hidden */
  34489. protected _environmentIntensity: number;
  34490. /**
  34491. * Intensity of the environment in all pbr material.
  34492. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34493. * As in the majority of the scene they are the same (exception for multi room and so on),
  34494. * this is easier to reference from here than from all the materials.
  34495. */
  34496. /**
  34497. * Intensity of the environment in all pbr material.
  34498. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34499. * As in the majority of the scene they are the same (exception for multi room and so on),
  34500. * this is easier to set here than in all the materials.
  34501. */
  34502. environmentIntensity: number;
  34503. /** @hidden */
  34504. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34505. /**
  34506. * Default image processing configuration used either in the rendering
  34507. * Forward main pass or through the imageProcessingPostProcess if present.
  34508. * As in the majority of the scene they are the same (exception for multi camera),
  34509. * this is easier to reference from here than from all the materials and post process.
  34510. *
  34511. * No setter as we it is a shared configuration, you can set the values instead.
  34512. */
  34513. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34514. private _forceWireframe;
  34515. /**
  34516. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34517. */
  34518. forceWireframe: boolean;
  34519. private _forcePointsCloud;
  34520. /**
  34521. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34522. */
  34523. forcePointsCloud: boolean;
  34524. /**
  34525. * Gets or sets the active clipplane 1
  34526. */
  34527. clipPlane: Nullable<Plane>;
  34528. /**
  34529. * Gets or sets the active clipplane 2
  34530. */
  34531. clipPlane2: Nullable<Plane>;
  34532. /**
  34533. * Gets or sets the active clipplane 3
  34534. */
  34535. clipPlane3: Nullable<Plane>;
  34536. /**
  34537. * Gets or sets the active clipplane 4
  34538. */
  34539. clipPlane4: Nullable<Plane>;
  34540. /**
  34541. * Gets or sets a boolean indicating if animations are enabled
  34542. */
  34543. animationsEnabled: boolean;
  34544. private _animationPropertiesOverride;
  34545. /**
  34546. * Gets or sets the animation properties override
  34547. */
  34548. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34549. /**
  34550. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34551. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34552. */
  34553. useConstantAnimationDeltaTime: boolean;
  34554. /**
  34555. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34556. * Please note that it requires to run a ray cast through the scene on every frame
  34557. */
  34558. constantlyUpdateMeshUnderPointer: boolean;
  34559. /**
  34560. * Defines the HTML cursor to use when hovering over interactive elements
  34561. */
  34562. hoverCursor: string;
  34563. /**
  34564. * Defines the HTML default cursor to use (empty by default)
  34565. */
  34566. defaultCursor: string;
  34567. /**
  34568. * Defines wether cursors are handled by the scene.
  34569. */
  34570. doNotHandleCursors: boolean;
  34571. /**
  34572. * This is used to call preventDefault() on pointer down
  34573. * in order to block unwanted artifacts like system double clicks
  34574. */
  34575. preventDefaultOnPointerDown: boolean;
  34576. /**
  34577. * This is used to call preventDefault() on pointer up
  34578. * in order to block unwanted artifacts like system double clicks
  34579. */
  34580. preventDefaultOnPointerUp: boolean;
  34581. /**
  34582. * Gets or sets user defined metadata
  34583. */
  34584. metadata: any;
  34585. /**
  34586. * For internal use only. Please do not use.
  34587. */
  34588. reservedDataStore: any;
  34589. /**
  34590. * Gets the name of the plugin used to load this scene (null by default)
  34591. */
  34592. loadingPluginName: string;
  34593. /**
  34594. * Use this array to add regular expressions used to disable offline support for specific urls
  34595. */
  34596. disableOfflineSupportExceptionRules: RegExp[];
  34597. /**
  34598. * An event triggered when the scene is disposed.
  34599. */
  34600. onDisposeObservable: Observable<Scene>;
  34601. private _onDisposeObserver;
  34602. /** Sets a function to be executed when this scene is disposed. */
  34603. onDispose: () => void;
  34604. /**
  34605. * An event triggered before rendering the scene (right after animations and physics)
  34606. */
  34607. onBeforeRenderObservable: Observable<Scene>;
  34608. private _onBeforeRenderObserver;
  34609. /** Sets a function to be executed before rendering this scene */
  34610. beforeRender: Nullable<() => void>;
  34611. /**
  34612. * An event triggered after rendering the scene
  34613. */
  34614. onAfterRenderObservable: Observable<Scene>;
  34615. /**
  34616. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34617. */
  34618. onAfterRenderCameraObservable: Observable<Camera>;
  34619. private _onAfterRenderObserver;
  34620. /** Sets a function to be executed after rendering this scene */
  34621. afterRender: Nullable<() => void>;
  34622. /**
  34623. * An event triggered before animating the scene
  34624. */
  34625. onBeforeAnimationsObservable: Observable<Scene>;
  34626. /**
  34627. * An event triggered after animations processing
  34628. */
  34629. onAfterAnimationsObservable: Observable<Scene>;
  34630. /**
  34631. * An event triggered before draw calls are ready to be sent
  34632. */
  34633. onBeforeDrawPhaseObservable: Observable<Scene>;
  34634. /**
  34635. * An event triggered after draw calls have been sent
  34636. */
  34637. onAfterDrawPhaseObservable: Observable<Scene>;
  34638. /**
  34639. * An event triggered when the scene is ready
  34640. */
  34641. onReadyObservable: Observable<Scene>;
  34642. /**
  34643. * An event triggered before rendering a camera
  34644. */
  34645. onBeforeCameraRenderObservable: Observable<Camera>;
  34646. private _onBeforeCameraRenderObserver;
  34647. /** Sets a function to be executed before rendering a camera*/
  34648. beforeCameraRender: () => void;
  34649. /**
  34650. * An event triggered after rendering a camera
  34651. */
  34652. onAfterCameraRenderObservable: Observable<Camera>;
  34653. private _onAfterCameraRenderObserver;
  34654. /** Sets a function to be executed after rendering a camera*/
  34655. afterCameraRender: () => void;
  34656. /**
  34657. * An event triggered when active meshes evaluation is about to start
  34658. */
  34659. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34660. /**
  34661. * An event triggered when active meshes evaluation is done
  34662. */
  34663. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34664. /**
  34665. * An event triggered when particles rendering is about to start
  34666. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34667. */
  34668. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34669. /**
  34670. * An event triggered when particles rendering is done
  34671. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34672. */
  34673. onAfterParticlesRenderingObservable: Observable<Scene>;
  34674. /**
  34675. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34676. */
  34677. onDataLoadedObservable: Observable<Scene>;
  34678. /**
  34679. * An event triggered when a camera is created
  34680. */
  34681. onNewCameraAddedObservable: Observable<Camera>;
  34682. /**
  34683. * An event triggered when a camera is removed
  34684. */
  34685. onCameraRemovedObservable: Observable<Camera>;
  34686. /**
  34687. * An event triggered when a light is created
  34688. */
  34689. onNewLightAddedObservable: Observable<Light>;
  34690. /**
  34691. * An event triggered when a light is removed
  34692. */
  34693. onLightRemovedObservable: Observable<Light>;
  34694. /**
  34695. * An event triggered when a geometry is created
  34696. */
  34697. onNewGeometryAddedObservable: Observable<Geometry>;
  34698. /**
  34699. * An event triggered when a geometry is removed
  34700. */
  34701. onGeometryRemovedObservable: Observable<Geometry>;
  34702. /**
  34703. * An event triggered when a transform node is created
  34704. */
  34705. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34706. /**
  34707. * An event triggered when a transform node is removed
  34708. */
  34709. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34710. /**
  34711. * An event triggered when a mesh is created
  34712. */
  34713. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34714. /**
  34715. * An event triggered when a mesh is removed
  34716. */
  34717. onMeshRemovedObservable: Observable<AbstractMesh>;
  34718. /**
  34719. * An event triggered when a skeleton is created
  34720. */
  34721. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34722. /**
  34723. * An event triggered when a skeleton is removed
  34724. */
  34725. onSkeletonRemovedObservable: Observable<Skeleton>;
  34726. /**
  34727. * An event triggered when a material is created
  34728. */
  34729. onNewMaterialAddedObservable: Observable<Material>;
  34730. /**
  34731. * An event triggered when a material is removed
  34732. */
  34733. onMaterialRemovedObservable: Observable<Material>;
  34734. /**
  34735. * An event triggered when a texture is created
  34736. */
  34737. onNewTextureAddedObservable: Observable<BaseTexture>;
  34738. /**
  34739. * An event triggered when a texture is removed
  34740. */
  34741. onTextureRemovedObservable: Observable<BaseTexture>;
  34742. /**
  34743. * An event triggered when render targets are about to be rendered
  34744. * Can happen multiple times per frame.
  34745. */
  34746. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34747. /**
  34748. * An event triggered when render targets were rendered.
  34749. * Can happen multiple times per frame.
  34750. */
  34751. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34752. /**
  34753. * An event triggered before calculating deterministic simulation step
  34754. */
  34755. onBeforeStepObservable: Observable<Scene>;
  34756. /**
  34757. * An event triggered after calculating deterministic simulation step
  34758. */
  34759. onAfterStepObservable: Observable<Scene>;
  34760. /**
  34761. * An event triggered when the activeCamera property is updated
  34762. */
  34763. onActiveCameraChanged: Observable<Scene>;
  34764. /**
  34765. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34766. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34767. * 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)
  34768. */
  34769. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34770. /**
  34771. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34772. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34773. * 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)
  34774. */
  34775. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34776. /**
  34777. * This Observable will when a mesh has been imported into the scene.
  34778. */
  34779. onMeshImportedObservable: Observable<AbstractMesh>;
  34780. /**
  34781. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34782. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34783. */
  34784. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34785. /** @hidden */
  34786. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34787. /**
  34788. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34789. */
  34790. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34791. /**
  34792. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34793. */
  34794. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34795. /**
  34796. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34797. */
  34798. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34799. /** Callback called when a pointer move is detected */
  34800. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34801. /** Callback called when a pointer down is detected */
  34802. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34803. /** Callback called when a pointer up is detected */
  34804. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34805. /** Callback called when a pointer pick is detected */
  34806. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34807. /**
  34808. * 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).
  34809. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34810. */
  34811. onPrePointerObservable: Observable<PointerInfoPre>;
  34812. /**
  34813. * Observable event triggered each time an input event is received from the rendering canvas
  34814. */
  34815. onPointerObservable: Observable<PointerInfo>;
  34816. /**
  34817. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34818. */
  34819. readonly unTranslatedPointer: Vector2;
  34820. /**
  34821. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34822. */
  34823. static DragMovementThreshold: number;
  34824. /**
  34825. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34826. */
  34827. static LongPressDelay: number;
  34828. /**
  34829. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34830. */
  34831. static DoubleClickDelay: number;
  34832. /** If you need to check double click without raising a single click at first click, enable this flag */
  34833. static ExclusiveDoubleClickMode: boolean;
  34834. /** @hidden */
  34835. _mirroredCameraPosition: Nullable<Vector3>;
  34836. /**
  34837. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34838. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34839. */
  34840. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34841. /**
  34842. * Observable event triggered each time an keyboard event is received from the hosting window
  34843. */
  34844. onKeyboardObservable: Observable<KeyboardInfo>;
  34845. private _useRightHandedSystem;
  34846. /**
  34847. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34848. */
  34849. useRightHandedSystem: boolean;
  34850. private _timeAccumulator;
  34851. private _currentStepId;
  34852. private _currentInternalStep;
  34853. /**
  34854. * Sets the step Id used by deterministic lock step
  34855. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34856. * @param newStepId defines the step Id
  34857. */
  34858. setStepId(newStepId: number): void;
  34859. /**
  34860. * Gets the step Id used by deterministic lock step
  34861. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34862. * @returns the step Id
  34863. */
  34864. getStepId(): number;
  34865. /**
  34866. * Gets the internal step used by deterministic lock step
  34867. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34868. * @returns the internal step
  34869. */
  34870. getInternalStep(): number;
  34871. private _fogEnabled;
  34872. /**
  34873. * Gets or sets a boolean indicating if fog is enabled on this scene
  34874. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34875. * (Default is true)
  34876. */
  34877. fogEnabled: boolean;
  34878. private _fogMode;
  34879. /**
  34880. * Gets or sets the fog mode to use
  34881. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34882. * | mode | value |
  34883. * | --- | --- |
  34884. * | FOGMODE_NONE | 0 |
  34885. * | FOGMODE_EXP | 1 |
  34886. * | FOGMODE_EXP2 | 2 |
  34887. * | FOGMODE_LINEAR | 3 |
  34888. */
  34889. fogMode: number;
  34890. /**
  34891. * Gets or sets the fog color to use
  34892. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34893. * (Default is Color3(0.2, 0.2, 0.3))
  34894. */
  34895. fogColor: Color3;
  34896. /**
  34897. * Gets or sets the fog density to use
  34898. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34899. * (Default is 0.1)
  34900. */
  34901. fogDensity: number;
  34902. /**
  34903. * Gets or sets the fog start distance to use
  34904. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34905. * (Default is 0)
  34906. */
  34907. fogStart: number;
  34908. /**
  34909. * Gets or sets the fog end distance to use
  34910. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34911. * (Default is 1000)
  34912. */
  34913. fogEnd: number;
  34914. private _shadowsEnabled;
  34915. /**
  34916. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34917. */
  34918. shadowsEnabled: boolean;
  34919. private _lightsEnabled;
  34920. /**
  34921. * Gets or sets a boolean indicating if lights are enabled on this scene
  34922. */
  34923. lightsEnabled: boolean;
  34924. /** All of the active cameras added to this scene. */
  34925. activeCameras: Camera[];
  34926. /** @hidden */
  34927. _activeCamera: Nullable<Camera>;
  34928. /** Gets or sets the current active camera */
  34929. activeCamera: Nullable<Camera>;
  34930. private _defaultMaterial;
  34931. /** The default material used on meshes when no material is affected */
  34932. /** The default material used on meshes when no material is affected */
  34933. defaultMaterial: Material;
  34934. private _texturesEnabled;
  34935. /**
  34936. * Gets or sets a boolean indicating if textures are enabled on this scene
  34937. */
  34938. texturesEnabled: boolean;
  34939. /**
  34940. * Gets or sets a boolean indicating if particles are enabled on this scene
  34941. */
  34942. particlesEnabled: boolean;
  34943. /**
  34944. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34945. */
  34946. spritesEnabled: boolean;
  34947. private _skeletonsEnabled;
  34948. /**
  34949. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34950. */
  34951. skeletonsEnabled: boolean;
  34952. /**
  34953. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34954. */
  34955. lensFlaresEnabled: boolean;
  34956. /**
  34957. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34958. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34959. */
  34960. collisionsEnabled: boolean;
  34961. private _collisionCoordinator;
  34962. /** @hidden */
  34963. readonly collisionCoordinator: ICollisionCoordinator;
  34964. /**
  34965. * Defines the gravity applied to this scene (used only for collisions)
  34966. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34967. */
  34968. gravity: Vector3;
  34969. /**
  34970. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34971. */
  34972. postProcessesEnabled: boolean;
  34973. /**
  34974. * The list of postprocesses added to the scene
  34975. */
  34976. postProcesses: PostProcess[];
  34977. /**
  34978. * Gets the current postprocess manager
  34979. */
  34980. postProcessManager: PostProcessManager;
  34981. /**
  34982. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34983. */
  34984. renderTargetsEnabled: boolean;
  34985. /**
  34986. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34987. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34988. */
  34989. dumpNextRenderTargets: boolean;
  34990. /**
  34991. * The list of user defined render targets added to the scene
  34992. */
  34993. customRenderTargets: RenderTargetTexture[];
  34994. /**
  34995. * Defines if texture loading must be delayed
  34996. * If true, textures will only be loaded when they need to be rendered
  34997. */
  34998. useDelayedTextureLoading: boolean;
  34999. /**
  35000. * Gets the list of meshes imported to the scene through SceneLoader
  35001. */
  35002. importedMeshesFiles: String[];
  35003. /**
  35004. * Gets or sets a boolean indicating if probes are enabled on this scene
  35005. */
  35006. probesEnabled: boolean;
  35007. /**
  35008. * Gets or sets the current offline provider to use to store scene data
  35009. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35010. */
  35011. offlineProvider: IOfflineProvider;
  35012. /**
  35013. * Gets or sets the action manager associated with the scene
  35014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35015. */
  35016. actionManager: AbstractActionManager;
  35017. private _meshesForIntersections;
  35018. /**
  35019. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35020. */
  35021. proceduralTexturesEnabled: boolean;
  35022. private _engine;
  35023. private _totalVertices;
  35024. /** @hidden */
  35025. _activeIndices: PerfCounter;
  35026. /** @hidden */
  35027. _activeParticles: PerfCounter;
  35028. /** @hidden */
  35029. _activeBones: PerfCounter;
  35030. private _animationRatio;
  35031. /** @hidden */
  35032. _animationTimeLast: number;
  35033. /** @hidden */
  35034. _animationTime: number;
  35035. /**
  35036. * Gets or sets a general scale for animation speed
  35037. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35038. */
  35039. animationTimeScale: number;
  35040. /** @hidden */
  35041. _cachedMaterial: Nullable<Material>;
  35042. /** @hidden */
  35043. _cachedEffect: Nullable<Effect>;
  35044. /** @hidden */
  35045. _cachedVisibility: Nullable<number>;
  35046. private _renderId;
  35047. private _frameId;
  35048. private _executeWhenReadyTimeoutId;
  35049. private _intermediateRendering;
  35050. private _viewUpdateFlag;
  35051. private _projectionUpdateFlag;
  35052. /** @hidden */
  35053. _toBeDisposed: Nullable<IDisposable>[];
  35054. private _activeRequests;
  35055. /** @hidden */
  35056. _pendingData: any[];
  35057. private _isDisposed;
  35058. /**
  35059. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35060. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35061. */
  35062. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35063. private _activeMeshes;
  35064. private _processedMaterials;
  35065. private _renderTargets;
  35066. /** @hidden */
  35067. _activeParticleSystems: SmartArray<IParticleSystem>;
  35068. private _activeSkeletons;
  35069. private _softwareSkinnedMeshes;
  35070. private _renderingManager;
  35071. /** @hidden */
  35072. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  35073. private _transformMatrix;
  35074. private _sceneUbo;
  35075. /** @hidden */
  35076. _viewMatrix: Matrix;
  35077. private _projectionMatrix;
  35078. /** @hidden */
  35079. _forcedViewPosition: Nullable<Vector3>;
  35080. /** @hidden */
  35081. _frustumPlanes: Plane[];
  35082. /**
  35083. * Gets the list of frustum planes (built from the active camera)
  35084. */
  35085. readonly frustumPlanes: Plane[];
  35086. /**
  35087. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35088. * This is useful if there are more lights that the maximum simulteanous authorized
  35089. */
  35090. requireLightSorting: boolean;
  35091. /** @hidden */
  35092. readonly useMaterialMeshMap: boolean;
  35093. /** @hidden */
  35094. readonly useClonedMeshhMap: boolean;
  35095. private _externalData;
  35096. private _uid;
  35097. /**
  35098. * @hidden
  35099. * Backing store of defined scene components.
  35100. */
  35101. _components: ISceneComponent[];
  35102. /**
  35103. * @hidden
  35104. * Backing store of defined scene components.
  35105. */
  35106. _serializableComponents: ISceneSerializableComponent[];
  35107. /**
  35108. * List of components to register on the next registration step.
  35109. */
  35110. private _transientComponents;
  35111. /**
  35112. * Registers the transient components if needed.
  35113. */
  35114. private _registerTransientComponents;
  35115. /**
  35116. * @hidden
  35117. * Add a component to the scene.
  35118. * Note that the ccomponent could be registered on th next frame if this is called after
  35119. * the register component stage.
  35120. * @param component Defines the component to add to the scene
  35121. */
  35122. _addComponent(component: ISceneComponent): void;
  35123. /**
  35124. * @hidden
  35125. * Gets a component from the scene.
  35126. * @param name defines the name of the component to retrieve
  35127. * @returns the component or null if not present
  35128. */
  35129. _getComponent(name: string): Nullable<ISceneComponent>;
  35130. /**
  35131. * @hidden
  35132. * Defines the actions happening before camera updates.
  35133. */
  35134. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35135. /**
  35136. * @hidden
  35137. * Defines the actions happening before clear the canvas.
  35138. */
  35139. _beforeClearStage: Stage<SimpleStageAction>;
  35140. /**
  35141. * @hidden
  35142. * Defines the actions when collecting render targets for the frame.
  35143. */
  35144. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35145. /**
  35146. * @hidden
  35147. * Defines the actions happening for one camera in the frame.
  35148. */
  35149. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35150. /**
  35151. * @hidden
  35152. * Defines the actions happening during the per mesh ready checks.
  35153. */
  35154. _isReadyForMeshStage: Stage<MeshStageAction>;
  35155. /**
  35156. * @hidden
  35157. * Defines the actions happening before evaluate active mesh checks.
  35158. */
  35159. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35160. /**
  35161. * @hidden
  35162. * Defines the actions happening during the evaluate sub mesh checks.
  35163. */
  35164. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35165. /**
  35166. * @hidden
  35167. * Defines the actions happening during the active mesh stage.
  35168. */
  35169. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35170. /**
  35171. * @hidden
  35172. * Defines the actions happening during the per camera render target step.
  35173. */
  35174. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35175. /**
  35176. * @hidden
  35177. * Defines the actions happening just before the active camera is drawing.
  35178. */
  35179. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35180. /**
  35181. * @hidden
  35182. * Defines the actions happening just before a render target is drawing.
  35183. */
  35184. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35185. /**
  35186. * @hidden
  35187. * Defines the actions happening just before a rendering group is drawing.
  35188. */
  35189. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35190. /**
  35191. * @hidden
  35192. * Defines the actions happening just before a mesh is drawing.
  35193. */
  35194. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35195. /**
  35196. * @hidden
  35197. * Defines the actions happening just after a mesh has been drawn.
  35198. */
  35199. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35200. /**
  35201. * @hidden
  35202. * Defines the actions happening just after a rendering group has been drawn.
  35203. */
  35204. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35205. /**
  35206. * @hidden
  35207. * Defines the actions happening just after the active camera has been drawn.
  35208. */
  35209. _afterCameraDrawStage: Stage<CameraStageAction>;
  35210. /**
  35211. * @hidden
  35212. * Defines the actions happening just after a render target has been drawn.
  35213. */
  35214. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35215. /**
  35216. * @hidden
  35217. * Defines the actions happening just after rendering all cameras and computing intersections.
  35218. */
  35219. _afterRenderStage: Stage<SimpleStageAction>;
  35220. /**
  35221. * @hidden
  35222. * Defines the actions happening when a pointer move event happens.
  35223. */
  35224. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35225. /**
  35226. * @hidden
  35227. * Defines the actions happening when a pointer down event happens.
  35228. */
  35229. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35230. /**
  35231. * @hidden
  35232. * Defines the actions happening when a pointer up event happens.
  35233. */
  35234. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35235. /**
  35236. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35237. */
  35238. private geometriesByUniqueId;
  35239. /**
  35240. * Creates a new Scene
  35241. * @param engine defines the engine to use to render this scene
  35242. * @param options defines the scene options
  35243. */
  35244. constructor(engine: Engine, options?: SceneOptions);
  35245. /**
  35246. * Gets a string idenfifying the name of the class
  35247. * @returns "Scene" string
  35248. */
  35249. getClassName(): string;
  35250. private _defaultMeshCandidates;
  35251. /**
  35252. * @hidden
  35253. */
  35254. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35255. private _defaultSubMeshCandidates;
  35256. /**
  35257. * @hidden
  35258. */
  35259. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35260. /**
  35261. * Sets the default candidate providers for the scene.
  35262. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35263. * and getCollidingSubMeshCandidates to their default function
  35264. */
  35265. setDefaultCandidateProviders(): void;
  35266. /**
  35267. * Gets the mesh that is currently under the pointer
  35268. */
  35269. readonly meshUnderPointer: Nullable<AbstractMesh>;
  35270. /**
  35271. * Gets or sets the current on-screen X position of the pointer
  35272. */
  35273. pointerX: number;
  35274. /**
  35275. * Gets or sets the current on-screen Y position of the pointer
  35276. */
  35277. pointerY: number;
  35278. /**
  35279. * Gets the cached material (ie. the latest rendered one)
  35280. * @returns the cached material
  35281. */
  35282. getCachedMaterial(): Nullable<Material>;
  35283. /**
  35284. * Gets the cached effect (ie. the latest rendered one)
  35285. * @returns the cached effect
  35286. */
  35287. getCachedEffect(): Nullable<Effect>;
  35288. /**
  35289. * Gets the cached visibility state (ie. the latest rendered one)
  35290. * @returns the cached visibility state
  35291. */
  35292. getCachedVisibility(): Nullable<number>;
  35293. /**
  35294. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35295. * @param material defines the current material
  35296. * @param effect defines the current effect
  35297. * @param visibility defines the current visibility state
  35298. * @returns true if one parameter is not cached
  35299. */
  35300. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35301. /**
  35302. * Gets the engine associated with the scene
  35303. * @returns an Engine
  35304. */
  35305. getEngine(): Engine;
  35306. /**
  35307. * Gets the total number of vertices rendered per frame
  35308. * @returns the total number of vertices rendered per frame
  35309. */
  35310. getTotalVertices(): number;
  35311. /**
  35312. * Gets the performance counter for total vertices
  35313. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35314. */
  35315. readonly totalVerticesPerfCounter: PerfCounter;
  35316. /**
  35317. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35318. * @returns the total number of active indices rendered per frame
  35319. */
  35320. getActiveIndices(): number;
  35321. /**
  35322. * Gets the performance counter for active indices
  35323. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35324. */
  35325. readonly totalActiveIndicesPerfCounter: PerfCounter;
  35326. /**
  35327. * Gets the total number of active particles rendered per frame
  35328. * @returns the total number of active particles rendered per frame
  35329. */
  35330. getActiveParticles(): number;
  35331. /**
  35332. * Gets the performance counter for active particles
  35333. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35334. */
  35335. readonly activeParticlesPerfCounter: PerfCounter;
  35336. /**
  35337. * Gets the total number of active bones rendered per frame
  35338. * @returns the total number of active bones rendered per frame
  35339. */
  35340. getActiveBones(): number;
  35341. /**
  35342. * Gets the performance counter for active bones
  35343. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35344. */
  35345. readonly activeBonesPerfCounter: PerfCounter;
  35346. /**
  35347. * Gets the array of active meshes
  35348. * @returns an array of AbstractMesh
  35349. */
  35350. getActiveMeshes(): SmartArray<AbstractMesh>;
  35351. /**
  35352. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35353. * @returns a number
  35354. */
  35355. getAnimationRatio(): number;
  35356. /**
  35357. * Gets an unique Id for the current render phase
  35358. * @returns a number
  35359. */
  35360. getRenderId(): number;
  35361. /**
  35362. * Gets an unique Id for the current frame
  35363. * @returns a number
  35364. */
  35365. getFrameId(): number;
  35366. /** Call this function if you want to manually increment the render Id*/
  35367. incrementRenderId(): void;
  35368. private _createUbo;
  35369. /**
  35370. * Use this method to simulate a pointer move on a mesh
  35371. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35372. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35373. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35374. * @returns the current scene
  35375. */
  35376. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35377. /**
  35378. * Use this method to simulate a pointer down on a mesh
  35379. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35380. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35381. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35382. * @returns the current scene
  35383. */
  35384. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35385. /**
  35386. * Use this method to simulate a pointer up on a mesh
  35387. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35388. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35389. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35390. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35391. * @returns the current scene
  35392. */
  35393. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35394. /**
  35395. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35396. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35397. * @returns true if the pointer was captured
  35398. */
  35399. isPointerCaptured(pointerId?: number): boolean;
  35400. /**
  35401. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35402. * @param attachUp defines if you want to attach events to pointerup
  35403. * @param attachDown defines if you want to attach events to pointerdown
  35404. * @param attachMove defines if you want to attach events to pointermove
  35405. */
  35406. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35407. /** Detaches all event handlers*/
  35408. detachControl(): void;
  35409. /**
  35410. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35411. * Delay loaded resources are not taking in account
  35412. * @return true if all required resources are ready
  35413. */
  35414. isReady(): boolean;
  35415. /** Resets all cached information relative to material (including effect and visibility) */
  35416. resetCachedMaterial(): void;
  35417. /**
  35418. * Registers a function to be called before every frame render
  35419. * @param func defines the function to register
  35420. */
  35421. registerBeforeRender(func: () => void): void;
  35422. /**
  35423. * Unregisters a function called before every frame render
  35424. * @param func defines the function to unregister
  35425. */
  35426. unregisterBeforeRender(func: () => void): void;
  35427. /**
  35428. * Registers a function to be called after every frame render
  35429. * @param func defines the function to register
  35430. */
  35431. registerAfterRender(func: () => void): void;
  35432. /**
  35433. * Unregisters a function called after every frame render
  35434. * @param func defines the function to unregister
  35435. */
  35436. unregisterAfterRender(func: () => void): void;
  35437. private _executeOnceBeforeRender;
  35438. /**
  35439. * The provided function will run before render once and will be disposed afterwards.
  35440. * A timeout delay can be provided so that the function will be executed in N ms.
  35441. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35442. * @param func The function to be executed.
  35443. * @param timeout optional delay in ms
  35444. */
  35445. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35446. /** @hidden */
  35447. _addPendingData(data: any): void;
  35448. /** @hidden */
  35449. _removePendingData(data: any): void;
  35450. /**
  35451. * Returns the number of items waiting to be loaded
  35452. * @returns the number of items waiting to be loaded
  35453. */
  35454. getWaitingItemsCount(): number;
  35455. /**
  35456. * Returns a boolean indicating if the scene is still loading data
  35457. */
  35458. readonly isLoading: boolean;
  35459. /**
  35460. * Registers a function to be executed when the scene is ready
  35461. * @param {Function} func - the function to be executed
  35462. */
  35463. executeWhenReady(func: () => void): void;
  35464. /**
  35465. * Returns a promise that resolves when the scene is ready
  35466. * @returns A promise that resolves when the scene is ready
  35467. */
  35468. whenReadyAsync(): Promise<void>;
  35469. /** @hidden */
  35470. _checkIsReady(): void;
  35471. /**
  35472. * Gets all animatable attached to the scene
  35473. */
  35474. readonly animatables: Animatable[];
  35475. /**
  35476. * Resets the last animation time frame.
  35477. * Useful to override when animations start running when loading a scene for the first time.
  35478. */
  35479. resetLastAnimationTimeFrame(): void;
  35480. /**
  35481. * Gets the current view matrix
  35482. * @returns a Matrix
  35483. */
  35484. getViewMatrix(): Matrix;
  35485. /**
  35486. * Gets the current projection matrix
  35487. * @returns a Matrix
  35488. */
  35489. getProjectionMatrix(): Matrix;
  35490. /**
  35491. * Gets the current transform matrix
  35492. * @returns a Matrix made of View * Projection
  35493. */
  35494. getTransformMatrix(): Matrix;
  35495. /**
  35496. * Sets the current transform matrix
  35497. * @param viewL defines the View matrix to use
  35498. * @param projectionL defines the Projection matrix to use
  35499. * @param viewR defines the right View matrix to use (if provided)
  35500. * @param projectionR defines the right Projection matrix to use (if provided)
  35501. */
  35502. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35503. /**
  35504. * Gets the uniform buffer used to store scene data
  35505. * @returns a UniformBuffer
  35506. */
  35507. getSceneUniformBuffer(): UniformBuffer;
  35508. /**
  35509. * Gets an unique (relatively to the current scene) Id
  35510. * @returns an unique number for the scene
  35511. */
  35512. getUniqueId(): number;
  35513. /**
  35514. * Add a mesh to the list of scene's meshes
  35515. * @param newMesh defines the mesh to add
  35516. * @param recursive if all child meshes should also be added to the scene
  35517. */
  35518. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35519. /**
  35520. * Remove a mesh for the list of scene's meshes
  35521. * @param toRemove defines the mesh to remove
  35522. * @param recursive if all child meshes should also be removed from the scene
  35523. * @returns the index where the mesh was in the mesh list
  35524. */
  35525. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35526. /**
  35527. * Add a transform node to the list of scene's transform nodes
  35528. * @param newTransformNode defines the transform node to add
  35529. */
  35530. addTransformNode(newTransformNode: TransformNode): void;
  35531. /**
  35532. * Remove a transform node for the list of scene's transform nodes
  35533. * @param toRemove defines the transform node to remove
  35534. * @returns the index where the transform node was in the transform node list
  35535. */
  35536. removeTransformNode(toRemove: TransformNode): number;
  35537. /**
  35538. * Remove a skeleton for the list of scene's skeletons
  35539. * @param toRemove defines the skeleton to remove
  35540. * @returns the index where the skeleton was in the skeleton list
  35541. */
  35542. removeSkeleton(toRemove: Skeleton): number;
  35543. /**
  35544. * Remove a morph target for the list of scene's morph targets
  35545. * @param toRemove defines the morph target to remove
  35546. * @returns the index where the morph target was in the morph target list
  35547. */
  35548. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35549. /**
  35550. * Remove a light for the list of scene's lights
  35551. * @param toRemove defines the light to remove
  35552. * @returns the index where the light was in the light list
  35553. */
  35554. removeLight(toRemove: Light): number;
  35555. /**
  35556. * Remove a camera for the list of scene's cameras
  35557. * @param toRemove defines the camera to remove
  35558. * @returns the index where the camera was in the camera list
  35559. */
  35560. removeCamera(toRemove: Camera): number;
  35561. /**
  35562. * Remove a particle system for the list of scene's particle systems
  35563. * @param toRemove defines the particle system to remove
  35564. * @returns the index where the particle system was in the particle system list
  35565. */
  35566. removeParticleSystem(toRemove: IParticleSystem): number;
  35567. /**
  35568. * Remove a animation for the list of scene's animations
  35569. * @param toRemove defines the animation to remove
  35570. * @returns the index where the animation was in the animation list
  35571. */
  35572. removeAnimation(toRemove: Animation): number;
  35573. /**
  35574. * Will stop the animation of the given target
  35575. * @param target - the target
  35576. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35577. * @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)
  35578. */
  35579. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35580. /**
  35581. * Removes the given animation group from this scene.
  35582. * @param toRemove The animation group to remove
  35583. * @returns The index of the removed animation group
  35584. */
  35585. removeAnimationGroup(toRemove: AnimationGroup): number;
  35586. /**
  35587. * Removes the given multi-material from this scene.
  35588. * @param toRemove The multi-material to remove
  35589. * @returns The index of the removed multi-material
  35590. */
  35591. removeMultiMaterial(toRemove: MultiMaterial): number;
  35592. /**
  35593. * Removes the given material from this scene.
  35594. * @param toRemove The material to remove
  35595. * @returns The index of the removed material
  35596. */
  35597. removeMaterial(toRemove: Material): number;
  35598. /**
  35599. * Removes the given action manager from this scene.
  35600. * @param toRemove The action manager to remove
  35601. * @returns The index of the removed action manager
  35602. */
  35603. removeActionManager(toRemove: AbstractActionManager): number;
  35604. /**
  35605. * Removes the given texture from this scene.
  35606. * @param toRemove The texture to remove
  35607. * @returns The index of the removed texture
  35608. */
  35609. removeTexture(toRemove: BaseTexture): number;
  35610. /**
  35611. * Adds the given light to this scene
  35612. * @param newLight The light to add
  35613. */
  35614. addLight(newLight: Light): void;
  35615. /**
  35616. * Sorts the list list based on light priorities
  35617. */
  35618. sortLightsByPriority(): void;
  35619. /**
  35620. * Adds the given camera to this scene
  35621. * @param newCamera The camera to add
  35622. */
  35623. addCamera(newCamera: Camera): void;
  35624. /**
  35625. * Adds the given skeleton to this scene
  35626. * @param newSkeleton The skeleton to add
  35627. */
  35628. addSkeleton(newSkeleton: Skeleton): void;
  35629. /**
  35630. * Adds the given particle system to this scene
  35631. * @param newParticleSystem The particle system to add
  35632. */
  35633. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35634. /**
  35635. * Adds the given animation to this scene
  35636. * @param newAnimation The animation to add
  35637. */
  35638. addAnimation(newAnimation: Animation): void;
  35639. /**
  35640. * Adds the given animation group to this scene.
  35641. * @param newAnimationGroup The animation group to add
  35642. */
  35643. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35644. /**
  35645. * Adds the given multi-material to this scene
  35646. * @param newMultiMaterial The multi-material to add
  35647. */
  35648. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35649. /**
  35650. * Adds the given material to this scene
  35651. * @param newMaterial The material to add
  35652. */
  35653. addMaterial(newMaterial: Material): void;
  35654. /**
  35655. * Adds the given morph target to this scene
  35656. * @param newMorphTargetManager The morph target to add
  35657. */
  35658. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35659. /**
  35660. * Adds the given geometry to this scene
  35661. * @param newGeometry The geometry to add
  35662. */
  35663. addGeometry(newGeometry: Geometry): void;
  35664. /**
  35665. * Adds the given action manager to this scene
  35666. * @param newActionManager The action manager to add
  35667. */
  35668. addActionManager(newActionManager: AbstractActionManager): void;
  35669. /**
  35670. * Adds the given texture to this scene.
  35671. * @param newTexture The texture to add
  35672. */
  35673. addTexture(newTexture: BaseTexture): void;
  35674. /**
  35675. * Switch active camera
  35676. * @param newCamera defines the new active camera
  35677. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35678. */
  35679. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35680. /**
  35681. * sets the active camera of the scene using its ID
  35682. * @param id defines the camera's ID
  35683. * @return the new active camera or null if none found.
  35684. */
  35685. setActiveCameraByID(id: string): Nullable<Camera>;
  35686. /**
  35687. * sets the active camera of the scene using its name
  35688. * @param name defines the camera's name
  35689. * @returns the new active camera or null if none found.
  35690. */
  35691. setActiveCameraByName(name: string): Nullable<Camera>;
  35692. /**
  35693. * get an animation group using its name
  35694. * @param name defines the material's name
  35695. * @return the animation group or null if none found.
  35696. */
  35697. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35698. /**
  35699. * Get a material using its unique id
  35700. * @param uniqueId defines the material's unique id
  35701. * @return the material or null if none found.
  35702. */
  35703. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35704. /**
  35705. * get a material using its id
  35706. * @param id defines the material's ID
  35707. * @return the material or null if none found.
  35708. */
  35709. getMaterialByID(id: string): Nullable<Material>;
  35710. /**
  35711. * Gets a the last added material using a given id
  35712. * @param id defines the material's ID
  35713. * @return the last material with the given id or null if none found.
  35714. */
  35715. getLastMaterialByID(id: string): Nullable<Material>;
  35716. /**
  35717. * Gets a material using its name
  35718. * @param name defines the material's name
  35719. * @return the material or null if none found.
  35720. */
  35721. getMaterialByName(name: string): Nullable<Material>;
  35722. /**
  35723. * Get a texture using its unique id
  35724. * @param uniqueId defines the texture's unique id
  35725. * @return the texture or null if none found.
  35726. */
  35727. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35728. /**
  35729. * Gets a camera using its id
  35730. * @param id defines the id to look for
  35731. * @returns the camera or null if not found
  35732. */
  35733. getCameraByID(id: string): Nullable<Camera>;
  35734. /**
  35735. * Gets a camera using its unique id
  35736. * @param uniqueId defines the unique id to look for
  35737. * @returns the camera or null if not found
  35738. */
  35739. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35740. /**
  35741. * Gets a camera using its name
  35742. * @param name defines the camera's name
  35743. * @return the camera or null if none found.
  35744. */
  35745. getCameraByName(name: string): Nullable<Camera>;
  35746. /**
  35747. * Gets a bone using its id
  35748. * @param id defines the bone's id
  35749. * @return the bone or null if not found
  35750. */
  35751. getBoneByID(id: string): Nullable<Bone>;
  35752. /**
  35753. * Gets a bone using its id
  35754. * @param name defines the bone's name
  35755. * @return the bone or null if not found
  35756. */
  35757. getBoneByName(name: string): Nullable<Bone>;
  35758. /**
  35759. * Gets a light node using its name
  35760. * @param name defines the the light's name
  35761. * @return the light or null if none found.
  35762. */
  35763. getLightByName(name: string): Nullable<Light>;
  35764. /**
  35765. * Gets a light node using its id
  35766. * @param id defines the light's id
  35767. * @return the light or null if none found.
  35768. */
  35769. getLightByID(id: string): Nullable<Light>;
  35770. /**
  35771. * Gets a light node using its scene-generated unique ID
  35772. * @param uniqueId defines the light's unique id
  35773. * @return the light or null if none found.
  35774. */
  35775. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35776. /**
  35777. * Gets a particle system by id
  35778. * @param id defines the particle system id
  35779. * @return the corresponding system or null if none found
  35780. */
  35781. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35782. /**
  35783. * Gets a geometry using its ID
  35784. * @param id defines the geometry's id
  35785. * @return the geometry or null if none found.
  35786. */
  35787. getGeometryByID(id: string): Nullable<Geometry>;
  35788. private _getGeometryByUniqueID;
  35789. /**
  35790. * Add a new geometry to this scene
  35791. * @param geometry defines the geometry to be added to the scene.
  35792. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35793. * @return a boolean defining if the geometry was added or not
  35794. */
  35795. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35796. /**
  35797. * Removes an existing geometry
  35798. * @param geometry defines the geometry to be removed from the scene
  35799. * @return a boolean defining if the geometry was removed or not
  35800. */
  35801. removeGeometry(geometry: Geometry): boolean;
  35802. /**
  35803. * Gets the list of geometries attached to the scene
  35804. * @returns an array of Geometry
  35805. */
  35806. getGeometries(): Geometry[];
  35807. /**
  35808. * Gets the first added mesh found of a given ID
  35809. * @param id defines the id to search for
  35810. * @return the mesh found or null if not found at all
  35811. */
  35812. getMeshByID(id: string): Nullable<AbstractMesh>;
  35813. /**
  35814. * Gets a list of meshes using their id
  35815. * @param id defines the id to search for
  35816. * @returns a list of meshes
  35817. */
  35818. getMeshesByID(id: string): Array<AbstractMesh>;
  35819. /**
  35820. * Gets the first added transform node found of a given ID
  35821. * @param id defines the id to search for
  35822. * @return the found transform node or null if not found at all.
  35823. */
  35824. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35825. /**
  35826. * Gets a transform node with its auto-generated unique id
  35827. * @param uniqueId efines the unique id to search for
  35828. * @return the found transform node or null if not found at all.
  35829. */
  35830. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35831. /**
  35832. * Gets a list of transform nodes using their id
  35833. * @param id defines the id to search for
  35834. * @returns a list of transform nodes
  35835. */
  35836. getTransformNodesByID(id: string): Array<TransformNode>;
  35837. /**
  35838. * Gets a mesh with its auto-generated unique id
  35839. * @param uniqueId defines the unique id to search for
  35840. * @return the found mesh or null if not found at all.
  35841. */
  35842. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35843. /**
  35844. * Gets a the last added mesh using a given id
  35845. * @param id defines the id to search for
  35846. * @return the found mesh or null if not found at all.
  35847. */
  35848. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35849. /**
  35850. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35851. * @param id defines the id to search for
  35852. * @return the found node or null if not found at all
  35853. */
  35854. getLastEntryByID(id: string): Nullable<Node>;
  35855. /**
  35856. * Gets a node (Mesh, Camera, Light) using a given id
  35857. * @param id defines the id to search for
  35858. * @return the found node or null if not found at all
  35859. */
  35860. getNodeByID(id: string): Nullable<Node>;
  35861. /**
  35862. * Gets a node (Mesh, Camera, Light) using a given name
  35863. * @param name defines the name to search for
  35864. * @return the found node or null if not found at all.
  35865. */
  35866. getNodeByName(name: string): Nullable<Node>;
  35867. /**
  35868. * Gets a mesh using a given name
  35869. * @param name defines the name to search for
  35870. * @return the found mesh or null if not found at all.
  35871. */
  35872. getMeshByName(name: string): Nullable<AbstractMesh>;
  35873. /**
  35874. * Gets a transform node using a given name
  35875. * @param name defines the name to search for
  35876. * @return the found transform node or null if not found at all.
  35877. */
  35878. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35879. /**
  35880. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35881. * @param id defines the id to search for
  35882. * @return the found skeleton or null if not found at all.
  35883. */
  35884. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35885. /**
  35886. * Gets a skeleton using a given auto generated unique id
  35887. * @param uniqueId defines the unique id to search for
  35888. * @return the found skeleton or null if not found at all.
  35889. */
  35890. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35891. /**
  35892. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35893. * @param id defines the id to search for
  35894. * @return the found skeleton or null if not found at all.
  35895. */
  35896. getSkeletonById(id: string): Nullable<Skeleton>;
  35897. /**
  35898. * Gets a skeleton using a given name
  35899. * @param name defines the name to search for
  35900. * @return the found skeleton or null if not found at all.
  35901. */
  35902. getSkeletonByName(name: string): Nullable<Skeleton>;
  35903. /**
  35904. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35905. * @param id defines the id to search for
  35906. * @return the found morph target manager or null if not found at all.
  35907. */
  35908. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35909. /**
  35910. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35911. * @param id defines the id to search for
  35912. * @return the found morph target or null if not found at all.
  35913. */
  35914. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35915. /**
  35916. * Gets a boolean indicating if the given mesh is active
  35917. * @param mesh defines the mesh to look for
  35918. * @returns true if the mesh is in the active list
  35919. */
  35920. isActiveMesh(mesh: AbstractMesh): boolean;
  35921. /**
  35922. * Return a unique id as a string which can serve as an identifier for the scene
  35923. */
  35924. readonly uid: string;
  35925. /**
  35926. * Add an externaly attached data from its key.
  35927. * This method call will fail and return false, if such key already exists.
  35928. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35929. * @param key the unique key that identifies the data
  35930. * @param data the data object to associate to the key for this Engine instance
  35931. * @return true if no such key were already present and the data was added successfully, false otherwise
  35932. */
  35933. addExternalData<T>(key: string, data: T): boolean;
  35934. /**
  35935. * Get an externaly attached data from its key
  35936. * @param key the unique key that identifies the data
  35937. * @return the associated data, if present (can be null), or undefined if not present
  35938. */
  35939. getExternalData<T>(key: string): Nullable<T>;
  35940. /**
  35941. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35942. * @param key the unique key that identifies the data
  35943. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35944. * @return the associated data, can be null if the factory returned null.
  35945. */
  35946. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35947. /**
  35948. * Remove an externaly attached data from the Engine instance
  35949. * @param key the unique key that identifies the data
  35950. * @return true if the data was successfully removed, false if it doesn't exist
  35951. */
  35952. removeExternalData(key: string): boolean;
  35953. private _evaluateSubMesh;
  35954. /**
  35955. * Clear the processed materials smart array preventing retention point in material dispose.
  35956. */
  35957. freeProcessedMaterials(): void;
  35958. private _preventFreeActiveMeshesAndRenderingGroups;
  35959. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35960. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35961. * when disposing several meshes in a row or a hierarchy of meshes.
  35962. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35963. */
  35964. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35965. /**
  35966. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35967. */
  35968. freeActiveMeshes(): void;
  35969. /**
  35970. * Clear the info related to rendering groups preventing retention points during dispose.
  35971. */
  35972. freeRenderingGroups(): void;
  35973. /** @hidden */
  35974. _isInIntermediateRendering(): boolean;
  35975. /**
  35976. * Lambda returning the list of potentially active meshes.
  35977. */
  35978. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35979. /**
  35980. * Lambda returning the list of potentially active sub meshes.
  35981. */
  35982. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35983. /**
  35984. * Lambda returning the list of potentially intersecting sub meshes.
  35985. */
  35986. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35987. /**
  35988. * Lambda returning the list of potentially colliding sub meshes.
  35989. */
  35990. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35991. private _activeMeshesFrozen;
  35992. private _skipEvaluateActiveMeshesCompletely;
  35993. /**
  35994. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35995. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  35996. * @returns the current scene
  35997. */
  35998. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  35999. /**
  36000. * Use this function to restart evaluating active meshes on every frame
  36001. * @returns the current scene
  36002. */
  36003. unfreezeActiveMeshes(): Scene;
  36004. private _evaluateActiveMeshes;
  36005. private _activeMesh;
  36006. /**
  36007. * Update the transform matrix to update from the current active camera
  36008. * @param force defines a boolean used to force the update even if cache is up to date
  36009. */
  36010. updateTransformMatrix(force?: boolean): void;
  36011. private _bindFrameBuffer;
  36012. /** @hidden */
  36013. _allowPostProcessClearColor: boolean;
  36014. /** @hidden */
  36015. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36016. private _processSubCameras;
  36017. private _checkIntersections;
  36018. /** @hidden */
  36019. _advancePhysicsEngineStep(step: number): void;
  36020. /**
  36021. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36022. */
  36023. getDeterministicFrameTime: () => number;
  36024. /** @hidden */
  36025. _animate(): void;
  36026. /** Execute all animations (for a frame) */
  36027. animate(): void;
  36028. /**
  36029. * Render the scene
  36030. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36031. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36032. */
  36033. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36034. /**
  36035. * Freeze all materials
  36036. * A frozen material will not be updatable but should be faster to render
  36037. */
  36038. freezeMaterials(): void;
  36039. /**
  36040. * Unfreeze all materials
  36041. * A frozen material will not be updatable but should be faster to render
  36042. */
  36043. unfreezeMaterials(): void;
  36044. /**
  36045. * Releases all held ressources
  36046. */
  36047. dispose(): void;
  36048. /**
  36049. * Gets if the scene is already disposed
  36050. */
  36051. readonly isDisposed: boolean;
  36052. /**
  36053. * Call this function to reduce memory footprint of the scene.
  36054. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36055. */
  36056. clearCachedVertexData(): void;
  36057. /**
  36058. * This function will remove the local cached buffer data from texture.
  36059. * It will save memory but will prevent the texture from being rebuilt
  36060. */
  36061. cleanCachedTextureBuffer(): void;
  36062. /**
  36063. * Get the world extend vectors with an optional filter
  36064. *
  36065. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36066. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36067. */
  36068. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36069. min: Vector3;
  36070. max: Vector3;
  36071. };
  36072. /**
  36073. * Creates a ray that can be used to pick in the scene
  36074. * @param x defines the x coordinate of the origin (on-screen)
  36075. * @param y defines the y coordinate of the origin (on-screen)
  36076. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36077. * @param camera defines the camera to use for the picking
  36078. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36079. * @returns a Ray
  36080. */
  36081. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36082. /**
  36083. * Creates a ray that can be used to pick in the scene
  36084. * @param x defines the x coordinate of the origin (on-screen)
  36085. * @param y defines the y coordinate of the origin (on-screen)
  36086. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36087. * @param result defines the ray where to store the picking ray
  36088. * @param camera defines the camera to use for the picking
  36089. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36090. * @returns the current scene
  36091. */
  36092. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36093. /**
  36094. * Creates a ray that can be used to pick in the scene
  36095. * @param x defines the x coordinate of the origin (on-screen)
  36096. * @param y defines the y coordinate of the origin (on-screen)
  36097. * @param camera defines the camera to use for the picking
  36098. * @returns a Ray
  36099. */
  36100. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36101. /**
  36102. * Creates a ray that can be used to pick in the scene
  36103. * @param x defines the x coordinate of the origin (on-screen)
  36104. * @param y defines the y coordinate of the origin (on-screen)
  36105. * @param result defines the ray where to store the picking ray
  36106. * @param camera defines the camera to use for the picking
  36107. * @returns the current scene
  36108. */
  36109. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36110. /** Launch a ray to try to pick a mesh in the scene
  36111. * @param x position on screen
  36112. * @param y position on screen
  36113. * @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
  36114. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36115. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36116. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36117. * @returns a PickingInfo
  36118. */
  36119. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36120. /** Use the given ray to pick a mesh in the scene
  36121. * @param ray The ray to use to pick meshes
  36122. * @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
  36123. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36124. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36125. * @returns a PickingInfo
  36126. */
  36127. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36128. /**
  36129. * Launch a ray to try to pick a mesh in the scene
  36130. * @param x X position on screen
  36131. * @param y Y position on screen
  36132. * @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
  36133. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36134. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36135. * @returns an array of PickingInfo
  36136. */
  36137. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36138. /**
  36139. * Launch a ray to try to pick a mesh in the scene
  36140. * @param ray Ray to use
  36141. * @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
  36142. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36143. * @returns an array of PickingInfo
  36144. */
  36145. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36146. /**
  36147. * Force the value of meshUnderPointer
  36148. * @param mesh defines the mesh to use
  36149. */
  36150. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36151. /**
  36152. * Gets the mesh under the pointer
  36153. * @returns a Mesh or null if no mesh is under the pointer
  36154. */
  36155. getPointerOverMesh(): Nullable<AbstractMesh>;
  36156. /** @hidden */
  36157. _rebuildGeometries(): void;
  36158. /** @hidden */
  36159. _rebuildTextures(): void;
  36160. private _getByTags;
  36161. /**
  36162. * Get a list of meshes by tags
  36163. * @param tagsQuery defines the tags query to use
  36164. * @param forEach defines a predicate used to filter results
  36165. * @returns an array of Mesh
  36166. */
  36167. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36168. /**
  36169. * Get a list of cameras by tags
  36170. * @param tagsQuery defines the tags query to use
  36171. * @param forEach defines a predicate used to filter results
  36172. * @returns an array of Camera
  36173. */
  36174. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36175. /**
  36176. * Get a list of lights by tags
  36177. * @param tagsQuery defines the tags query to use
  36178. * @param forEach defines a predicate used to filter results
  36179. * @returns an array of Light
  36180. */
  36181. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36182. /**
  36183. * Get a list of materials by tags
  36184. * @param tagsQuery defines the tags query to use
  36185. * @param forEach defines a predicate used to filter results
  36186. * @returns an array of Material
  36187. */
  36188. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36189. /**
  36190. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36191. * This allowed control for front to back rendering or reversly depending of the special needs.
  36192. *
  36193. * @param renderingGroupId The rendering group id corresponding to its index
  36194. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36195. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36196. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36197. */
  36198. 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;
  36199. /**
  36200. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36201. *
  36202. * @param renderingGroupId The rendering group id corresponding to its index
  36203. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36204. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36205. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36206. */
  36207. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36208. /**
  36209. * Gets the current auto clear configuration for one rendering group of the rendering
  36210. * manager.
  36211. * @param index the rendering group index to get the information for
  36212. * @returns The auto clear setup for the requested rendering group
  36213. */
  36214. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36215. private _blockMaterialDirtyMechanism;
  36216. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36217. blockMaterialDirtyMechanism: boolean;
  36218. /**
  36219. * Will flag all materials as dirty to trigger new shader compilation
  36220. * @param flag defines the flag used to specify which material part must be marked as dirty
  36221. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36222. */
  36223. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36224. /** @hidden */
  36225. _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;
  36226. /** @hidden */
  36227. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36228. /** @hidden */
  36229. _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;
  36230. /** @hidden */
  36231. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36232. /** @hidden */
  36233. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36234. /** @hidden */
  36235. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36236. }
  36237. }
  36238. declare module "babylonjs/assetContainer" {
  36239. import { AbstractScene } from "babylonjs/abstractScene";
  36240. import { Scene } from "babylonjs/scene";
  36241. import { Mesh } from "babylonjs/Meshes/mesh";
  36242. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36243. import { Skeleton } from "babylonjs/Bones/skeleton";
  36244. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36245. /**
  36246. * Set of assets to keep when moving a scene into an asset container.
  36247. */
  36248. export class KeepAssets extends AbstractScene {
  36249. }
  36250. /**
  36251. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36252. */
  36253. export class InstantiatedEntries {
  36254. /**
  36255. * List of new root nodes (eg. nodes with no parent)
  36256. */
  36257. rootNodes: TransformNode[];
  36258. /**
  36259. * List of new skeletons
  36260. */
  36261. skeletons: Skeleton[];
  36262. /**
  36263. * List of new animation groups
  36264. */
  36265. animationGroups: AnimationGroup[];
  36266. }
  36267. /**
  36268. * Container with a set of assets that can be added or removed from a scene.
  36269. */
  36270. export class AssetContainer extends AbstractScene {
  36271. /**
  36272. * The scene the AssetContainer belongs to.
  36273. */
  36274. scene: Scene;
  36275. /**
  36276. * Instantiates an AssetContainer.
  36277. * @param scene The scene the AssetContainer belongs to.
  36278. */
  36279. constructor(scene: Scene);
  36280. /**
  36281. * Instantiate or clone all meshes and add the new ones to the scene.
  36282. * Skeletons and animation groups will all be cloned
  36283. * @param nameFunction defines an optional function used to get new names for clones
  36284. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36285. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36286. */
  36287. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36288. /**
  36289. * Adds all the assets from the container to the scene.
  36290. */
  36291. addAllToScene(): void;
  36292. /**
  36293. * Removes all the assets in the container from the scene
  36294. */
  36295. removeAllFromScene(): void;
  36296. /**
  36297. * Disposes all the assets in the container
  36298. */
  36299. dispose(): void;
  36300. private _moveAssets;
  36301. /**
  36302. * Removes all the assets contained in the scene and adds them to the container.
  36303. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36304. */
  36305. moveAllFromScene(keepAssets?: KeepAssets): void;
  36306. /**
  36307. * 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.
  36308. * @returns the root mesh
  36309. */
  36310. createRootMesh(): Mesh;
  36311. }
  36312. }
  36313. declare module "babylonjs/abstractScene" {
  36314. import { Scene } from "babylonjs/scene";
  36315. import { Nullable } from "babylonjs/types";
  36316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36317. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36318. import { Geometry } from "babylonjs/Meshes/geometry";
  36319. import { Skeleton } from "babylonjs/Bones/skeleton";
  36320. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36321. import { AssetContainer } from "babylonjs/assetContainer";
  36322. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36323. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36324. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36325. import { Material } from "babylonjs/Materials/material";
  36326. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36327. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36328. import { Camera } from "babylonjs/Cameras/camera";
  36329. import { Light } from "babylonjs/Lights/light";
  36330. import { Node } from "babylonjs/node";
  36331. import { Animation } from "babylonjs/Animations/animation";
  36332. /**
  36333. * Defines how the parser contract is defined.
  36334. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36335. */
  36336. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36337. /**
  36338. * Defines how the individual parser contract is defined.
  36339. * These parser can parse an individual asset
  36340. */
  36341. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36342. /**
  36343. * Base class of the scene acting as a container for the different elements composing a scene.
  36344. * This class is dynamically extended by the different components of the scene increasing
  36345. * flexibility and reducing coupling
  36346. */
  36347. export abstract class AbstractScene {
  36348. /**
  36349. * Stores the list of available parsers in the application.
  36350. */
  36351. private static _BabylonFileParsers;
  36352. /**
  36353. * Stores the list of available individual parsers in the application.
  36354. */
  36355. private static _IndividualBabylonFileParsers;
  36356. /**
  36357. * Adds a parser in the list of available ones
  36358. * @param name Defines the name of the parser
  36359. * @param parser Defines the parser to add
  36360. */
  36361. static AddParser(name: string, parser: BabylonFileParser): void;
  36362. /**
  36363. * Gets a general parser from the list of avaialble ones
  36364. * @param name Defines the name of the parser
  36365. * @returns the requested parser or null
  36366. */
  36367. static GetParser(name: string): Nullable<BabylonFileParser>;
  36368. /**
  36369. * Adds n individual parser in the list of available ones
  36370. * @param name Defines the name of the parser
  36371. * @param parser Defines the parser to add
  36372. */
  36373. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36374. /**
  36375. * Gets an individual parser from the list of avaialble ones
  36376. * @param name Defines the name of the parser
  36377. * @returns the requested parser or null
  36378. */
  36379. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36380. /**
  36381. * Parser json data and populate both a scene and its associated container object
  36382. * @param jsonData Defines the data to parse
  36383. * @param scene Defines the scene to parse the data for
  36384. * @param container Defines the container attached to the parsing sequence
  36385. * @param rootUrl Defines the root url of the data
  36386. */
  36387. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36388. /**
  36389. * Gets the list of root nodes (ie. nodes with no parent)
  36390. */
  36391. rootNodes: Node[];
  36392. /** All of the cameras added to this scene
  36393. * @see http://doc.babylonjs.com/babylon101/cameras
  36394. */
  36395. cameras: Camera[];
  36396. /**
  36397. * All of the lights added to this scene
  36398. * @see http://doc.babylonjs.com/babylon101/lights
  36399. */
  36400. lights: Light[];
  36401. /**
  36402. * All of the (abstract) meshes added to this scene
  36403. */
  36404. meshes: AbstractMesh[];
  36405. /**
  36406. * The list of skeletons added to the scene
  36407. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36408. */
  36409. skeletons: Skeleton[];
  36410. /**
  36411. * All of the particle systems added to this scene
  36412. * @see http://doc.babylonjs.com/babylon101/particles
  36413. */
  36414. particleSystems: IParticleSystem[];
  36415. /**
  36416. * Gets a list of Animations associated with the scene
  36417. */
  36418. animations: Animation[];
  36419. /**
  36420. * All of the animation groups added to this scene
  36421. * @see http://doc.babylonjs.com/how_to/group
  36422. */
  36423. animationGroups: AnimationGroup[];
  36424. /**
  36425. * All of the multi-materials added to this scene
  36426. * @see http://doc.babylonjs.com/how_to/multi_materials
  36427. */
  36428. multiMaterials: MultiMaterial[];
  36429. /**
  36430. * All of the materials added to this scene
  36431. * In the context of a Scene, it is not supposed to be modified manually.
  36432. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36433. * Note also that the order of the Material within the array is not significant and might change.
  36434. * @see http://doc.babylonjs.com/babylon101/materials
  36435. */
  36436. materials: Material[];
  36437. /**
  36438. * The list of morph target managers added to the scene
  36439. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36440. */
  36441. morphTargetManagers: MorphTargetManager[];
  36442. /**
  36443. * The list of geometries used in the scene.
  36444. */
  36445. geometries: Geometry[];
  36446. /**
  36447. * All of the tranform nodes added to this scene
  36448. * In the context of a Scene, it is not supposed to be modified manually.
  36449. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36450. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36451. * @see http://doc.babylonjs.com/how_to/transformnode
  36452. */
  36453. transformNodes: TransformNode[];
  36454. /**
  36455. * ActionManagers available on the scene.
  36456. */
  36457. actionManagers: AbstractActionManager[];
  36458. /**
  36459. * Textures to keep.
  36460. */
  36461. textures: BaseTexture[];
  36462. /**
  36463. * Environment texture for the scene
  36464. */
  36465. environmentTexture: Nullable<BaseTexture>;
  36466. }
  36467. }
  36468. declare module "babylonjs/Audio/sound" {
  36469. import { Observable } from "babylonjs/Misc/observable";
  36470. import { Vector3 } from "babylonjs/Maths/math.vector";
  36471. import { Nullable } from "babylonjs/types";
  36472. import { Scene } from "babylonjs/scene";
  36473. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36474. /**
  36475. * Interface used to define options for Sound class
  36476. */
  36477. export interface ISoundOptions {
  36478. /**
  36479. * Does the sound autoplay once loaded.
  36480. */
  36481. autoplay?: boolean;
  36482. /**
  36483. * Does the sound loop after it finishes playing once.
  36484. */
  36485. loop?: boolean;
  36486. /**
  36487. * Sound's volume
  36488. */
  36489. volume?: number;
  36490. /**
  36491. * Is it a spatial sound?
  36492. */
  36493. spatialSound?: boolean;
  36494. /**
  36495. * Maximum distance to hear that sound
  36496. */
  36497. maxDistance?: number;
  36498. /**
  36499. * Uses user defined attenuation function
  36500. */
  36501. useCustomAttenuation?: boolean;
  36502. /**
  36503. * Define the roll off factor of spatial sounds.
  36504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36505. */
  36506. rolloffFactor?: number;
  36507. /**
  36508. * Define the reference distance the sound should be heard perfectly.
  36509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36510. */
  36511. refDistance?: number;
  36512. /**
  36513. * Define the distance attenuation model the sound will follow.
  36514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36515. */
  36516. distanceModel?: string;
  36517. /**
  36518. * Defines the playback speed (1 by default)
  36519. */
  36520. playbackRate?: number;
  36521. /**
  36522. * Defines if the sound is from a streaming source
  36523. */
  36524. streaming?: boolean;
  36525. /**
  36526. * Defines an optional length (in seconds) inside the sound file
  36527. */
  36528. length?: number;
  36529. /**
  36530. * Defines an optional offset (in seconds) inside the sound file
  36531. */
  36532. offset?: number;
  36533. /**
  36534. * If true, URLs will not be required to state the audio file codec to use.
  36535. */
  36536. skipCodecCheck?: boolean;
  36537. }
  36538. /**
  36539. * Defines a sound that can be played in the application.
  36540. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36542. */
  36543. export class Sound {
  36544. /**
  36545. * The name of the sound in the scene.
  36546. */
  36547. name: string;
  36548. /**
  36549. * Does the sound autoplay once loaded.
  36550. */
  36551. autoplay: boolean;
  36552. /**
  36553. * Does the sound loop after it finishes playing once.
  36554. */
  36555. loop: boolean;
  36556. /**
  36557. * Does the sound use a custom attenuation curve to simulate the falloff
  36558. * happening when the source gets further away from the camera.
  36559. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36560. */
  36561. useCustomAttenuation: boolean;
  36562. /**
  36563. * The sound track id this sound belongs to.
  36564. */
  36565. soundTrackId: number;
  36566. /**
  36567. * Is this sound currently played.
  36568. */
  36569. isPlaying: boolean;
  36570. /**
  36571. * Is this sound currently paused.
  36572. */
  36573. isPaused: boolean;
  36574. /**
  36575. * Does this sound enables spatial sound.
  36576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36577. */
  36578. spatialSound: boolean;
  36579. /**
  36580. * Define the reference distance the sound should be heard perfectly.
  36581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36582. */
  36583. refDistance: number;
  36584. /**
  36585. * Define the roll off factor of spatial sounds.
  36586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36587. */
  36588. rolloffFactor: number;
  36589. /**
  36590. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36592. */
  36593. maxDistance: number;
  36594. /**
  36595. * Define the distance attenuation model the sound will follow.
  36596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36597. */
  36598. distanceModel: string;
  36599. /**
  36600. * @hidden
  36601. * Back Compat
  36602. **/
  36603. onended: () => any;
  36604. /**
  36605. * Observable event when the current playing sound finishes.
  36606. */
  36607. onEndedObservable: Observable<Sound>;
  36608. private _panningModel;
  36609. private _playbackRate;
  36610. private _streaming;
  36611. private _startTime;
  36612. private _startOffset;
  36613. private _position;
  36614. /** @hidden */
  36615. _positionInEmitterSpace: boolean;
  36616. private _localDirection;
  36617. private _volume;
  36618. private _isReadyToPlay;
  36619. private _isDirectional;
  36620. private _readyToPlayCallback;
  36621. private _audioBuffer;
  36622. private _soundSource;
  36623. private _streamingSource;
  36624. private _soundPanner;
  36625. private _soundGain;
  36626. private _inputAudioNode;
  36627. private _outputAudioNode;
  36628. private _coneInnerAngle;
  36629. private _coneOuterAngle;
  36630. private _coneOuterGain;
  36631. private _scene;
  36632. private _connectedTransformNode;
  36633. private _customAttenuationFunction;
  36634. private _registerFunc;
  36635. private _isOutputConnected;
  36636. private _htmlAudioElement;
  36637. private _urlType;
  36638. private _length?;
  36639. private _offset?;
  36640. /** @hidden */
  36641. static _SceneComponentInitialization: (scene: Scene) => void;
  36642. /**
  36643. * Create a sound and attach it to a scene
  36644. * @param name Name of your sound
  36645. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36646. * @param scene defines the scene the sound belongs to
  36647. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36648. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36649. */
  36650. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36651. /**
  36652. * Release the sound and its associated resources
  36653. */
  36654. dispose(): void;
  36655. /**
  36656. * Gets if the sounds is ready to be played or not.
  36657. * @returns true if ready, otherwise false
  36658. */
  36659. isReady(): boolean;
  36660. private _soundLoaded;
  36661. /**
  36662. * Sets the data of the sound from an audiobuffer
  36663. * @param audioBuffer The audioBuffer containing the data
  36664. */
  36665. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36666. /**
  36667. * Updates the current sounds options such as maxdistance, loop...
  36668. * @param options A JSON object containing values named as the object properties
  36669. */
  36670. updateOptions(options: ISoundOptions): void;
  36671. private _createSpatialParameters;
  36672. private _updateSpatialParameters;
  36673. /**
  36674. * Switch the panning model to HRTF:
  36675. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36677. */
  36678. switchPanningModelToHRTF(): void;
  36679. /**
  36680. * Switch the panning model to Equal Power:
  36681. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36683. */
  36684. switchPanningModelToEqualPower(): void;
  36685. private _switchPanningModel;
  36686. /**
  36687. * Connect this sound to a sound track audio node like gain...
  36688. * @param soundTrackAudioNode the sound track audio node to connect to
  36689. */
  36690. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36691. /**
  36692. * Transform this sound into a directional source
  36693. * @param coneInnerAngle Size of the inner cone in degree
  36694. * @param coneOuterAngle Size of the outer cone in degree
  36695. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36696. */
  36697. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36698. /**
  36699. * Gets or sets the inner angle for the directional cone.
  36700. */
  36701. /**
  36702. * Gets or sets the inner angle for the directional cone.
  36703. */
  36704. directionalConeInnerAngle: number;
  36705. /**
  36706. * Gets or sets the outer angle for the directional cone.
  36707. */
  36708. /**
  36709. * Gets or sets the outer angle for the directional cone.
  36710. */
  36711. directionalConeOuterAngle: number;
  36712. /**
  36713. * Sets the position of the emitter if spatial sound is enabled
  36714. * @param newPosition Defines the new posisiton
  36715. */
  36716. setPosition(newPosition: Vector3): void;
  36717. /**
  36718. * Sets the local direction of the emitter if spatial sound is enabled
  36719. * @param newLocalDirection Defines the new local direction
  36720. */
  36721. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36722. private _updateDirection;
  36723. /** @hidden */
  36724. updateDistanceFromListener(): void;
  36725. /**
  36726. * Sets a new custom attenuation function for the sound.
  36727. * @param callback Defines the function used for the attenuation
  36728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36729. */
  36730. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36731. /**
  36732. * Play the sound
  36733. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36734. * @param offset (optional) Start the sound at a specific time in seconds
  36735. * @param length (optional) Sound duration (in seconds)
  36736. */
  36737. play(time?: number, offset?: number, length?: number): void;
  36738. private _onended;
  36739. /**
  36740. * Stop the sound
  36741. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36742. */
  36743. stop(time?: number): void;
  36744. /**
  36745. * Put the sound in pause
  36746. */
  36747. pause(): void;
  36748. /**
  36749. * Sets a dedicated volume for this sounds
  36750. * @param newVolume Define the new volume of the sound
  36751. * @param time Define time for gradual change to new volume
  36752. */
  36753. setVolume(newVolume: number, time?: number): void;
  36754. /**
  36755. * Set the sound play back rate
  36756. * @param newPlaybackRate Define the playback rate the sound should be played at
  36757. */
  36758. setPlaybackRate(newPlaybackRate: number): void;
  36759. /**
  36760. * Gets the volume of the sound.
  36761. * @returns the volume of the sound
  36762. */
  36763. getVolume(): number;
  36764. /**
  36765. * Attach the sound to a dedicated mesh
  36766. * @param transformNode The transform node to connect the sound with
  36767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36768. */
  36769. attachToMesh(transformNode: TransformNode): void;
  36770. /**
  36771. * Detach the sound from the previously attached mesh
  36772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36773. */
  36774. detachFromMesh(): void;
  36775. private _onRegisterAfterWorldMatrixUpdate;
  36776. /**
  36777. * Clone the current sound in the scene.
  36778. * @returns the new sound clone
  36779. */
  36780. clone(): Nullable<Sound>;
  36781. /**
  36782. * Gets the current underlying audio buffer containing the data
  36783. * @returns the audio buffer
  36784. */
  36785. getAudioBuffer(): Nullable<AudioBuffer>;
  36786. /**
  36787. * Serializes the Sound in a JSON representation
  36788. * @returns the JSON representation of the sound
  36789. */
  36790. serialize(): any;
  36791. /**
  36792. * Parse a JSON representation of a sound to innstantiate in a given scene
  36793. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36794. * @param scene Define the scene the new parsed sound should be created in
  36795. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36796. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36797. * @returns the newly parsed sound
  36798. */
  36799. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36800. }
  36801. }
  36802. declare module "babylonjs/Actions/directAudioActions" {
  36803. import { Action } from "babylonjs/Actions/action";
  36804. import { Condition } from "babylonjs/Actions/condition";
  36805. import { Sound } from "babylonjs/Audio/sound";
  36806. /**
  36807. * This defines an action helpful to play a defined sound on a triggered action.
  36808. */
  36809. export class PlaySoundAction extends Action {
  36810. private _sound;
  36811. /**
  36812. * Instantiate the action
  36813. * @param triggerOptions defines the trigger options
  36814. * @param sound defines the sound to play
  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 play 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. * This defines an action helpful to stop a defined sound on a triggered action.
  36833. */
  36834. export class StopSoundAction extends Action {
  36835. private _sound;
  36836. /**
  36837. * Instantiate the action
  36838. * @param triggerOptions defines the trigger options
  36839. * @param sound defines the sound to stop
  36840. * @param condition defines the trigger related conditions
  36841. */
  36842. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36843. /** @hidden */
  36844. _prepare(): void;
  36845. /**
  36846. * Execute the action and stop the sound.
  36847. */
  36848. execute(): void;
  36849. /**
  36850. * Serializes the actions and its related information.
  36851. * @param parent defines the object to serialize in
  36852. * @returns the serialized object
  36853. */
  36854. serialize(parent: any): any;
  36855. }
  36856. }
  36857. declare module "babylonjs/Actions/interpolateValueAction" {
  36858. import { Action } from "babylonjs/Actions/action";
  36859. import { Condition } from "babylonjs/Actions/condition";
  36860. import { Observable } from "babylonjs/Misc/observable";
  36861. /**
  36862. * This defines an action responsible to change the value of a property
  36863. * by interpolating between its current value and the newly set one once triggered.
  36864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36865. */
  36866. export class InterpolateValueAction extends Action {
  36867. /**
  36868. * Defines the path of the property where the value should be interpolated
  36869. */
  36870. propertyPath: string;
  36871. /**
  36872. * Defines the target value at the end of the interpolation.
  36873. */
  36874. value: any;
  36875. /**
  36876. * Defines the time it will take for the property to interpolate to the value.
  36877. */
  36878. duration: number;
  36879. /**
  36880. * Defines if the other scene animations should be stopped when the action has been triggered
  36881. */
  36882. stopOtherAnimations?: boolean;
  36883. /**
  36884. * Defines a callback raised once the interpolation animation has been done.
  36885. */
  36886. onInterpolationDone?: () => void;
  36887. /**
  36888. * Observable triggered once the interpolation animation has been done.
  36889. */
  36890. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36891. private _target;
  36892. private _effectiveTarget;
  36893. private _property;
  36894. /**
  36895. * Instantiate the action
  36896. * @param triggerOptions defines the trigger options
  36897. * @param target defines the object containing the value to interpolate
  36898. * @param propertyPath defines the path to the property in the target object
  36899. * @param value defines the target value at the end of the interpolation
  36900. * @param duration deines the time it will take for the property to interpolate to the value.
  36901. * @param condition defines the trigger related conditions
  36902. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36903. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36904. */
  36905. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36906. /** @hidden */
  36907. _prepare(): void;
  36908. /**
  36909. * Execute the action starts the value interpolation.
  36910. */
  36911. execute(): void;
  36912. /**
  36913. * Serializes the actions and its related information.
  36914. * @param parent defines the object to serialize in
  36915. * @returns the serialized object
  36916. */
  36917. serialize(parent: any): any;
  36918. }
  36919. }
  36920. declare module "babylonjs/Actions/index" {
  36921. export * from "babylonjs/Actions/abstractActionManager";
  36922. export * from "babylonjs/Actions/action";
  36923. export * from "babylonjs/Actions/actionEvent";
  36924. export * from "babylonjs/Actions/actionManager";
  36925. export * from "babylonjs/Actions/condition";
  36926. export * from "babylonjs/Actions/directActions";
  36927. export * from "babylonjs/Actions/directAudioActions";
  36928. export * from "babylonjs/Actions/interpolateValueAction";
  36929. }
  36930. declare module "babylonjs/Animations/index" {
  36931. export * from "babylonjs/Animations/animatable";
  36932. export * from "babylonjs/Animations/animation";
  36933. export * from "babylonjs/Animations/animationGroup";
  36934. export * from "babylonjs/Animations/animationPropertiesOverride";
  36935. export * from "babylonjs/Animations/easing";
  36936. export * from "babylonjs/Animations/runtimeAnimation";
  36937. export * from "babylonjs/Animations/animationEvent";
  36938. export * from "babylonjs/Animations/animationGroup";
  36939. export * from "babylonjs/Animations/animationKey";
  36940. export * from "babylonjs/Animations/animationRange";
  36941. export * from "babylonjs/Animations/animatable.interface";
  36942. }
  36943. declare module "babylonjs/Audio/soundTrack" {
  36944. import { Sound } from "babylonjs/Audio/sound";
  36945. import { Analyser } from "babylonjs/Audio/analyser";
  36946. import { Scene } from "babylonjs/scene";
  36947. /**
  36948. * Options allowed during the creation of a sound track.
  36949. */
  36950. export interface ISoundTrackOptions {
  36951. /**
  36952. * The volume the sound track should take during creation
  36953. */
  36954. volume?: number;
  36955. /**
  36956. * Define if the sound track is the main sound track of the scene
  36957. */
  36958. mainTrack?: boolean;
  36959. }
  36960. /**
  36961. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36962. * It will be also used in a future release to apply effects on a specific track.
  36963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36964. */
  36965. export class SoundTrack {
  36966. /**
  36967. * The unique identifier of the sound track in the scene.
  36968. */
  36969. id: number;
  36970. /**
  36971. * The list of sounds included in the sound track.
  36972. */
  36973. soundCollection: Array<Sound>;
  36974. private _outputAudioNode;
  36975. private _scene;
  36976. private _connectedAnalyser;
  36977. private _options;
  36978. private _isInitialized;
  36979. /**
  36980. * Creates a new sound track.
  36981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36982. * @param scene Define the scene the sound track belongs to
  36983. * @param options
  36984. */
  36985. constructor(scene: Scene, options?: ISoundTrackOptions);
  36986. private _initializeSoundTrackAudioGraph;
  36987. /**
  36988. * Release the sound track and its associated resources
  36989. */
  36990. dispose(): void;
  36991. /**
  36992. * Adds a sound to this sound track
  36993. * @param sound define the cound to add
  36994. * @ignoreNaming
  36995. */
  36996. AddSound(sound: Sound): void;
  36997. /**
  36998. * Removes a sound to this sound track
  36999. * @param sound define the cound to remove
  37000. * @ignoreNaming
  37001. */
  37002. RemoveSound(sound: Sound): void;
  37003. /**
  37004. * Set a global volume for the full sound track.
  37005. * @param newVolume Define the new volume of the sound track
  37006. */
  37007. setVolume(newVolume: number): void;
  37008. /**
  37009. * Switch the panning model to HRTF:
  37010. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37012. */
  37013. switchPanningModelToHRTF(): void;
  37014. /**
  37015. * Switch the panning model to Equal Power:
  37016. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37017. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37018. */
  37019. switchPanningModelToEqualPower(): void;
  37020. /**
  37021. * Connect the sound track to an audio analyser allowing some amazing
  37022. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37023. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37024. * @param analyser The analyser to connect to the engine
  37025. */
  37026. connectToAnalyser(analyser: Analyser): void;
  37027. }
  37028. }
  37029. declare module "babylonjs/Audio/audioSceneComponent" {
  37030. import { Sound } from "babylonjs/Audio/sound";
  37031. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  37032. import { Nullable } from "babylonjs/types";
  37033. import { Vector3 } from "babylonjs/Maths/math.vector";
  37034. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  37035. import { Scene } from "babylonjs/scene";
  37036. import { AbstractScene } from "babylonjs/abstractScene";
  37037. import "babylonjs/Audio/audioEngine";
  37038. module "babylonjs/abstractScene" {
  37039. interface AbstractScene {
  37040. /**
  37041. * The list of sounds used in the scene.
  37042. */
  37043. sounds: Nullable<Array<Sound>>;
  37044. }
  37045. }
  37046. module "babylonjs/scene" {
  37047. interface Scene {
  37048. /**
  37049. * @hidden
  37050. * Backing field
  37051. */
  37052. _mainSoundTrack: SoundTrack;
  37053. /**
  37054. * The main sound track played by the scene.
  37055. * It cotains your primary collection of sounds.
  37056. */
  37057. mainSoundTrack: SoundTrack;
  37058. /**
  37059. * The list of sound tracks added to the scene
  37060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37061. */
  37062. soundTracks: Nullable<Array<SoundTrack>>;
  37063. /**
  37064. * Gets a sound using a given name
  37065. * @param name defines the name to search for
  37066. * @return the found sound or null if not found at all.
  37067. */
  37068. getSoundByName(name: string): Nullable<Sound>;
  37069. /**
  37070. * Gets or sets if audio support is enabled
  37071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37072. */
  37073. audioEnabled: boolean;
  37074. /**
  37075. * Gets or sets if audio will be output to headphones
  37076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37077. */
  37078. headphone: boolean;
  37079. /**
  37080. * Gets or sets custom audio listener position provider
  37081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37082. */
  37083. audioListenerPositionProvider: Nullable<() => Vector3>;
  37084. /**
  37085. * Gets or sets a refresh rate when using 3D audio positioning
  37086. */
  37087. audioPositioningRefreshRate: number;
  37088. }
  37089. }
  37090. /**
  37091. * Defines the sound scene component responsible to manage any sounds
  37092. * in a given scene.
  37093. */
  37094. export class AudioSceneComponent implements ISceneSerializableComponent {
  37095. /**
  37096. * The component name helpfull to identify the component in the list of scene components.
  37097. */
  37098. readonly name: string;
  37099. /**
  37100. * The scene the component belongs to.
  37101. */
  37102. scene: Scene;
  37103. private _audioEnabled;
  37104. /**
  37105. * Gets whether audio is enabled or not.
  37106. * Please use related enable/disable method to switch state.
  37107. */
  37108. readonly audioEnabled: boolean;
  37109. private _headphone;
  37110. /**
  37111. * Gets whether audio is outputing to headphone or not.
  37112. * Please use the according Switch methods to change output.
  37113. */
  37114. readonly headphone: boolean;
  37115. /**
  37116. * Gets or sets a refresh rate when using 3D audio positioning
  37117. */
  37118. audioPositioningRefreshRate: number;
  37119. private _audioListenerPositionProvider;
  37120. /**
  37121. * Gets the current audio listener position provider
  37122. */
  37123. /**
  37124. * Sets a custom listener position for all sounds in the scene
  37125. * By default, this is the position of the first active camera
  37126. */
  37127. audioListenerPositionProvider: Nullable<() => Vector3>;
  37128. /**
  37129. * Creates a new instance of the component for the given scene
  37130. * @param scene Defines the scene to register the component in
  37131. */
  37132. constructor(scene: Scene);
  37133. /**
  37134. * Registers the component in a given scene
  37135. */
  37136. register(): void;
  37137. /**
  37138. * Rebuilds the elements related to this component in case of
  37139. * context lost for instance.
  37140. */
  37141. rebuild(): void;
  37142. /**
  37143. * Serializes the component data to the specified json object
  37144. * @param serializationObject The object to serialize to
  37145. */
  37146. serialize(serializationObject: any): void;
  37147. /**
  37148. * Adds all the elements from the container to the scene
  37149. * @param container the container holding the elements
  37150. */
  37151. addFromContainer(container: AbstractScene): void;
  37152. /**
  37153. * Removes all the elements in the container from the scene
  37154. * @param container contains the elements to remove
  37155. * @param dispose if the removed element should be disposed (default: false)
  37156. */
  37157. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37158. /**
  37159. * Disposes the component and the associated ressources.
  37160. */
  37161. dispose(): void;
  37162. /**
  37163. * Disables audio in the associated scene.
  37164. */
  37165. disableAudio(): void;
  37166. /**
  37167. * Enables audio in the associated scene.
  37168. */
  37169. enableAudio(): void;
  37170. /**
  37171. * Switch audio to headphone output.
  37172. */
  37173. switchAudioModeForHeadphones(): void;
  37174. /**
  37175. * Switch audio to normal speakers.
  37176. */
  37177. switchAudioModeForNormalSpeakers(): void;
  37178. private _cachedCameraDirection;
  37179. private _cachedCameraPosition;
  37180. private _lastCheck;
  37181. private _afterRender;
  37182. }
  37183. }
  37184. declare module "babylonjs/Audio/weightedsound" {
  37185. import { Sound } from "babylonjs/Audio/sound";
  37186. /**
  37187. * Wraps one or more Sound objects and selects one with random weight for playback.
  37188. */
  37189. export class WeightedSound {
  37190. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37191. loop: boolean;
  37192. private _coneInnerAngle;
  37193. private _coneOuterAngle;
  37194. private _volume;
  37195. /** A Sound is currently playing. */
  37196. isPlaying: boolean;
  37197. /** A Sound is currently paused. */
  37198. isPaused: boolean;
  37199. private _sounds;
  37200. private _weights;
  37201. private _currentIndex?;
  37202. /**
  37203. * Creates a new WeightedSound from the list of sounds given.
  37204. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37205. * @param sounds Array of Sounds that will be selected from.
  37206. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37207. */
  37208. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37209. /**
  37210. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37211. */
  37212. /**
  37213. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37214. */
  37215. directionalConeInnerAngle: number;
  37216. /**
  37217. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37218. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37219. */
  37220. /**
  37221. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37222. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37223. */
  37224. directionalConeOuterAngle: number;
  37225. /**
  37226. * Playback volume.
  37227. */
  37228. /**
  37229. * Playback volume.
  37230. */
  37231. volume: number;
  37232. private _onended;
  37233. /**
  37234. * Suspend playback
  37235. */
  37236. pause(): void;
  37237. /**
  37238. * Stop playback
  37239. */
  37240. stop(): void;
  37241. /**
  37242. * Start playback.
  37243. * @param startOffset Position the clip head at a specific time in seconds.
  37244. */
  37245. play(startOffset?: number): void;
  37246. }
  37247. }
  37248. declare module "babylonjs/Audio/index" {
  37249. export * from "babylonjs/Audio/analyser";
  37250. export * from "babylonjs/Audio/audioEngine";
  37251. export * from "babylonjs/Audio/audioSceneComponent";
  37252. export * from "babylonjs/Audio/sound";
  37253. export * from "babylonjs/Audio/soundTrack";
  37254. export * from "babylonjs/Audio/weightedsound";
  37255. }
  37256. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  37257. import { Behavior } from "babylonjs/Behaviors/behavior";
  37258. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37259. import { BackEase } from "babylonjs/Animations/easing";
  37260. /**
  37261. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37262. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37263. */
  37264. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37265. /**
  37266. * Gets the name of the behavior.
  37267. */
  37268. readonly name: string;
  37269. /**
  37270. * The easing function used by animations
  37271. */
  37272. static EasingFunction: BackEase;
  37273. /**
  37274. * The easing mode used by animations
  37275. */
  37276. static EasingMode: number;
  37277. /**
  37278. * The duration of the animation, in milliseconds
  37279. */
  37280. transitionDuration: number;
  37281. /**
  37282. * Length of the distance animated by the transition when lower radius is reached
  37283. */
  37284. lowerRadiusTransitionRange: number;
  37285. /**
  37286. * Length of the distance animated by the transition when upper radius is reached
  37287. */
  37288. upperRadiusTransitionRange: number;
  37289. private _autoTransitionRange;
  37290. /**
  37291. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37292. */
  37293. /**
  37294. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37295. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37296. */
  37297. autoTransitionRange: boolean;
  37298. private _attachedCamera;
  37299. private _onAfterCheckInputsObserver;
  37300. private _onMeshTargetChangedObserver;
  37301. /**
  37302. * Initializes the behavior.
  37303. */
  37304. init(): void;
  37305. /**
  37306. * Attaches the behavior to its arc rotate camera.
  37307. * @param camera Defines the camera to attach the behavior to
  37308. */
  37309. attach(camera: ArcRotateCamera): void;
  37310. /**
  37311. * Detaches the behavior from its current arc rotate camera.
  37312. */
  37313. detach(): void;
  37314. private _radiusIsAnimating;
  37315. private _radiusBounceTransition;
  37316. private _animatables;
  37317. private _cachedWheelPrecision;
  37318. /**
  37319. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37320. * @param radiusLimit The limit to check against.
  37321. * @return Bool to indicate if at limit.
  37322. */
  37323. private _isRadiusAtLimit;
  37324. /**
  37325. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37326. * @param radiusDelta The delta by which to animate to. Can be negative.
  37327. */
  37328. private _applyBoundRadiusAnimation;
  37329. /**
  37330. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37331. */
  37332. protected _clearAnimationLocks(): void;
  37333. /**
  37334. * Stops and removes all animations that have been applied to the camera
  37335. */
  37336. stopAllAnimations(): void;
  37337. }
  37338. }
  37339. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  37340. import { Behavior } from "babylonjs/Behaviors/behavior";
  37341. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37342. import { ExponentialEase } from "babylonjs/Animations/easing";
  37343. import { Nullable } from "babylonjs/types";
  37344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37345. import { Vector3 } from "babylonjs/Maths/math.vector";
  37346. /**
  37347. * 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.
  37348. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37349. */
  37350. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37351. /**
  37352. * Gets the name of the behavior.
  37353. */
  37354. readonly name: string;
  37355. private _mode;
  37356. private _radiusScale;
  37357. private _positionScale;
  37358. private _defaultElevation;
  37359. private _elevationReturnTime;
  37360. private _elevationReturnWaitTime;
  37361. private _zoomStopsAnimation;
  37362. private _framingTime;
  37363. /**
  37364. * The easing function used by animations
  37365. */
  37366. static EasingFunction: ExponentialEase;
  37367. /**
  37368. * The easing mode used by animations
  37369. */
  37370. static EasingMode: number;
  37371. /**
  37372. * Sets the current mode used by the behavior
  37373. */
  37374. /**
  37375. * Gets current mode used by the behavior.
  37376. */
  37377. mode: number;
  37378. /**
  37379. * Sets the scale applied to the radius (1 by default)
  37380. */
  37381. /**
  37382. * Gets the scale applied to the radius
  37383. */
  37384. radiusScale: number;
  37385. /**
  37386. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37387. */
  37388. /**
  37389. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37390. */
  37391. positionScale: number;
  37392. /**
  37393. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37394. * behaviour is triggered, in radians.
  37395. */
  37396. /**
  37397. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37398. * behaviour is triggered, in radians.
  37399. */
  37400. defaultElevation: number;
  37401. /**
  37402. * Sets the time (in milliseconds) taken to return to the default beta position.
  37403. * Negative value indicates camera should not return to default.
  37404. */
  37405. /**
  37406. * Gets the time (in milliseconds) taken to return to the default beta position.
  37407. * Negative value indicates camera should not return to default.
  37408. */
  37409. elevationReturnTime: number;
  37410. /**
  37411. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37412. */
  37413. /**
  37414. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37415. */
  37416. elevationReturnWaitTime: number;
  37417. /**
  37418. * Sets the flag that indicates if user zooming should stop animation.
  37419. */
  37420. /**
  37421. * Gets the flag that indicates if user zooming should stop animation.
  37422. */
  37423. zoomStopsAnimation: boolean;
  37424. /**
  37425. * Sets the transition time when framing the mesh, in milliseconds
  37426. */
  37427. /**
  37428. * Gets the transition time when framing the mesh, in milliseconds
  37429. */
  37430. framingTime: number;
  37431. /**
  37432. * Define if the behavior should automatically change the configured
  37433. * camera limits and sensibilities.
  37434. */
  37435. autoCorrectCameraLimitsAndSensibility: boolean;
  37436. private _onPrePointerObservableObserver;
  37437. private _onAfterCheckInputsObserver;
  37438. private _onMeshTargetChangedObserver;
  37439. private _attachedCamera;
  37440. private _isPointerDown;
  37441. private _lastInteractionTime;
  37442. /**
  37443. * Initializes the behavior.
  37444. */
  37445. init(): void;
  37446. /**
  37447. * Attaches the behavior to its arc rotate camera.
  37448. * @param camera Defines the camera to attach the behavior to
  37449. */
  37450. attach(camera: ArcRotateCamera): void;
  37451. /**
  37452. * Detaches the behavior from its current arc rotate camera.
  37453. */
  37454. detach(): void;
  37455. private _animatables;
  37456. private _betaIsAnimating;
  37457. private _betaTransition;
  37458. private _radiusTransition;
  37459. private _vectorTransition;
  37460. /**
  37461. * Targets the given mesh and updates zoom level accordingly.
  37462. * @param mesh The mesh to target.
  37463. * @param radius Optional. If a cached radius position already exists, overrides default.
  37464. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37465. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37466. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37467. */
  37468. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37469. /**
  37470. * Targets the given mesh with its children and updates zoom level accordingly.
  37471. * @param mesh The mesh to target.
  37472. * @param radius Optional. If a cached radius position already exists, overrides default.
  37473. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37474. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37475. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37476. */
  37477. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37478. /**
  37479. * Targets the given meshes with their children and updates zoom level accordingly.
  37480. * @param meshes The mesh to target.
  37481. * @param radius Optional. If a cached radius position already exists, overrides default.
  37482. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37483. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37484. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37485. */
  37486. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37487. /**
  37488. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37489. * @param minimumWorld Determines the smaller position of the bounding box extend
  37490. * @param maximumWorld Determines the bigger position of the bounding box extend
  37491. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37492. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37493. */
  37494. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37495. /**
  37496. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37497. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37498. * frustum width.
  37499. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37500. * to fully enclose the mesh in the viewing frustum.
  37501. */
  37502. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37503. /**
  37504. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37505. * is automatically returned to its default position (expected to be above ground plane).
  37506. */
  37507. private _maintainCameraAboveGround;
  37508. /**
  37509. * Returns the frustum slope based on the canvas ratio and camera FOV
  37510. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37511. */
  37512. private _getFrustumSlope;
  37513. /**
  37514. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37515. */
  37516. private _clearAnimationLocks;
  37517. /**
  37518. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37519. */
  37520. private _applyUserInteraction;
  37521. /**
  37522. * Stops and removes all animations that have been applied to the camera
  37523. */
  37524. stopAllAnimations(): void;
  37525. /**
  37526. * Gets a value indicating if the user is moving the camera
  37527. */
  37528. readonly isUserIsMoving: boolean;
  37529. /**
  37530. * The camera can move all the way towards the mesh.
  37531. */
  37532. static IgnoreBoundsSizeMode: number;
  37533. /**
  37534. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37535. */
  37536. static FitFrustumSidesMode: number;
  37537. }
  37538. }
  37539. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37540. import { Nullable } from "babylonjs/types";
  37541. import { Camera } from "babylonjs/Cameras/camera";
  37542. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37543. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37544. /**
  37545. * Base class for Camera Pointer Inputs.
  37546. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37547. * for example usage.
  37548. */
  37549. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37550. /**
  37551. * Defines the camera the input is attached to.
  37552. */
  37553. abstract camera: Camera;
  37554. /**
  37555. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37556. */
  37557. protected _altKey: boolean;
  37558. protected _ctrlKey: boolean;
  37559. protected _metaKey: boolean;
  37560. protected _shiftKey: boolean;
  37561. /**
  37562. * Which mouse buttons were pressed at time of last mouse event.
  37563. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37564. */
  37565. protected _buttonsPressed: number;
  37566. /**
  37567. * Defines the buttons associated with the input to handle camera move.
  37568. */
  37569. buttons: number[];
  37570. /**
  37571. * Attach the input controls to a specific dom element to get the input from.
  37572. * @param element Defines the element the controls should be listened from
  37573. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37574. */
  37575. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37576. /**
  37577. * Detach the current controls from the specified dom element.
  37578. * @param element Defines the element to stop listening the inputs from
  37579. */
  37580. detachControl(element: Nullable<HTMLElement>): void;
  37581. /**
  37582. * Gets the class name of the current input.
  37583. * @returns the class name
  37584. */
  37585. getClassName(): string;
  37586. /**
  37587. * Get the friendly name associated with the input class.
  37588. * @returns the input friendly name
  37589. */
  37590. getSimpleName(): string;
  37591. /**
  37592. * Called on pointer POINTERDOUBLETAP event.
  37593. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37594. */
  37595. protected onDoubleTap(type: string): void;
  37596. /**
  37597. * Called on pointer POINTERMOVE event if only a single touch is active.
  37598. * Override this method to provide functionality.
  37599. */
  37600. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37601. /**
  37602. * Called on pointer POINTERMOVE event if multiple touches are active.
  37603. * Override this method to provide functionality.
  37604. */
  37605. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37606. /**
  37607. * Called on JS contextmenu event.
  37608. * Override this method to provide functionality.
  37609. */
  37610. protected onContextMenu(evt: PointerEvent): void;
  37611. /**
  37612. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37613. * press.
  37614. * Override this method to provide functionality.
  37615. */
  37616. protected onButtonDown(evt: PointerEvent): void;
  37617. /**
  37618. * Called each time a new POINTERUP event occurs. Ie, for each button
  37619. * release.
  37620. * Override this method to provide functionality.
  37621. */
  37622. protected onButtonUp(evt: PointerEvent): void;
  37623. /**
  37624. * Called when window becomes inactive.
  37625. * Override this method to provide functionality.
  37626. */
  37627. protected onLostFocus(): void;
  37628. private _pointerInput;
  37629. private _observer;
  37630. private _onLostFocus;
  37631. private pointA;
  37632. private pointB;
  37633. }
  37634. }
  37635. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37636. import { Nullable } from "babylonjs/types";
  37637. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37638. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37639. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37640. /**
  37641. * Manage the pointers inputs to control an arc rotate camera.
  37642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37643. */
  37644. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37645. /**
  37646. * Defines the camera the input is attached to.
  37647. */
  37648. camera: ArcRotateCamera;
  37649. /**
  37650. * Gets the class name of the current input.
  37651. * @returns the class name
  37652. */
  37653. getClassName(): string;
  37654. /**
  37655. * Defines the buttons associated with the input to handle camera move.
  37656. */
  37657. buttons: number[];
  37658. /**
  37659. * Defines the pointer angular sensibility along the X axis or how fast is
  37660. * the camera rotating.
  37661. */
  37662. angularSensibilityX: number;
  37663. /**
  37664. * Defines the pointer angular sensibility along the Y axis or how fast is
  37665. * the camera rotating.
  37666. */
  37667. angularSensibilityY: number;
  37668. /**
  37669. * Defines the pointer pinch precision or how fast is the camera zooming.
  37670. */
  37671. pinchPrecision: number;
  37672. /**
  37673. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37674. * from 0.
  37675. * It defines the percentage of current camera.radius to use as delta when
  37676. * pinch zoom is used.
  37677. */
  37678. pinchDeltaPercentage: number;
  37679. /**
  37680. * Defines the pointer panning sensibility or how fast is the camera moving.
  37681. */
  37682. panningSensibility: number;
  37683. /**
  37684. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37685. */
  37686. multiTouchPanning: boolean;
  37687. /**
  37688. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37689. * zoom (pinch) through multitouch.
  37690. */
  37691. multiTouchPanAndZoom: boolean;
  37692. /**
  37693. * Revers pinch action direction.
  37694. */
  37695. pinchInwards: boolean;
  37696. private _isPanClick;
  37697. private _twoFingerActivityCount;
  37698. private _isPinching;
  37699. /**
  37700. * Called on pointer POINTERMOVE event if only a single touch is active.
  37701. */
  37702. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37703. /**
  37704. * Called on pointer POINTERDOUBLETAP event.
  37705. */
  37706. protected onDoubleTap(type: string): void;
  37707. /**
  37708. * Called on pointer POINTERMOVE event if multiple touches are active.
  37709. */
  37710. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37711. /**
  37712. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37713. * press.
  37714. */
  37715. protected onButtonDown(evt: PointerEvent): void;
  37716. /**
  37717. * Called each time a new POINTERUP event occurs. Ie, for each button
  37718. * release.
  37719. */
  37720. protected onButtonUp(evt: PointerEvent): void;
  37721. /**
  37722. * Called when window becomes inactive.
  37723. */
  37724. protected onLostFocus(): void;
  37725. }
  37726. }
  37727. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37728. import { Nullable } from "babylonjs/types";
  37729. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37730. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37731. /**
  37732. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37734. */
  37735. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37736. /**
  37737. * Defines the camera the input is attached to.
  37738. */
  37739. camera: ArcRotateCamera;
  37740. /**
  37741. * Defines the list of key codes associated with the up action (increase alpha)
  37742. */
  37743. keysUp: number[];
  37744. /**
  37745. * Defines the list of key codes associated with the down action (decrease alpha)
  37746. */
  37747. keysDown: number[];
  37748. /**
  37749. * Defines the list of key codes associated with the left action (increase beta)
  37750. */
  37751. keysLeft: number[];
  37752. /**
  37753. * Defines the list of key codes associated with the right action (decrease beta)
  37754. */
  37755. keysRight: number[];
  37756. /**
  37757. * Defines the list of key codes associated with the reset action.
  37758. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37759. */
  37760. keysReset: number[];
  37761. /**
  37762. * Defines the panning sensibility of the inputs.
  37763. * (How fast is the camera paning)
  37764. */
  37765. panningSensibility: number;
  37766. /**
  37767. * Defines the zooming sensibility of the inputs.
  37768. * (How fast is the camera zooming)
  37769. */
  37770. zoomingSensibility: number;
  37771. /**
  37772. * Defines wether maintaining the alt key down switch the movement mode from
  37773. * orientation to zoom.
  37774. */
  37775. useAltToZoom: boolean;
  37776. /**
  37777. * Rotation speed of the camera
  37778. */
  37779. angularSpeed: number;
  37780. private _keys;
  37781. private _ctrlPressed;
  37782. private _altPressed;
  37783. private _onCanvasBlurObserver;
  37784. private _onKeyboardObserver;
  37785. private _engine;
  37786. private _scene;
  37787. /**
  37788. * Attach the input controls to a specific dom element to get the input from.
  37789. * @param element Defines the element the controls should be listened from
  37790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37791. */
  37792. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37793. /**
  37794. * Detach the current controls from the specified dom element.
  37795. * @param element Defines the element to stop listening the inputs from
  37796. */
  37797. detachControl(element: Nullable<HTMLElement>): void;
  37798. /**
  37799. * Update the current camera state depending on the inputs that have been used this frame.
  37800. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37801. */
  37802. checkInputs(): void;
  37803. /**
  37804. * Gets the class name of the current intput.
  37805. * @returns the class name
  37806. */
  37807. getClassName(): string;
  37808. /**
  37809. * Get the friendly name associated with the input class.
  37810. * @returns the input friendly name
  37811. */
  37812. getSimpleName(): string;
  37813. }
  37814. }
  37815. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37816. import { Nullable } from "babylonjs/types";
  37817. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37818. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37819. /**
  37820. * Manage the mouse wheel inputs to control an arc rotate camera.
  37821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37822. */
  37823. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37824. /**
  37825. * Defines the camera the input is attached to.
  37826. */
  37827. camera: ArcRotateCamera;
  37828. /**
  37829. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37830. */
  37831. wheelPrecision: number;
  37832. /**
  37833. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37834. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37835. */
  37836. wheelDeltaPercentage: number;
  37837. private _wheel;
  37838. private _observer;
  37839. private computeDeltaFromMouseWheelLegacyEvent;
  37840. /**
  37841. * Attach the input controls to a specific dom element to get the input from.
  37842. * @param element Defines the element the controls should be listened from
  37843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37844. */
  37845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37846. /**
  37847. * Detach the current controls from the specified dom element.
  37848. * @param element Defines the element to stop listening the inputs from
  37849. */
  37850. detachControl(element: Nullable<HTMLElement>): void;
  37851. /**
  37852. * Gets the class name of the current intput.
  37853. * @returns the class name
  37854. */
  37855. getClassName(): string;
  37856. /**
  37857. * Get the friendly name associated with the input class.
  37858. * @returns the input friendly name
  37859. */
  37860. getSimpleName(): string;
  37861. }
  37862. }
  37863. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37864. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37865. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37866. /**
  37867. * Default Inputs manager for the ArcRotateCamera.
  37868. * It groups all the default supported inputs for ease of use.
  37869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37870. */
  37871. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37872. /**
  37873. * Instantiates a new ArcRotateCameraInputsManager.
  37874. * @param camera Defines the camera the inputs belong to
  37875. */
  37876. constructor(camera: ArcRotateCamera);
  37877. /**
  37878. * Add mouse wheel input support to the input manager.
  37879. * @returns the current input manager
  37880. */
  37881. addMouseWheel(): ArcRotateCameraInputsManager;
  37882. /**
  37883. * Add pointers input support to the input manager.
  37884. * @returns the current input manager
  37885. */
  37886. addPointers(): ArcRotateCameraInputsManager;
  37887. /**
  37888. * Add keyboard input support to the input manager.
  37889. * @returns the current input manager
  37890. */
  37891. addKeyboard(): ArcRotateCameraInputsManager;
  37892. }
  37893. }
  37894. declare module "babylonjs/Cameras/arcRotateCamera" {
  37895. import { Observable } from "babylonjs/Misc/observable";
  37896. import { Nullable } from "babylonjs/types";
  37897. import { Scene } from "babylonjs/scene";
  37898. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37900. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37901. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37902. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37903. import { Camera } from "babylonjs/Cameras/camera";
  37904. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37905. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37906. import { Collider } from "babylonjs/Collisions/collider";
  37907. /**
  37908. * This represents an orbital type of camera.
  37909. *
  37910. * 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.
  37911. * 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.
  37912. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37913. */
  37914. export class ArcRotateCamera extends TargetCamera {
  37915. /**
  37916. * Defines the rotation angle of the camera along the longitudinal axis.
  37917. */
  37918. alpha: number;
  37919. /**
  37920. * Defines the rotation angle of the camera along the latitudinal axis.
  37921. */
  37922. beta: number;
  37923. /**
  37924. * Defines the radius of the camera from it s target point.
  37925. */
  37926. radius: number;
  37927. protected _target: Vector3;
  37928. protected _targetHost: Nullable<AbstractMesh>;
  37929. /**
  37930. * Defines the target point of the camera.
  37931. * The camera looks towards it form the radius distance.
  37932. */
  37933. target: Vector3;
  37934. /**
  37935. * Define the current local position of the camera in the scene
  37936. */
  37937. position: Vector3;
  37938. protected _upVector: Vector3;
  37939. protected _upToYMatrix: Matrix;
  37940. protected _YToUpMatrix: Matrix;
  37941. /**
  37942. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37943. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37944. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37945. */
  37946. upVector: Vector3;
  37947. /**
  37948. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37949. */
  37950. setMatUp(): void;
  37951. /**
  37952. * Current inertia value on the longitudinal axis.
  37953. * The bigger this number the longer it will take for the camera to stop.
  37954. */
  37955. inertialAlphaOffset: number;
  37956. /**
  37957. * Current inertia value on the latitudinal axis.
  37958. * The bigger this number the longer it will take for the camera to stop.
  37959. */
  37960. inertialBetaOffset: number;
  37961. /**
  37962. * Current inertia value on the radius axis.
  37963. * The bigger this number the longer it will take for the camera to stop.
  37964. */
  37965. inertialRadiusOffset: number;
  37966. /**
  37967. * Minimum allowed angle on the longitudinal axis.
  37968. * This can help limiting how the Camera is able to move in the scene.
  37969. */
  37970. lowerAlphaLimit: Nullable<number>;
  37971. /**
  37972. * Maximum allowed angle on the longitudinal axis.
  37973. * This can help limiting how the Camera is able to move in the scene.
  37974. */
  37975. upperAlphaLimit: Nullable<number>;
  37976. /**
  37977. * Minimum allowed angle on the latitudinal axis.
  37978. * This can help limiting how the Camera is able to move in the scene.
  37979. */
  37980. lowerBetaLimit: number;
  37981. /**
  37982. * Maximum allowed angle on the latitudinal axis.
  37983. * This can help limiting how the Camera is able to move in the scene.
  37984. */
  37985. upperBetaLimit: number;
  37986. /**
  37987. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37988. * This can help limiting how the Camera is able to move in the scene.
  37989. */
  37990. lowerRadiusLimit: Nullable<number>;
  37991. /**
  37992. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37993. * This can help limiting how the Camera is able to move in the scene.
  37994. */
  37995. upperRadiusLimit: Nullable<number>;
  37996. /**
  37997. * Defines the current inertia value used during panning of the camera along the X axis.
  37998. */
  37999. inertialPanningX: number;
  38000. /**
  38001. * Defines the current inertia value used during panning of the camera along the Y axis.
  38002. */
  38003. inertialPanningY: number;
  38004. /**
  38005. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38006. * Basically if your fingers moves away from more than this distance you will be considered
  38007. * in pinch mode.
  38008. */
  38009. pinchToPanMaxDistance: number;
  38010. /**
  38011. * Defines the maximum distance the camera can pan.
  38012. * This could help keeping the cammera always in your scene.
  38013. */
  38014. panningDistanceLimit: Nullable<number>;
  38015. /**
  38016. * Defines the target of the camera before paning.
  38017. */
  38018. panningOriginTarget: Vector3;
  38019. /**
  38020. * Defines the value of the inertia used during panning.
  38021. * 0 would mean stop inertia and one would mean no decelleration at all.
  38022. */
  38023. panningInertia: number;
  38024. /**
  38025. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38026. */
  38027. angularSensibilityX: number;
  38028. /**
  38029. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38030. */
  38031. angularSensibilityY: number;
  38032. /**
  38033. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38034. */
  38035. pinchPrecision: number;
  38036. /**
  38037. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38038. * It will be used instead of pinchDeltaPrecision if different from 0.
  38039. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38040. */
  38041. pinchDeltaPercentage: number;
  38042. /**
  38043. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38044. */
  38045. panningSensibility: number;
  38046. /**
  38047. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38048. */
  38049. keysUp: number[];
  38050. /**
  38051. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38052. */
  38053. keysDown: number[];
  38054. /**
  38055. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38056. */
  38057. keysLeft: number[];
  38058. /**
  38059. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38060. */
  38061. keysRight: number[];
  38062. /**
  38063. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38064. */
  38065. wheelPrecision: number;
  38066. /**
  38067. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38068. * It will be used instead of pinchDeltaPrecision if different from 0.
  38069. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38070. */
  38071. wheelDeltaPercentage: number;
  38072. /**
  38073. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38074. */
  38075. zoomOnFactor: number;
  38076. /**
  38077. * Defines a screen offset for the camera position.
  38078. */
  38079. targetScreenOffset: Vector2;
  38080. /**
  38081. * Allows the camera to be completely reversed.
  38082. * If false the camera can not arrive upside down.
  38083. */
  38084. allowUpsideDown: boolean;
  38085. /**
  38086. * Define if double tap/click is used to restore the previously saved state of the camera.
  38087. */
  38088. useInputToRestoreState: boolean;
  38089. /** @hidden */
  38090. _viewMatrix: Matrix;
  38091. /** @hidden */
  38092. _useCtrlForPanning: boolean;
  38093. /** @hidden */
  38094. _panningMouseButton: number;
  38095. /**
  38096. * Defines the input associated to the camera.
  38097. */
  38098. inputs: ArcRotateCameraInputsManager;
  38099. /** @hidden */
  38100. _reset: () => void;
  38101. /**
  38102. * Defines the allowed panning axis.
  38103. */
  38104. panningAxis: Vector3;
  38105. protected _localDirection: Vector3;
  38106. protected _transformedDirection: Vector3;
  38107. private _bouncingBehavior;
  38108. /**
  38109. * Gets the bouncing behavior of the camera if it has been enabled.
  38110. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38111. */
  38112. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  38113. /**
  38114. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38115. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38116. */
  38117. useBouncingBehavior: boolean;
  38118. private _framingBehavior;
  38119. /**
  38120. * Gets the framing behavior of the camera if it has been enabled.
  38121. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38122. */
  38123. readonly framingBehavior: Nullable<FramingBehavior>;
  38124. /**
  38125. * Defines if the framing behavior of the camera is enabled on the camera.
  38126. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38127. */
  38128. useFramingBehavior: boolean;
  38129. private _autoRotationBehavior;
  38130. /**
  38131. * Gets the auto rotation behavior of the camera if it has been enabled.
  38132. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38133. */
  38134. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  38135. /**
  38136. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38137. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38138. */
  38139. useAutoRotationBehavior: boolean;
  38140. /**
  38141. * Observable triggered when the mesh target has been changed on the camera.
  38142. */
  38143. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38144. /**
  38145. * Event raised when the camera is colliding with a mesh.
  38146. */
  38147. onCollide: (collidedMesh: AbstractMesh) => void;
  38148. /**
  38149. * Defines whether the camera should check collision with the objects oh the scene.
  38150. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38151. */
  38152. checkCollisions: boolean;
  38153. /**
  38154. * Defines the collision radius of the camera.
  38155. * This simulates a sphere around the camera.
  38156. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38157. */
  38158. collisionRadius: Vector3;
  38159. protected _collider: Collider;
  38160. protected _previousPosition: Vector3;
  38161. protected _collisionVelocity: Vector3;
  38162. protected _newPosition: Vector3;
  38163. protected _previousAlpha: number;
  38164. protected _previousBeta: number;
  38165. protected _previousRadius: number;
  38166. protected _collisionTriggered: boolean;
  38167. protected _targetBoundingCenter: Nullable<Vector3>;
  38168. private _computationVector;
  38169. /**
  38170. * Instantiates a new ArcRotateCamera in a given scene
  38171. * @param name Defines the name of the camera
  38172. * @param alpha Defines the camera rotation along the logitudinal axis
  38173. * @param beta Defines the camera rotation along the latitudinal axis
  38174. * @param radius Defines the camera distance from its target
  38175. * @param target Defines the camera target
  38176. * @param scene Defines the scene the camera belongs to
  38177. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38178. */
  38179. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38180. /** @hidden */
  38181. _initCache(): void;
  38182. /** @hidden */
  38183. _updateCache(ignoreParentClass?: boolean): void;
  38184. protected _getTargetPosition(): Vector3;
  38185. private _storedAlpha;
  38186. private _storedBeta;
  38187. private _storedRadius;
  38188. private _storedTarget;
  38189. private _storedTargetScreenOffset;
  38190. /**
  38191. * Stores the current state of the camera (alpha, beta, radius and target)
  38192. * @returns the camera itself
  38193. */
  38194. storeState(): Camera;
  38195. /**
  38196. * @hidden
  38197. * Restored camera state. You must call storeState() first
  38198. */
  38199. _restoreStateValues(): boolean;
  38200. /** @hidden */
  38201. _isSynchronizedViewMatrix(): boolean;
  38202. /**
  38203. * Attached controls to the current camera.
  38204. * @param element Defines the element the controls should be listened from
  38205. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38206. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38207. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38208. */
  38209. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38210. /**
  38211. * Detach the current controls from the camera.
  38212. * The camera will stop reacting to inputs.
  38213. * @param element Defines the element to stop listening the inputs from
  38214. */
  38215. detachControl(element: HTMLElement): void;
  38216. /** @hidden */
  38217. _checkInputs(): void;
  38218. protected _checkLimits(): void;
  38219. /**
  38220. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38221. */
  38222. rebuildAnglesAndRadius(): void;
  38223. /**
  38224. * Use a position to define the current camera related information like alpha, beta and radius
  38225. * @param position Defines the position to set the camera at
  38226. */
  38227. setPosition(position: Vector3): void;
  38228. /**
  38229. * Defines the target the camera should look at.
  38230. * This will automatically adapt alpha beta and radius to fit within the new target.
  38231. * @param target Defines the new target as a Vector or a mesh
  38232. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38233. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38234. */
  38235. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38236. /** @hidden */
  38237. _getViewMatrix(): Matrix;
  38238. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38239. /**
  38240. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38241. * @param meshes Defines the mesh to zoom on
  38242. * @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)
  38243. */
  38244. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38245. /**
  38246. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38247. * The target will be changed but the radius
  38248. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38249. * @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)
  38250. */
  38251. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38252. min: Vector3;
  38253. max: Vector3;
  38254. distance: number;
  38255. }, doNotUpdateMaxZ?: boolean): void;
  38256. /**
  38257. * @override
  38258. * Override Camera.createRigCamera
  38259. */
  38260. createRigCamera(name: string, cameraIndex: number): Camera;
  38261. /**
  38262. * @hidden
  38263. * @override
  38264. * Override Camera._updateRigCameras
  38265. */
  38266. _updateRigCameras(): void;
  38267. /**
  38268. * Destroy the camera and release the current resources hold by it.
  38269. */
  38270. dispose(): void;
  38271. /**
  38272. * Gets the current object class name.
  38273. * @return the class name
  38274. */
  38275. getClassName(): string;
  38276. }
  38277. }
  38278. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  38279. import { Behavior } from "babylonjs/Behaviors/behavior";
  38280. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38281. /**
  38282. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38283. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38284. */
  38285. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38286. /**
  38287. * Gets the name of the behavior.
  38288. */
  38289. readonly name: string;
  38290. private _zoomStopsAnimation;
  38291. private _idleRotationSpeed;
  38292. private _idleRotationWaitTime;
  38293. private _idleRotationSpinupTime;
  38294. /**
  38295. * Sets the flag that indicates if user zooming should stop animation.
  38296. */
  38297. /**
  38298. * Gets the flag that indicates if user zooming should stop animation.
  38299. */
  38300. zoomStopsAnimation: boolean;
  38301. /**
  38302. * Sets the default speed at which the camera rotates around the model.
  38303. */
  38304. /**
  38305. * Gets the default speed at which the camera rotates around the model.
  38306. */
  38307. idleRotationSpeed: number;
  38308. /**
  38309. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38310. */
  38311. /**
  38312. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38313. */
  38314. idleRotationWaitTime: number;
  38315. /**
  38316. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38317. */
  38318. /**
  38319. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38320. */
  38321. idleRotationSpinupTime: number;
  38322. /**
  38323. * Gets a value indicating if the camera is currently rotating because of this behavior
  38324. */
  38325. readonly rotationInProgress: boolean;
  38326. private _onPrePointerObservableObserver;
  38327. private _onAfterCheckInputsObserver;
  38328. private _attachedCamera;
  38329. private _isPointerDown;
  38330. private _lastFrameTime;
  38331. private _lastInteractionTime;
  38332. private _cameraRotationSpeed;
  38333. /**
  38334. * Initializes the behavior.
  38335. */
  38336. init(): void;
  38337. /**
  38338. * Attaches the behavior to its arc rotate camera.
  38339. * @param camera Defines the camera to attach the behavior to
  38340. */
  38341. attach(camera: ArcRotateCamera): void;
  38342. /**
  38343. * Detaches the behavior from its current arc rotate camera.
  38344. */
  38345. detach(): void;
  38346. /**
  38347. * Returns true if user is scrolling.
  38348. * @return true if user is scrolling.
  38349. */
  38350. private _userIsZooming;
  38351. private _lastFrameRadius;
  38352. private _shouldAnimationStopForInteraction;
  38353. /**
  38354. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38355. */
  38356. private _applyUserInteraction;
  38357. private _userIsMoving;
  38358. }
  38359. }
  38360. declare module "babylonjs/Behaviors/Cameras/index" {
  38361. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  38362. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  38363. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  38364. }
  38365. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  38366. import { Mesh } from "babylonjs/Meshes/mesh";
  38367. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38368. import { Behavior } from "babylonjs/Behaviors/behavior";
  38369. /**
  38370. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38371. */
  38372. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38373. private ui;
  38374. /**
  38375. * The name of the behavior
  38376. */
  38377. name: string;
  38378. /**
  38379. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38380. */
  38381. distanceAwayFromFace: number;
  38382. /**
  38383. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38384. */
  38385. distanceAwayFromBottomOfFace: number;
  38386. private _faceVectors;
  38387. private _target;
  38388. private _scene;
  38389. private _onRenderObserver;
  38390. private _tmpMatrix;
  38391. private _tmpVector;
  38392. /**
  38393. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38394. * @param ui The transform node that should be attched to the mesh
  38395. */
  38396. constructor(ui: TransformNode);
  38397. /**
  38398. * Initializes the behavior
  38399. */
  38400. init(): void;
  38401. private _closestFace;
  38402. private _zeroVector;
  38403. private _lookAtTmpMatrix;
  38404. private _lookAtToRef;
  38405. /**
  38406. * Attaches the AttachToBoxBehavior to the passed in mesh
  38407. * @param target The mesh that the specified node will be attached to
  38408. */
  38409. attach(target: Mesh): void;
  38410. /**
  38411. * Detaches the behavior from the mesh
  38412. */
  38413. detach(): void;
  38414. }
  38415. }
  38416. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  38417. import { Behavior } from "babylonjs/Behaviors/behavior";
  38418. import { Mesh } from "babylonjs/Meshes/mesh";
  38419. /**
  38420. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38421. */
  38422. export class FadeInOutBehavior implements Behavior<Mesh> {
  38423. /**
  38424. * Time in milliseconds to delay before fading in (Default: 0)
  38425. */
  38426. delay: number;
  38427. /**
  38428. * Time in milliseconds for the mesh to fade in (Default: 300)
  38429. */
  38430. fadeInTime: number;
  38431. private _millisecondsPerFrame;
  38432. private _hovered;
  38433. private _hoverValue;
  38434. private _ownerNode;
  38435. /**
  38436. * Instatiates the FadeInOutBehavior
  38437. */
  38438. constructor();
  38439. /**
  38440. * The name of the behavior
  38441. */
  38442. readonly name: string;
  38443. /**
  38444. * Initializes the behavior
  38445. */
  38446. init(): void;
  38447. /**
  38448. * Attaches the fade behavior on the passed in mesh
  38449. * @param ownerNode The mesh that will be faded in/out once attached
  38450. */
  38451. attach(ownerNode: Mesh): void;
  38452. /**
  38453. * Detaches the behavior from the mesh
  38454. */
  38455. detach(): void;
  38456. /**
  38457. * Triggers the mesh to begin fading in or out
  38458. * @param value if the object should fade in or out (true to fade in)
  38459. */
  38460. fadeIn(value: boolean): void;
  38461. private _update;
  38462. private _setAllVisibility;
  38463. }
  38464. }
  38465. declare module "babylonjs/Misc/pivotTools" {
  38466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38467. /**
  38468. * Class containing a set of static utilities functions for managing Pivots
  38469. * @hidden
  38470. */
  38471. export class PivotTools {
  38472. private static _PivotCached;
  38473. private static _OldPivotPoint;
  38474. private static _PivotTranslation;
  38475. private static _PivotTmpVector;
  38476. /** @hidden */
  38477. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38478. /** @hidden */
  38479. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38480. }
  38481. }
  38482. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38483. import { Scene } from "babylonjs/scene";
  38484. import { Vector4 } from "babylonjs/Maths/math.vector";
  38485. import { Mesh } from "babylonjs/Meshes/mesh";
  38486. import { Nullable } from "babylonjs/types";
  38487. import { Plane } from "babylonjs/Maths/math.plane";
  38488. /**
  38489. * Class containing static functions to help procedurally build meshes
  38490. */
  38491. export class PlaneBuilder {
  38492. /**
  38493. * Creates a plane mesh
  38494. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38495. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38496. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38500. * @param name defines the name of the mesh
  38501. * @param options defines the options used to create the mesh
  38502. * @param scene defines the hosting scene
  38503. * @returns the plane mesh
  38504. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38505. */
  38506. static CreatePlane(name: string, options: {
  38507. size?: number;
  38508. width?: number;
  38509. height?: number;
  38510. sideOrientation?: number;
  38511. frontUVs?: Vector4;
  38512. backUVs?: Vector4;
  38513. updatable?: boolean;
  38514. sourcePlane?: Plane;
  38515. }, scene?: Nullable<Scene>): Mesh;
  38516. }
  38517. }
  38518. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38519. import { Behavior } from "babylonjs/Behaviors/behavior";
  38520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38521. import { Observable } from "babylonjs/Misc/observable";
  38522. import { Vector3 } from "babylonjs/Maths/math.vector";
  38523. import { Ray } from "babylonjs/Culling/ray";
  38524. import "babylonjs/Meshes/Builders/planeBuilder";
  38525. /**
  38526. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38527. */
  38528. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38529. private static _AnyMouseID;
  38530. /**
  38531. * Abstract mesh the behavior is set on
  38532. */
  38533. attachedNode: AbstractMesh;
  38534. private _dragPlane;
  38535. private _scene;
  38536. private _pointerObserver;
  38537. private _beforeRenderObserver;
  38538. private static _planeScene;
  38539. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38540. /**
  38541. * 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)
  38542. */
  38543. maxDragAngle: number;
  38544. /**
  38545. * @hidden
  38546. */
  38547. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38548. /**
  38549. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38550. */
  38551. currentDraggingPointerID: number;
  38552. /**
  38553. * The last position where the pointer hit the drag plane in world space
  38554. */
  38555. lastDragPosition: Vector3;
  38556. /**
  38557. * If the behavior is currently in a dragging state
  38558. */
  38559. dragging: boolean;
  38560. /**
  38561. * 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)
  38562. */
  38563. dragDeltaRatio: number;
  38564. /**
  38565. * If the drag plane orientation should be updated during the dragging (Default: true)
  38566. */
  38567. updateDragPlane: boolean;
  38568. private _debugMode;
  38569. private _moving;
  38570. /**
  38571. * Fires each time the attached mesh is dragged with the pointer
  38572. * * delta between last drag position and current drag position in world space
  38573. * * dragDistance along the drag axis
  38574. * * dragPlaneNormal normal of the current drag plane used during the drag
  38575. * * dragPlanePoint in world space where the drag intersects the drag plane
  38576. */
  38577. onDragObservable: Observable<{
  38578. delta: Vector3;
  38579. dragPlanePoint: Vector3;
  38580. dragPlaneNormal: Vector3;
  38581. dragDistance: number;
  38582. pointerId: number;
  38583. }>;
  38584. /**
  38585. * Fires each time a drag begins (eg. mouse down on mesh)
  38586. */
  38587. onDragStartObservable: Observable<{
  38588. dragPlanePoint: Vector3;
  38589. pointerId: number;
  38590. }>;
  38591. /**
  38592. * Fires each time a drag ends (eg. mouse release after drag)
  38593. */
  38594. onDragEndObservable: Observable<{
  38595. dragPlanePoint: Vector3;
  38596. pointerId: number;
  38597. }>;
  38598. /**
  38599. * If the attached mesh should be moved when dragged
  38600. */
  38601. moveAttached: boolean;
  38602. /**
  38603. * If the drag behavior will react to drag events (Default: true)
  38604. */
  38605. enabled: boolean;
  38606. /**
  38607. * If pointer events should start and release the drag (Default: true)
  38608. */
  38609. startAndReleaseDragOnPointerEvents: boolean;
  38610. /**
  38611. * If camera controls should be detached during the drag
  38612. */
  38613. detachCameraControls: boolean;
  38614. /**
  38615. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38616. */
  38617. useObjectOrienationForDragging: boolean;
  38618. private _options;
  38619. /**
  38620. * Creates a pointer drag behavior that can be attached to a mesh
  38621. * @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)
  38622. */
  38623. constructor(options?: {
  38624. dragAxis?: Vector3;
  38625. dragPlaneNormal?: Vector3;
  38626. });
  38627. /**
  38628. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38629. */
  38630. validateDrag: (targetPosition: Vector3) => boolean;
  38631. /**
  38632. * The name of the behavior
  38633. */
  38634. readonly name: string;
  38635. /**
  38636. * Initializes the behavior
  38637. */
  38638. init(): void;
  38639. private _tmpVector;
  38640. private _alternatePickedPoint;
  38641. private _worldDragAxis;
  38642. private _targetPosition;
  38643. private _attachedElement;
  38644. /**
  38645. * Attaches the drag behavior the passed in mesh
  38646. * @param ownerNode The mesh that will be dragged around once attached
  38647. * @param predicate Predicate to use for pick filtering
  38648. */
  38649. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38650. /**
  38651. * Force relase the drag action by code.
  38652. */
  38653. releaseDrag(): void;
  38654. private _startDragRay;
  38655. private _lastPointerRay;
  38656. /**
  38657. * Simulates the start of a pointer drag event on the behavior
  38658. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38659. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38660. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38661. */
  38662. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38663. private _startDrag;
  38664. private _dragDelta;
  38665. private _moveDrag;
  38666. private _pickWithRayOnDragPlane;
  38667. private _pointA;
  38668. private _pointB;
  38669. private _pointC;
  38670. private _lineA;
  38671. private _lineB;
  38672. private _localAxis;
  38673. private _lookAt;
  38674. private _updateDragPlanePosition;
  38675. /**
  38676. * Detaches the behavior from the mesh
  38677. */
  38678. detach(): void;
  38679. }
  38680. }
  38681. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38682. import { Mesh } from "babylonjs/Meshes/mesh";
  38683. import { Behavior } from "babylonjs/Behaviors/behavior";
  38684. /**
  38685. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38686. */
  38687. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38688. private _dragBehaviorA;
  38689. private _dragBehaviorB;
  38690. private _startDistance;
  38691. private _initialScale;
  38692. private _targetScale;
  38693. private _ownerNode;
  38694. private _sceneRenderObserver;
  38695. /**
  38696. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38697. */
  38698. constructor();
  38699. /**
  38700. * The name of the behavior
  38701. */
  38702. readonly name: string;
  38703. /**
  38704. * Initializes the behavior
  38705. */
  38706. init(): void;
  38707. private _getCurrentDistance;
  38708. /**
  38709. * Attaches the scale behavior the passed in mesh
  38710. * @param ownerNode The mesh that will be scaled around once attached
  38711. */
  38712. attach(ownerNode: Mesh): void;
  38713. /**
  38714. * Detaches the behavior from the mesh
  38715. */
  38716. detach(): void;
  38717. }
  38718. }
  38719. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38720. import { Behavior } from "babylonjs/Behaviors/behavior";
  38721. import { Mesh } from "babylonjs/Meshes/mesh";
  38722. import { Observable } from "babylonjs/Misc/observable";
  38723. /**
  38724. * 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
  38725. */
  38726. export class SixDofDragBehavior implements Behavior<Mesh> {
  38727. private static _virtualScene;
  38728. private _ownerNode;
  38729. private _sceneRenderObserver;
  38730. private _scene;
  38731. private _targetPosition;
  38732. private _virtualOriginMesh;
  38733. private _virtualDragMesh;
  38734. private _pointerObserver;
  38735. private _moving;
  38736. private _startingOrientation;
  38737. /**
  38738. * 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)
  38739. */
  38740. private zDragFactor;
  38741. /**
  38742. * If the object should rotate to face the drag origin
  38743. */
  38744. rotateDraggedObject: boolean;
  38745. /**
  38746. * If the behavior is currently in a dragging state
  38747. */
  38748. dragging: boolean;
  38749. /**
  38750. * 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)
  38751. */
  38752. dragDeltaRatio: number;
  38753. /**
  38754. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38755. */
  38756. currentDraggingPointerID: number;
  38757. /**
  38758. * If camera controls should be detached during the drag
  38759. */
  38760. detachCameraControls: boolean;
  38761. /**
  38762. * Fires each time a drag starts
  38763. */
  38764. onDragStartObservable: Observable<{}>;
  38765. /**
  38766. * Fires each time a drag ends (eg. mouse release after drag)
  38767. */
  38768. onDragEndObservable: Observable<{}>;
  38769. /**
  38770. * 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
  38771. */
  38772. constructor();
  38773. /**
  38774. * The name of the behavior
  38775. */
  38776. readonly name: string;
  38777. /**
  38778. * Initializes the behavior
  38779. */
  38780. init(): void;
  38781. /**
  38782. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38783. */
  38784. private readonly _pointerCamera;
  38785. /**
  38786. * Attaches the scale behavior the passed in mesh
  38787. * @param ownerNode The mesh that will be scaled around once attached
  38788. */
  38789. attach(ownerNode: Mesh): void;
  38790. /**
  38791. * Detaches the behavior from the mesh
  38792. */
  38793. detach(): void;
  38794. }
  38795. }
  38796. declare module "babylonjs/Behaviors/Meshes/index" {
  38797. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38798. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38799. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38800. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38801. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38802. }
  38803. declare module "babylonjs/Behaviors/index" {
  38804. export * from "babylonjs/Behaviors/behavior";
  38805. export * from "babylonjs/Behaviors/Cameras/index";
  38806. export * from "babylonjs/Behaviors/Meshes/index";
  38807. }
  38808. declare module "babylonjs/Bones/boneIKController" {
  38809. import { Bone } from "babylonjs/Bones/bone";
  38810. import { Vector3 } from "babylonjs/Maths/math.vector";
  38811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38812. import { Nullable } from "babylonjs/types";
  38813. /**
  38814. * Class used to apply inverse kinematics to bones
  38815. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38816. */
  38817. export class BoneIKController {
  38818. private static _tmpVecs;
  38819. private static _tmpQuat;
  38820. private static _tmpMats;
  38821. /**
  38822. * Gets or sets the target mesh
  38823. */
  38824. targetMesh: AbstractMesh;
  38825. /** Gets or sets the mesh used as pole */
  38826. poleTargetMesh: AbstractMesh;
  38827. /**
  38828. * Gets or sets the bone used as pole
  38829. */
  38830. poleTargetBone: Nullable<Bone>;
  38831. /**
  38832. * Gets or sets the target position
  38833. */
  38834. targetPosition: Vector3;
  38835. /**
  38836. * Gets or sets the pole target position
  38837. */
  38838. poleTargetPosition: Vector3;
  38839. /**
  38840. * Gets or sets the pole target local offset
  38841. */
  38842. poleTargetLocalOffset: Vector3;
  38843. /**
  38844. * Gets or sets the pole angle
  38845. */
  38846. poleAngle: number;
  38847. /**
  38848. * Gets or sets the mesh associated with the controller
  38849. */
  38850. mesh: AbstractMesh;
  38851. /**
  38852. * 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)
  38853. */
  38854. slerpAmount: number;
  38855. private _bone1Quat;
  38856. private _bone1Mat;
  38857. private _bone2Ang;
  38858. private _bone1;
  38859. private _bone2;
  38860. private _bone1Length;
  38861. private _bone2Length;
  38862. private _maxAngle;
  38863. private _maxReach;
  38864. private _rightHandedSystem;
  38865. private _bendAxis;
  38866. private _slerping;
  38867. private _adjustRoll;
  38868. /**
  38869. * Gets or sets maximum allowed angle
  38870. */
  38871. maxAngle: number;
  38872. /**
  38873. * Creates a new BoneIKController
  38874. * @param mesh defines the mesh to control
  38875. * @param bone defines the bone to control
  38876. * @param options defines options to set up the controller
  38877. */
  38878. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38879. targetMesh?: AbstractMesh;
  38880. poleTargetMesh?: AbstractMesh;
  38881. poleTargetBone?: Bone;
  38882. poleTargetLocalOffset?: Vector3;
  38883. poleAngle?: number;
  38884. bendAxis?: Vector3;
  38885. maxAngle?: number;
  38886. slerpAmount?: number;
  38887. });
  38888. private _setMaxAngle;
  38889. /**
  38890. * Force the controller to update the bones
  38891. */
  38892. update(): void;
  38893. }
  38894. }
  38895. declare module "babylonjs/Bones/boneLookController" {
  38896. import { Vector3 } from "babylonjs/Maths/math.vector";
  38897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38898. import { Bone } from "babylonjs/Bones/bone";
  38899. import { Space } from "babylonjs/Maths/math.axis";
  38900. /**
  38901. * Class used to make a bone look toward a point in space
  38902. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38903. */
  38904. export class BoneLookController {
  38905. private static _tmpVecs;
  38906. private static _tmpQuat;
  38907. private static _tmpMats;
  38908. /**
  38909. * The target Vector3 that the bone will look at
  38910. */
  38911. target: Vector3;
  38912. /**
  38913. * The mesh that the bone is attached to
  38914. */
  38915. mesh: AbstractMesh;
  38916. /**
  38917. * The bone that will be looking to the target
  38918. */
  38919. bone: Bone;
  38920. /**
  38921. * The up axis of the coordinate system that is used when the bone is rotated
  38922. */
  38923. upAxis: Vector3;
  38924. /**
  38925. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38926. */
  38927. upAxisSpace: Space;
  38928. /**
  38929. * Used to make an adjustment to the yaw of the bone
  38930. */
  38931. adjustYaw: number;
  38932. /**
  38933. * Used to make an adjustment to the pitch of the bone
  38934. */
  38935. adjustPitch: number;
  38936. /**
  38937. * Used to make an adjustment to the roll of the bone
  38938. */
  38939. adjustRoll: number;
  38940. /**
  38941. * 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)
  38942. */
  38943. slerpAmount: number;
  38944. private _minYaw;
  38945. private _maxYaw;
  38946. private _minPitch;
  38947. private _maxPitch;
  38948. private _minYawSin;
  38949. private _minYawCos;
  38950. private _maxYawSin;
  38951. private _maxYawCos;
  38952. private _midYawConstraint;
  38953. private _minPitchTan;
  38954. private _maxPitchTan;
  38955. private _boneQuat;
  38956. private _slerping;
  38957. private _transformYawPitch;
  38958. private _transformYawPitchInv;
  38959. private _firstFrameSkipped;
  38960. private _yawRange;
  38961. private _fowardAxis;
  38962. /**
  38963. * Gets or sets the minimum yaw angle that the bone can look to
  38964. */
  38965. minYaw: number;
  38966. /**
  38967. * Gets or sets the maximum yaw angle that the bone can look to
  38968. */
  38969. maxYaw: number;
  38970. /**
  38971. * Gets or sets the minimum pitch angle that the bone can look to
  38972. */
  38973. minPitch: number;
  38974. /**
  38975. * Gets or sets the maximum pitch angle that the bone can look to
  38976. */
  38977. maxPitch: number;
  38978. /**
  38979. * Create a BoneLookController
  38980. * @param mesh the mesh that the bone belongs to
  38981. * @param bone the bone that will be looking to the target
  38982. * @param target the target Vector3 to look at
  38983. * @param options optional settings:
  38984. * * maxYaw: the maximum angle the bone will yaw to
  38985. * * minYaw: the minimum angle the bone will yaw to
  38986. * * maxPitch: the maximum angle the bone will pitch to
  38987. * * minPitch: the minimum angle the bone will yaw to
  38988. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38989. * * upAxis: the up axis of the coordinate system
  38990. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38991. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38992. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38993. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38994. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38995. * * adjustRoll: used to make an adjustment to the roll of the bone
  38996. **/
  38997. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38998. maxYaw?: number;
  38999. minYaw?: number;
  39000. maxPitch?: number;
  39001. minPitch?: number;
  39002. slerpAmount?: number;
  39003. upAxis?: Vector3;
  39004. upAxisSpace?: Space;
  39005. yawAxis?: Vector3;
  39006. pitchAxis?: Vector3;
  39007. adjustYaw?: number;
  39008. adjustPitch?: number;
  39009. adjustRoll?: number;
  39010. });
  39011. /**
  39012. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39013. */
  39014. update(): void;
  39015. private _getAngleDiff;
  39016. private _getAngleBetween;
  39017. private _isAngleBetween;
  39018. }
  39019. }
  39020. declare module "babylonjs/Bones/index" {
  39021. export * from "babylonjs/Bones/bone";
  39022. export * from "babylonjs/Bones/boneIKController";
  39023. export * from "babylonjs/Bones/boneLookController";
  39024. export * from "babylonjs/Bones/skeleton";
  39025. }
  39026. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  39027. import { Nullable } from "babylonjs/types";
  39028. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39029. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39030. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39031. /**
  39032. * Manage the gamepad inputs to control an arc rotate camera.
  39033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39034. */
  39035. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39036. /**
  39037. * Defines the camera the input is attached to.
  39038. */
  39039. camera: ArcRotateCamera;
  39040. /**
  39041. * Defines the gamepad the input is gathering event from.
  39042. */
  39043. gamepad: Nullable<Gamepad>;
  39044. /**
  39045. * Defines the gamepad rotation sensiblity.
  39046. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39047. */
  39048. gamepadRotationSensibility: number;
  39049. /**
  39050. * Defines the gamepad move sensiblity.
  39051. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39052. */
  39053. gamepadMoveSensibility: number;
  39054. private _yAxisScale;
  39055. /**
  39056. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39057. */
  39058. invertYAxis: boolean;
  39059. private _onGamepadConnectedObserver;
  39060. private _onGamepadDisconnectedObserver;
  39061. /**
  39062. * Attach the input controls to a specific dom element to get the input from.
  39063. * @param element Defines the element the controls should be listened from
  39064. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39065. */
  39066. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39067. /**
  39068. * Detach the current controls from the specified dom element.
  39069. * @param element Defines the element to stop listening the inputs from
  39070. */
  39071. detachControl(element: Nullable<HTMLElement>): void;
  39072. /**
  39073. * Update the current camera state depending on the inputs that have been used this frame.
  39074. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39075. */
  39076. checkInputs(): void;
  39077. /**
  39078. * Gets the class name of the current intput.
  39079. * @returns the class name
  39080. */
  39081. getClassName(): string;
  39082. /**
  39083. * Get the friendly name associated with the input class.
  39084. * @returns the input friendly name
  39085. */
  39086. getSimpleName(): string;
  39087. }
  39088. }
  39089. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  39090. import { Nullable } from "babylonjs/types";
  39091. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39092. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39093. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39094. interface ArcRotateCameraInputsManager {
  39095. /**
  39096. * Add orientation input support to the input manager.
  39097. * @returns the current input manager
  39098. */
  39099. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39100. }
  39101. }
  39102. /**
  39103. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39105. */
  39106. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39107. /**
  39108. * Defines the camera the input is attached to.
  39109. */
  39110. camera: ArcRotateCamera;
  39111. /**
  39112. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39113. */
  39114. alphaCorrection: number;
  39115. /**
  39116. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39117. */
  39118. gammaCorrection: number;
  39119. private _alpha;
  39120. private _gamma;
  39121. private _dirty;
  39122. private _deviceOrientationHandler;
  39123. /**
  39124. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39125. */
  39126. constructor();
  39127. /**
  39128. * Attach the input controls to a specific dom element to get the input from.
  39129. * @param element Defines the element the controls should be listened from
  39130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39131. */
  39132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39133. /** @hidden */
  39134. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39135. /**
  39136. * Update the current camera state depending on the inputs that have been used this frame.
  39137. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39138. */
  39139. checkInputs(): void;
  39140. /**
  39141. * Detach the current controls from the specified dom element.
  39142. * @param element Defines the element to stop listening the inputs from
  39143. */
  39144. detachControl(element: Nullable<HTMLElement>): void;
  39145. /**
  39146. * Gets the class name of the current intput.
  39147. * @returns the class name
  39148. */
  39149. getClassName(): string;
  39150. /**
  39151. * Get the friendly name associated with the input class.
  39152. * @returns the input friendly name
  39153. */
  39154. getSimpleName(): string;
  39155. }
  39156. }
  39157. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  39158. import { Nullable } from "babylonjs/types";
  39159. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39160. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39161. /**
  39162. * Listen to mouse events to control the camera.
  39163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39164. */
  39165. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39166. /**
  39167. * Defines the camera the input is attached to.
  39168. */
  39169. camera: FlyCamera;
  39170. /**
  39171. * Defines if touch is enabled. (Default is true.)
  39172. */
  39173. touchEnabled: boolean;
  39174. /**
  39175. * Defines the buttons associated with the input to handle camera rotation.
  39176. */
  39177. buttons: number[];
  39178. /**
  39179. * Assign buttons for Yaw control.
  39180. */
  39181. buttonsYaw: number[];
  39182. /**
  39183. * Assign buttons for Pitch control.
  39184. */
  39185. buttonsPitch: number[];
  39186. /**
  39187. * Assign buttons for Roll control.
  39188. */
  39189. buttonsRoll: number[];
  39190. /**
  39191. * Detect if any button is being pressed while mouse is moved.
  39192. * -1 = Mouse locked.
  39193. * 0 = Left button.
  39194. * 1 = Middle Button.
  39195. * 2 = Right Button.
  39196. */
  39197. activeButton: number;
  39198. /**
  39199. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39200. * Higher values reduce its sensitivity.
  39201. */
  39202. angularSensibility: number;
  39203. private _mousemoveCallback;
  39204. private _observer;
  39205. private _rollObserver;
  39206. private previousPosition;
  39207. private noPreventDefault;
  39208. private element;
  39209. /**
  39210. * Listen to mouse events to control the camera.
  39211. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39212. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39213. */
  39214. constructor(touchEnabled?: boolean);
  39215. /**
  39216. * Attach the mouse control to the HTML DOM element.
  39217. * @param element Defines the element that listens to the input events.
  39218. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39219. */
  39220. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39221. /**
  39222. * Detach the current controls from the specified dom element.
  39223. * @param element Defines the element to stop listening the inputs from
  39224. */
  39225. detachControl(element: Nullable<HTMLElement>): void;
  39226. /**
  39227. * Gets the class name of the current input.
  39228. * @returns the class name.
  39229. */
  39230. getClassName(): string;
  39231. /**
  39232. * Get the friendly name associated with the input class.
  39233. * @returns the input's friendly name.
  39234. */
  39235. getSimpleName(): string;
  39236. private _pointerInput;
  39237. private _onMouseMove;
  39238. /**
  39239. * Rotate camera by mouse offset.
  39240. */
  39241. private rotateCamera;
  39242. }
  39243. }
  39244. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  39245. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39246. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39247. /**
  39248. * Default Inputs manager for the FlyCamera.
  39249. * It groups all the default supported inputs for ease of use.
  39250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39251. */
  39252. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39253. /**
  39254. * Instantiates a new FlyCameraInputsManager.
  39255. * @param camera Defines the camera the inputs belong to.
  39256. */
  39257. constructor(camera: FlyCamera);
  39258. /**
  39259. * Add keyboard input support to the input manager.
  39260. * @returns the new FlyCameraKeyboardMoveInput().
  39261. */
  39262. addKeyboard(): FlyCameraInputsManager;
  39263. /**
  39264. * Add mouse input support to the input manager.
  39265. * @param touchEnabled Enable touch screen support.
  39266. * @returns the new FlyCameraMouseInput().
  39267. */
  39268. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39269. }
  39270. }
  39271. declare module "babylonjs/Cameras/flyCamera" {
  39272. import { Scene } from "babylonjs/scene";
  39273. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  39274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39275. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39276. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  39277. /**
  39278. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39279. * such as in a 3D Space Shooter or a Flight Simulator.
  39280. */
  39281. export class FlyCamera extends TargetCamera {
  39282. /**
  39283. * Define the collision ellipsoid of the camera.
  39284. * This is helpful for simulating a camera body, like a player's body.
  39285. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39286. */
  39287. ellipsoid: Vector3;
  39288. /**
  39289. * Define an offset for the position of the ellipsoid around the camera.
  39290. * This can be helpful if the camera is attached away from the player's body center,
  39291. * such as at its head.
  39292. */
  39293. ellipsoidOffset: Vector3;
  39294. /**
  39295. * Enable or disable collisions of the camera with the rest of the scene objects.
  39296. */
  39297. checkCollisions: boolean;
  39298. /**
  39299. * Enable or disable gravity on the camera.
  39300. */
  39301. applyGravity: boolean;
  39302. /**
  39303. * Define the current direction the camera is moving to.
  39304. */
  39305. cameraDirection: Vector3;
  39306. /**
  39307. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39308. * This overrides and empties cameraRotation.
  39309. */
  39310. rotationQuaternion: Quaternion;
  39311. /**
  39312. * Track Roll to maintain the wanted Rolling when looking around.
  39313. */
  39314. _trackRoll: number;
  39315. /**
  39316. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39317. */
  39318. rollCorrect: number;
  39319. /**
  39320. * Mimic a banked turn, Rolling the camera when Yawing.
  39321. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39322. */
  39323. bankedTurn: boolean;
  39324. /**
  39325. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39326. */
  39327. bankedTurnLimit: number;
  39328. /**
  39329. * Value of 0 disables the banked Roll.
  39330. * Value of 1 is equal to the Yaw angle in radians.
  39331. */
  39332. bankedTurnMultiplier: number;
  39333. /**
  39334. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39335. */
  39336. inputs: FlyCameraInputsManager;
  39337. /**
  39338. * Gets the input sensibility for mouse input.
  39339. * Higher values reduce sensitivity.
  39340. */
  39341. /**
  39342. * Sets the input sensibility for a mouse input.
  39343. * Higher values reduce sensitivity.
  39344. */
  39345. angularSensibility: number;
  39346. /**
  39347. * Get the keys for camera movement forward.
  39348. */
  39349. /**
  39350. * Set the keys for camera movement forward.
  39351. */
  39352. keysForward: number[];
  39353. /**
  39354. * Get the keys for camera movement backward.
  39355. */
  39356. keysBackward: number[];
  39357. /**
  39358. * Get the keys for camera movement up.
  39359. */
  39360. /**
  39361. * Set the keys for camera movement up.
  39362. */
  39363. keysUp: number[];
  39364. /**
  39365. * Get the keys for camera movement down.
  39366. */
  39367. /**
  39368. * Set the keys for camera movement down.
  39369. */
  39370. keysDown: number[];
  39371. /**
  39372. * Get the keys for camera movement left.
  39373. */
  39374. /**
  39375. * Set the keys for camera movement left.
  39376. */
  39377. keysLeft: number[];
  39378. /**
  39379. * Set the keys for camera movement right.
  39380. */
  39381. /**
  39382. * Set the keys for camera movement right.
  39383. */
  39384. keysRight: number[];
  39385. /**
  39386. * Event raised when the camera collides with a mesh in the scene.
  39387. */
  39388. onCollide: (collidedMesh: AbstractMesh) => void;
  39389. private _collider;
  39390. private _needMoveForGravity;
  39391. private _oldPosition;
  39392. private _diffPosition;
  39393. private _newPosition;
  39394. /** @hidden */
  39395. _localDirection: Vector3;
  39396. /** @hidden */
  39397. _transformedDirection: Vector3;
  39398. /**
  39399. * Instantiates a FlyCamera.
  39400. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39401. * such as in a 3D Space Shooter or a Flight Simulator.
  39402. * @param name Define the name of the camera in the scene.
  39403. * @param position Define the starting position of the camera in the scene.
  39404. * @param scene Define the scene the camera belongs to.
  39405. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39406. */
  39407. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39408. /**
  39409. * Attach a control to the HTML DOM element.
  39410. * @param element Defines the element that listens to the input events.
  39411. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39412. */
  39413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39414. /**
  39415. * Detach a control from the HTML DOM element.
  39416. * The camera will stop reacting to that input.
  39417. * @param element Defines the element that listens to the input events.
  39418. */
  39419. detachControl(element: HTMLElement): void;
  39420. private _collisionMask;
  39421. /**
  39422. * Get the mask that the camera ignores in collision events.
  39423. */
  39424. /**
  39425. * Set the mask that the camera ignores in collision events.
  39426. */
  39427. collisionMask: number;
  39428. /** @hidden */
  39429. _collideWithWorld(displacement: Vector3): void;
  39430. /** @hidden */
  39431. private _onCollisionPositionChange;
  39432. /** @hidden */
  39433. _checkInputs(): void;
  39434. /** @hidden */
  39435. _decideIfNeedsToMove(): boolean;
  39436. /** @hidden */
  39437. _updatePosition(): void;
  39438. /**
  39439. * Restore the Roll to its target value at the rate specified.
  39440. * @param rate - Higher means slower restoring.
  39441. * @hidden
  39442. */
  39443. restoreRoll(rate: number): void;
  39444. /**
  39445. * Destroy the camera and release the current resources held by it.
  39446. */
  39447. dispose(): void;
  39448. /**
  39449. * Get the current object class name.
  39450. * @returns the class name.
  39451. */
  39452. getClassName(): string;
  39453. }
  39454. }
  39455. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  39456. import { Nullable } from "babylonjs/types";
  39457. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39458. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39459. /**
  39460. * Listen to keyboard events to control the camera.
  39461. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39462. */
  39463. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39464. /**
  39465. * Defines the camera the input is attached to.
  39466. */
  39467. camera: FlyCamera;
  39468. /**
  39469. * The list of keyboard keys used to control the forward move of the camera.
  39470. */
  39471. keysForward: number[];
  39472. /**
  39473. * The list of keyboard keys used to control the backward move of the camera.
  39474. */
  39475. keysBackward: number[];
  39476. /**
  39477. * The list of keyboard keys used to control the forward move of the camera.
  39478. */
  39479. keysUp: number[];
  39480. /**
  39481. * The list of keyboard keys used to control the backward move of the camera.
  39482. */
  39483. keysDown: number[];
  39484. /**
  39485. * The list of keyboard keys used to control the right strafe move of the camera.
  39486. */
  39487. keysRight: number[];
  39488. /**
  39489. * The list of keyboard keys used to control the left strafe move of the camera.
  39490. */
  39491. keysLeft: number[];
  39492. private _keys;
  39493. private _onCanvasBlurObserver;
  39494. private _onKeyboardObserver;
  39495. private _engine;
  39496. private _scene;
  39497. /**
  39498. * Attach the input controls to a specific dom element to get the input from.
  39499. * @param element Defines the element the controls should be listened from
  39500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39501. */
  39502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39503. /**
  39504. * Detach the current controls from the specified dom element.
  39505. * @param element Defines the element to stop listening the inputs from
  39506. */
  39507. detachControl(element: Nullable<HTMLElement>): void;
  39508. /**
  39509. * Gets the class name of the current intput.
  39510. * @returns the class name
  39511. */
  39512. getClassName(): string;
  39513. /** @hidden */
  39514. _onLostFocus(e: FocusEvent): void;
  39515. /**
  39516. * Get the friendly name associated with the input class.
  39517. * @returns the input friendly name
  39518. */
  39519. getSimpleName(): string;
  39520. /**
  39521. * Update the current camera state depending on the inputs that have been used this frame.
  39522. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39523. */
  39524. checkInputs(): void;
  39525. }
  39526. }
  39527. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39528. import { Nullable } from "babylonjs/types";
  39529. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39530. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39531. /**
  39532. * Manage the mouse wheel inputs to control a follow camera.
  39533. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39534. */
  39535. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39536. /**
  39537. * Defines the camera the input is attached to.
  39538. */
  39539. camera: FollowCamera;
  39540. /**
  39541. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39542. */
  39543. axisControlRadius: boolean;
  39544. /**
  39545. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39546. */
  39547. axisControlHeight: boolean;
  39548. /**
  39549. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39550. */
  39551. axisControlRotation: boolean;
  39552. /**
  39553. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39554. * relation to mouseWheel events.
  39555. */
  39556. wheelPrecision: number;
  39557. /**
  39558. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39559. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39560. */
  39561. wheelDeltaPercentage: number;
  39562. private _wheel;
  39563. private _observer;
  39564. /**
  39565. * Attach the input controls to a specific dom element to get the input from.
  39566. * @param element Defines the element the controls should be listened from
  39567. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39568. */
  39569. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39570. /**
  39571. * Detach the current controls from the specified dom element.
  39572. * @param element Defines the element to stop listening the inputs from
  39573. */
  39574. detachControl(element: Nullable<HTMLElement>): void;
  39575. /**
  39576. * Gets the class name of the current intput.
  39577. * @returns the class name
  39578. */
  39579. getClassName(): string;
  39580. /**
  39581. * Get the friendly name associated with the input class.
  39582. * @returns the input friendly name
  39583. */
  39584. getSimpleName(): string;
  39585. }
  39586. }
  39587. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39588. import { Nullable } from "babylonjs/types";
  39589. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39590. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39591. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39592. /**
  39593. * Manage the pointers inputs to control an follow camera.
  39594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39595. */
  39596. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39597. /**
  39598. * Defines the camera the input is attached to.
  39599. */
  39600. camera: FollowCamera;
  39601. /**
  39602. * Gets the class name of the current input.
  39603. * @returns the class name
  39604. */
  39605. getClassName(): string;
  39606. /**
  39607. * Defines the pointer angular sensibility along the X axis or how fast is
  39608. * the camera rotating.
  39609. * A negative number will reverse the axis direction.
  39610. */
  39611. angularSensibilityX: number;
  39612. /**
  39613. * Defines the pointer angular sensibility along the Y axis or how fast is
  39614. * the camera rotating.
  39615. * A negative number will reverse the axis direction.
  39616. */
  39617. angularSensibilityY: number;
  39618. /**
  39619. * Defines the pointer pinch precision or how fast is the camera zooming.
  39620. * A negative number will reverse the axis direction.
  39621. */
  39622. pinchPrecision: number;
  39623. /**
  39624. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39625. * from 0.
  39626. * It defines the percentage of current camera.radius to use as delta when
  39627. * pinch zoom is used.
  39628. */
  39629. pinchDeltaPercentage: number;
  39630. /**
  39631. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39632. */
  39633. axisXControlRadius: boolean;
  39634. /**
  39635. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39636. */
  39637. axisXControlHeight: boolean;
  39638. /**
  39639. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39640. */
  39641. axisXControlRotation: boolean;
  39642. /**
  39643. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39644. */
  39645. axisYControlRadius: boolean;
  39646. /**
  39647. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39648. */
  39649. axisYControlHeight: boolean;
  39650. /**
  39651. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39652. */
  39653. axisYControlRotation: boolean;
  39654. /**
  39655. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39656. */
  39657. axisPinchControlRadius: boolean;
  39658. /**
  39659. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39660. */
  39661. axisPinchControlHeight: boolean;
  39662. /**
  39663. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39664. */
  39665. axisPinchControlRotation: boolean;
  39666. /**
  39667. * Log error messages if basic misconfiguration has occurred.
  39668. */
  39669. warningEnable: boolean;
  39670. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39671. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39672. private _warningCounter;
  39673. private _warning;
  39674. }
  39675. }
  39676. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39677. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39678. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39679. /**
  39680. * Default Inputs manager for the FollowCamera.
  39681. * It groups all the default supported inputs for ease of use.
  39682. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39683. */
  39684. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39685. /**
  39686. * Instantiates a new FollowCameraInputsManager.
  39687. * @param camera Defines the camera the inputs belong to
  39688. */
  39689. constructor(camera: FollowCamera);
  39690. /**
  39691. * Add keyboard input support to the input manager.
  39692. * @returns the current input manager
  39693. */
  39694. addKeyboard(): FollowCameraInputsManager;
  39695. /**
  39696. * Add mouse wheel input support to the input manager.
  39697. * @returns the current input manager
  39698. */
  39699. addMouseWheel(): FollowCameraInputsManager;
  39700. /**
  39701. * Add pointers input support to the input manager.
  39702. * @returns the current input manager
  39703. */
  39704. addPointers(): FollowCameraInputsManager;
  39705. /**
  39706. * Add orientation input support to the input manager.
  39707. * @returns the current input manager
  39708. */
  39709. addVRDeviceOrientation(): FollowCameraInputsManager;
  39710. }
  39711. }
  39712. declare module "babylonjs/Cameras/followCamera" {
  39713. import { Nullable } from "babylonjs/types";
  39714. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39715. import { Scene } from "babylonjs/scene";
  39716. import { Vector3 } from "babylonjs/Maths/math.vector";
  39717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39718. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39719. /**
  39720. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39721. * an arc rotate version arcFollowCamera are available.
  39722. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39723. */
  39724. export class FollowCamera extends TargetCamera {
  39725. /**
  39726. * Distance the follow camera should follow an object at
  39727. */
  39728. radius: number;
  39729. /**
  39730. * Minimum allowed distance of the camera to the axis of rotation
  39731. * (The camera can not get closer).
  39732. * This can help limiting how the Camera is able to move in the scene.
  39733. */
  39734. lowerRadiusLimit: Nullable<number>;
  39735. /**
  39736. * Maximum allowed distance of the camera to the axis of rotation
  39737. * (The camera can not get further).
  39738. * This can help limiting how the Camera is able to move in the scene.
  39739. */
  39740. upperRadiusLimit: Nullable<number>;
  39741. /**
  39742. * Define a rotation offset between the camera and the object it follows
  39743. */
  39744. rotationOffset: number;
  39745. /**
  39746. * Minimum allowed angle to camera position relative to target object.
  39747. * This can help limiting how the Camera is able to move in the scene.
  39748. */
  39749. lowerRotationOffsetLimit: Nullable<number>;
  39750. /**
  39751. * Maximum allowed angle to camera position relative to target object.
  39752. * This can help limiting how the Camera is able to move in the scene.
  39753. */
  39754. upperRotationOffsetLimit: Nullable<number>;
  39755. /**
  39756. * Define a height offset between the camera and the object it follows.
  39757. * It can help following an object from the top (like a car chaing a plane)
  39758. */
  39759. heightOffset: number;
  39760. /**
  39761. * Minimum allowed height of camera position relative to target object.
  39762. * This can help limiting how the Camera is able to move in the scene.
  39763. */
  39764. lowerHeightOffsetLimit: Nullable<number>;
  39765. /**
  39766. * Maximum allowed height of camera position relative to target object.
  39767. * This can help limiting how the Camera is able to move in the scene.
  39768. */
  39769. upperHeightOffsetLimit: Nullable<number>;
  39770. /**
  39771. * Define how fast the camera can accelerate to follow it s target.
  39772. */
  39773. cameraAcceleration: number;
  39774. /**
  39775. * Define the speed limit of the camera following an object.
  39776. */
  39777. maxCameraSpeed: number;
  39778. /**
  39779. * Define the target of the camera.
  39780. */
  39781. lockedTarget: Nullable<AbstractMesh>;
  39782. /**
  39783. * Defines the input associated with the camera.
  39784. */
  39785. inputs: FollowCameraInputsManager;
  39786. /**
  39787. * Instantiates the follow camera.
  39788. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39789. * @param name Define the name of the camera in the scene
  39790. * @param position Define the position of the camera
  39791. * @param scene Define the scene the camera belong to
  39792. * @param lockedTarget Define the target of the camera
  39793. */
  39794. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39795. private _follow;
  39796. /**
  39797. * Attached controls to the current camera.
  39798. * @param element Defines the element the controls should be listened from
  39799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39800. */
  39801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39802. /**
  39803. * Detach the current controls from the camera.
  39804. * The camera will stop reacting to inputs.
  39805. * @param element Defines the element to stop listening the inputs from
  39806. */
  39807. detachControl(element: HTMLElement): void;
  39808. /** @hidden */
  39809. _checkInputs(): void;
  39810. private _checkLimits;
  39811. /**
  39812. * Gets the camera class name.
  39813. * @returns the class name
  39814. */
  39815. getClassName(): string;
  39816. }
  39817. /**
  39818. * Arc Rotate version of the follow camera.
  39819. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39820. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39821. */
  39822. export class ArcFollowCamera extends TargetCamera {
  39823. /** The longitudinal angle of the camera */
  39824. alpha: number;
  39825. /** The latitudinal angle of the camera */
  39826. beta: number;
  39827. /** The radius of the camera from its target */
  39828. radius: number;
  39829. /** Define the camera target (the messh it should follow) */
  39830. target: Nullable<AbstractMesh>;
  39831. private _cartesianCoordinates;
  39832. /**
  39833. * Instantiates a new ArcFollowCamera
  39834. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39835. * @param name Define the name of the camera
  39836. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39837. * @param beta Define the rotation angle of the camera around the elevation axis
  39838. * @param radius Define the radius of the camera from its target point
  39839. * @param target Define the target of the camera
  39840. * @param scene Define the scene the camera belongs to
  39841. */
  39842. constructor(name: string,
  39843. /** The longitudinal angle of the camera */
  39844. alpha: number,
  39845. /** The latitudinal angle of the camera */
  39846. beta: number,
  39847. /** The radius of the camera from its target */
  39848. radius: number,
  39849. /** Define the camera target (the messh it should follow) */
  39850. target: Nullable<AbstractMesh>, scene: Scene);
  39851. private _follow;
  39852. /** @hidden */
  39853. _checkInputs(): void;
  39854. /**
  39855. * Returns the class name of the object.
  39856. * It is mostly used internally for serialization purposes.
  39857. */
  39858. getClassName(): string;
  39859. }
  39860. }
  39861. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39862. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39863. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39864. import { Nullable } from "babylonjs/types";
  39865. /**
  39866. * Manage the keyboard inputs to control the movement of a follow camera.
  39867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39868. */
  39869. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39870. /**
  39871. * Defines the camera the input is attached to.
  39872. */
  39873. camera: FollowCamera;
  39874. /**
  39875. * Defines the list of key codes associated with the up action (increase heightOffset)
  39876. */
  39877. keysHeightOffsetIncr: number[];
  39878. /**
  39879. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39880. */
  39881. keysHeightOffsetDecr: number[];
  39882. /**
  39883. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39884. */
  39885. keysHeightOffsetModifierAlt: boolean;
  39886. /**
  39887. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39888. */
  39889. keysHeightOffsetModifierCtrl: boolean;
  39890. /**
  39891. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39892. */
  39893. keysHeightOffsetModifierShift: boolean;
  39894. /**
  39895. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39896. */
  39897. keysRotationOffsetIncr: number[];
  39898. /**
  39899. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39900. */
  39901. keysRotationOffsetDecr: number[];
  39902. /**
  39903. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39904. */
  39905. keysRotationOffsetModifierAlt: boolean;
  39906. /**
  39907. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39908. */
  39909. keysRotationOffsetModifierCtrl: boolean;
  39910. /**
  39911. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39912. */
  39913. keysRotationOffsetModifierShift: boolean;
  39914. /**
  39915. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39916. */
  39917. keysRadiusIncr: number[];
  39918. /**
  39919. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39920. */
  39921. keysRadiusDecr: number[];
  39922. /**
  39923. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39924. */
  39925. keysRadiusModifierAlt: boolean;
  39926. /**
  39927. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39928. */
  39929. keysRadiusModifierCtrl: boolean;
  39930. /**
  39931. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39932. */
  39933. keysRadiusModifierShift: boolean;
  39934. /**
  39935. * Defines the rate of change of heightOffset.
  39936. */
  39937. heightSensibility: number;
  39938. /**
  39939. * Defines the rate of change of rotationOffset.
  39940. */
  39941. rotationSensibility: number;
  39942. /**
  39943. * Defines the rate of change of radius.
  39944. */
  39945. radiusSensibility: number;
  39946. private _keys;
  39947. private _ctrlPressed;
  39948. private _altPressed;
  39949. private _shiftPressed;
  39950. private _onCanvasBlurObserver;
  39951. private _onKeyboardObserver;
  39952. private _engine;
  39953. private _scene;
  39954. /**
  39955. * Attach the input controls to a specific dom element to get the input from.
  39956. * @param element Defines the element the controls should be listened from
  39957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39958. */
  39959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39960. /**
  39961. * Detach the current controls from the specified dom element.
  39962. * @param element Defines the element to stop listening the inputs from
  39963. */
  39964. detachControl(element: Nullable<HTMLElement>): void;
  39965. /**
  39966. * Update the current camera state depending on the inputs that have been used this frame.
  39967. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39968. */
  39969. checkInputs(): void;
  39970. /**
  39971. * Gets the class name of the current input.
  39972. * @returns the class name
  39973. */
  39974. getClassName(): string;
  39975. /**
  39976. * Get the friendly name associated with the input class.
  39977. * @returns the input friendly name
  39978. */
  39979. getSimpleName(): string;
  39980. /**
  39981. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39982. * allow modification of the heightOffset value.
  39983. */
  39984. private _modifierHeightOffset;
  39985. /**
  39986. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39987. * allow modification of the rotationOffset value.
  39988. */
  39989. private _modifierRotationOffset;
  39990. /**
  39991. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39992. * allow modification of the radius value.
  39993. */
  39994. private _modifierRadius;
  39995. }
  39996. }
  39997. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39998. import { Nullable } from "babylonjs/types";
  39999. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40000. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40001. import { Observable } from "babylonjs/Misc/observable";
  40002. module "babylonjs/Cameras/freeCameraInputsManager" {
  40003. interface FreeCameraInputsManager {
  40004. /**
  40005. * @hidden
  40006. */
  40007. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40008. /**
  40009. * Add orientation input support to the input manager.
  40010. * @returns the current input manager
  40011. */
  40012. addDeviceOrientation(): FreeCameraInputsManager;
  40013. }
  40014. }
  40015. /**
  40016. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40017. * Screen rotation is taken into account.
  40018. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40019. */
  40020. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40021. private _camera;
  40022. private _screenOrientationAngle;
  40023. private _constantTranform;
  40024. private _screenQuaternion;
  40025. private _alpha;
  40026. private _beta;
  40027. private _gamma;
  40028. /**
  40029. * Can be used to detect if a device orientation sensor is availible on a device
  40030. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40031. * @returns a promise that will resolve on orientation change
  40032. */
  40033. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40034. /**
  40035. * @hidden
  40036. */
  40037. _onDeviceOrientationChangedObservable: Observable<void>;
  40038. /**
  40039. * Instantiates a new input
  40040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40041. */
  40042. constructor();
  40043. /**
  40044. * Define the camera controlled by the input.
  40045. */
  40046. camera: FreeCamera;
  40047. /**
  40048. * Attach the input controls to a specific dom element to get the input from.
  40049. * @param element Defines the element the controls should be listened from
  40050. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40051. */
  40052. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40053. private _orientationChanged;
  40054. private _deviceOrientation;
  40055. /**
  40056. * Detach the current controls from the specified dom element.
  40057. * @param element Defines the element to stop listening the inputs from
  40058. */
  40059. detachControl(element: Nullable<HTMLElement>): void;
  40060. /**
  40061. * Update the current camera state depending on the inputs that have been used this frame.
  40062. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40063. */
  40064. checkInputs(): void;
  40065. /**
  40066. * Gets the class name of the current intput.
  40067. * @returns the class name
  40068. */
  40069. getClassName(): string;
  40070. /**
  40071. * Get the friendly name associated with the input class.
  40072. * @returns the input friendly name
  40073. */
  40074. getSimpleName(): string;
  40075. }
  40076. }
  40077. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  40078. import { Nullable } from "babylonjs/types";
  40079. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40080. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40081. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40082. /**
  40083. * Manage the gamepad inputs to control a free camera.
  40084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40085. */
  40086. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40087. /**
  40088. * Define the camera the input is attached to.
  40089. */
  40090. camera: FreeCamera;
  40091. /**
  40092. * Define the Gamepad controlling the input
  40093. */
  40094. gamepad: Nullable<Gamepad>;
  40095. /**
  40096. * Defines the gamepad rotation sensiblity.
  40097. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40098. */
  40099. gamepadAngularSensibility: number;
  40100. /**
  40101. * Defines the gamepad move sensiblity.
  40102. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40103. */
  40104. gamepadMoveSensibility: number;
  40105. private _yAxisScale;
  40106. /**
  40107. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40108. */
  40109. invertYAxis: boolean;
  40110. private _onGamepadConnectedObserver;
  40111. private _onGamepadDisconnectedObserver;
  40112. private _cameraTransform;
  40113. private _deltaTransform;
  40114. private _vector3;
  40115. private _vector2;
  40116. /**
  40117. * Attach the input controls to a specific dom element to get the input from.
  40118. * @param element Defines the element the controls should be listened from
  40119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40120. */
  40121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40122. /**
  40123. * Detach the current controls from the specified dom element.
  40124. * @param element Defines the element to stop listening the inputs from
  40125. */
  40126. detachControl(element: Nullable<HTMLElement>): void;
  40127. /**
  40128. * Update the current camera state depending on the inputs that have been used this frame.
  40129. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40130. */
  40131. checkInputs(): void;
  40132. /**
  40133. * Gets the class name of the current intput.
  40134. * @returns the class name
  40135. */
  40136. getClassName(): string;
  40137. /**
  40138. * Get the friendly name associated with the input class.
  40139. * @returns the input friendly name
  40140. */
  40141. getSimpleName(): string;
  40142. }
  40143. }
  40144. declare module "babylonjs/Misc/virtualJoystick" {
  40145. import { Nullable } from "babylonjs/types";
  40146. import { Vector3 } from "babylonjs/Maths/math.vector";
  40147. /**
  40148. * Defines the potential axis of a Joystick
  40149. */
  40150. export enum JoystickAxis {
  40151. /** X axis */
  40152. X = 0,
  40153. /** Y axis */
  40154. Y = 1,
  40155. /** Z axis */
  40156. Z = 2
  40157. }
  40158. /**
  40159. * Class used to define virtual joystick (used in touch mode)
  40160. */
  40161. export class VirtualJoystick {
  40162. /**
  40163. * Gets or sets a boolean indicating that left and right values must be inverted
  40164. */
  40165. reverseLeftRight: boolean;
  40166. /**
  40167. * Gets or sets a boolean indicating that up and down values must be inverted
  40168. */
  40169. reverseUpDown: boolean;
  40170. /**
  40171. * Gets the offset value for the position (ie. the change of the position value)
  40172. */
  40173. deltaPosition: Vector3;
  40174. /**
  40175. * Gets a boolean indicating if the virtual joystick was pressed
  40176. */
  40177. pressed: boolean;
  40178. /**
  40179. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40180. */
  40181. static Canvas: Nullable<HTMLCanvasElement>;
  40182. private static _globalJoystickIndex;
  40183. private static vjCanvasContext;
  40184. private static vjCanvasWidth;
  40185. private static vjCanvasHeight;
  40186. private static halfWidth;
  40187. private _action;
  40188. private _axisTargetedByLeftAndRight;
  40189. private _axisTargetedByUpAndDown;
  40190. private _joystickSensibility;
  40191. private _inversedSensibility;
  40192. private _joystickPointerID;
  40193. private _joystickColor;
  40194. private _joystickPointerPos;
  40195. private _joystickPreviousPointerPos;
  40196. private _joystickPointerStartPos;
  40197. private _deltaJoystickVector;
  40198. private _leftJoystick;
  40199. private _touches;
  40200. private _onPointerDownHandlerRef;
  40201. private _onPointerMoveHandlerRef;
  40202. private _onPointerUpHandlerRef;
  40203. private _onResize;
  40204. /**
  40205. * Creates a new virtual joystick
  40206. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40207. */
  40208. constructor(leftJoystick?: boolean);
  40209. /**
  40210. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40211. * @param newJoystickSensibility defines the new sensibility
  40212. */
  40213. setJoystickSensibility(newJoystickSensibility: number): void;
  40214. private _onPointerDown;
  40215. private _onPointerMove;
  40216. private _onPointerUp;
  40217. /**
  40218. * Change the color of the virtual joystick
  40219. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40220. */
  40221. setJoystickColor(newColor: string): void;
  40222. /**
  40223. * Defines a callback to call when the joystick is touched
  40224. * @param action defines the callback
  40225. */
  40226. setActionOnTouch(action: () => any): void;
  40227. /**
  40228. * Defines which axis you'd like to control for left & right
  40229. * @param axis defines the axis to use
  40230. */
  40231. setAxisForLeftRight(axis: JoystickAxis): void;
  40232. /**
  40233. * Defines which axis you'd like to control for up & down
  40234. * @param axis defines the axis to use
  40235. */
  40236. setAxisForUpDown(axis: JoystickAxis): void;
  40237. private _drawVirtualJoystick;
  40238. /**
  40239. * Release internal HTML canvas
  40240. */
  40241. releaseCanvas(): void;
  40242. }
  40243. }
  40244. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  40245. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  40246. import { Nullable } from "babylonjs/types";
  40247. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40248. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40249. module "babylonjs/Cameras/freeCameraInputsManager" {
  40250. interface FreeCameraInputsManager {
  40251. /**
  40252. * Add virtual joystick input support to the input manager.
  40253. * @returns the current input manager
  40254. */
  40255. addVirtualJoystick(): FreeCameraInputsManager;
  40256. }
  40257. }
  40258. /**
  40259. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40260. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40261. */
  40262. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40263. /**
  40264. * Defines the camera the input is attached to.
  40265. */
  40266. camera: FreeCamera;
  40267. private _leftjoystick;
  40268. private _rightjoystick;
  40269. /**
  40270. * Gets the left stick of the virtual joystick.
  40271. * @returns The virtual Joystick
  40272. */
  40273. getLeftJoystick(): VirtualJoystick;
  40274. /**
  40275. * Gets the right stick of the virtual joystick.
  40276. * @returns The virtual Joystick
  40277. */
  40278. getRightJoystick(): VirtualJoystick;
  40279. /**
  40280. * Update the current camera state depending on the inputs that have been used this frame.
  40281. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40282. */
  40283. checkInputs(): void;
  40284. /**
  40285. * Attach the input controls to a specific dom element to get the input from.
  40286. * @param element Defines the element the controls should be listened from
  40287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40288. */
  40289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40290. /**
  40291. * Detach the current controls from the specified dom element.
  40292. * @param element Defines the element to stop listening the inputs from
  40293. */
  40294. detachControl(element: Nullable<HTMLElement>): void;
  40295. /**
  40296. * Gets the class name of the current intput.
  40297. * @returns the class name
  40298. */
  40299. getClassName(): string;
  40300. /**
  40301. * Get the friendly name associated with the input class.
  40302. * @returns the input friendly name
  40303. */
  40304. getSimpleName(): string;
  40305. }
  40306. }
  40307. declare module "babylonjs/Cameras/Inputs/index" {
  40308. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  40309. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  40310. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  40311. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  40312. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40313. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  40314. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  40315. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  40316. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  40317. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  40318. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40319. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  40320. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  40321. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  40322. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  40323. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40324. }
  40325. declare module "babylonjs/Cameras/touchCamera" {
  40326. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40327. import { Scene } from "babylonjs/scene";
  40328. import { Vector3 } from "babylonjs/Maths/math.vector";
  40329. /**
  40330. * This represents a FPS type of camera controlled by touch.
  40331. * This is like a universal camera minus the Gamepad controls.
  40332. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40333. */
  40334. export class TouchCamera extends FreeCamera {
  40335. /**
  40336. * Defines the touch sensibility for rotation.
  40337. * The higher the faster.
  40338. */
  40339. touchAngularSensibility: number;
  40340. /**
  40341. * Defines the touch sensibility for move.
  40342. * The higher the faster.
  40343. */
  40344. touchMoveSensibility: number;
  40345. /**
  40346. * Instantiates a new touch camera.
  40347. * This represents a FPS type of camera controlled by touch.
  40348. * This is like a universal camera minus the Gamepad controls.
  40349. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40350. * @param name Define the name of the camera in the scene
  40351. * @param position Define the start position of the camera in the scene
  40352. * @param scene Define the scene the camera belongs to
  40353. */
  40354. constructor(name: string, position: Vector3, scene: Scene);
  40355. /**
  40356. * Gets the current object class name.
  40357. * @return the class name
  40358. */
  40359. getClassName(): string;
  40360. /** @hidden */
  40361. _setupInputs(): void;
  40362. }
  40363. }
  40364. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  40365. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40366. import { Scene } from "babylonjs/scene";
  40367. import { Vector3 } from "babylonjs/Maths/math.vector";
  40368. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  40369. import { Axis } from "babylonjs/Maths/math.axis";
  40370. /**
  40371. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40372. * being tilted forward or back and left or right.
  40373. */
  40374. export class DeviceOrientationCamera extends FreeCamera {
  40375. private _initialQuaternion;
  40376. private _quaternionCache;
  40377. private _tmpDragQuaternion;
  40378. private _disablePointerInputWhenUsingDeviceOrientation;
  40379. /**
  40380. * Creates a new device orientation camera
  40381. * @param name The name of the camera
  40382. * @param position The start position camera
  40383. * @param scene The scene the camera belongs to
  40384. */
  40385. constructor(name: string, position: Vector3, scene: Scene);
  40386. /**
  40387. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40388. */
  40389. disablePointerInputWhenUsingDeviceOrientation: boolean;
  40390. private _dragFactor;
  40391. /**
  40392. * Enabled turning on the y axis when the orientation sensor is active
  40393. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40394. */
  40395. enableHorizontalDragging(dragFactor?: number): void;
  40396. /**
  40397. * Gets the current instance class name ("DeviceOrientationCamera").
  40398. * This helps avoiding instanceof at run time.
  40399. * @returns the class name
  40400. */
  40401. getClassName(): string;
  40402. /**
  40403. * @hidden
  40404. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40405. */
  40406. _checkInputs(): void;
  40407. /**
  40408. * Reset the camera to its default orientation on the specified axis only.
  40409. * @param axis The axis to reset
  40410. */
  40411. resetToCurrentRotation(axis?: Axis): void;
  40412. }
  40413. }
  40414. declare module "babylonjs/Gamepads/xboxGamepad" {
  40415. import { Observable } from "babylonjs/Misc/observable";
  40416. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40417. /**
  40418. * Defines supported buttons for XBox360 compatible gamepads
  40419. */
  40420. export enum Xbox360Button {
  40421. /** A */
  40422. A = 0,
  40423. /** B */
  40424. B = 1,
  40425. /** X */
  40426. X = 2,
  40427. /** Y */
  40428. Y = 3,
  40429. /** Start */
  40430. Start = 4,
  40431. /** Back */
  40432. Back = 5,
  40433. /** Left button */
  40434. LB = 6,
  40435. /** Right button */
  40436. RB = 7,
  40437. /** Left stick */
  40438. LeftStick = 8,
  40439. /** Right stick */
  40440. RightStick = 9
  40441. }
  40442. /** Defines values for XBox360 DPad */
  40443. export enum Xbox360Dpad {
  40444. /** Up */
  40445. Up = 0,
  40446. /** Down */
  40447. Down = 1,
  40448. /** Left */
  40449. Left = 2,
  40450. /** Right */
  40451. Right = 3
  40452. }
  40453. /**
  40454. * Defines a XBox360 gamepad
  40455. */
  40456. export class Xbox360Pad extends Gamepad {
  40457. private _leftTrigger;
  40458. private _rightTrigger;
  40459. private _onlefttriggerchanged;
  40460. private _onrighttriggerchanged;
  40461. private _onbuttondown;
  40462. private _onbuttonup;
  40463. private _ondpaddown;
  40464. private _ondpadup;
  40465. /** Observable raised when a button is pressed */
  40466. onButtonDownObservable: Observable<Xbox360Button>;
  40467. /** Observable raised when a button is released */
  40468. onButtonUpObservable: Observable<Xbox360Button>;
  40469. /** Observable raised when a pad is pressed */
  40470. onPadDownObservable: Observable<Xbox360Dpad>;
  40471. /** Observable raised when a pad is released */
  40472. onPadUpObservable: Observable<Xbox360Dpad>;
  40473. private _buttonA;
  40474. private _buttonB;
  40475. private _buttonX;
  40476. private _buttonY;
  40477. private _buttonBack;
  40478. private _buttonStart;
  40479. private _buttonLB;
  40480. private _buttonRB;
  40481. private _buttonLeftStick;
  40482. private _buttonRightStick;
  40483. private _dPadUp;
  40484. private _dPadDown;
  40485. private _dPadLeft;
  40486. private _dPadRight;
  40487. private _isXboxOnePad;
  40488. /**
  40489. * Creates a new XBox360 gamepad object
  40490. * @param id defines the id of this gamepad
  40491. * @param index defines its index
  40492. * @param gamepad defines the internal HTML gamepad object
  40493. * @param xboxOne defines if it is a XBox One gamepad
  40494. */
  40495. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40496. /**
  40497. * Defines the callback to call when left trigger is pressed
  40498. * @param callback defines the callback to use
  40499. */
  40500. onlefttriggerchanged(callback: (value: number) => void): void;
  40501. /**
  40502. * Defines the callback to call when right trigger is pressed
  40503. * @param callback defines the callback to use
  40504. */
  40505. onrighttriggerchanged(callback: (value: number) => void): void;
  40506. /**
  40507. * Gets the left trigger value
  40508. */
  40509. /**
  40510. * Sets the left trigger value
  40511. */
  40512. leftTrigger: number;
  40513. /**
  40514. * Gets the right trigger value
  40515. */
  40516. /**
  40517. * Sets the right trigger value
  40518. */
  40519. rightTrigger: number;
  40520. /**
  40521. * Defines the callback to call when a button is pressed
  40522. * @param callback defines the callback to use
  40523. */
  40524. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40525. /**
  40526. * Defines the callback to call when a button is released
  40527. * @param callback defines the callback to use
  40528. */
  40529. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40530. /**
  40531. * Defines the callback to call when a pad is pressed
  40532. * @param callback defines the callback to use
  40533. */
  40534. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40535. /**
  40536. * Defines the callback to call when a pad is released
  40537. * @param callback defines the callback to use
  40538. */
  40539. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40540. private _setButtonValue;
  40541. private _setDPadValue;
  40542. /**
  40543. * Gets the value of the `A` button
  40544. */
  40545. /**
  40546. * Sets the value of the `A` button
  40547. */
  40548. buttonA: number;
  40549. /**
  40550. * Gets the value of the `B` button
  40551. */
  40552. /**
  40553. * Sets the value of the `B` button
  40554. */
  40555. buttonB: number;
  40556. /**
  40557. * Gets the value of the `X` button
  40558. */
  40559. /**
  40560. * Sets the value of the `X` button
  40561. */
  40562. buttonX: number;
  40563. /**
  40564. * Gets the value of the `Y` button
  40565. */
  40566. /**
  40567. * Sets the value of the `Y` button
  40568. */
  40569. buttonY: number;
  40570. /**
  40571. * Gets the value of the `Start` button
  40572. */
  40573. /**
  40574. * Sets the value of the `Start` button
  40575. */
  40576. buttonStart: number;
  40577. /**
  40578. * Gets the value of the `Back` button
  40579. */
  40580. /**
  40581. * Sets the value of the `Back` button
  40582. */
  40583. buttonBack: number;
  40584. /**
  40585. * Gets the value of the `Left` button
  40586. */
  40587. /**
  40588. * Sets the value of the `Left` button
  40589. */
  40590. buttonLB: number;
  40591. /**
  40592. * Gets the value of the `Right` button
  40593. */
  40594. /**
  40595. * Sets the value of the `Right` button
  40596. */
  40597. buttonRB: number;
  40598. /**
  40599. * Gets the value of the Left joystick
  40600. */
  40601. /**
  40602. * Sets the value of the Left joystick
  40603. */
  40604. buttonLeftStick: number;
  40605. /**
  40606. * Gets the value of the Right joystick
  40607. */
  40608. /**
  40609. * Sets the value of the Right joystick
  40610. */
  40611. buttonRightStick: number;
  40612. /**
  40613. * Gets the value of D-pad up
  40614. */
  40615. /**
  40616. * Sets the value of D-pad up
  40617. */
  40618. dPadUp: number;
  40619. /**
  40620. * Gets the value of D-pad down
  40621. */
  40622. /**
  40623. * Sets the value of D-pad down
  40624. */
  40625. dPadDown: number;
  40626. /**
  40627. * Gets the value of D-pad left
  40628. */
  40629. /**
  40630. * Sets the value of D-pad left
  40631. */
  40632. dPadLeft: number;
  40633. /**
  40634. * Gets the value of D-pad right
  40635. */
  40636. /**
  40637. * Sets the value of D-pad right
  40638. */
  40639. dPadRight: number;
  40640. /**
  40641. * Force the gamepad to synchronize with device values
  40642. */
  40643. update(): void;
  40644. /**
  40645. * Disposes the gamepad
  40646. */
  40647. dispose(): void;
  40648. }
  40649. }
  40650. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40651. import { Observable } from "babylonjs/Misc/observable";
  40652. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40653. /**
  40654. * Defines supported buttons for DualShock compatible gamepads
  40655. */
  40656. export enum DualShockButton {
  40657. /** Cross */
  40658. Cross = 0,
  40659. /** Circle */
  40660. Circle = 1,
  40661. /** Square */
  40662. Square = 2,
  40663. /** Triangle */
  40664. Triangle = 3,
  40665. /** Options */
  40666. Options = 4,
  40667. /** Share */
  40668. Share = 5,
  40669. /** L1 */
  40670. L1 = 6,
  40671. /** R1 */
  40672. R1 = 7,
  40673. /** Left stick */
  40674. LeftStick = 8,
  40675. /** Right stick */
  40676. RightStick = 9
  40677. }
  40678. /** Defines values for DualShock DPad */
  40679. export enum DualShockDpad {
  40680. /** Up */
  40681. Up = 0,
  40682. /** Down */
  40683. Down = 1,
  40684. /** Left */
  40685. Left = 2,
  40686. /** Right */
  40687. Right = 3
  40688. }
  40689. /**
  40690. * Defines a DualShock gamepad
  40691. */
  40692. export class DualShockPad extends Gamepad {
  40693. private _leftTrigger;
  40694. private _rightTrigger;
  40695. private _onlefttriggerchanged;
  40696. private _onrighttriggerchanged;
  40697. private _onbuttondown;
  40698. private _onbuttonup;
  40699. private _ondpaddown;
  40700. private _ondpadup;
  40701. /** Observable raised when a button is pressed */
  40702. onButtonDownObservable: Observable<DualShockButton>;
  40703. /** Observable raised when a button is released */
  40704. onButtonUpObservable: Observable<DualShockButton>;
  40705. /** Observable raised when a pad is pressed */
  40706. onPadDownObservable: Observable<DualShockDpad>;
  40707. /** Observable raised when a pad is released */
  40708. onPadUpObservable: Observable<DualShockDpad>;
  40709. private _buttonCross;
  40710. private _buttonCircle;
  40711. private _buttonSquare;
  40712. private _buttonTriangle;
  40713. private _buttonShare;
  40714. private _buttonOptions;
  40715. private _buttonL1;
  40716. private _buttonR1;
  40717. private _buttonLeftStick;
  40718. private _buttonRightStick;
  40719. private _dPadUp;
  40720. private _dPadDown;
  40721. private _dPadLeft;
  40722. private _dPadRight;
  40723. /**
  40724. * Creates a new DualShock gamepad object
  40725. * @param id defines the id of this gamepad
  40726. * @param index defines its index
  40727. * @param gamepad defines the internal HTML gamepad object
  40728. */
  40729. constructor(id: string, index: number, gamepad: any);
  40730. /**
  40731. * Defines the callback to call when left trigger is pressed
  40732. * @param callback defines the callback to use
  40733. */
  40734. onlefttriggerchanged(callback: (value: number) => void): void;
  40735. /**
  40736. * Defines the callback to call when right trigger is pressed
  40737. * @param callback defines the callback to use
  40738. */
  40739. onrighttriggerchanged(callback: (value: number) => void): void;
  40740. /**
  40741. * Gets the left trigger value
  40742. */
  40743. /**
  40744. * Sets the left trigger value
  40745. */
  40746. leftTrigger: number;
  40747. /**
  40748. * Gets the right trigger value
  40749. */
  40750. /**
  40751. * Sets the right trigger value
  40752. */
  40753. rightTrigger: number;
  40754. /**
  40755. * Defines the callback to call when a button is pressed
  40756. * @param callback defines the callback to use
  40757. */
  40758. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40759. /**
  40760. * Defines the callback to call when a button is released
  40761. * @param callback defines the callback to use
  40762. */
  40763. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40764. /**
  40765. * Defines the callback to call when a pad is pressed
  40766. * @param callback defines the callback to use
  40767. */
  40768. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40769. /**
  40770. * Defines the callback to call when a pad is released
  40771. * @param callback defines the callback to use
  40772. */
  40773. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40774. private _setButtonValue;
  40775. private _setDPadValue;
  40776. /**
  40777. * Gets the value of the `Cross` button
  40778. */
  40779. /**
  40780. * Sets the value of the `Cross` button
  40781. */
  40782. buttonCross: number;
  40783. /**
  40784. * Gets the value of the `Circle` button
  40785. */
  40786. /**
  40787. * Sets the value of the `Circle` button
  40788. */
  40789. buttonCircle: number;
  40790. /**
  40791. * Gets the value of the `Square` button
  40792. */
  40793. /**
  40794. * Sets the value of the `Square` button
  40795. */
  40796. buttonSquare: number;
  40797. /**
  40798. * Gets the value of the `Triangle` button
  40799. */
  40800. /**
  40801. * Sets the value of the `Triangle` button
  40802. */
  40803. buttonTriangle: number;
  40804. /**
  40805. * Gets the value of the `Options` button
  40806. */
  40807. /**
  40808. * Sets the value of the `Options` button
  40809. */
  40810. buttonOptions: number;
  40811. /**
  40812. * Gets the value of the `Share` button
  40813. */
  40814. /**
  40815. * Sets the value of the `Share` button
  40816. */
  40817. buttonShare: number;
  40818. /**
  40819. * Gets the value of the `L1` button
  40820. */
  40821. /**
  40822. * Sets the value of the `L1` button
  40823. */
  40824. buttonL1: number;
  40825. /**
  40826. * Gets the value of the `R1` button
  40827. */
  40828. /**
  40829. * Sets the value of the `R1` button
  40830. */
  40831. buttonR1: number;
  40832. /**
  40833. * Gets the value of the Left joystick
  40834. */
  40835. /**
  40836. * Sets the value of the Left joystick
  40837. */
  40838. buttonLeftStick: number;
  40839. /**
  40840. * Gets the value of the Right joystick
  40841. */
  40842. /**
  40843. * Sets the value of the Right joystick
  40844. */
  40845. buttonRightStick: number;
  40846. /**
  40847. * Gets the value of D-pad up
  40848. */
  40849. /**
  40850. * Sets the value of D-pad up
  40851. */
  40852. dPadUp: number;
  40853. /**
  40854. * Gets the value of D-pad down
  40855. */
  40856. /**
  40857. * Sets the value of D-pad down
  40858. */
  40859. dPadDown: number;
  40860. /**
  40861. * Gets the value of D-pad left
  40862. */
  40863. /**
  40864. * Sets the value of D-pad left
  40865. */
  40866. dPadLeft: number;
  40867. /**
  40868. * Gets the value of D-pad right
  40869. */
  40870. /**
  40871. * Sets the value of D-pad right
  40872. */
  40873. dPadRight: number;
  40874. /**
  40875. * Force the gamepad to synchronize with device values
  40876. */
  40877. update(): void;
  40878. /**
  40879. * Disposes the gamepad
  40880. */
  40881. dispose(): void;
  40882. }
  40883. }
  40884. declare module "babylonjs/Gamepads/gamepadManager" {
  40885. import { Observable } from "babylonjs/Misc/observable";
  40886. import { Nullable } from "babylonjs/types";
  40887. import { Scene } from "babylonjs/scene";
  40888. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40889. /**
  40890. * Manager for handling gamepads
  40891. */
  40892. export class GamepadManager {
  40893. private _scene?;
  40894. private _babylonGamepads;
  40895. private _oneGamepadConnected;
  40896. /** @hidden */
  40897. _isMonitoring: boolean;
  40898. private _gamepadEventSupported;
  40899. private _gamepadSupport;
  40900. /**
  40901. * observable to be triggered when the gamepad controller has been connected
  40902. */
  40903. onGamepadConnectedObservable: Observable<Gamepad>;
  40904. /**
  40905. * observable to be triggered when the gamepad controller has been disconnected
  40906. */
  40907. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40908. private _onGamepadConnectedEvent;
  40909. private _onGamepadDisconnectedEvent;
  40910. /**
  40911. * Initializes the gamepad manager
  40912. * @param _scene BabylonJS scene
  40913. */
  40914. constructor(_scene?: Scene | undefined);
  40915. /**
  40916. * The gamepads in the game pad manager
  40917. */
  40918. readonly gamepads: Gamepad[];
  40919. /**
  40920. * Get the gamepad controllers based on type
  40921. * @param type The type of gamepad controller
  40922. * @returns Nullable gamepad
  40923. */
  40924. getGamepadByType(type?: number): Nullable<Gamepad>;
  40925. /**
  40926. * Disposes the gamepad manager
  40927. */
  40928. dispose(): void;
  40929. private _addNewGamepad;
  40930. private _startMonitoringGamepads;
  40931. private _stopMonitoringGamepads;
  40932. /** @hidden */
  40933. _checkGamepadsStatus(): void;
  40934. private _updateGamepadObjects;
  40935. }
  40936. }
  40937. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40938. import { Nullable } from "babylonjs/types";
  40939. import { Scene } from "babylonjs/scene";
  40940. import { ISceneComponent } from "babylonjs/sceneComponent";
  40941. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40942. module "babylonjs/scene" {
  40943. interface Scene {
  40944. /** @hidden */
  40945. _gamepadManager: Nullable<GamepadManager>;
  40946. /**
  40947. * Gets the gamepad manager associated with the scene
  40948. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40949. */
  40950. gamepadManager: GamepadManager;
  40951. }
  40952. }
  40953. module "babylonjs/Cameras/freeCameraInputsManager" {
  40954. /**
  40955. * Interface representing a free camera inputs manager
  40956. */
  40957. interface FreeCameraInputsManager {
  40958. /**
  40959. * Adds gamepad input support to the FreeCameraInputsManager.
  40960. * @returns the FreeCameraInputsManager
  40961. */
  40962. addGamepad(): FreeCameraInputsManager;
  40963. }
  40964. }
  40965. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40966. /**
  40967. * Interface representing an arc rotate camera inputs manager
  40968. */
  40969. interface ArcRotateCameraInputsManager {
  40970. /**
  40971. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40972. * @returns the camera inputs manager
  40973. */
  40974. addGamepad(): ArcRotateCameraInputsManager;
  40975. }
  40976. }
  40977. /**
  40978. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40979. */
  40980. export class GamepadSystemSceneComponent implements ISceneComponent {
  40981. /**
  40982. * The component name helpfull to identify the component in the list of scene components.
  40983. */
  40984. readonly name: string;
  40985. /**
  40986. * The scene the component belongs to.
  40987. */
  40988. scene: Scene;
  40989. /**
  40990. * Creates a new instance of the component for the given scene
  40991. * @param scene Defines the scene to register the component in
  40992. */
  40993. constructor(scene: Scene);
  40994. /**
  40995. * Registers the component in a given scene
  40996. */
  40997. register(): void;
  40998. /**
  40999. * Rebuilds the elements related to this component in case of
  41000. * context lost for instance.
  41001. */
  41002. rebuild(): void;
  41003. /**
  41004. * Disposes the component and the associated ressources
  41005. */
  41006. dispose(): void;
  41007. private _beforeCameraUpdate;
  41008. }
  41009. }
  41010. declare module "babylonjs/Cameras/universalCamera" {
  41011. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  41012. import { Scene } from "babylonjs/scene";
  41013. import { Vector3 } from "babylonjs/Maths/math.vector";
  41014. import "babylonjs/Gamepads/gamepadSceneComponent";
  41015. /**
  41016. * 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,
  41017. * which still works and will still be found in many Playgrounds.
  41018. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41019. */
  41020. export class UniversalCamera extends TouchCamera {
  41021. /**
  41022. * Defines the gamepad rotation sensiblity.
  41023. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41024. */
  41025. gamepadAngularSensibility: number;
  41026. /**
  41027. * Defines the gamepad move sensiblity.
  41028. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41029. */
  41030. gamepadMoveSensibility: number;
  41031. /**
  41032. * 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,
  41033. * which still works and will still be found in many Playgrounds.
  41034. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41035. * @param name Define the name of the camera in the scene
  41036. * @param position Define the start position of the camera in the scene
  41037. * @param scene Define the scene the camera belongs to
  41038. */
  41039. constructor(name: string, position: Vector3, scene: Scene);
  41040. /**
  41041. * Gets the current object class name.
  41042. * @return the class name
  41043. */
  41044. getClassName(): string;
  41045. }
  41046. }
  41047. declare module "babylonjs/Cameras/gamepadCamera" {
  41048. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41049. import { Scene } from "babylonjs/scene";
  41050. import { Vector3 } from "babylonjs/Maths/math.vector";
  41051. /**
  41052. * This represents a FPS type of camera. This is only here for back compat purpose.
  41053. * Please use the UniversalCamera instead as both are identical.
  41054. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41055. */
  41056. export class GamepadCamera extends UniversalCamera {
  41057. /**
  41058. * Instantiates a new Gamepad Camera
  41059. * This represents a FPS type of camera. This is only here for back compat purpose.
  41060. * Please use the UniversalCamera instead as both are identical.
  41061. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41062. * @param name Define the name of the camera in the scene
  41063. * @param position Define the start position of the camera in the scene
  41064. * @param scene Define the scene the camera belongs to
  41065. */
  41066. constructor(name: string, position: Vector3, scene: Scene);
  41067. /**
  41068. * Gets the current object class name.
  41069. * @return the class name
  41070. */
  41071. getClassName(): string;
  41072. }
  41073. }
  41074. declare module "babylonjs/Shaders/pass.fragment" {
  41075. /** @hidden */
  41076. export var passPixelShader: {
  41077. name: string;
  41078. shader: string;
  41079. };
  41080. }
  41081. declare module "babylonjs/Shaders/passCube.fragment" {
  41082. /** @hidden */
  41083. export var passCubePixelShader: {
  41084. name: string;
  41085. shader: string;
  41086. };
  41087. }
  41088. declare module "babylonjs/PostProcesses/passPostProcess" {
  41089. import { Nullable } from "babylonjs/types";
  41090. import { Camera } from "babylonjs/Cameras/camera";
  41091. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41092. import { Engine } from "babylonjs/Engines/engine";
  41093. import "babylonjs/Shaders/pass.fragment";
  41094. import "babylonjs/Shaders/passCube.fragment";
  41095. /**
  41096. * PassPostProcess which produces an output the same as it's input
  41097. */
  41098. export class PassPostProcess extends PostProcess {
  41099. /**
  41100. * Creates the PassPostProcess
  41101. * @param name The name of the effect.
  41102. * @param options The required width/height ratio to downsize to before computing the render pass.
  41103. * @param camera The camera to apply the render pass to.
  41104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41105. * @param engine The engine which the post process will be applied. (default: current engine)
  41106. * @param reusable If the post process can be reused on the same frame. (default: false)
  41107. * @param textureType The type of texture to be used when performing the post processing.
  41108. * @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)
  41109. */
  41110. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41111. }
  41112. /**
  41113. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41114. */
  41115. export class PassCubePostProcess extends PostProcess {
  41116. private _face;
  41117. /**
  41118. * Gets or sets the cube face to display.
  41119. * * 0 is +X
  41120. * * 1 is -X
  41121. * * 2 is +Y
  41122. * * 3 is -Y
  41123. * * 4 is +Z
  41124. * * 5 is -Z
  41125. */
  41126. face: number;
  41127. /**
  41128. * Creates the PassCubePostProcess
  41129. * @param name The name of the effect.
  41130. * @param options The required width/height ratio to downsize to before computing the render pass.
  41131. * @param camera The camera to apply the render pass to.
  41132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41133. * @param engine The engine which the post process will be applied. (default: current engine)
  41134. * @param reusable If the post process can be reused on the same frame. (default: false)
  41135. * @param textureType The type of texture to be used when performing the post processing.
  41136. * @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)
  41137. */
  41138. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41139. }
  41140. }
  41141. declare module "babylonjs/Shaders/anaglyph.fragment" {
  41142. /** @hidden */
  41143. export var anaglyphPixelShader: {
  41144. name: string;
  41145. shader: string;
  41146. };
  41147. }
  41148. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  41149. import { Engine } from "babylonjs/Engines/engine";
  41150. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41151. import { Camera } from "babylonjs/Cameras/camera";
  41152. import "babylonjs/Shaders/anaglyph.fragment";
  41153. /**
  41154. * Postprocess used to generate anaglyphic rendering
  41155. */
  41156. export class AnaglyphPostProcess extends PostProcess {
  41157. private _passedProcess;
  41158. /**
  41159. * Creates a new AnaglyphPostProcess
  41160. * @param name defines postprocess name
  41161. * @param options defines creation options or target ratio scale
  41162. * @param rigCameras defines cameras using this postprocess
  41163. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41164. * @param engine defines hosting engine
  41165. * @param reusable defines if the postprocess will be reused multiple times per frame
  41166. */
  41167. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41168. }
  41169. }
  41170. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  41171. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  41172. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41173. import { Scene } from "babylonjs/scene";
  41174. import { Vector3 } from "babylonjs/Maths/math.vector";
  41175. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41176. /**
  41177. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41178. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41179. */
  41180. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41181. /**
  41182. * Creates a new AnaglyphArcRotateCamera
  41183. * @param name defines camera name
  41184. * @param alpha defines alpha angle (in radians)
  41185. * @param beta defines beta angle (in radians)
  41186. * @param radius defines radius
  41187. * @param target defines camera target
  41188. * @param interaxialDistance defines distance between each color axis
  41189. * @param scene defines the hosting scene
  41190. */
  41191. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41192. /**
  41193. * Gets camera class name
  41194. * @returns AnaglyphArcRotateCamera
  41195. */
  41196. getClassName(): string;
  41197. }
  41198. }
  41199. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  41200. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  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 FreeCamera)
  41206. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41207. */
  41208. export class AnaglyphFreeCamera extends FreeCamera {
  41209. /**
  41210. * Creates a new AnaglyphFreeCamera
  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 AnaglyphFreeCamera
  41220. */
  41221. getClassName(): string;
  41222. }
  41223. }
  41224. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  41225. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  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 GamepadCamera)
  41231. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41232. */
  41233. export class AnaglyphGamepadCamera extends GamepadCamera {
  41234. /**
  41235. * Creates a new AnaglyphGamepadCamera
  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 AnaglyphGamepadCamera
  41245. */
  41246. getClassName(): string;
  41247. }
  41248. }
  41249. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  41250. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41251. import { Scene } from "babylonjs/scene";
  41252. import { Vector3 } from "babylonjs/Maths/math.vector";
  41253. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41254. /**
  41255. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41256. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41257. */
  41258. export class AnaglyphUniversalCamera extends UniversalCamera {
  41259. /**
  41260. * Creates a new AnaglyphUniversalCamera
  41261. * @param name defines camera name
  41262. * @param position defines initial position
  41263. * @param interaxialDistance defines distance between each color axis
  41264. * @param scene defines the hosting scene
  41265. */
  41266. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41267. /**
  41268. * Gets camera class name
  41269. * @returns AnaglyphUniversalCamera
  41270. */
  41271. getClassName(): string;
  41272. }
  41273. }
  41274. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  41275. /** @hidden */
  41276. export var stereoscopicInterlacePixelShader: {
  41277. name: string;
  41278. shader: string;
  41279. };
  41280. }
  41281. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  41282. import { Camera } from "babylonjs/Cameras/camera";
  41283. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41284. import { Engine } from "babylonjs/Engines/engine";
  41285. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  41286. /**
  41287. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41288. */
  41289. export class StereoscopicInterlacePostProcess extends PostProcess {
  41290. private _stepSize;
  41291. private _passedProcess;
  41292. /**
  41293. * Initializes a StereoscopicInterlacePostProcess
  41294. * @param name The name of the effect.
  41295. * @param rigCameras The rig cameras to be appled to the post process
  41296. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41298. * @param engine The engine which the post process will be applied. (default: current engine)
  41299. * @param reusable If the post process can be reused on the same frame. (default: false)
  41300. */
  41301. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41302. }
  41303. }
  41304. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  41305. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  41306. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41307. import { Scene } from "babylonjs/scene";
  41308. import { Vector3 } from "babylonjs/Maths/math.vector";
  41309. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41310. /**
  41311. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41312. * @see http://doc.babylonjs.com/features/cameras
  41313. */
  41314. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41315. /**
  41316. * Creates a new StereoscopicArcRotateCamera
  41317. * @param name defines camera name
  41318. * @param alpha defines alpha angle (in radians)
  41319. * @param beta defines beta angle (in radians)
  41320. * @param radius defines radius
  41321. * @param target defines camera target
  41322. * @param interaxialDistance defines distance between each color axis
  41323. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41324. * @param scene defines the hosting scene
  41325. */
  41326. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41327. /**
  41328. * Gets camera class name
  41329. * @returns StereoscopicArcRotateCamera
  41330. */
  41331. getClassName(): string;
  41332. }
  41333. }
  41334. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  41335. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41336. import { Scene } from "babylonjs/scene";
  41337. import { Vector3 } from "babylonjs/Maths/math.vector";
  41338. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41339. /**
  41340. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41341. * @see http://doc.babylonjs.com/features/cameras
  41342. */
  41343. export class StereoscopicFreeCamera extends FreeCamera {
  41344. /**
  41345. * Creates a new StereoscopicFreeCamera
  41346. * @param name defines camera name
  41347. * @param position defines initial position
  41348. * @param interaxialDistance defines distance between each color axis
  41349. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41350. * @param scene defines the hosting scene
  41351. */
  41352. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41353. /**
  41354. * Gets camera class name
  41355. * @returns StereoscopicFreeCamera
  41356. */
  41357. getClassName(): string;
  41358. }
  41359. }
  41360. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  41361. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  41362. import { Scene } from "babylonjs/scene";
  41363. import { Vector3 } from "babylonjs/Maths/math.vector";
  41364. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41365. /**
  41366. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41367. * @see http://doc.babylonjs.com/features/cameras
  41368. */
  41369. export class StereoscopicGamepadCamera extends GamepadCamera {
  41370. /**
  41371. * Creates a new StereoscopicGamepadCamera
  41372. * @param name defines camera name
  41373. * @param position defines initial position
  41374. * @param interaxialDistance defines distance between each color axis
  41375. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41376. * @param scene defines the hosting scene
  41377. */
  41378. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41379. /**
  41380. * Gets camera class name
  41381. * @returns StereoscopicGamepadCamera
  41382. */
  41383. getClassName(): string;
  41384. }
  41385. }
  41386. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  41387. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  41388. import { Scene } from "babylonjs/scene";
  41389. import { Vector3 } from "babylonjs/Maths/math.vector";
  41390. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41391. /**
  41392. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41393. * @see http://doc.babylonjs.com/features/cameras
  41394. */
  41395. export class StereoscopicUniversalCamera extends UniversalCamera {
  41396. /**
  41397. * Creates a new StereoscopicUniversalCamera
  41398. * @param name defines camera name
  41399. * @param position defines initial position
  41400. * @param interaxialDistance defines distance between each color axis
  41401. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41402. * @param scene defines the hosting scene
  41403. */
  41404. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41405. /**
  41406. * Gets camera class name
  41407. * @returns StereoscopicUniversalCamera
  41408. */
  41409. getClassName(): string;
  41410. }
  41411. }
  41412. declare module "babylonjs/Cameras/Stereoscopic/index" {
  41413. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  41414. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  41415. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  41416. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  41417. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  41418. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  41419. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  41420. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  41421. }
  41422. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  41423. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41424. import { Scene } from "babylonjs/scene";
  41425. import { Vector3 } from "babylonjs/Maths/math.vector";
  41426. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41427. /**
  41428. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41429. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41430. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41431. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41432. */
  41433. export class VirtualJoysticksCamera extends FreeCamera {
  41434. /**
  41435. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41436. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41437. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41438. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41439. * @param name Define the name of the camera in the scene
  41440. * @param position Define the start position of the camera in the scene
  41441. * @param scene Define the scene the camera belongs to
  41442. */
  41443. constructor(name: string, position: Vector3, scene: Scene);
  41444. /**
  41445. * Gets the current object class name.
  41446. * @return the class name
  41447. */
  41448. getClassName(): string;
  41449. }
  41450. }
  41451. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  41452. import { Matrix } from "babylonjs/Maths/math.vector";
  41453. /**
  41454. * This represents all the required metrics to create a VR camera.
  41455. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41456. */
  41457. export class VRCameraMetrics {
  41458. /**
  41459. * Define the horizontal resolution off the screen.
  41460. */
  41461. hResolution: number;
  41462. /**
  41463. * Define the vertical resolution off the screen.
  41464. */
  41465. vResolution: number;
  41466. /**
  41467. * Define the horizontal screen size.
  41468. */
  41469. hScreenSize: number;
  41470. /**
  41471. * Define the vertical screen size.
  41472. */
  41473. vScreenSize: number;
  41474. /**
  41475. * Define the vertical screen center position.
  41476. */
  41477. vScreenCenter: number;
  41478. /**
  41479. * Define the distance of the eyes to the screen.
  41480. */
  41481. eyeToScreenDistance: number;
  41482. /**
  41483. * Define the distance between both lenses
  41484. */
  41485. lensSeparationDistance: number;
  41486. /**
  41487. * Define the distance between both viewer's eyes.
  41488. */
  41489. interpupillaryDistance: number;
  41490. /**
  41491. * Define the distortion factor of the VR postprocess.
  41492. * Please, touch with care.
  41493. */
  41494. distortionK: number[];
  41495. /**
  41496. * Define the chromatic aberration correction factors for the VR post process.
  41497. */
  41498. chromaAbCorrection: number[];
  41499. /**
  41500. * Define the scale factor of the post process.
  41501. * The smaller the better but the slower.
  41502. */
  41503. postProcessScaleFactor: number;
  41504. /**
  41505. * Define an offset for the lens center.
  41506. */
  41507. lensCenterOffset: number;
  41508. /**
  41509. * Define if the current vr camera should compensate the distortion of the lense or not.
  41510. */
  41511. compensateDistortion: boolean;
  41512. /**
  41513. * Defines if multiview should be enabled when rendering (Default: false)
  41514. */
  41515. multiviewEnabled: boolean;
  41516. /**
  41517. * Gets the rendering aspect ratio based on the provided resolutions.
  41518. */
  41519. readonly aspectRatio: number;
  41520. /**
  41521. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41522. */
  41523. readonly aspectRatioFov: number;
  41524. /**
  41525. * @hidden
  41526. */
  41527. readonly leftHMatrix: Matrix;
  41528. /**
  41529. * @hidden
  41530. */
  41531. readonly rightHMatrix: Matrix;
  41532. /**
  41533. * @hidden
  41534. */
  41535. readonly leftPreViewMatrix: Matrix;
  41536. /**
  41537. * @hidden
  41538. */
  41539. readonly rightPreViewMatrix: Matrix;
  41540. /**
  41541. * Get the default VRMetrics based on the most generic setup.
  41542. * @returns the default vr metrics
  41543. */
  41544. static GetDefault(): VRCameraMetrics;
  41545. }
  41546. }
  41547. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41548. /** @hidden */
  41549. export var vrDistortionCorrectionPixelShader: {
  41550. name: string;
  41551. shader: string;
  41552. };
  41553. }
  41554. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41555. import { Camera } from "babylonjs/Cameras/camera";
  41556. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41557. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41558. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41559. /**
  41560. * VRDistortionCorrectionPostProcess used for mobile VR
  41561. */
  41562. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41563. private _isRightEye;
  41564. private _distortionFactors;
  41565. private _postProcessScaleFactor;
  41566. private _lensCenterOffset;
  41567. private _scaleIn;
  41568. private _scaleFactor;
  41569. private _lensCenter;
  41570. /**
  41571. * Initializes the VRDistortionCorrectionPostProcess
  41572. * @param name The name of the effect.
  41573. * @param camera The camera to apply the render pass to.
  41574. * @param isRightEye If this is for the right eye distortion
  41575. * @param vrMetrics All the required metrics for the VR camera
  41576. */
  41577. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41578. }
  41579. }
  41580. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41581. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41582. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41583. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41584. import { Scene } from "babylonjs/scene";
  41585. import { Vector3 } from "babylonjs/Maths/math.vector";
  41586. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41587. import "babylonjs/Cameras/RigModes/vrRigMode";
  41588. /**
  41589. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41590. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41591. */
  41592. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41593. /**
  41594. * Creates a new VRDeviceOrientationArcRotateCamera
  41595. * @param name defines camera name
  41596. * @param alpha defines the camera rotation along the logitudinal axis
  41597. * @param beta defines the camera rotation along the latitudinal axis
  41598. * @param radius defines the camera distance from its target
  41599. * @param target defines the camera target
  41600. * @param scene defines the scene the camera belongs to
  41601. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41602. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41603. */
  41604. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41605. /**
  41606. * Gets camera class name
  41607. * @returns VRDeviceOrientationArcRotateCamera
  41608. */
  41609. getClassName(): string;
  41610. }
  41611. }
  41612. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41613. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41614. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41615. import { Scene } from "babylonjs/scene";
  41616. import { Vector3 } from "babylonjs/Maths/math.vector";
  41617. import "babylonjs/Cameras/RigModes/vrRigMode";
  41618. /**
  41619. * Camera used to simulate VR rendering (based on FreeCamera)
  41620. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41621. */
  41622. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41623. /**
  41624. * Creates a new VRDeviceOrientationFreeCamera
  41625. * @param name defines camera name
  41626. * @param position defines the start position of the camera
  41627. * @param scene defines the scene the camera belongs to
  41628. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41629. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41630. */
  41631. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41632. /**
  41633. * Gets camera class name
  41634. * @returns VRDeviceOrientationFreeCamera
  41635. */
  41636. getClassName(): string;
  41637. }
  41638. }
  41639. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41640. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41641. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41642. import { Scene } from "babylonjs/scene";
  41643. import { Vector3 } from "babylonjs/Maths/math.vector";
  41644. import "babylonjs/Gamepads/gamepadSceneComponent";
  41645. /**
  41646. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41647. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41648. */
  41649. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41650. /**
  41651. * Creates a new VRDeviceOrientationGamepadCamera
  41652. * @param name defines camera name
  41653. * @param position defines the start position of the camera
  41654. * @param scene defines the scene the camera belongs to
  41655. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41656. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41657. */
  41658. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41659. /**
  41660. * Gets camera class name
  41661. * @returns VRDeviceOrientationGamepadCamera
  41662. */
  41663. getClassName(): string;
  41664. }
  41665. }
  41666. declare module "babylonjs/Materials/pushMaterial" {
  41667. import { Nullable } from "babylonjs/types";
  41668. import { Scene } from "babylonjs/scene";
  41669. import { Matrix } from "babylonjs/Maths/math.vector";
  41670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41671. import { Mesh } from "babylonjs/Meshes/mesh";
  41672. import { Material } from "babylonjs/Materials/material";
  41673. import { Effect } from "babylonjs/Materials/effect";
  41674. /**
  41675. * Base class of materials working in push mode in babylon JS
  41676. * @hidden
  41677. */
  41678. export class PushMaterial extends Material {
  41679. protected _activeEffect: Effect;
  41680. protected _normalMatrix: Matrix;
  41681. /**
  41682. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41683. * This means that the material can keep using a previous shader while a new one is being compiled.
  41684. * This is mostly used when shader parallel compilation is supported (true by default)
  41685. */
  41686. allowShaderHotSwapping: boolean;
  41687. constructor(name: string, scene: Scene);
  41688. getEffect(): Effect;
  41689. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41690. /**
  41691. * Binds the given world matrix to the active effect
  41692. *
  41693. * @param world the matrix to bind
  41694. */
  41695. bindOnlyWorldMatrix(world: Matrix): void;
  41696. /**
  41697. * Binds the given normal matrix to the active effect
  41698. *
  41699. * @param normalMatrix the matrix to bind
  41700. */
  41701. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41702. bind(world: Matrix, mesh?: Mesh): void;
  41703. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41704. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41705. }
  41706. }
  41707. declare module "babylonjs/Materials/materialFlags" {
  41708. /**
  41709. * This groups all the flags used to control the materials channel.
  41710. */
  41711. export class MaterialFlags {
  41712. private static _DiffuseTextureEnabled;
  41713. /**
  41714. * Are diffuse textures enabled in the application.
  41715. */
  41716. static DiffuseTextureEnabled: boolean;
  41717. private static _AmbientTextureEnabled;
  41718. /**
  41719. * Are ambient textures enabled in the application.
  41720. */
  41721. static AmbientTextureEnabled: boolean;
  41722. private static _OpacityTextureEnabled;
  41723. /**
  41724. * Are opacity textures enabled in the application.
  41725. */
  41726. static OpacityTextureEnabled: boolean;
  41727. private static _ReflectionTextureEnabled;
  41728. /**
  41729. * Are reflection textures enabled in the application.
  41730. */
  41731. static ReflectionTextureEnabled: boolean;
  41732. private static _EmissiveTextureEnabled;
  41733. /**
  41734. * Are emissive textures enabled in the application.
  41735. */
  41736. static EmissiveTextureEnabled: boolean;
  41737. private static _SpecularTextureEnabled;
  41738. /**
  41739. * Are specular textures enabled in the application.
  41740. */
  41741. static SpecularTextureEnabled: boolean;
  41742. private static _BumpTextureEnabled;
  41743. /**
  41744. * Are bump textures enabled in the application.
  41745. */
  41746. static BumpTextureEnabled: boolean;
  41747. private static _LightmapTextureEnabled;
  41748. /**
  41749. * Are lightmap textures enabled in the application.
  41750. */
  41751. static LightmapTextureEnabled: boolean;
  41752. private static _RefractionTextureEnabled;
  41753. /**
  41754. * Are refraction textures enabled in the application.
  41755. */
  41756. static RefractionTextureEnabled: boolean;
  41757. private static _ColorGradingTextureEnabled;
  41758. /**
  41759. * Are color grading textures enabled in the application.
  41760. */
  41761. static ColorGradingTextureEnabled: boolean;
  41762. private static _FresnelEnabled;
  41763. /**
  41764. * Are fresnels enabled in the application.
  41765. */
  41766. static FresnelEnabled: boolean;
  41767. private static _ClearCoatTextureEnabled;
  41768. /**
  41769. * Are clear coat textures enabled in the application.
  41770. */
  41771. static ClearCoatTextureEnabled: boolean;
  41772. private static _ClearCoatBumpTextureEnabled;
  41773. /**
  41774. * Are clear coat bump textures enabled in the application.
  41775. */
  41776. static ClearCoatBumpTextureEnabled: boolean;
  41777. private static _ClearCoatTintTextureEnabled;
  41778. /**
  41779. * Are clear coat tint textures enabled in the application.
  41780. */
  41781. static ClearCoatTintTextureEnabled: boolean;
  41782. private static _SheenTextureEnabled;
  41783. /**
  41784. * Are sheen textures enabled in the application.
  41785. */
  41786. static SheenTextureEnabled: boolean;
  41787. private static _AnisotropicTextureEnabled;
  41788. /**
  41789. * Are anisotropic textures enabled in the application.
  41790. */
  41791. static AnisotropicTextureEnabled: boolean;
  41792. private static _ThicknessTextureEnabled;
  41793. /**
  41794. * Are thickness textures enabled in the application.
  41795. */
  41796. static ThicknessTextureEnabled: boolean;
  41797. }
  41798. }
  41799. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41800. /** @hidden */
  41801. export var defaultFragmentDeclaration: {
  41802. name: string;
  41803. shader: string;
  41804. };
  41805. }
  41806. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41807. /** @hidden */
  41808. export var defaultUboDeclaration: {
  41809. name: string;
  41810. shader: string;
  41811. };
  41812. }
  41813. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41814. /** @hidden */
  41815. export var lightFragmentDeclaration: {
  41816. name: string;
  41817. shader: string;
  41818. };
  41819. }
  41820. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41821. /** @hidden */
  41822. export var lightUboDeclaration: {
  41823. name: string;
  41824. shader: string;
  41825. };
  41826. }
  41827. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41828. /** @hidden */
  41829. export var lightsFragmentFunctions: {
  41830. name: string;
  41831. shader: string;
  41832. };
  41833. }
  41834. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41835. /** @hidden */
  41836. export var shadowsFragmentFunctions: {
  41837. name: string;
  41838. shader: string;
  41839. };
  41840. }
  41841. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41842. /** @hidden */
  41843. export var fresnelFunction: {
  41844. name: string;
  41845. shader: string;
  41846. };
  41847. }
  41848. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41849. /** @hidden */
  41850. export var reflectionFunction: {
  41851. name: string;
  41852. shader: string;
  41853. };
  41854. }
  41855. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41856. /** @hidden */
  41857. export var bumpFragmentFunctions: {
  41858. name: string;
  41859. shader: string;
  41860. };
  41861. }
  41862. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41863. /** @hidden */
  41864. export var logDepthDeclaration: {
  41865. name: string;
  41866. shader: string;
  41867. };
  41868. }
  41869. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41870. /** @hidden */
  41871. export var bumpFragment: {
  41872. name: string;
  41873. shader: string;
  41874. };
  41875. }
  41876. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41877. /** @hidden */
  41878. export var depthPrePass: {
  41879. name: string;
  41880. shader: string;
  41881. };
  41882. }
  41883. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41884. /** @hidden */
  41885. export var lightFragment: {
  41886. name: string;
  41887. shader: string;
  41888. };
  41889. }
  41890. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41891. /** @hidden */
  41892. export var logDepthFragment: {
  41893. name: string;
  41894. shader: string;
  41895. };
  41896. }
  41897. declare module "babylonjs/Shaders/default.fragment" {
  41898. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41899. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41900. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41901. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41902. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41903. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41904. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41905. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41906. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41907. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41908. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41909. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41910. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41911. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41912. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41913. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41914. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41915. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41916. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41917. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41918. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41919. /** @hidden */
  41920. export var defaultPixelShader: {
  41921. name: string;
  41922. shader: string;
  41923. };
  41924. }
  41925. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41926. /** @hidden */
  41927. export var defaultVertexDeclaration: {
  41928. name: string;
  41929. shader: string;
  41930. };
  41931. }
  41932. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41933. /** @hidden */
  41934. export var bumpVertexDeclaration: {
  41935. name: string;
  41936. shader: string;
  41937. };
  41938. }
  41939. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41940. /** @hidden */
  41941. export var bumpVertex: {
  41942. name: string;
  41943. shader: string;
  41944. };
  41945. }
  41946. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41947. /** @hidden */
  41948. export var fogVertex: {
  41949. name: string;
  41950. shader: string;
  41951. };
  41952. }
  41953. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41954. /** @hidden */
  41955. export var shadowsVertex: {
  41956. name: string;
  41957. shader: string;
  41958. };
  41959. }
  41960. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41961. /** @hidden */
  41962. export var pointCloudVertex: {
  41963. name: string;
  41964. shader: string;
  41965. };
  41966. }
  41967. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41968. /** @hidden */
  41969. export var logDepthVertex: {
  41970. name: string;
  41971. shader: string;
  41972. };
  41973. }
  41974. declare module "babylonjs/Shaders/default.vertex" {
  41975. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41976. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41977. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41978. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41979. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41980. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41981. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41982. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41983. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41984. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41985. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41986. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41987. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41988. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41989. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41990. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41991. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41992. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41993. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41994. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41995. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41996. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41997. /** @hidden */
  41998. export var defaultVertexShader: {
  41999. name: string;
  42000. shader: string;
  42001. };
  42002. }
  42003. declare module "babylonjs/Materials/standardMaterial" {
  42004. import { SmartArray } from "babylonjs/Misc/smartArray";
  42005. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  42006. import { Nullable } from "babylonjs/types";
  42007. import { Scene } from "babylonjs/scene";
  42008. import { Matrix } from "babylonjs/Maths/math.vector";
  42009. import { Color3 } from "babylonjs/Maths/math.color";
  42010. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42012. import { Mesh } from "babylonjs/Meshes/mesh";
  42013. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  42014. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42015. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  42016. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  42017. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  42018. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42019. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42020. import "babylonjs/Shaders/default.fragment";
  42021. import "babylonjs/Shaders/default.vertex";
  42022. /** @hidden */
  42023. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  42024. MAINUV1: boolean;
  42025. MAINUV2: boolean;
  42026. DIFFUSE: boolean;
  42027. DIFFUSEDIRECTUV: number;
  42028. AMBIENT: boolean;
  42029. AMBIENTDIRECTUV: number;
  42030. OPACITY: boolean;
  42031. OPACITYDIRECTUV: number;
  42032. OPACITYRGB: boolean;
  42033. REFLECTION: boolean;
  42034. EMISSIVE: boolean;
  42035. EMISSIVEDIRECTUV: number;
  42036. SPECULAR: boolean;
  42037. SPECULARDIRECTUV: number;
  42038. BUMP: boolean;
  42039. BUMPDIRECTUV: number;
  42040. PARALLAX: boolean;
  42041. PARALLAXOCCLUSION: boolean;
  42042. SPECULAROVERALPHA: boolean;
  42043. CLIPPLANE: boolean;
  42044. CLIPPLANE2: boolean;
  42045. CLIPPLANE3: boolean;
  42046. CLIPPLANE4: boolean;
  42047. ALPHATEST: boolean;
  42048. DEPTHPREPASS: boolean;
  42049. ALPHAFROMDIFFUSE: boolean;
  42050. POINTSIZE: boolean;
  42051. FOG: boolean;
  42052. SPECULARTERM: boolean;
  42053. DIFFUSEFRESNEL: boolean;
  42054. OPACITYFRESNEL: boolean;
  42055. REFLECTIONFRESNEL: boolean;
  42056. REFRACTIONFRESNEL: boolean;
  42057. EMISSIVEFRESNEL: boolean;
  42058. FRESNEL: boolean;
  42059. NORMAL: boolean;
  42060. UV1: boolean;
  42061. UV2: boolean;
  42062. VERTEXCOLOR: boolean;
  42063. VERTEXALPHA: boolean;
  42064. NUM_BONE_INFLUENCERS: number;
  42065. BonesPerMesh: number;
  42066. BONETEXTURE: boolean;
  42067. INSTANCES: boolean;
  42068. GLOSSINESS: boolean;
  42069. ROUGHNESS: boolean;
  42070. EMISSIVEASILLUMINATION: boolean;
  42071. LINKEMISSIVEWITHDIFFUSE: boolean;
  42072. REFLECTIONFRESNELFROMSPECULAR: boolean;
  42073. LIGHTMAP: boolean;
  42074. LIGHTMAPDIRECTUV: number;
  42075. OBJECTSPACE_NORMALMAP: boolean;
  42076. USELIGHTMAPASSHADOWMAP: boolean;
  42077. REFLECTIONMAP_3D: boolean;
  42078. REFLECTIONMAP_SPHERICAL: boolean;
  42079. REFLECTIONMAP_PLANAR: boolean;
  42080. REFLECTIONMAP_CUBIC: boolean;
  42081. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  42082. REFLECTIONMAP_PROJECTION: boolean;
  42083. REFLECTIONMAP_SKYBOX: boolean;
  42084. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  42085. REFLECTIONMAP_EXPLICIT: boolean;
  42086. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  42087. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  42088. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  42089. INVERTCUBICMAP: boolean;
  42090. LOGARITHMICDEPTH: boolean;
  42091. REFRACTION: boolean;
  42092. REFRACTIONMAP_3D: boolean;
  42093. REFLECTIONOVERALPHA: boolean;
  42094. TWOSIDEDLIGHTING: boolean;
  42095. SHADOWFLOAT: boolean;
  42096. MORPHTARGETS: boolean;
  42097. MORPHTARGETS_NORMAL: boolean;
  42098. MORPHTARGETS_TANGENT: boolean;
  42099. MORPHTARGETS_UV: boolean;
  42100. NUM_MORPH_INFLUENCERS: number;
  42101. NONUNIFORMSCALING: boolean;
  42102. PREMULTIPLYALPHA: boolean;
  42103. IMAGEPROCESSING: boolean;
  42104. VIGNETTE: boolean;
  42105. VIGNETTEBLENDMODEMULTIPLY: boolean;
  42106. VIGNETTEBLENDMODEOPAQUE: boolean;
  42107. TONEMAPPING: boolean;
  42108. TONEMAPPING_ACES: boolean;
  42109. CONTRAST: boolean;
  42110. COLORCURVES: boolean;
  42111. COLORGRADING: boolean;
  42112. COLORGRADING3D: boolean;
  42113. SAMPLER3DGREENDEPTH: boolean;
  42114. SAMPLER3DBGRMAP: boolean;
  42115. IMAGEPROCESSINGPOSTPROCESS: boolean;
  42116. MULTIVIEW: boolean;
  42117. /**
  42118. * If the reflection texture on this material is in linear color space
  42119. * @hidden
  42120. */
  42121. IS_REFLECTION_LINEAR: boolean;
  42122. /**
  42123. * If the refraction texture on this material is in linear color space
  42124. * @hidden
  42125. */
  42126. IS_REFRACTION_LINEAR: boolean;
  42127. EXPOSURE: boolean;
  42128. constructor();
  42129. setReflectionMode(modeToEnable: string): void;
  42130. }
  42131. /**
  42132. * This is the default material used in Babylon. It is the best trade off between quality
  42133. * and performances.
  42134. * @see http://doc.babylonjs.com/babylon101/materials
  42135. */
  42136. export class StandardMaterial extends PushMaterial {
  42137. private _diffuseTexture;
  42138. /**
  42139. * The basic texture of the material as viewed under a light.
  42140. */
  42141. diffuseTexture: Nullable<BaseTexture>;
  42142. private _ambientTexture;
  42143. /**
  42144. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  42145. */
  42146. ambientTexture: Nullable<BaseTexture>;
  42147. private _opacityTexture;
  42148. /**
  42149. * Define the transparency of the material from a texture.
  42150. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  42151. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  42152. */
  42153. opacityTexture: Nullable<BaseTexture>;
  42154. private _reflectionTexture;
  42155. /**
  42156. * Define the texture used to display the reflection.
  42157. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42158. */
  42159. reflectionTexture: Nullable<BaseTexture>;
  42160. private _emissiveTexture;
  42161. /**
  42162. * Define texture of the material as if self lit.
  42163. * This will be mixed in the final result even in the absence of light.
  42164. */
  42165. emissiveTexture: Nullable<BaseTexture>;
  42166. private _specularTexture;
  42167. /**
  42168. * Define how the color and intensity of the highlight given by the light in the material.
  42169. */
  42170. specularTexture: Nullable<BaseTexture>;
  42171. private _bumpTexture;
  42172. /**
  42173. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  42174. * 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.
  42175. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  42176. */
  42177. bumpTexture: Nullable<BaseTexture>;
  42178. private _lightmapTexture;
  42179. /**
  42180. * Complex lighting can be computationally expensive to compute at runtime.
  42181. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  42182. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  42183. */
  42184. lightmapTexture: Nullable<BaseTexture>;
  42185. private _refractionTexture;
  42186. /**
  42187. * Define the texture used to display the refraction.
  42188. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42189. */
  42190. refractionTexture: Nullable<BaseTexture>;
  42191. /**
  42192. * The color of the material lit by the environmental background lighting.
  42193. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  42194. */
  42195. ambientColor: Color3;
  42196. /**
  42197. * The basic color of the material as viewed under a light.
  42198. */
  42199. diffuseColor: Color3;
  42200. /**
  42201. * Define how the color and intensity of the highlight given by the light in the material.
  42202. */
  42203. specularColor: Color3;
  42204. /**
  42205. * Define the color of the material as if self lit.
  42206. * This will be mixed in the final result even in the absence of light.
  42207. */
  42208. emissiveColor: Color3;
  42209. /**
  42210. * Defines how sharp are the highlights in the material.
  42211. * The bigger the value the sharper giving a more glossy feeling to the result.
  42212. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  42213. */
  42214. specularPower: number;
  42215. private _useAlphaFromDiffuseTexture;
  42216. /**
  42217. * Does the transparency come from the diffuse texture alpha channel.
  42218. */
  42219. useAlphaFromDiffuseTexture: boolean;
  42220. private _useEmissiveAsIllumination;
  42221. /**
  42222. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  42223. */
  42224. useEmissiveAsIllumination: boolean;
  42225. private _linkEmissiveWithDiffuse;
  42226. /**
  42227. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  42228. * the emissive level when the final color is close to one.
  42229. */
  42230. linkEmissiveWithDiffuse: boolean;
  42231. private _useSpecularOverAlpha;
  42232. /**
  42233. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42234. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42235. */
  42236. useSpecularOverAlpha: boolean;
  42237. private _useReflectionOverAlpha;
  42238. /**
  42239. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42240. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42241. */
  42242. useReflectionOverAlpha: boolean;
  42243. private _disableLighting;
  42244. /**
  42245. * Does lights from the scene impacts this material.
  42246. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  42247. */
  42248. disableLighting: boolean;
  42249. private _useObjectSpaceNormalMap;
  42250. /**
  42251. * Allows using an object space normal map (instead of tangent space).
  42252. */
  42253. useObjectSpaceNormalMap: boolean;
  42254. private _useParallax;
  42255. /**
  42256. * Is parallax enabled or not.
  42257. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42258. */
  42259. useParallax: boolean;
  42260. private _useParallaxOcclusion;
  42261. /**
  42262. * Is parallax occlusion enabled or not.
  42263. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  42264. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  42265. */
  42266. useParallaxOcclusion: boolean;
  42267. /**
  42268. * 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.
  42269. */
  42270. parallaxScaleBias: number;
  42271. private _roughness;
  42272. /**
  42273. * Helps to define how blurry the reflections should appears in the material.
  42274. */
  42275. roughness: number;
  42276. /**
  42277. * In case of refraction, define the value of the index of refraction.
  42278. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42279. */
  42280. indexOfRefraction: number;
  42281. /**
  42282. * Invert the refraction texture alongside the y axis.
  42283. * It can be useful with procedural textures or probe for instance.
  42284. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  42285. */
  42286. invertRefractionY: boolean;
  42287. /**
  42288. * Defines the alpha limits in alpha test mode.
  42289. */
  42290. alphaCutOff: number;
  42291. private _useLightmapAsShadowmap;
  42292. /**
  42293. * In case of light mapping, define whether the map contains light or shadow informations.
  42294. */
  42295. useLightmapAsShadowmap: boolean;
  42296. private _diffuseFresnelParameters;
  42297. /**
  42298. * Define the diffuse fresnel parameters of the material.
  42299. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42300. */
  42301. diffuseFresnelParameters: FresnelParameters;
  42302. private _opacityFresnelParameters;
  42303. /**
  42304. * Define the opacity fresnel parameters of the material.
  42305. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42306. */
  42307. opacityFresnelParameters: FresnelParameters;
  42308. private _reflectionFresnelParameters;
  42309. /**
  42310. * Define the reflection fresnel parameters of the material.
  42311. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42312. */
  42313. reflectionFresnelParameters: FresnelParameters;
  42314. private _refractionFresnelParameters;
  42315. /**
  42316. * Define the refraction fresnel parameters of the material.
  42317. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42318. */
  42319. refractionFresnelParameters: FresnelParameters;
  42320. private _emissiveFresnelParameters;
  42321. /**
  42322. * Define the emissive fresnel parameters of the material.
  42323. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42324. */
  42325. emissiveFresnelParameters: FresnelParameters;
  42326. private _useReflectionFresnelFromSpecular;
  42327. /**
  42328. * If true automatically deducts the fresnels values from the material specularity.
  42329. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  42330. */
  42331. useReflectionFresnelFromSpecular: boolean;
  42332. private _useGlossinessFromSpecularMapAlpha;
  42333. /**
  42334. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  42335. */
  42336. useGlossinessFromSpecularMapAlpha: boolean;
  42337. private _maxSimultaneousLights;
  42338. /**
  42339. * Defines the maximum number of lights that can be used in the material
  42340. */
  42341. maxSimultaneousLights: number;
  42342. private _invertNormalMapX;
  42343. /**
  42344. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  42345. */
  42346. invertNormalMapX: boolean;
  42347. private _invertNormalMapY;
  42348. /**
  42349. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  42350. */
  42351. invertNormalMapY: boolean;
  42352. private _twoSidedLighting;
  42353. /**
  42354. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42355. */
  42356. twoSidedLighting: boolean;
  42357. /**
  42358. * Default configuration related to image processing available in the standard Material.
  42359. */
  42360. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42361. /**
  42362. * Gets the image processing configuration used either in this material.
  42363. */
  42364. /**
  42365. * Sets the Default image processing configuration used either in the this material.
  42366. *
  42367. * If sets to null, the scene one is in use.
  42368. */
  42369. imageProcessingConfiguration: ImageProcessingConfiguration;
  42370. /**
  42371. * Keep track of the image processing observer to allow dispose and replace.
  42372. */
  42373. private _imageProcessingObserver;
  42374. /**
  42375. * Attaches a new image processing configuration to the Standard Material.
  42376. * @param configuration
  42377. */
  42378. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42379. /**
  42380. * Gets wether the color curves effect is enabled.
  42381. */
  42382. /**
  42383. * Sets wether the color curves effect is enabled.
  42384. */
  42385. cameraColorCurvesEnabled: boolean;
  42386. /**
  42387. * Gets wether the color grading effect is enabled.
  42388. */
  42389. /**
  42390. * Gets wether the color grading effect is enabled.
  42391. */
  42392. cameraColorGradingEnabled: boolean;
  42393. /**
  42394. * Gets wether tonemapping is enabled or not.
  42395. */
  42396. /**
  42397. * Sets wether tonemapping is enabled or not
  42398. */
  42399. cameraToneMappingEnabled: boolean;
  42400. /**
  42401. * The camera exposure used on this material.
  42402. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42403. * This corresponds to a photographic exposure.
  42404. */
  42405. /**
  42406. * The camera exposure used on this material.
  42407. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42408. * This corresponds to a photographic exposure.
  42409. */
  42410. cameraExposure: number;
  42411. /**
  42412. * Gets The camera contrast used on this material.
  42413. */
  42414. /**
  42415. * Sets The camera contrast used on this material.
  42416. */
  42417. cameraContrast: number;
  42418. /**
  42419. * Gets the Color Grading 2D Lookup Texture.
  42420. */
  42421. /**
  42422. * Sets the Color Grading 2D Lookup Texture.
  42423. */
  42424. cameraColorGradingTexture: Nullable<BaseTexture>;
  42425. /**
  42426. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42427. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42428. * 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;
  42429. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42430. */
  42431. /**
  42432. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42433. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42434. * 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;
  42435. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42436. */
  42437. cameraColorCurves: Nullable<ColorCurves>;
  42438. /**
  42439. * Custom callback helping to override the default shader used in the material.
  42440. */
  42441. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  42442. protected _renderTargets: SmartArray<RenderTargetTexture>;
  42443. protected _worldViewProjectionMatrix: Matrix;
  42444. protected _globalAmbientColor: Color3;
  42445. protected _useLogarithmicDepth: boolean;
  42446. protected _rebuildInParallel: boolean;
  42447. /**
  42448. * Instantiates a new standard material.
  42449. * This is the default material used in Babylon. It is the best trade off between quality
  42450. * and performances.
  42451. * @see http://doc.babylonjs.com/babylon101/materials
  42452. * @param name Define the name of the material in the scene
  42453. * @param scene Define the scene the material belong to
  42454. */
  42455. constructor(name: string, scene: Scene);
  42456. /**
  42457. * Gets a boolean indicating that current material needs to register RTT
  42458. */
  42459. readonly hasRenderTargetTextures: boolean;
  42460. /**
  42461. * Gets the current class name of the material e.g. "StandardMaterial"
  42462. * Mainly use in serialization.
  42463. * @returns the class name
  42464. */
  42465. getClassName(): string;
  42466. /**
  42467. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42468. * You can try switching to logarithmic depth.
  42469. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42470. */
  42471. useLogarithmicDepth: boolean;
  42472. /**
  42473. * Specifies if the material will require alpha blending
  42474. * @returns a boolean specifying if alpha blending is needed
  42475. */
  42476. needAlphaBlending(): boolean;
  42477. /**
  42478. * Specifies if this material should be rendered in alpha test mode
  42479. * @returns a boolean specifying if an alpha test is needed.
  42480. */
  42481. needAlphaTesting(): boolean;
  42482. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42483. /**
  42484. * Get the texture used for alpha test purpose.
  42485. * @returns the diffuse texture in case of the standard material.
  42486. */
  42487. getAlphaTestTexture(): Nullable<BaseTexture>;
  42488. /**
  42489. * Get if the submesh is ready to be used and all its information available.
  42490. * Child classes can use it to update shaders
  42491. * @param mesh defines the mesh to check
  42492. * @param subMesh defines which submesh to check
  42493. * @param useInstances specifies that instances should be used
  42494. * @returns a boolean indicating that the submesh is ready or not
  42495. */
  42496. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42497. /**
  42498. * Builds the material UBO layouts.
  42499. * Used internally during the effect preparation.
  42500. */
  42501. buildUniformLayout(): void;
  42502. /**
  42503. * Unbinds the material from the mesh
  42504. */
  42505. unbind(): void;
  42506. /**
  42507. * Binds the submesh to this material by preparing the effect and shader to draw
  42508. * @param world defines the world transformation matrix
  42509. * @param mesh defines the mesh containing the submesh
  42510. * @param subMesh defines the submesh to bind the material to
  42511. */
  42512. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42513. /**
  42514. * Get the list of animatables in the material.
  42515. * @returns the list of animatables object used in the material
  42516. */
  42517. getAnimatables(): IAnimatable[];
  42518. /**
  42519. * Gets the active textures from the material
  42520. * @returns an array of textures
  42521. */
  42522. getActiveTextures(): BaseTexture[];
  42523. /**
  42524. * Specifies if the material uses a texture
  42525. * @param texture defines the texture to check against the material
  42526. * @returns a boolean specifying if the material uses the texture
  42527. */
  42528. hasTexture(texture: BaseTexture): boolean;
  42529. /**
  42530. * Disposes the material
  42531. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42532. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42533. */
  42534. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42535. /**
  42536. * Makes a duplicate of the material, and gives it a new name
  42537. * @param name defines the new name for the duplicated material
  42538. * @returns the cloned material
  42539. */
  42540. clone(name: string): StandardMaterial;
  42541. /**
  42542. * Serializes this material in a JSON representation
  42543. * @returns the serialized material object
  42544. */
  42545. serialize(): any;
  42546. /**
  42547. * Creates a standard material from parsed material data
  42548. * @param source defines the JSON representation of the material
  42549. * @param scene defines the hosting scene
  42550. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42551. * @returns a new standard material
  42552. */
  42553. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42554. /**
  42555. * Are diffuse textures enabled in the application.
  42556. */
  42557. static DiffuseTextureEnabled: boolean;
  42558. /**
  42559. * Are ambient textures enabled in the application.
  42560. */
  42561. static AmbientTextureEnabled: boolean;
  42562. /**
  42563. * Are opacity textures enabled in the application.
  42564. */
  42565. static OpacityTextureEnabled: boolean;
  42566. /**
  42567. * Are reflection textures enabled in the application.
  42568. */
  42569. static ReflectionTextureEnabled: boolean;
  42570. /**
  42571. * Are emissive textures enabled in the application.
  42572. */
  42573. static EmissiveTextureEnabled: boolean;
  42574. /**
  42575. * Are specular textures enabled in the application.
  42576. */
  42577. static SpecularTextureEnabled: boolean;
  42578. /**
  42579. * Are bump textures enabled in the application.
  42580. */
  42581. static BumpTextureEnabled: boolean;
  42582. /**
  42583. * Are lightmap textures enabled in the application.
  42584. */
  42585. static LightmapTextureEnabled: boolean;
  42586. /**
  42587. * Are refraction textures enabled in the application.
  42588. */
  42589. static RefractionTextureEnabled: boolean;
  42590. /**
  42591. * Are color grading textures enabled in the application.
  42592. */
  42593. static ColorGradingTextureEnabled: boolean;
  42594. /**
  42595. * Are fresnels enabled in the application.
  42596. */
  42597. static FresnelEnabled: boolean;
  42598. }
  42599. }
  42600. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42601. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42602. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42603. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42604. /** @hidden */
  42605. export var imageProcessingPixelShader: {
  42606. name: string;
  42607. shader: string;
  42608. };
  42609. }
  42610. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42611. import { Nullable } from "babylonjs/types";
  42612. import { Color4 } from "babylonjs/Maths/math.color";
  42613. import { Camera } from "babylonjs/Cameras/camera";
  42614. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42615. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42616. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42617. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42618. import { Engine } from "babylonjs/Engines/engine";
  42619. import "babylonjs/Shaders/imageProcessing.fragment";
  42620. import "babylonjs/Shaders/postprocess.vertex";
  42621. /**
  42622. * ImageProcessingPostProcess
  42623. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42624. */
  42625. export class ImageProcessingPostProcess extends PostProcess {
  42626. /**
  42627. * Default configuration related to image processing available in the PBR Material.
  42628. */
  42629. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42630. /**
  42631. * Gets the image processing configuration used either in this material.
  42632. */
  42633. /**
  42634. * Sets the Default image processing configuration used either in the this material.
  42635. *
  42636. * If sets to null, the scene one is in use.
  42637. */
  42638. imageProcessingConfiguration: ImageProcessingConfiguration;
  42639. /**
  42640. * Keep track of the image processing observer to allow dispose and replace.
  42641. */
  42642. private _imageProcessingObserver;
  42643. /**
  42644. * Attaches a new image processing configuration to the PBR Material.
  42645. * @param configuration
  42646. */
  42647. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42648. /**
  42649. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42650. */
  42651. /**
  42652. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42653. */
  42654. colorCurves: Nullable<ColorCurves>;
  42655. /**
  42656. * Gets wether the color curves effect is enabled.
  42657. */
  42658. /**
  42659. * Sets wether the color curves effect is enabled.
  42660. */
  42661. colorCurvesEnabled: boolean;
  42662. /**
  42663. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42664. */
  42665. /**
  42666. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42667. */
  42668. colorGradingTexture: Nullable<BaseTexture>;
  42669. /**
  42670. * Gets wether the color grading effect is enabled.
  42671. */
  42672. /**
  42673. * Gets wether the color grading effect is enabled.
  42674. */
  42675. colorGradingEnabled: boolean;
  42676. /**
  42677. * Gets exposure used in the effect.
  42678. */
  42679. /**
  42680. * Sets exposure used in the effect.
  42681. */
  42682. exposure: number;
  42683. /**
  42684. * Gets wether tonemapping is enabled or not.
  42685. */
  42686. /**
  42687. * Sets wether tonemapping is enabled or not
  42688. */
  42689. toneMappingEnabled: boolean;
  42690. /**
  42691. * Gets the type of tone mapping effect.
  42692. */
  42693. /**
  42694. * Sets the type of tone mapping effect.
  42695. */
  42696. toneMappingType: number;
  42697. /**
  42698. * Gets contrast used in the effect.
  42699. */
  42700. /**
  42701. * Sets contrast used in the effect.
  42702. */
  42703. contrast: number;
  42704. /**
  42705. * Gets Vignette stretch size.
  42706. */
  42707. /**
  42708. * Sets Vignette stretch size.
  42709. */
  42710. vignetteStretch: number;
  42711. /**
  42712. * Gets Vignette centre X Offset.
  42713. */
  42714. /**
  42715. * Sets Vignette centre X Offset.
  42716. */
  42717. vignetteCentreX: number;
  42718. /**
  42719. * Gets Vignette centre Y Offset.
  42720. */
  42721. /**
  42722. * Sets Vignette centre Y Offset.
  42723. */
  42724. vignetteCentreY: number;
  42725. /**
  42726. * Gets Vignette weight or intensity of the vignette effect.
  42727. */
  42728. /**
  42729. * Sets Vignette weight or intensity of the vignette effect.
  42730. */
  42731. vignetteWeight: number;
  42732. /**
  42733. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42734. * if vignetteEnabled is set to true.
  42735. */
  42736. /**
  42737. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42738. * if vignetteEnabled is set to true.
  42739. */
  42740. vignetteColor: Color4;
  42741. /**
  42742. * Gets Camera field of view used by the Vignette effect.
  42743. */
  42744. /**
  42745. * Sets Camera field of view used by the Vignette effect.
  42746. */
  42747. vignetteCameraFov: number;
  42748. /**
  42749. * Gets the vignette blend mode allowing different kind of effect.
  42750. */
  42751. /**
  42752. * Sets the vignette blend mode allowing different kind of effect.
  42753. */
  42754. vignetteBlendMode: number;
  42755. /**
  42756. * Gets wether the vignette effect is enabled.
  42757. */
  42758. /**
  42759. * Sets wether the vignette effect is enabled.
  42760. */
  42761. vignetteEnabled: boolean;
  42762. private _fromLinearSpace;
  42763. /**
  42764. * Gets wether the input of the processing is in Gamma or Linear Space.
  42765. */
  42766. /**
  42767. * Sets wether the input of the processing is in Gamma or Linear Space.
  42768. */
  42769. fromLinearSpace: boolean;
  42770. /**
  42771. * Defines cache preventing GC.
  42772. */
  42773. private _defines;
  42774. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42775. /**
  42776. * "ImageProcessingPostProcess"
  42777. * @returns "ImageProcessingPostProcess"
  42778. */
  42779. getClassName(): string;
  42780. protected _updateParameters(): void;
  42781. dispose(camera?: Camera): void;
  42782. }
  42783. }
  42784. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42785. import { Scene } from "babylonjs/scene";
  42786. import { Color3 } from "babylonjs/Maths/math.color";
  42787. import { Mesh } from "babylonjs/Meshes/mesh";
  42788. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42789. import { Nullable } from "babylonjs/types";
  42790. /**
  42791. * Class containing static functions to help procedurally build meshes
  42792. */
  42793. export class GroundBuilder {
  42794. /**
  42795. * Creates a ground mesh
  42796. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42797. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42799. * @param name defines the name of the mesh
  42800. * @param options defines the options used to create the mesh
  42801. * @param scene defines the hosting scene
  42802. * @returns the ground mesh
  42803. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42804. */
  42805. static CreateGround(name: string, options: {
  42806. width?: number;
  42807. height?: number;
  42808. subdivisions?: number;
  42809. subdivisionsX?: number;
  42810. subdivisionsY?: number;
  42811. updatable?: boolean;
  42812. }, scene: any): Mesh;
  42813. /**
  42814. * Creates a tiled ground mesh
  42815. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42816. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42817. * * 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
  42818. * * 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
  42819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42820. * @param name defines the name of the mesh
  42821. * @param options defines the options used to create the mesh
  42822. * @param scene defines the hosting scene
  42823. * @returns the tiled ground mesh
  42824. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42825. */
  42826. static CreateTiledGround(name: string, options: {
  42827. xmin: number;
  42828. zmin: number;
  42829. xmax: number;
  42830. zmax: number;
  42831. subdivisions?: {
  42832. w: number;
  42833. h: number;
  42834. };
  42835. precision?: {
  42836. w: number;
  42837. h: number;
  42838. };
  42839. updatable?: boolean;
  42840. }, scene?: Nullable<Scene>): Mesh;
  42841. /**
  42842. * Creates a ground mesh from a height map
  42843. * * The parameter `url` sets the URL of the height map image resource.
  42844. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42845. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42846. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42847. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42848. * * 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.
  42849. * * 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).
  42850. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42852. * @param name defines the name of the mesh
  42853. * @param url defines the url to the height map
  42854. * @param options defines the options used to create the mesh
  42855. * @param scene defines the hosting scene
  42856. * @returns the ground mesh
  42857. * @see https://doc.babylonjs.com/babylon101/height_map
  42858. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42859. */
  42860. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42861. width?: number;
  42862. height?: number;
  42863. subdivisions?: number;
  42864. minHeight?: number;
  42865. maxHeight?: number;
  42866. colorFilter?: Color3;
  42867. alphaFilter?: number;
  42868. updatable?: boolean;
  42869. onReady?: (mesh: GroundMesh) => void;
  42870. }, scene?: Nullable<Scene>): GroundMesh;
  42871. }
  42872. }
  42873. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42874. import { Vector4 } from "babylonjs/Maths/math.vector";
  42875. import { Mesh } from "babylonjs/Meshes/mesh";
  42876. /**
  42877. * Class containing static functions to help procedurally build meshes
  42878. */
  42879. export class TorusBuilder {
  42880. /**
  42881. * Creates a torus mesh
  42882. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42883. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42884. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42888. * @param name defines the name of the mesh
  42889. * @param options defines the options used to create the mesh
  42890. * @param scene defines the hosting scene
  42891. * @returns the torus mesh
  42892. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42893. */
  42894. static CreateTorus(name: string, options: {
  42895. diameter?: number;
  42896. thickness?: number;
  42897. tessellation?: number;
  42898. updatable?: boolean;
  42899. sideOrientation?: number;
  42900. frontUVs?: Vector4;
  42901. backUVs?: Vector4;
  42902. }, scene: any): Mesh;
  42903. }
  42904. }
  42905. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42906. import { Vector4 } from "babylonjs/Maths/math.vector";
  42907. import { Color4 } from "babylonjs/Maths/math.color";
  42908. import { Mesh } from "babylonjs/Meshes/mesh";
  42909. /**
  42910. * Class containing static functions to help procedurally build meshes
  42911. */
  42912. export class CylinderBuilder {
  42913. /**
  42914. * Creates a cylinder or a cone mesh
  42915. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42916. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42917. * * 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.
  42918. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42919. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42920. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42921. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42922. * * 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).
  42923. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42924. * * 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).
  42925. * * 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
  42926. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42927. * * 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
  42928. * * 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.
  42929. * * If `enclose` is false, a ring surface is one element.
  42930. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42931. * * 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
  42932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42935. * @param name defines the name of the mesh
  42936. * @param options defines the options used to create the mesh
  42937. * @param scene defines the hosting scene
  42938. * @returns the cylinder mesh
  42939. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42940. */
  42941. static CreateCylinder(name: string, options: {
  42942. height?: number;
  42943. diameterTop?: number;
  42944. diameterBottom?: number;
  42945. diameter?: number;
  42946. tessellation?: number;
  42947. subdivisions?: number;
  42948. arc?: number;
  42949. faceColors?: Color4[];
  42950. faceUV?: Vector4[];
  42951. updatable?: boolean;
  42952. hasRings?: boolean;
  42953. enclose?: boolean;
  42954. cap?: number;
  42955. sideOrientation?: number;
  42956. frontUVs?: Vector4;
  42957. backUVs?: Vector4;
  42958. }, scene: any): Mesh;
  42959. }
  42960. }
  42961. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42962. import { Observable } from "babylonjs/Misc/observable";
  42963. import { Nullable } from "babylonjs/types";
  42964. import { Camera } from "babylonjs/Cameras/camera";
  42965. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42966. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42967. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42968. import { Scene } from "babylonjs/scene";
  42969. import { Vector3 } from "babylonjs/Maths/math.vector";
  42970. import { Color3 } from "babylonjs/Maths/math.color";
  42971. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42973. import { Mesh } from "babylonjs/Meshes/mesh";
  42974. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42975. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42976. import "babylonjs/Meshes/Builders/groundBuilder";
  42977. import "babylonjs/Meshes/Builders/torusBuilder";
  42978. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42979. import "babylonjs/Gamepads/gamepadSceneComponent";
  42980. import "babylonjs/Animations/animatable";
  42981. /**
  42982. * Options to modify the vr teleportation behavior.
  42983. */
  42984. export interface VRTeleportationOptions {
  42985. /**
  42986. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42987. */
  42988. floorMeshName?: string;
  42989. /**
  42990. * A list of meshes to be used as the teleportation floor. (default: empty)
  42991. */
  42992. floorMeshes?: Mesh[];
  42993. }
  42994. /**
  42995. * Options to modify the vr experience helper's behavior.
  42996. */
  42997. export interface VRExperienceHelperOptions extends WebVROptions {
  42998. /**
  42999. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  43000. */
  43001. createDeviceOrientationCamera?: boolean;
  43002. /**
  43003. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  43004. */
  43005. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  43006. /**
  43007. * Uses the main button on the controller to toggle the laser casted. (default: true)
  43008. */
  43009. laserToggle?: boolean;
  43010. /**
  43011. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  43012. */
  43013. floorMeshes?: Mesh[];
  43014. /**
  43015. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  43016. */
  43017. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  43018. }
  43019. /**
  43020. * Event containing information after VR has been entered
  43021. */
  43022. export class OnAfterEnteringVRObservableEvent {
  43023. /**
  43024. * If entering vr was successful
  43025. */
  43026. success: boolean;
  43027. }
  43028. /**
  43029. * Helps to quickly add VR support to an existing scene.
  43030. * See http://doc.babylonjs.com/how_to/webvr_helper
  43031. */
  43032. export class VRExperienceHelper {
  43033. /** Options to modify the vr experience helper's behavior. */
  43034. webVROptions: VRExperienceHelperOptions;
  43035. private _scene;
  43036. private _position;
  43037. private _btnVR;
  43038. private _btnVRDisplayed;
  43039. private _webVRsupported;
  43040. private _webVRready;
  43041. private _webVRrequesting;
  43042. private _webVRpresenting;
  43043. private _hasEnteredVR;
  43044. private _fullscreenVRpresenting;
  43045. private _inputElement;
  43046. private _webVRCamera;
  43047. private _vrDeviceOrientationCamera;
  43048. private _deviceOrientationCamera;
  43049. private _existingCamera;
  43050. private _onKeyDown;
  43051. private _onVrDisplayPresentChange;
  43052. private _onVRDisplayChanged;
  43053. private _onVRRequestPresentStart;
  43054. private _onVRRequestPresentComplete;
  43055. /**
  43056. * 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)
  43057. */
  43058. enableGazeEvenWhenNoPointerLock: boolean;
  43059. /**
  43060. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  43061. */
  43062. exitVROnDoubleTap: boolean;
  43063. /**
  43064. * Observable raised right before entering VR.
  43065. */
  43066. onEnteringVRObservable: Observable<VRExperienceHelper>;
  43067. /**
  43068. * Observable raised when entering VR has completed.
  43069. */
  43070. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  43071. /**
  43072. * Observable raised when exiting VR.
  43073. */
  43074. onExitingVRObservable: Observable<VRExperienceHelper>;
  43075. /**
  43076. * Observable raised when controller mesh is loaded.
  43077. */
  43078. onControllerMeshLoadedObservable: Observable<WebVRController>;
  43079. /** Return this.onEnteringVRObservable
  43080. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  43081. */
  43082. readonly onEnteringVR: Observable<VRExperienceHelper>;
  43083. /** Return this.onExitingVRObservable
  43084. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  43085. */
  43086. readonly onExitingVR: Observable<VRExperienceHelper>;
  43087. /** Return this.onControllerMeshLoadedObservable
  43088. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  43089. */
  43090. readonly onControllerMeshLoaded: Observable<WebVRController>;
  43091. private _rayLength;
  43092. private _useCustomVRButton;
  43093. private _teleportationRequested;
  43094. private _teleportActive;
  43095. private _floorMeshName;
  43096. private _floorMeshesCollection;
  43097. private _rotationAllowed;
  43098. private _teleportBackwardsVector;
  43099. private _teleportationTarget;
  43100. private _isDefaultTeleportationTarget;
  43101. private _postProcessMove;
  43102. private _teleportationFillColor;
  43103. private _teleportationBorderColor;
  43104. private _rotationAngle;
  43105. private _haloCenter;
  43106. private _cameraGazer;
  43107. private _padSensibilityUp;
  43108. private _padSensibilityDown;
  43109. private _leftController;
  43110. private _rightController;
  43111. /**
  43112. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  43113. */
  43114. onNewMeshSelected: Observable<AbstractMesh>;
  43115. /**
  43116. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  43117. * This observable will provide the mesh and the controller used to select the mesh
  43118. */
  43119. onMeshSelectedWithController: Observable<{
  43120. mesh: AbstractMesh;
  43121. controller: WebVRController;
  43122. }>;
  43123. /**
  43124. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  43125. */
  43126. onNewMeshPicked: Observable<PickingInfo>;
  43127. private _circleEase;
  43128. /**
  43129. * Observable raised before camera teleportation
  43130. */
  43131. onBeforeCameraTeleport: Observable<Vector3>;
  43132. /**
  43133. * Observable raised after camera teleportation
  43134. */
  43135. onAfterCameraTeleport: Observable<Vector3>;
  43136. /**
  43137. * Observable raised when current selected mesh gets unselected
  43138. */
  43139. onSelectedMeshUnselected: Observable<AbstractMesh>;
  43140. private _raySelectionPredicate;
  43141. /**
  43142. * To be optionaly changed by user to define custom ray selection
  43143. */
  43144. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  43145. /**
  43146. * To be optionaly changed by user to define custom selection logic (after ray selection)
  43147. */
  43148. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  43149. /**
  43150. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  43151. */
  43152. teleportationEnabled: boolean;
  43153. private _defaultHeight;
  43154. private _teleportationInitialized;
  43155. private _interactionsEnabled;
  43156. private _interactionsRequested;
  43157. private _displayGaze;
  43158. private _displayLaserPointer;
  43159. /**
  43160. * The mesh used to display where the user is going to teleport.
  43161. */
  43162. /**
  43163. * Sets the mesh to be used to display where the user is going to teleport.
  43164. */
  43165. teleportationTarget: Mesh;
  43166. /**
  43167. * 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
  43168. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  43169. * See http://doc.babylonjs.com/resources/baking_transformations
  43170. */
  43171. gazeTrackerMesh: Mesh;
  43172. /**
  43173. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  43174. */
  43175. updateGazeTrackerScale: boolean;
  43176. /**
  43177. * If the gaze trackers color should be updated when selecting meshes
  43178. */
  43179. updateGazeTrackerColor: boolean;
  43180. /**
  43181. * If the controller laser color should be updated when selecting meshes
  43182. */
  43183. updateControllerLaserColor: boolean;
  43184. /**
  43185. * The gaze tracking mesh corresponding to the left controller
  43186. */
  43187. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  43188. /**
  43189. * The gaze tracking mesh corresponding to the right controller
  43190. */
  43191. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  43192. /**
  43193. * If the ray of the gaze should be displayed.
  43194. */
  43195. /**
  43196. * Sets if the ray of the gaze should be displayed.
  43197. */
  43198. displayGaze: boolean;
  43199. /**
  43200. * If the ray of the LaserPointer should be displayed.
  43201. */
  43202. /**
  43203. * Sets if the ray of the LaserPointer should be displayed.
  43204. */
  43205. displayLaserPointer: boolean;
  43206. /**
  43207. * The deviceOrientationCamera used as the camera when not in VR.
  43208. */
  43209. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  43210. /**
  43211. * Based on the current WebVR support, returns the current VR camera used.
  43212. */
  43213. readonly currentVRCamera: Nullable<Camera>;
  43214. /**
  43215. * The webVRCamera which is used when in VR.
  43216. */
  43217. readonly webVRCamera: WebVRFreeCamera;
  43218. /**
  43219. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  43220. */
  43221. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  43222. /**
  43223. * The html button that is used to trigger entering into VR.
  43224. */
  43225. readonly vrButton: Nullable<HTMLButtonElement>;
  43226. private readonly _teleportationRequestInitiated;
  43227. /**
  43228. * Defines wether or not Pointer lock should be requested when switching to
  43229. * full screen.
  43230. */
  43231. requestPointerLockOnFullScreen: boolean;
  43232. /**
  43233. * Instantiates a VRExperienceHelper.
  43234. * Helps to quickly add VR support to an existing scene.
  43235. * @param scene The scene the VRExperienceHelper belongs to.
  43236. * @param webVROptions Options to modify the vr experience helper's behavior.
  43237. */
  43238. constructor(scene: Scene,
  43239. /** Options to modify the vr experience helper's behavior. */
  43240. webVROptions?: VRExperienceHelperOptions);
  43241. private _onDefaultMeshLoaded;
  43242. private _onResize;
  43243. private _onFullscreenChange;
  43244. /**
  43245. * Gets a value indicating if we are currently in VR mode.
  43246. */
  43247. readonly isInVRMode: boolean;
  43248. private onVrDisplayPresentChange;
  43249. private onVRDisplayChanged;
  43250. private moveButtonToBottomRight;
  43251. private displayVRButton;
  43252. private updateButtonVisibility;
  43253. private _cachedAngularSensibility;
  43254. /**
  43255. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  43256. * Otherwise, will use the fullscreen API.
  43257. */
  43258. enterVR(): void;
  43259. /**
  43260. * Attempt to exit VR, or fullscreen.
  43261. */
  43262. exitVR(): void;
  43263. /**
  43264. * The position of the vr experience helper.
  43265. */
  43266. /**
  43267. * Sets the position of the vr experience helper.
  43268. */
  43269. position: Vector3;
  43270. /**
  43271. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  43272. */
  43273. enableInteractions(): void;
  43274. private readonly _noControllerIsActive;
  43275. private beforeRender;
  43276. private _isTeleportationFloor;
  43277. /**
  43278. * Adds a floor mesh to be used for teleportation.
  43279. * @param floorMesh the mesh to be used for teleportation.
  43280. */
  43281. addFloorMesh(floorMesh: Mesh): void;
  43282. /**
  43283. * Removes a floor mesh from being used for teleportation.
  43284. * @param floorMesh the mesh to be removed.
  43285. */
  43286. removeFloorMesh(floorMesh: Mesh): void;
  43287. /**
  43288. * Enables interactions and teleportation using the VR controllers and gaze.
  43289. * @param vrTeleportationOptions options to modify teleportation behavior.
  43290. */
  43291. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  43292. private _onNewGamepadConnected;
  43293. private _tryEnableInteractionOnController;
  43294. private _onNewGamepadDisconnected;
  43295. private _enableInteractionOnController;
  43296. private _checkTeleportWithRay;
  43297. private _checkRotate;
  43298. private _checkTeleportBackwards;
  43299. private _enableTeleportationOnController;
  43300. private _createTeleportationCircles;
  43301. private _displayTeleportationTarget;
  43302. private _hideTeleportationTarget;
  43303. private _rotateCamera;
  43304. private _moveTeleportationSelectorTo;
  43305. private _workingVector;
  43306. private _workingQuaternion;
  43307. private _workingMatrix;
  43308. /**
  43309. * Teleports the users feet to the desired location
  43310. * @param location The location where the user's feet should be placed
  43311. */
  43312. teleportCamera(location: Vector3): void;
  43313. private _convertNormalToDirectionOfRay;
  43314. private _castRayAndSelectObject;
  43315. private _notifySelectedMeshUnselected;
  43316. /**
  43317. * Sets the color of the laser ray from the vr controllers.
  43318. * @param color new color for the ray.
  43319. */
  43320. changeLaserColor(color: Color3): void;
  43321. /**
  43322. * Sets the color of the ray from the vr headsets gaze.
  43323. * @param color new color for the ray.
  43324. */
  43325. changeGazeColor(color: Color3): void;
  43326. /**
  43327. * Exits VR and disposes of the vr experience helper
  43328. */
  43329. dispose(): void;
  43330. /**
  43331. * Gets the name of the VRExperienceHelper class
  43332. * @returns "VRExperienceHelper"
  43333. */
  43334. getClassName(): string;
  43335. }
  43336. }
  43337. declare module "babylonjs/Cameras/VR/index" {
  43338. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  43339. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  43340. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43341. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  43342. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  43343. export * from "babylonjs/Cameras/VR/webVRCamera";
  43344. }
  43345. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43346. import { Nullable } from "babylonjs/types";
  43347. import { IDisposable } from "babylonjs/scene";
  43348. /**
  43349. * States of the webXR experience
  43350. */
  43351. export enum WebXRState {
  43352. /**
  43353. * Transitioning to being in XR mode
  43354. */
  43355. ENTERING_XR = 0,
  43356. /**
  43357. * Transitioning to non XR mode
  43358. */
  43359. EXITING_XR = 1,
  43360. /**
  43361. * In XR mode and presenting
  43362. */
  43363. IN_XR = 2,
  43364. /**
  43365. * Not entered XR mode
  43366. */
  43367. NOT_IN_XR = 3
  43368. }
  43369. /**
  43370. * Abstraction of the XR render target
  43371. */
  43372. export interface WebXRRenderTarget extends IDisposable {
  43373. /**
  43374. * xrpresent context of the canvas which can be used to display/mirror xr content
  43375. */
  43376. canvasContext: WebGLRenderingContext;
  43377. /**
  43378. * xr layer for the canvas
  43379. */
  43380. xrLayer: Nullable<XRWebGLLayer>;
  43381. /**
  43382. * Initializes the xr layer for the session
  43383. * @param xrSession xr session
  43384. * @returns a promise that will resolve once the XR Layer has been created
  43385. */
  43386. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43387. }
  43388. }
  43389. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43390. import { Nullable } from "babylonjs/types";
  43391. import { Observable } from "babylonjs/Misc/observable";
  43392. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43393. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43394. /**
  43395. * COnfiguration object for WebXR output canvas
  43396. */
  43397. export class WebXRManagedOutputCanvasOptions {
  43398. /**
  43399. * Options for this XR Layer output
  43400. */
  43401. canvasOptions: XRWebGLLayerOptions;
  43402. /**
  43403. * CSS styling for a newly created canvas (if not provided)
  43404. */
  43405. newCanvasCssStyle?: string;
  43406. /**
  43407. * Get the default values of the configuration object
  43408. * @returns default values of this configuration object
  43409. */
  43410. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43411. }
  43412. /**
  43413. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43414. */
  43415. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43416. private configuration;
  43417. private _engine;
  43418. private _canvas;
  43419. /**
  43420. * xrpresent context of the canvas which can be used to display/mirror xr content
  43421. */
  43422. canvasContext: WebGLRenderingContext;
  43423. /**
  43424. * xr layer for the canvas
  43425. */
  43426. xrLayer: Nullable<XRWebGLLayer>;
  43427. /**
  43428. * Initializes the xr layer for the session
  43429. * @param xrSession xr session
  43430. * @returns a promise that will resolve once the XR Layer has been created
  43431. */
  43432. initializeXRLayerAsync(xrSession: any): any;
  43433. /**
  43434. * Initializes the canvas to be added/removed upon entering/exiting xr
  43435. * @param engine the Babylon engine
  43436. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43437. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43438. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43439. */
  43440. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43441. /**
  43442. * Disposes of the object
  43443. */
  43444. dispose(): void;
  43445. private _setManagedOutputCanvas;
  43446. private _addCanvas;
  43447. private _removeCanvas;
  43448. }
  43449. }
  43450. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43451. import { Observable } from "babylonjs/Misc/observable";
  43452. import { Nullable } from "babylonjs/types";
  43453. import { IDisposable, Scene } from "babylonjs/scene";
  43454. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43455. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43456. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43457. /**
  43458. * Manages an XRSession to work with Babylon's engine
  43459. * @see https://doc.babylonjs.com/how_to/webxr
  43460. */
  43461. export class WebXRSessionManager implements IDisposable {
  43462. private scene;
  43463. /**
  43464. * Fires every time a new xrFrame arrives which can be used to update the camera
  43465. */
  43466. onXRFrameObservable: Observable<any>;
  43467. /**
  43468. * Fires when the xr session is ended either by the device or manually done
  43469. */
  43470. onXRSessionEnded: Observable<any>;
  43471. /**
  43472. * Underlying xr session
  43473. */
  43474. session: XRSession;
  43475. /**
  43476. * Type of reference space used when creating the session
  43477. */
  43478. referenceSpace: XRReferenceSpace;
  43479. /**
  43480. * Current XR frame
  43481. */
  43482. currentFrame: Nullable<XRFrame>;
  43483. private _xrNavigator;
  43484. private baseLayer;
  43485. private _rttProvider;
  43486. private _sessionEnded;
  43487. /**
  43488. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43489. * @param scene The scene which the session should be created for
  43490. */
  43491. constructor(scene: Scene);
  43492. /**
  43493. * Initializes the manager
  43494. * After initialization enterXR can be called to start an XR session
  43495. * @returns Promise which resolves after it is initialized
  43496. */
  43497. initializeAsync(): Promise<void>;
  43498. /**
  43499. * Initializes an xr session
  43500. * @param xrSessionMode mode to initialize
  43501. * @param optionalFeatures defines optional values to pass to the session builder
  43502. * @returns a promise which will resolve once the session has been initialized
  43503. */
  43504. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43505. /**
  43506. * Sets the reference space on the xr session
  43507. * @param referenceSpace space to set
  43508. * @returns a promise that will resolve once the reference space has been set
  43509. */
  43510. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43511. /**
  43512. * Updates the render state of the session
  43513. * @param state state to set
  43514. * @returns a promise that resolves once the render state has been updated
  43515. */
  43516. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43517. /**
  43518. * Starts rendering to the xr layer
  43519. * @returns a promise that will resolve once rendering has started
  43520. */
  43521. startRenderingToXRAsync(): Promise<void>;
  43522. /**
  43523. * Gets the correct render target texture to be rendered this frame for this eye
  43524. * @param eye the eye for which to get the render target
  43525. * @returns the render target for the specified eye
  43526. */
  43527. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43528. /**
  43529. * Stops the xrSession and restores the renderloop
  43530. * @returns Promise which resolves after it exits XR
  43531. */
  43532. exitXRAsync(): Promise<void>;
  43533. /**
  43534. * Checks if a session would be supported for the creation options specified
  43535. * @param sessionMode session mode to check if supported eg. immersive-vr
  43536. * @returns true if supported
  43537. */
  43538. supportsSessionAsync(sessionMode: XRSessionMode): any;
  43539. /**
  43540. * Creates a WebXRRenderTarget object for the XR session
  43541. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43542. * @param options optional options to provide when creating a new render target
  43543. * @returns a WebXR render target to which the session can render
  43544. */
  43545. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43546. /**
  43547. * @hidden
  43548. * Converts the render layer of xrSession to a render target
  43549. * @param session session to create render target for
  43550. * @param scene scene the new render target should be created for
  43551. */
  43552. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43553. /**
  43554. * Disposes of the session manager
  43555. */
  43556. dispose(): void;
  43557. }
  43558. }
  43559. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43560. import { Scene } from "babylonjs/scene";
  43561. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43562. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43563. /**
  43564. * WebXR Camera which holds the views for the xrSession
  43565. * @see https://doc.babylonjs.com/how_to/webxr
  43566. */
  43567. export class WebXRCamera extends FreeCamera {
  43568. /**
  43569. * Is the camera in debug mode. Used when using an emulator
  43570. */
  43571. debugMode: boolean;
  43572. /**
  43573. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43574. * @param name the name of the camera
  43575. * @param scene the scene to add the camera to
  43576. */
  43577. constructor(name: string, scene: Scene);
  43578. private _updateNumberOfRigCameras;
  43579. /** @hidden */
  43580. _updateForDualEyeDebugging(): void;
  43581. /**
  43582. * Updates the cameras position from the current pose information of the XR session
  43583. * @param xrSessionManager the session containing pose information
  43584. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43585. */
  43586. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43587. }
  43588. }
  43589. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43590. import { Observable } from "babylonjs/Misc/observable";
  43591. import { IDisposable, Scene } from "babylonjs/scene";
  43592. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43594. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43595. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43596. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43597. /**
  43598. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43599. * @see https://doc.babylonjs.com/how_to/webxr
  43600. */
  43601. export class WebXRExperienceHelper implements IDisposable {
  43602. private scene;
  43603. /**
  43604. * 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
  43605. */
  43606. container: AbstractMesh;
  43607. /**
  43608. * Camera used to render xr content
  43609. */
  43610. camera: WebXRCamera;
  43611. /**
  43612. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43613. */
  43614. state: WebXRState;
  43615. private _setState;
  43616. private static _TmpVector;
  43617. /**
  43618. * Fires when the state of the experience helper has changed
  43619. */
  43620. onStateChangedObservable: Observable<WebXRState>;
  43621. /** Session manager used to keep track of xr session */
  43622. sessionManager: WebXRSessionManager;
  43623. private _nonVRCamera;
  43624. private _originalSceneAutoClear;
  43625. private _supported;
  43626. /**
  43627. * Creates the experience helper
  43628. * @param scene the scene to attach the experience helper to
  43629. * @returns a promise for the experience helper
  43630. */
  43631. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43632. /**
  43633. * Creates a WebXRExperienceHelper
  43634. * @param scene The scene the helper should be created in
  43635. */
  43636. private constructor();
  43637. /**
  43638. * Exits XR mode and returns the scene to its original state
  43639. * @returns promise that resolves after xr mode has exited
  43640. */
  43641. exitXRAsync(): Promise<void>;
  43642. /**
  43643. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43644. * @param sessionMode options for the XR session
  43645. * @param referenceSpaceType frame of reference of the XR session
  43646. * @param renderTarget the output canvas that will be used to enter XR mode
  43647. * @returns promise that resolves after xr mode has entered
  43648. */
  43649. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43650. /**
  43651. * Updates the global position of the camera by moving the camera's container
  43652. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43653. * @param position The desired global position of the camera
  43654. */
  43655. setPositionOfCameraUsingContainer(position: Vector3): void;
  43656. /**
  43657. * Rotates the xr camera by rotating the camera's container around the camera's position
  43658. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43659. * @param rotation the desired quaternion rotation to apply to the camera
  43660. */
  43661. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43662. /**
  43663. * Disposes of the experience helper
  43664. */
  43665. dispose(): void;
  43666. }
  43667. }
  43668. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43669. import { Nullable } from "babylonjs/types";
  43670. import { Observable } from "babylonjs/Misc/observable";
  43671. import { IDisposable, Scene } from "babylonjs/scene";
  43672. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43673. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43674. /**
  43675. * Button which can be used to enter a different mode of XR
  43676. */
  43677. export class WebXREnterExitUIButton {
  43678. /** button element */
  43679. element: HTMLElement;
  43680. /** XR initialization options for the button */
  43681. sessionMode: XRSessionMode;
  43682. /** Reference space type */
  43683. referenceSpaceType: XRReferenceSpaceType;
  43684. /**
  43685. * Creates a WebXREnterExitUIButton
  43686. * @param element button element
  43687. * @param sessionMode XR initialization session mode
  43688. * @param referenceSpaceType the type of reference space to be used
  43689. */
  43690. constructor(
  43691. /** button element */
  43692. element: HTMLElement,
  43693. /** XR initialization options for the button */
  43694. sessionMode: XRSessionMode,
  43695. /** Reference space type */
  43696. referenceSpaceType: XRReferenceSpaceType);
  43697. /**
  43698. * Overwritable function which can be used to update the button's visuals when the state changes
  43699. * @param activeButton the current active button in the UI
  43700. */
  43701. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43702. }
  43703. /**
  43704. * Options to create the webXR UI
  43705. */
  43706. export class WebXREnterExitUIOptions {
  43707. /**
  43708. * Context to enter xr with
  43709. */
  43710. renderTarget?: Nullable<WebXRRenderTarget>;
  43711. /**
  43712. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43713. */
  43714. customButtons?: Array<WebXREnterExitUIButton>;
  43715. /**
  43716. * A session mode to use when creating the default button.
  43717. * Default is immersive-vr
  43718. */
  43719. sessionMode?: XRSessionMode;
  43720. /**
  43721. * A reference space type to use when creating the default button.
  43722. * Default is local-floor
  43723. */
  43724. referenceSpaceType?: XRReferenceSpaceType;
  43725. }
  43726. /**
  43727. * UI to allow the user to enter/exit XR mode
  43728. */
  43729. export class WebXREnterExitUI implements IDisposable {
  43730. private scene;
  43731. private _overlay;
  43732. private _buttons;
  43733. private _activeButton;
  43734. /**
  43735. * Fired every time the active button is changed.
  43736. *
  43737. * When xr is entered via a button that launches xr that button will be the callback parameter
  43738. *
  43739. * When exiting xr the callback parameter will be null)
  43740. */
  43741. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43742. /**
  43743. * Creates UI to allow the user to enter/exit XR mode
  43744. * @param scene the scene to add the ui to
  43745. * @param helper the xr experience helper to enter/exit xr with
  43746. * @param options options to configure the UI
  43747. * @returns the created ui
  43748. */
  43749. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43750. private constructor();
  43751. private _updateButtons;
  43752. /**
  43753. * Disposes of the object
  43754. */
  43755. dispose(): void;
  43756. }
  43757. }
  43758. declare module "babylonjs/Cameras/XR/webXRController" {
  43759. import { Nullable } from "babylonjs/types";
  43760. import { Observable } from "babylonjs/Misc/observable";
  43761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43762. import { Ray } from "babylonjs/Culling/ray";
  43763. import { Scene } from "babylonjs/scene";
  43764. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43765. /**
  43766. * Represents an XR input
  43767. */
  43768. export class WebXRController {
  43769. private scene;
  43770. /** The underlying input source for the controller */
  43771. inputSource: XRInputSource;
  43772. private parentContainer;
  43773. /**
  43774. * 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
  43775. */
  43776. grip?: AbstractMesh;
  43777. /**
  43778. * Pointer which can be used to select objects or attach a visible laser to
  43779. */
  43780. pointer: AbstractMesh;
  43781. private _gamepadMode;
  43782. /**
  43783. * If available, this is the gamepad object related to this controller.
  43784. * Using this object it is possible to get click events and trackpad changes of the
  43785. * webxr controller that is currently being used.
  43786. */
  43787. gamepadController?: WebVRController;
  43788. /**
  43789. * Event that fires when the controller is removed/disposed
  43790. */
  43791. onDisposeObservable: Observable<{}>;
  43792. private _tmpMatrix;
  43793. private _tmpQuaternion;
  43794. private _tmpVector;
  43795. /**
  43796. * Creates the controller
  43797. * @see https://doc.babylonjs.com/how_to/webxr
  43798. * @param scene the scene which the controller should be associated to
  43799. * @param inputSource the underlying input source for the controller
  43800. * @param parentContainer parent that the controller meshes should be children of
  43801. */
  43802. constructor(scene: Scene,
  43803. /** The underlying input source for the controller */
  43804. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43805. /**
  43806. * Updates the controller pose based on the given XRFrame
  43807. * @param xrFrame xr frame to update the pose with
  43808. * @param referenceSpace reference space to use
  43809. */
  43810. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43811. /**
  43812. * Gets a world space ray coming from the controller
  43813. * @param result the resulting ray
  43814. */
  43815. getWorldPointerRayToRef(result: Ray): void;
  43816. /**
  43817. * Get the scene associated with this controller
  43818. * @returns the scene object
  43819. */
  43820. getScene(): Scene;
  43821. /**
  43822. * Disposes of the object
  43823. */
  43824. dispose(): void;
  43825. }
  43826. }
  43827. declare module "babylonjs/Cameras/XR/webXRInput" {
  43828. import { Observable } from "babylonjs/Misc/observable";
  43829. import { IDisposable } from "babylonjs/scene";
  43830. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43831. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43832. /**
  43833. * XR input used to track XR inputs such as controllers/rays
  43834. */
  43835. export class WebXRInput implements IDisposable {
  43836. /**
  43837. * Base experience the input listens to
  43838. */
  43839. baseExperience: WebXRExperienceHelper;
  43840. /**
  43841. * XR controllers being tracked
  43842. */
  43843. controllers: Array<WebXRController>;
  43844. private _frameObserver;
  43845. private _stateObserver;
  43846. /**
  43847. * Event when a controller has been connected/added
  43848. */
  43849. onControllerAddedObservable: Observable<WebXRController>;
  43850. /**
  43851. * Event when a controller has been removed/disconnected
  43852. */
  43853. onControllerRemovedObservable: Observable<WebXRController>;
  43854. /**
  43855. * Initializes the WebXRInput
  43856. * @param baseExperience experience helper which the input should be created for
  43857. */
  43858. constructor(
  43859. /**
  43860. * Base experience the input listens to
  43861. */
  43862. baseExperience: WebXRExperienceHelper);
  43863. private _onInputSourcesChange;
  43864. private _addAndRemoveControllers;
  43865. /**
  43866. * Disposes of the object
  43867. */
  43868. dispose(): void;
  43869. }
  43870. }
  43871. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43873. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43874. /**
  43875. * Enables teleportation
  43876. */
  43877. export class WebXRControllerTeleportation {
  43878. private _teleportationFillColor;
  43879. private _teleportationBorderColor;
  43880. private _tmpRay;
  43881. private _tmpVector;
  43882. /**
  43883. * Creates a WebXRControllerTeleportation
  43884. * @param input input manager to add teleportation to
  43885. * @param floorMeshes floormeshes which can be teleported to
  43886. */
  43887. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43888. }
  43889. }
  43890. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43891. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43892. /**
  43893. * Handles pointer input automatically for the pointer of XR controllers
  43894. */
  43895. export class WebXRControllerPointerSelection {
  43896. private static _idCounter;
  43897. private _tmpRay;
  43898. /**
  43899. * Creates a WebXRControllerPointerSelection
  43900. * @param input input manager to setup pointer selection
  43901. */
  43902. constructor(input: WebXRInput);
  43903. private _convertNormalToDirectionOfRay;
  43904. private _updatePointerDistance;
  43905. }
  43906. }
  43907. declare module "babylonjs/Loading/sceneLoader" {
  43908. import { Observable } from "babylonjs/Misc/observable";
  43909. import { Nullable } from "babylonjs/types";
  43910. import { Scene } from "babylonjs/scene";
  43911. import { Engine } from "babylonjs/Engines/engine";
  43912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43913. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43914. import { AssetContainer } from "babylonjs/assetContainer";
  43915. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43916. import { Skeleton } from "babylonjs/Bones/skeleton";
  43917. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43918. import { WebRequest } from "babylonjs/Misc/webRequest";
  43919. /**
  43920. * Class used to represent data loading progression
  43921. */
  43922. export class SceneLoaderProgressEvent {
  43923. /** defines if data length to load can be evaluated */
  43924. readonly lengthComputable: boolean;
  43925. /** defines the loaded data length */
  43926. readonly loaded: number;
  43927. /** defines the data length to load */
  43928. readonly total: number;
  43929. /**
  43930. * Create a new progress event
  43931. * @param lengthComputable defines if data length to load can be evaluated
  43932. * @param loaded defines the loaded data length
  43933. * @param total defines the data length to load
  43934. */
  43935. constructor(
  43936. /** defines if data length to load can be evaluated */
  43937. lengthComputable: boolean,
  43938. /** defines the loaded data length */
  43939. loaded: number,
  43940. /** defines the data length to load */
  43941. total: number);
  43942. /**
  43943. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43944. * @param event defines the source event
  43945. * @returns a new SceneLoaderProgressEvent
  43946. */
  43947. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43948. }
  43949. /**
  43950. * Interface used by SceneLoader plugins to define supported file extensions
  43951. */
  43952. export interface ISceneLoaderPluginExtensions {
  43953. /**
  43954. * Defines the list of supported extensions
  43955. */
  43956. [extension: string]: {
  43957. isBinary: boolean;
  43958. };
  43959. }
  43960. /**
  43961. * Interface used by SceneLoader plugin factory
  43962. */
  43963. export interface ISceneLoaderPluginFactory {
  43964. /**
  43965. * Defines the name of the factory
  43966. */
  43967. name: string;
  43968. /**
  43969. * Function called to create a new plugin
  43970. * @return the new plugin
  43971. */
  43972. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43973. /**
  43974. * The callback that returns true if the data can be directly loaded.
  43975. * @param data string containing the file data
  43976. * @returns if the data can be loaded directly
  43977. */
  43978. canDirectLoad?(data: string): boolean;
  43979. }
  43980. /**
  43981. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43982. */
  43983. export interface ISceneLoaderPluginBase {
  43984. /**
  43985. * The friendly name of this plugin.
  43986. */
  43987. name: string;
  43988. /**
  43989. * The file extensions supported by this plugin.
  43990. */
  43991. extensions: string | ISceneLoaderPluginExtensions;
  43992. /**
  43993. * The callback called when loading from a url.
  43994. * @param scene scene loading this url
  43995. * @param url url to load
  43996. * @param onSuccess callback called when the file successfully loads
  43997. * @param onProgress callback called while file is loading (if the server supports this mode)
  43998. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43999. * @param onError callback called when the file fails to load
  44000. * @returns a file request object
  44001. */
  44002. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44003. /**
  44004. * The callback called when loading from a file object.
  44005. * @param scene scene loading this file
  44006. * @param file defines the file to load
  44007. * @param onSuccess defines the callback to call when data is loaded
  44008. * @param onProgress defines the callback to call during loading process
  44009. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44010. * @param onError defines the callback to call when an error occurs
  44011. * @returns a file request object
  44012. */
  44013. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44014. /**
  44015. * The callback that returns true if the data can be directly loaded.
  44016. * @param data string containing the file data
  44017. * @returns if the data can be loaded directly
  44018. */
  44019. canDirectLoad?(data: string): boolean;
  44020. /**
  44021. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44022. * @param scene scene loading this data
  44023. * @param data string containing the data
  44024. * @returns data to pass to the plugin
  44025. */
  44026. directLoad?(scene: Scene, data: string): any;
  44027. /**
  44028. * The callback that allows custom handling of the root url based on the response url.
  44029. * @param rootUrl the original root url
  44030. * @param responseURL the response url if available
  44031. * @returns the new root url
  44032. */
  44033. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44034. }
  44035. /**
  44036. * Interface used to define a SceneLoader plugin
  44037. */
  44038. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44039. /**
  44040. * Import meshes into a scene.
  44041. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44042. * @param scene The scene to import into
  44043. * @param data The data to import
  44044. * @param rootUrl The root url for scene and resources
  44045. * @param meshes The meshes array to import into
  44046. * @param particleSystems The particle systems array to import into
  44047. * @param skeletons The skeletons array to import into
  44048. * @param onError The callback when import fails
  44049. * @returns True if successful or false otherwise
  44050. */
  44051. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44052. /**
  44053. * Load into a scene.
  44054. * @param scene The scene to load into
  44055. * @param data The data to import
  44056. * @param rootUrl The root url for scene and resources
  44057. * @param onError The callback when import fails
  44058. * @returns True if successful or false otherwise
  44059. */
  44060. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44061. /**
  44062. * Load into an asset container.
  44063. * @param scene The scene to load into
  44064. * @param data The data to import
  44065. * @param rootUrl The root url for scene and resources
  44066. * @param onError The callback when import fails
  44067. * @returns The loaded asset container
  44068. */
  44069. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44070. }
  44071. /**
  44072. * Interface used to define an async SceneLoader plugin
  44073. */
  44074. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44075. /**
  44076. * Import meshes into a scene.
  44077. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44078. * @param scene The scene to import into
  44079. * @param data The data to import
  44080. * @param rootUrl The root url for scene and resources
  44081. * @param onProgress The callback when the load progresses
  44082. * @param fileName Defines the name of the file to load
  44083. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44084. */
  44085. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44086. meshes: AbstractMesh[];
  44087. particleSystems: IParticleSystem[];
  44088. skeletons: Skeleton[];
  44089. animationGroups: AnimationGroup[];
  44090. }>;
  44091. /**
  44092. * Load into a scene.
  44093. * @param scene The scene to load into
  44094. * @param data The data to import
  44095. * @param rootUrl The root url for scene and resources
  44096. * @param onProgress The callback when the load progresses
  44097. * @param fileName Defines the name of the file to load
  44098. * @returns Nothing
  44099. */
  44100. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44101. /**
  44102. * Load into an asset container.
  44103. * @param scene The scene to load into
  44104. * @param data The data to import
  44105. * @param rootUrl The root url for scene and resources
  44106. * @param onProgress The callback when the load progresses
  44107. * @param fileName Defines the name of the file to load
  44108. * @returns The loaded asset container
  44109. */
  44110. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44111. }
  44112. /**
  44113. * Class used to load scene from various file formats using registered plugins
  44114. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44115. */
  44116. export class SceneLoader {
  44117. /**
  44118. * No logging while loading
  44119. */
  44120. static readonly NO_LOGGING: number;
  44121. /**
  44122. * Minimal logging while loading
  44123. */
  44124. static readonly MINIMAL_LOGGING: number;
  44125. /**
  44126. * Summary logging while loading
  44127. */
  44128. static readonly SUMMARY_LOGGING: number;
  44129. /**
  44130. * Detailled logging while loading
  44131. */
  44132. static readonly DETAILED_LOGGING: number;
  44133. /**
  44134. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44135. */
  44136. static ForceFullSceneLoadingForIncremental: boolean;
  44137. /**
  44138. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44139. */
  44140. static ShowLoadingScreen: boolean;
  44141. /**
  44142. * Defines the current logging level (while loading the scene)
  44143. * @ignorenaming
  44144. */
  44145. static loggingLevel: number;
  44146. /**
  44147. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44148. */
  44149. static CleanBoneMatrixWeights: boolean;
  44150. /**
  44151. * Event raised when a plugin is used to load a scene
  44152. */
  44153. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44154. private static _registeredPlugins;
  44155. private static _getDefaultPlugin;
  44156. private static _getPluginForExtension;
  44157. private static _getPluginForDirectLoad;
  44158. private static _getPluginForFilename;
  44159. private static _getDirectLoad;
  44160. private static _loadData;
  44161. private static _getFileInfo;
  44162. /**
  44163. * Gets a plugin that can load the given extension
  44164. * @param extension defines the extension to load
  44165. * @returns a plugin or null if none works
  44166. */
  44167. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44168. /**
  44169. * Gets a boolean indicating that the given extension can be loaded
  44170. * @param extension defines the extension to load
  44171. * @returns true if the extension is supported
  44172. */
  44173. static IsPluginForExtensionAvailable(extension: string): boolean;
  44174. /**
  44175. * Adds a new plugin to the list of registered plugins
  44176. * @param plugin defines the plugin to add
  44177. */
  44178. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44179. /**
  44180. * Import meshes into a scene
  44181. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44182. * @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)
  44183. * @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)
  44184. * @param scene the instance of BABYLON.Scene to append to
  44185. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44186. * @param onProgress a callback with a progress event for each file being loaded
  44187. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44188. * @param pluginExtension the extension used to determine the plugin
  44189. * @returns The loaded plugin
  44190. */
  44191. 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>;
  44192. /**
  44193. * Import meshes into a scene
  44194. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44195. * @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)
  44196. * @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)
  44197. * @param scene the instance of BABYLON.Scene to append to
  44198. * @param onProgress a callback with a progress event for each file being loaded
  44199. * @param pluginExtension the extension used to determine the plugin
  44200. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44201. */
  44202. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44203. meshes: AbstractMesh[];
  44204. particleSystems: IParticleSystem[];
  44205. skeletons: Skeleton[];
  44206. animationGroups: AnimationGroup[];
  44207. }>;
  44208. /**
  44209. * Load a scene
  44210. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  44211. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  44212. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44213. * @param onSuccess a callback with the scene when import succeeds
  44214. * @param onProgress a callback with a progress event for each file being loaded
  44215. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44216. * @param pluginExtension the extension used to determine the plugin
  44217. * @returns The loaded plugin
  44218. */
  44219. static 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>;
  44220. /**
  44221. * Load a scene
  44222. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  44223. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  44224. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44225. * @param onProgress a callback with a progress event for each file being loaded
  44226. * @param pluginExtension the extension used to determine the plugin
  44227. * @returns The loaded scene
  44228. */
  44229. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44230. /**
  44231. * Append a scene
  44232. * @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)
  44233. * @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)
  44234. * @param scene is the instance of BABYLON.Scene to append to
  44235. * @param onSuccess a callback with the scene when import succeeds
  44236. * @param onProgress a callback with a progress event for each file being loaded
  44237. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44238. * @param pluginExtension the extension used to determine the plugin
  44239. * @returns The loaded plugin
  44240. */
  44241. 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>;
  44242. /**
  44243. * Append a scene
  44244. * @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)
  44245. * @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)
  44246. * @param scene is the instance of BABYLON.Scene to append to
  44247. * @param onProgress a callback with a progress event for each file being loaded
  44248. * @param pluginExtension the extension used to determine the plugin
  44249. * @returns The given scene
  44250. */
  44251. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44252. /**
  44253. * Load a scene into an asset container
  44254. * @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)
  44255. * @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)
  44256. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44257. * @param onSuccess a callback with the scene when import succeeds
  44258. * @param onProgress a callback with a progress event for each file being loaded
  44259. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44260. * @param pluginExtension the extension used to determine the plugin
  44261. * @returns The loaded plugin
  44262. */
  44263. 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>;
  44264. /**
  44265. * Load a scene into an asset container
  44266. * @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)
  44267. * @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)
  44268. * @param scene is the instance of Scene to append to
  44269. * @param onProgress a callback with a progress event for each file being loaded
  44270. * @param pluginExtension the extension used to determine the plugin
  44271. * @returns The loaded asset container
  44272. */
  44273. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44274. }
  44275. }
  44276. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44277. import { Scene } from "babylonjs/scene";
  44278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44279. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44280. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44281. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44282. /**
  44283. * Generic Controller
  44284. */
  44285. export class GenericController extends WebVRController {
  44286. /**
  44287. * Base Url for the controller model.
  44288. */
  44289. static readonly MODEL_BASE_URL: string;
  44290. /**
  44291. * File name for the controller model.
  44292. */
  44293. static readonly MODEL_FILENAME: string;
  44294. /**
  44295. * Creates a new GenericController from a gamepad
  44296. * @param vrGamepad the gamepad that the controller should be created from
  44297. */
  44298. constructor(vrGamepad: any);
  44299. /**
  44300. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44301. * @param scene scene in which to add meshes
  44302. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44303. */
  44304. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44305. /**
  44306. * Called once for each button that changed state since the last frame
  44307. * @param buttonIdx Which button index changed
  44308. * @param state New state of the button
  44309. * @param changes Which properties on the state changed since last frame
  44310. */
  44311. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44312. }
  44313. }
  44314. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44315. import { Observable } from "babylonjs/Misc/observable";
  44316. import { Scene } from "babylonjs/scene";
  44317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44318. import { Ray } from "babylonjs/Culling/ray";
  44319. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44320. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44321. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44322. /**
  44323. * Defines the WindowsMotionController object that the state of the windows motion controller
  44324. */
  44325. export class WindowsMotionController extends WebVRController {
  44326. /**
  44327. * The base url used to load the left and right controller models
  44328. */
  44329. static MODEL_BASE_URL: string;
  44330. /**
  44331. * The name of the left controller model file
  44332. */
  44333. static MODEL_LEFT_FILENAME: string;
  44334. /**
  44335. * The name of the right controller model file
  44336. */
  44337. static MODEL_RIGHT_FILENAME: string;
  44338. /**
  44339. * The controller name prefix for this controller type
  44340. */
  44341. static readonly GAMEPAD_ID_PREFIX: string;
  44342. /**
  44343. * The controller id pattern for this controller type
  44344. */
  44345. private static readonly GAMEPAD_ID_PATTERN;
  44346. private _loadedMeshInfo;
  44347. private readonly _mapping;
  44348. /**
  44349. * Fired when the trackpad on this controller is clicked
  44350. */
  44351. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44352. /**
  44353. * Fired when the trackpad on this controller is modified
  44354. */
  44355. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44356. /**
  44357. * The current x and y values of this controller's trackpad
  44358. */
  44359. trackpad: StickValues;
  44360. /**
  44361. * Creates a new WindowsMotionController from a gamepad
  44362. * @param vrGamepad the gamepad that the controller should be created from
  44363. */
  44364. constructor(vrGamepad: any);
  44365. /**
  44366. * Fired when the trigger on this controller is modified
  44367. */
  44368. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44369. /**
  44370. * Fired when the menu button on this controller is modified
  44371. */
  44372. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44373. /**
  44374. * Fired when the grip button on this controller is modified
  44375. */
  44376. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44377. /**
  44378. * Fired when the thumbstick button on this controller is modified
  44379. */
  44380. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44381. /**
  44382. * Fired when the touchpad button on this controller is modified
  44383. */
  44384. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44385. /**
  44386. * Fired when the touchpad values on this controller are modified
  44387. */
  44388. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44389. private _updateTrackpad;
  44390. /**
  44391. * Called once per frame by the engine.
  44392. */
  44393. update(): void;
  44394. /**
  44395. * Called once for each button that changed state since the last frame
  44396. * @param buttonIdx Which button index changed
  44397. * @param state New state of the button
  44398. * @param changes Which properties on the state changed since last frame
  44399. */
  44400. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44401. /**
  44402. * Moves the buttons on the controller mesh based on their current state
  44403. * @param buttonName the name of the button to move
  44404. * @param buttonValue the value of the button which determines the buttons new position
  44405. */
  44406. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44407. /**
  44408. * Moves the axis on the controller mesh based on its current state
  44409. * @param axis the index of the axis
  44410. * @param axisValue the value of the axis which determines the meshes new position
  44411. * @hidden
  44412. */
  44413. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44414. /**
  44415. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44416. * @param scene scene in which to add meshes
  44417. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44418. */
  44419. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44420. /**
  44421. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44422. * can be transformed by button presses and axes values, based on this._mapping.
  44423. *
  44424. * @param scene scene in which the meshes exist
  44425. * @param meshes list of meshes that make up the controller model to process
  44426. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44427. */
  44428. private processModel;
  44429. private createMeshInfo;
  44430. /**
  44431. * Gets the ray of the controller in the direction the controller is pointing
  44432. * @param length the length the resulting ray should be
  44433. * @returns a ray in the direction the controller is pointing
  44434. */
  44435. getForwardRay(length?: number): Ray;
  44436. /**
  44437. * Disposes of the controller
  44438. */
  44439. dispose(): void;
  44440. }
  44441. }
  44442. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44443. import { Observable } from "babylonjs/Misc/observable";
  44444. import { Scene } from "babylonjs/scene";
  44445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44446. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44447. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44448. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44449. /**
  44450. * Oculus Touch Controller
  44451. */
  44452. export class OculusTouchController extends WebVRController {
  44453. /**
  44454. * Base Url for the controller model.
  44455. */
  44456. static MODEL_BASE_URL: string;
  44457. /**
  44458. * File name for the left controller model.
  44459. */
  44460. static MODEL_LEFT_FILENAME: string;
  44461. /**
  44462. * File name for the right controller model.
  44463. */
  44464. static MODEL_RIGHT_FILENAME: string;
  44465. /**
  44466. * Base Url for the Quest controller model.
  44467. */
  44468. static QUEST_MODEL_BASE_URL: string;
  44469. /**
  44470. * @hidden
  44471. * If the controllers are running on a device that needs the updated Quest controller models
  44472. */
  44473. static _IsQuest: boolean;
  44474. /**
  44475. * Fired when the secondary trigger on this controller is modified
  44476. */
  44477. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44478. /**
  44479. * Fired when the thumb rest on this controller is modified
  44480. */
  44481. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44482. /**
  44483. * Creates a new OculusTouchController from a gamepad
  44484. * @param vrGamepad the gamepad that the controller should be created from
  44485. */
  44486. constructor(vrGamepad: any);
  44487. /**
  44488. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44489. * @param scene scene in which to add meshes
  44490. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44491. */
  44492. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44493. /**
  44494. * Fired when the A button on this controller is modified
  44495. */
  44496. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44497. /**
  44498. * Fired when the B button on this controller is modified
  44499. */
  44500. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44501. /**
  44502. * Fired when the X button on this controller is modified
  44503. */
  44504. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44505. /**
  44506. * Fired when the Y button on this controller is modified
  44507. */
  44508. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44509. /**
  44510. * Called once for each button that changed state since the last frame
  44511. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44512. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44513. * 2) secondary trigger (same)
  44514. * 3) A (right) X (left), touch, pressed = value
  44515. * 4) B / Y
  44516. * 5) thumb rest
  44517. * @param buttonIdx Which button index changed
  44518. * @param state New state of the button
  44519. * @param changes Which properties on the state changed since last frame
  44520. */
  44521. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44522. }
  44523. }
  44524. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44525. import { Scene } from "babylonjs/scene";
  44526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44527. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44528. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44529. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44530. import { Observable } from "babylonjs/Misc/observable";
  44531. /**
  44532. * Vive Controller
  44533. */
  44534. export class ViveController extends WebVRController {
  44535. /**
  44536. * Base Url for the controller model.
  44537. */
  44538. static MODEL_BASE_URL: string;
  44539. /**
  44540. * File name for the controller model.
  44541. */
  44542. static MODEL_FILENAME: string;
  44543. /**
  44544. * Creates a new ViveController from a gamepad
  44545. * @param vrGamepad the gamepad that the controller should be created from
  44546. */
  44547. constructor(vrGamepad: any);
  44548. /**
  44549. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44550. * @param scene scene in which to add meshes
  44551. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44552. */
  44553. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44554. /**
  44555. * Fired when the left button on this controller is modified
  44556. */
  44557. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44558. /**
  44559. * Fired when the right button on this controller is modified
  44560. */
  44561. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44562. /**
  44563. * Fired when the menu button on this controller is modified
  44564. */
  44565. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44566. /**
  44567. * Called once for each button that changed state since the last frame
  44568. * Vive mapping:
  44569. * 0: touchpad
  44570. * 1: trigger
  44571. * 2: left AND right buttons
  44572. * 3: menu button
  44573. * @param buttonIdx Which button index changed
  44574. * @param state New state of the button
  44575. * @param changes Which properties on the state changed since last frame
  44576. */
  44577. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44578. }
  44579. }
  44580. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44581. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44582. import { Observable } from "babylonjs/Misc/observable";
  44583. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  44584. /**
  44585. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44586. */
  44587. export class WebXRControllerModelLoader {
  44588. /**
  44589. * an observable that triggers when a new model (the mesh itself) was initialized.
  44590. * To know when the mesh was loaded use the controller's own modelLoaded() method
  44591. */
  44592. onControllerModelLoaded: Observable<WebXRController>;
  44593. /**
  44594. * Creates the WebXRControllerModelLoader
  44595. * @param input xr input that creates the controllers
  44596. */
  44597. constructor(input: WebXRInput);
  44598. }
  44599. }
  44600. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  44601. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44602. import { Scene } from "babylonjs/scene";
  44603. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44604. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44605. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44606. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44607. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44608. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  44609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44610. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44611. /**
  44612. * Options for the default xr helper
  44613. */
  44614. export class WebXRDefaultExperienceOptions {
  44615. /**
  44616. * Floor meshes that should be used for teleporting
  44617. */
  44618. floorMeshes: Array<AbstractMesh>;
  44619. /**
  44620. * Enable or disable default UI to enter XR
  44621. */
  44622. disableDefaultUI: boolean;
  44623. /**
  44624. * optional configuration for the output canvas
  44625. */
  44626. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44627. }
  44628. /**
  44629. * Default experience which provides a similar setup to the previous webVRExperience
  44630. */
  44631. export class WebXRDefaultExperience {
  44632. /**
  44633. * Base experience
  44634. */
  44635. baseExperience: WebXRExperienceHelper;
  44636. /**
  44637. * Input experience extension
  44638. */
  44639. input: WebXRInput;
  44640. /**
  44641. * Loads the controller models
  44642. */
  44643. controllerModelLoader: WebXRControllerModelLoader;
  44644. /**
  44645. * Enables laser pointer and selection
  44646. */
  44647. pointerSelection: WebXRControllerPointerSelection;
  44648. /**
  44649. * Enables teleportation
  44650. */
  44651. teleportation: WebXRControllerTeleportation;
  44652. /**
  44653. * Enables ui for enetering/exiting xr
  44654. */
  44655. enterExitUI: WebXREnterExitUI;
  44656. /**
  44657. * Default target xr should render to
  44658. */
  44659. renderTarget: WebXRRenderTarget;
  44660. /**
  44661. * Creates the default xr experience
  44662. * @param scene scene
  44663. * @param options options for basic configuration
  44664. * @returns resulting WebXRDefaultExperience
  44665. */
  44666. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44667. private constructor();
  44668. /**
  44669. * DIsposes of the experience helper
  44670. */
  44671. dispose(): void;
  44672. }
  44673. }
  44674. declare module "babylonjs/Cameras/XR/index" {
  44675. export * from "babylonjs/Cameras/XR/webXRCamera";
  44676. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44677. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44678. export * from "babylonjs/Cameras/XR/webXRInput";
  44679. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44680. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44681. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44682. export * from "babylonjs/Cameras/XR/webXRController";
  44683. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44684. export * from "babylonjs/Cameras/XR/webXRTypes";
  44685. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44686. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  44687. }
  44688. declare module "babylonjs/Cameras/RigModes/index" {
  44689. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44690. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44691. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44692. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44693. }
  44694. declare module "babylonjs/Cameras/index" {
  44695. export * from "babylonjs/Cameras/Inputs/index";
  44696. export * from "babylonjs/Cameras/cameraInputsManager";
  44697. export * from "babylonjs/Cameras/camera";
  44698. export * from "babylonjs/Cameras/targetCamera";
  44699. export * from "babylonjs/Cameras/freeCamera";
  44700. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44701. export * from "babylonjs/Cameras/touchCamera";
  44702. export * from "babylonjs/Cameras/arcRotateCamera";
  44703. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44704. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44705. export * from "babylonjs/Cameras/flyCamera";
  44706. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44707. export * from "babylonjs/Cameras/followCamera";
  44708. export * from "babylonjs/Cameras/followCameraInputsManager";
  44709. export * from "babylonjs/Cameras/gamepadCamera";
  44710. export * from "babylonjs/Cameras/Stereoscopic/index";
  44711. export * from "babylonjs/Cameras/universalCamera";
  44712. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44713. export * from "babylonjs/Cameras/VR/index";
  44714. export * from "babylonjs/Cameras/XR/index";
  44715. export * from "babylonjs/Cameras/RigModes/index";
  44716. }
  44717. declare module "babylonjs/Collisions/index" {
  44718. export * from "babylonjs/Collisions/collider";
  44719. export * from "babylonjs/Collisions/collisionCoordinator";
  44720. export * from "babylonjs/Collisions/pickingInfo";
  44721. export * from "babylonjs/Collisions/intersectionInfo";
  44722. export * from "babylonjs/Collisions/meshCollisionData";
  44723. }
  44724. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44725. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44726. import { Vector3 } from "babylonjs/Maths/math.vector";
  44727. import { Ray } from "babylonjs/Culling/ray";
  44728. import { Plane } from "babylonjs/Maths/math.plane";
  44729. /**
  44730. * Contains an array of blocks representing the octree
  44731. */
  44732. export interface IOctreeContainer<T> {
  44733. /**
  44734. * Blocks within the octree
  44735. */
  44736. blocks: Array<OctreeBlock<T>>;
  44737. }
  44738. /**
  44739. * Class used to store a cell in an octree
  44740. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44741. */
  44742. export class OctreeBlock<T> {
  44743. /**
  44744. * Gets the content of the current block
  44745. */
  44746. entries: T[];
  44747. /**
  44748. * Gets the list of block children
  44749. */
  44750. blocks: Array<OctreeBlock<T>>;
  44751. private _depth;
  44752. private _maxDepth;
  44753. private _capacity;
  44754. private _minPoint;
  44755. private _maxPoint;
  44756. private _boundingVectors;
  44757. private _creationFunc;
  44758. /**
  44759. * Creates a new block
  44760. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44761. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44762. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44763. * @param depth defines the current depth of this block in the octree
  44764. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44765. * @param creationFunc defines a callback to call when an element is added to the block
  44766. */
  44767. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44768. /**
  44769. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44770. */
  44771. readonly capacity: number;
  44772. /**
  44773. * Gets the minimum vector (in world space) of the block's bounding box
  44774. */
  44775. readonly minPoint: Vector3;
  44776. /**
  44777. * Gets the maximum vector (in world space) of the block's bounding box
  44778. */
  44779. readonly maxPoint: Vector3;
  44780. /**
  44781. * Add a new element to this block
  44782. * @param entry defines the element to add
  44783. */
  44784. addEntry(entry: T): void;
  44785. /**
  44786. * Remove an element from this block
  44787. * @param entry defines the element to remove
  44788. */
  44789. removeEntry(entry: T): void;
  44790. /**
  44791. * Add an array of elements to this block
  44792. * @param entries defines the array of elements to add
  44793. */
  44794. addEntries(entries: T[]): void;
  44795. /**
  44796. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44797. * @param frustumPlanes defines the frustum planes to test
  44798. * @param selection defines the array to store current content if selection is positive
  44799. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44800. */
  44801. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44802. /**
  44803. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44804. * @param sphereCenter defines the bounding sphere center
  44805. * @param sphereRadius defines the bounding sphere radius
  44806. * @param selection defines the array to store current content if selection is positive
  44807. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44808. */
  44809. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44810. /**
  44811. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44812. * @param ray defines the ray to test with
  44813. * @param selection defines the array to store current content if selection is positive
  44814. */
  44815. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44816. /**
  44817. * Subdivide the content into child blocks (this block will then be empty)
  44818. */
  44819. createInnerBlocks(): void;
  44820. /**
  44821. * @hidden
  44822. */
  44823. 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;
  44824. }
  44825. }
  44826. declare module "babylonjs/Culling/Octrees/octree" {
  44827. import { SmartArray } from "babylonjs/Misc/smartArray";
  44828. import { Vector3 } from "babylonjs/Maths/math.vector";
  44829. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44831. import { Ray } from "babylonjs/Culling/ray";
  44832. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44833. import { Plane } from "babylonjs/Maths/math.plane";
  44834. /**
  44835. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44836. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44837. */
  44838. export class Octree<T> {
  44839. /** 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.) */
  44840. maxDepth: number;
  44841. /**
  44842. * Blocks within the octree containing objects
  44843. */
  44844. blocks: Array<OctreeBlock<T>>;
  44845. /**
  44846. * Content stored in the octree
  44847. */
  44848. dynamicContent: T[];
  44849. private _maxBlockCapacity;
  44850. private _selectionContent;
  44851. private _creationFunc;
  44852. /**
  44853. * Creates a octree
  44854. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44855. * @param creationFunc function to be used to instatiate the octree
  44856. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44857. * @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.)
  44858. */
  44859. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44860. /** 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.) */
  44861. maxDepth?: number);
  44862. /**
  44863. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44864. * @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);
  44865. * @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);
  44866. * @param entries meshes to be added to the octree blocks
  44867. */
  44868. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44869. /**
  44870. * Adds a mesh to the octree
  44871. * @param entry Mesh to add to the octree
  44872. */
  44873. addMesh(entry: T): void;
  44874. /**
  44875. * Remove an element from the octree
  44876. * @param entry defines the element to remove
  44877. */
  44878. removeMesh(entry: T): void;
  44879. /**
  44880. * Selects an array of meshes within the frustum
  44881. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44882. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44883. * @returns array of meshes within the frustum
  44884. */
  44885. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44886. /**
  44887. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44888. * @param sphereCenter defines the bounding sphere center
  44889. * @param sphereRadius defines the bounding sphere radius
  44890. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44891. * @returns an array of objects that intersect the sphere
  44892. */
  44893. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44894. /**
  44895. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44896. * @param ray defines the ray to test with
  44897. * @returns array of intersected objects
  44898. */
  44899. intersectsRay(ray: Ray): SmartArray<T>;
  44900. /**
  44901. * Adds a mesh into the octree block if it intersects the block
  44902. */
  44903. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44904. /**
  44905. * Adds a submesh into the octree block if it intersects the block
  44906. */
  44907. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44908. }
  44909. }
  44910. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44911. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44912. import { Scene } from "babylonjs/scene";
  44913. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44915. import { Ray } from "babylonjs/Culling/ray";
  44916. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44917. import { Collider } from "babylonjs/Collisions/collider";
  44918. module "babylonjs/scene" {
  44919. interface Scene {
  44920. /**
  44921. * @hidden
  44922. * Backing Filed
  44923. */
  44924. _selectionOctree: Octree<AbstractMesh>;
  44925. /**
  44926. * Gets the octree used to boost mesh selection (picking)
  44927. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44928. */
  44929. selectionOctree: Octree<AbstractMesh>;
  44930. /**
  44931. * Creates or updates the octree used to boost selection (picking)
  44932. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44933. * @param maxCapacity defines the maximum capacity per leaf
  44934. * @param maxDepth defines the maximum depth of the octree
  44935. * @returns an octree of AbstractMesh
  44936. */
  44937. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44938. }
  44939. }
  44940. module "babylonjs/Meshes/abstractMesh" {
  44941. interface AbstractMesh {
  44942. /**
  44943. * @hidden
  44944. * Backing Field
  44945. */
  44946. _submeshesOctree: Octree<SubMesh>;
  44947. /**
  44948. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44949. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44950. * @param maxCapacity defines the maximum size of each block (64 by default)
  44951. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44952. * @returns the new octree
  44953. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44954. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44955. */
  44956. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44957. }
  44958. }
  44959. /**
  44960. * Defines the octree scene component responsible to manage any octrees
  44961. * in a given scene.
  44962. */
  44963. export class OctreeSceneComponent {
  44964. /**
  44965. * The component name help to identify the component in the list of scene components.
  44966. */
  44967. readonly name: string;
  44968. /**
  44969. * The scene the component belongs to.
  44970. */
  44971. scene: Scene;
  44972. /**
  44973. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44974. */
  44975. readonly checksIsEnabled: boolean;
  44976. /**
  44977. * Creates a new instance of the component for the given scene
  44978. * @param scene Defines the scene to register the component in
  44979. */
  44980. constructor(scene: Scene);
  44981. /**
  44982. * Registers the component in a given scene
  44983. */
  44984. register(): void;
  44985. /**
  44986. * Return the list of active meshes
  44987. * @returns the list of active meshes
  44988. */
  44989. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44990. /**
  44991. * Return the list of active sub meshes
  44992. * @param mesh The mesh to get the candidates sub meshes from
  44993. * @returns the list of active sub meshes
  44994. */
  44995. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44996. private _tempRay;
  44997. /**
  44998. * Return the list of sub meshes intersecting with a given local ray
  44999. * @param mesh defines the mesh to find the submesh for
  45000. * @param localRay defines the ray in local space
  45001. * @returns the list of intersecting sub meshes
  45002. */
  45003. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45004. /**
  45005. * Return the list of sub meshes colliding with a collider
  45006. * @param mesh defines the mesh to find the submesh for
  45007. * @param collider defines the collider to evaluate the collision against
  45008. * @returns the list of colliding sub meshes
  45009. */
  45010. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45011. /**
  45012. * Rebuilds the elements related to this component in case of
  45013. * context lost for instance.
  45014. */
  45015. rebuild(): void;
  45016. /**
  45017. * Disposes the component and the associated ressources.
  45018. */
  45019. dispose(): void;
  45020. }
  45021. }
  45022. declare module "babylonjs/Culling/Octrees/index" {
  45023. export * from "babylonjs/Culling/Octrees/octree";
  45024. export * from "babylonjs/Culling/Octrees/octreeBlock";
  45025. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  45026. }
  45027. declare module "babylonjs/Culling/index" {
  45028. export * from "babylonjs/Culling/boundingBox";
  45029. export * from "babylonjs/Culling/boundingInfo";
  45030. export * from "babylonjs/Culling/boundingSphere";
  45031. export * from "babylonjs/Culling/Octrees/index";
  45032. export * from "babylonjs/Culling/ray";
  45033. }
  45034. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45035. import { IDisposable, Scene } from "babylonjs/scene";
  45036. import { Nullable } from "babylonjs/types";
  45037. import { Observable } from "babylonjs/Misc/observable";
  45038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45039. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45040. import { Camera } from "babylonjs/Cameras/camera";
  45041. /**
  45042. * Renders a layer on top of an existing scene
  45043. */
  45044. export class UtilityLayerRenderer implements IDisposable {
  45045. /** the original scene that will be rendered on top of */
  45046. originalScene: Scene;
  45047. private _pointerCaptures;
  45048. private _lastPointerEvents;
  45049. private static _DefaultUtilityLayer;
  45050. private static _DefaultKeepDepthUtilityLayer;
  45051. private _sharedGizmoLight;
  45052. private _renderCamera;
  45053. /**
  45054. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45055. * @returns the camera that is used when rendering the utility layer
  45056. */
  45057. getRenderCamera(): Nullable<Camera>;
  45058. /**
  45059. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45060. * @param cam the camera that should be used when rendering the utility layer
  45061. */
  45062. setRenderCamera(cam: Nullable<Camera>): void;
  45063. /**
  45064. * @hidden
  45065. * Light which used by gizmos to get light shading
  45066. */
  45067. _getSharedGizmoLight(): HemisphericLight;
  45068. /**
  45069. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45070. */
  45071. pickUtilitySceneFirst: boolean;
  45072. /**
  45073. * 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)
  45074. */
  45075. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  45076. /**
  45077. * 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)
  45078. */
  45079. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  45080. /**
  45081. * The scene that is rendered on top of the original scene
  45082. */
  45083. utilityLayerScene: Scene;
  45084. /**
  45085. * If the utility layer should automatically be rendered on top of existing scene
  45086. */
  45087. shouldRender: boolean;
  45088. /**
  45089. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45090. */
  45091. onlyCheckPointerDownEvents: boolean;
  45092. /**
  45093. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45094. */
  45095. processAllEvents: boolean;
  45096. /**
  45097. * Observable raised when the pointer move from the utility layer scene to the main scene
  45098. */
  45099. onPointerOutObservable: Observable<number>;
  45100. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45101. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45102. private _afterRenderObserver;
  45103. private _sceneDisposeObserver;
  45104. private _originalPointerObserver;
  45105. /**
  45106. * Instantiates a UtilityLayerRenderer
  45107. * @param originalScene the original scene that will be rendered on top of
  45108. * @param handleEvents boolean indicating if the utility layer should handle events
  45109. */
  45110. constructor(
  45111. /** the original scene that will be rendered on top of */
  45112. originalScene: Scene, handleEvents?: boolean);
  45113. private _notifyObservers;
  45114. /**
  45115. * Renders the utility layers scene on top of the original scene
  45116. */
  45117. render(): void;
  45118. /**
  45119. * Disposes of the renderer
  45120. */
  45121. dispose(): void;
  45122. private _updateCamera;
  45123. }
  45124. }
  45125. declare module "babylonjs/Gizmos/gizmo" {
  45126. import { Nullable } from "babylonjs/types";
  45127. import { IDisposable } from "babylonjs/scene";
  45128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45129. import { Mesh } from "babylonjs/Meshes/mesh";
  45130. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45131. /**
  45132. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45133. */
  45134. export class Gizmo implements IDisposable {
  45135. /** The utility layer the gizmo will be added to */
  45136. gizmoLayer: UtilityLayerRenderer;
  45137. /**
  45138. * The root mesh of the gizmo
  45139. */
  45140. _rootMesh: Mesh;
  45141. private _attachedMesh;
  45142. /**
  45143. * Ratio for the scale of the gizmo (Default: 1)
  45144. */
  45145. scaleRatio: number;
  45146. /**
  45147. * If a custom mesh has been set (Default: false)
  45148. */
  45149. protected _customMeshSet: boolean;
  45150. /**
  45151. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45152. * * When set, interactions will be enabled
  45153. */
  45154. attachedMesh: Nullable<AbstractMesh>;
  45155. /**
  45156. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45157. * @param mesh The mesh to replace the default mesh of the gizmo
  45158. */
  45159. setCustomMesh(mesh: Mesh): void;
  45160. /**
  45161. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45162. */
  45163. updateGizmoRotationToMatchAttachedMesh: boolean;
  45164. /**
  45165. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45166. */
  45167. updateGizmoPositionToMatchAttachedMesh: boolean;
  45168. /**
  45169. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45170. */
  45171. updateScale: boolean;
  45172. protected _interactionsEnabled: boolean;
  45173. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45174. private _beforeRenderObserver;
  45175. private _tempVector;
  45176. /**
  45177. * Creates a gizmo
  45178. * @param gizmoLayer The utility layer the gizmo will be added to
  45179. */
  45180. constructor(
  45181. /** The utility layer the gizmo will be added to */
  45182. gizmoLayer?: UtilityLayerRenderer);
  45183. /**
  45184. * Updates the gizmo to match the attached mesh's position/rotation
  45185. */
  45186. protected _update(): void;
  45187. /**
  45188. * Disposes of the gizmo
  45189. */
  45190. dispose(): void;
  45191. }
  45192. }
  45193. declare module "babylonjs/Gizmos/planeDragGizmo" {
  45194. import { Observable } from "babylonjs/Misc/observable";
  45195. import { Nullable } from "babylonjs/types";
  45196. import { Vector3 } from "babylonjs/Maths/math.vector";
  45197. import { Color3 } from "babylonjs/Maths/math.color";
  45198. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45200. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45201. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45202. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45203. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45204. import { Scene } from "babylonjs/scene";
  45205. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45206. /**
  45207. * Single plane drag gizmo
  45208. */
  45209. export class PlaneDragGizmo extends Gizmo {
  45210. /**
  45211. * Drag behavior responsible for the gizmos dragging interactions
  45212. */
  45213. dragBehavior: PointerDragBehavior;
  45214. private _pointerObserver;
  45215. /**
  45216. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45217. */
  45218. snapDistance: number;
  45219. /**
  45220. * Event that fires each time the gizmo snaps to a new location.
  45221. * * snapDistance is the the change in distance
  45222. */
  45223. onSnapObservable: Observable<{
  45224. snapDistance: number;
  45225. }>;
  45226. private _plane;
  45227. private _coloredMaterial;
  45228. private _hoverMaterial;
  45229. private _isEnabled;
  45230. private _parent;
  45231. /** @hidden */
  45232. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45233. /** @hidden */
  45234. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45235. /**
  45236. * Creates a PlaneDragGizmo
  45237. * @param gizmoLayer The utility layer the gizmo will be added to
  45238. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45239. * @param color The color of the gizmo
  45240. */
  45241. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45242. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45243. /**
  45244. * If the gizmo is enabled
  45245. */
  45246. isEnabled: boolean;
  45247. /**
  45248. * Disposes of the gizmo
  45249. */
  45250. dispose(): void;
  45251. }
  45252. }
  45253. declare module "babylonjs/Gizmos/positionGizmo" {
  45254. import { Observable } from "babylonjs/Misc/observable";
  45255. import { Nullable } from "babylonjs/types";
  45256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45257. import { Mesh } from "babylonjs/Meshes/mesh";
  45258. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45259. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  45260. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  45261. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45262. /**
  45263. * Gizmo that enables dragging a mesh along 3 axis
  45264. */
  45265. export class PositionGizmo extends Gizmo {
  45266. /**
  45267. * Internal gizmo used for interactions on the x axis
  45268. */
  45269. xGizmo: AxisDragGizmo;
  45270. /**
  45271. * Internal gizmo used for interactions on the y axis
  45272. */
  45273. yGizmo: AxisDragGizmo;
  45274. /**
  45275. * Internal gizmo used for interactions on the z axis
  45276. */
  45277. zGizmo: AxisDragGizmo;
  45278. /**
  45279. * Internal gizmo used for interactions on the yz plane
  45280. */
  45281. xPlaneGizmo: PlaneDragGizmo;
  45282. /**
  45283. * Internal gizmo used for interactions on the xz plane
  45284. */
  45285. yPlaneGizmo: PlaneDragGizmo;
  45286. /**
  45287. * Internal gizmo used for interactions on the xy plane
  45288. */
  45289. zPlaneGizmo: PlaneDragGizmo;
  45290. /**
  45291. * private variables
  45292. */
  45293. private _meshAttached;
  45294. private _updateGizmoRotationToMatchAttachedMesh;
  45295. private _snapDistance;
  45296. private _scaleRatio;
  45297. /** Fires an event when any of it's sub gizmos are dragged */
  45298. onDragStartObservable: Observable<unknown>;
  45299. /** Fires an event when any of it's sub gizmos are released from dragging */
  45300. onDragEndObservable: Observable<unknown>;
  45301. /**
  45302. * If set to true, planar drag is enabled
  45303. */
  45304. private _planarGizmoEnabled;
  45305. attachedMesh: Nullable<AbstractMesh>;
  45306. /**
  45307. * Creates a PositionGizmo
  45308. * @param gizmoLayer The utility layer the gizmo will be added to
  45309. */
  45310. constructor(gizmoLayer?: UtilityLayerRenderer);
  45311. /**
  45312. * If the planar drag gizmo is enabled
  45313. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45314. */
  45315. planarGizmoEnabled: boolean;
  45316. updateGizmoRotationToMatchAttachedMesh: boolean;
  45317. /**
  45318. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45319. */
  45320. snapDistance: number;
  45321. /**
  45322. * Ratio for the scale of the gizmo (Default: 1)
  45323. */
  45324. scaleRatio: number;
  45325. /**
  45326. * Disposes of the gizmo
  45327. */
  45328. dispose(): void;
  45329. /**
  45330. * CustomMeshes are not supported by this gizmo
  45331. * @param mesh The mesh to replace the default mesh of the gizmo
  45332. */
  45333. setCustomMesh(mesh: Mesh): void;
  45334. }
  45335. }
  45336. declare module "babylonjs/Gizmos/axisDragGizmo" {
  45337. import { Observable } from "babylonjs/Misc/observable";
  45338. import { Nullable } from "babylonjs/types";
  45339. import { Vector3 } from "babylonjs/Maths/math.vector";
  45340. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45342. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45343. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45344. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45345. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  45346. import { Scene } from "babylonjs/scene";
  45347. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45348. import { Color3 } from "babylonjs/Maths/math.color";
  45349. /**
  45350. * Single axis drag gizmo
  45351. */
  45352. export class AxisDragGizmo extends Gizmo {
  45353. /**
  45354. * Drag behavior responsible for the gizmos dragging interactions
  45355. */
  45356. dragBehavior: PointerDragBehavior;
  45357. private _pointerObserver;
  45358. /**
  45359. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45360. */
  45361. snapDistance: number;
  45362. /**
  45363. * Event that fires each time the gizmo snaps to a new location.
  45364. * * snapDistance is the the change in distance
  45365. */
  45366. onSnapObservable: Observable<{
  45367. snapDistance: number;
  45368. }>;
  45369. private _isEnabled;
  45370. private _parent;
  45371. private _arrow;
  45372. private _coloredMaterial;
  45373. private _hoverMaterial;
  45374. /** @hidden */
  45375. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45376. /** @hidden */
  45377. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45378. /**
  45379. * Creates an AxisDragGizmo
  45380. * @param gizmoLayer The utility layer the gizmo will be added to
  45381. * @param dragAxis The axis which the gizmo will be able to drag on
  45382. * @param color The color of the gizmo
  45383. */
  45384. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45385. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45386. /**
  45387. * If the gizmo is enabled
  45388. */
  45389. isEnabled: boolean;
  45390. /**
  45391. * Disposes of the gizmo
  45392. */
  45393. dispose(): void;
  45394. }
  45395. }
  45396. declare module "babylonjs/Debug/axesViewer" {
  45397. import { Vector3 } from "babylonjs/Maths/math.vector";
  45398. import { Nullable } from "babylonjs/types";
  45399. import { Scene } from "babylonjs/scene";
  45400. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45401. /**
  45402. * The Axes viewer will show 3 axes in a specific point in space
  45403. */
  45404. export class AxesViewer {
  45405. private _xAxis;
  45406. private _yAxis;
  45407. private _zAxis;
  45408. private _scaleLinesFactor;
  45409. private _instanced;
  45410. /**
  45411. * Gets the hosting scene
  45412. */
  45413. scene: Scene;
  45414. /**
  45415. * Gets or sets a number used to scale line length
  45416. */
  45417. scaleLines: number;
  45418. /** Gets the node hierarchy used to render x-axis */
  45419. readonly xAxis: TransformNode;
  45420. /** Gets the node hierarchy used to render y-axis */
  45421. readonly yAxis: TransformNode;
  45422. /** Gets the node hierarchy used to render z-axis */
  45423. readonly zAxis: TransformNode;
  45424. /**
  45425. * Creates a new AxesViewer
  45426. * @param scene defines the hosting scene
  45427. * @param scaleLines defines a number used to scale line length (1 by default)
  45428. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45429. * @param xAxis defines the node hierarchy used to render the x-axis
  45430. * @param yAxis defines the node hierarchy used to render the y-axis
  45431. * @param zAxis defines the node hierarchy used to render the z-axis
  45432. */
  45433. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45434. /**
  45435. * Force the viewer to update
  45436. * @param position defines the position of the viewer
  45437. * @param xaxis defines the x axis of the viewer
  45438. * @param yaxis defines the y axis of the viewer
  45439. * @param zaxis defines the z axis of the viewer
  45440. */
  45441. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45442. /**
  45443. * Creates an instance of this axes viewer.
  45444. * @returns a new axes viewer with instanced meshes
  45445. */
  45446. createInstance(): AxesViewer;
  45447. /** Releases resources */
  45448. dispose(): void;
  45449. private static _SetRenderingGroupId;
  45450. }
  45451. }
  45452. declare module "babylonjs/Debug/boneAxesViewer" {
  45453. import { Nullable } from "babylonjs/types";
  45454. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  45455. import { Vector3 } from "babylonjs/Maths/math.vector";
  45456. import { Mesh } from "babylonjs/Meshes/mesh";
  45457. import { Bone } from "babylonjs/Bones/bone";
  45458. import { Scene } from "babylonjs/scene";
  45459. /**
  45460. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45461. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45462. */
  45463. export class BoneAxesViewer extends AxesViewer {
  45464. /**
  45465. * Gets or sets the target mesh where to display the axes viewer
  45466. */
  45467. mesh: Nullable<Mesh>;
  45468. /**
  45469. * Gets or sets the target bone where to display the axes viewer
  45470. */
  45471. bone: Nullable<Bone>;
  45472. /** Gets current position */
  45473. pos: Vector3;
  45474. /** Gets direction of X axis */
  45475. xaxis: Vector3;
  45476. /** Gets direction of Y axis */
  45477. yaxis: Vector3;
  45478. /** Gets direction of Z axis */
  45479. zaxis: Vector3;
  45480. /**
  45481. * Creates a new BoneAxesViewer
  45482. * @param scene defines the hosting scene
  45483. * @param bone defines the target bone
  45484. * @param mesh defines the target mesh
  45485. * @param scaleLines defines a scaling factor for line length (1 by default)
  45486. */
  45487. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  45488. /**
  45489. * Force the viewer to update
  45490. */
  45491. update(): void;
  45492. /** Releases resources */
  45493. dispose(): void;
  45494. }
  45495. }
  45496. declare module "babylonjs/Debug/debugLayer" {
  45497. import { Scene } from "babylonjs/scene";
  45498. /**
  45499. * Interface used to define scene explorer extensibility option
  45500. */
  45501. export interface IExplorerExtensibilityOption {
  45502. /**
  45503. * Define the option label
  45504. */
  45505. label: string;
  45506. /**
  45507. * Defines the action to execute on click
  45508. */
  45509. action: (entity: any) => void;
  45510. }
  45511. /**
  45512. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  45513. */
  45514. export interface IExplorerExtensibilityGroup {
  45515. /**
  45516. * Defines a predicate to test if a given type mut be extended
  45517. */
  45518. predicate: (entity: any) => boolean;
  45519. /**
  45520. * Gets the list of options added to a type
  45521. */
  45522. entries: IExplorerExtensibilityOption[];
  45523. }
  45524. /**
  45525. * Interface used to define the options to use to create the Inspector
  45526. */
  45527. export interface IInspectorOptions {
  45528. /**
  45529. * Display in overlay mode (default: false)
  45530. */
  45531. overlay?: boolean;
  45532. /**
  45533. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  45534. */
  45535. globalRoot?: HTMLElement;
  45536. /**
  45537. * Display the Scene explorer
  45538. */
  45539. showExplorer?: boolean;
  45540. /**
  45541. * Display the property inspector
  45542. */
  45543. showInspector?: boolean;
  45544. /**
  45545. * Display in embed mode (both panes on the right)
  45546. */
  45547. embedMode?: boolean;
  45548. /**
  45549. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  45550. */
  45551. handleResize?: boolean;
  45552. /**
  45553. * Allow the panes to popup (default: true)
  45554. */
  45555. enablePopup?: boolean;
  45556. /**
  45557. * Allow the panes to be closed by users (default: true)
  45558. */
  45559. enableClose?: boolean;
  45560. /**
  45561. * Optional list of extensibility entries
  45562. */
  45563. explorerExtensibility?: IExplorerExtensibilityGroup[];
  45564. /**
  45565. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  45566. */
  45567. inspectorURL?: string;
  45568. }
  45569. module "babylonjs/scene" {
  45570. interface Scene {
  45571. /**
  45572. * @hidden
  45573. * Backing field
  45574. */
  45575. _debugLayer: DebugLayer;
  45576. /**
  45577. * Gets the debug layer (aka Inspector) associated with the scene
  45578. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45579. */
  45580. debugLayer: DebugLayer;
  45581. }
  45582. }
  45583. /**
  45584. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45585. * what is happening in your scene
  45586. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45587. */
  45588. export class DebugLayer {
  45589. /**
  45590. * Define the url to get the inspector script from.
  45591. * By default it uses the babylonjs CDN.
  45592. * @ignoreNaming
  45593. */
  45594. static InspectorURL: string;
  45595. private _scene;
  45596. private BJSINSPECTOR;
  45597. private _onPropertyChangedObservable?;
  45598. /**
  45599. * Observable triggered when a property is changed through the inspector.
  45600. */
  45601. readonly onPropertyChangedObservable: any;
  45602. /**
  45603. * Instantiates a new debug layer.
  45604. * The debug layer (aka Inspector) is the go to tool in order to better understand
  45605. * what is happening in your scene
  45606. * @see http://doc.babylonjs.com/features/playground_debuglayer
  45607. * @param scene Defines the scene to inspect
  45608. */
  45609. constructor(scene: Scene);
  45610. /** Creates the inspector window. */
  45611. private _createInspector;
  45612. /**
  45613. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  45614. * @param entity defines the entity to select
  45615. * @param lineContainerTitle defines the specific block to highlight
  45616. */
  45617. select(entity: any, lineContainerTitle?: string): void;
  45618. /** Get the inspector from bundle or global */
  45619. private _getGlobalInspector;
  45620. /**
  45621. * Get if the inspector is visible or not.
  45622. * @returns true if visible otherwise, false
  45623. */
  45624. isVisible(): boolean;
  45625. /**
  45626. * Hide the inspector and close its window.
  45627. */
  45628. hide(): void;
  45629. /**
  45630. * Launch the debugLayer.
  45631. * @param config Define the configuration of the inspector
  45632. * @return a promise fulfilled when the debug layer is visible
  45633. */
  45634. show(config?: IInspectorOptions): Promise<DebugLayer>;
  45635. }
  45636. }
  45637. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  45638. import { Nullable } from "babylonjs/types";
  45639. import { Scene } from "babylonjs/scene";
  45640. import { Vector4 } from "babylonjs/Maths/math.vector";
  45641. import { Color4 } from "babylonjs/Maths/math.color";
  45642. import { Mesh } from "babylonjs/Meshes/mesh";
  45643. /**
  45644. * Class containing static functions to help procedurally build meshes
  45645. */
  45646. export class BoxBuilder {
  45647. /**
  45648. * Creates a box mesh
  45649. * * The parameter `size` sets the size (float) of each box side (default 1)
  45650. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  45651. * * 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)
  45652. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  45657. * @param name defines the name of the mesh
  45658. * @param options defines the options used to create the mesh
  45659. * @param scene defines the hosting scene
  45660. * @returns the box mesh
  45661. */
  45662. static CreateBox(name: string, options: {
  45663. size?: number;
  45664. width?: number;
  45665. height?: number;
  45666. depth?: number;
  45667. faceUV?: Vector4[];
  45668. faceColors?: Color4[];
  45669. sideOrientation?: number;
  45670. frontUVs?: Vector4;
  45671. backUVs?: Vector4;
  45672. wrap?: boolean;
  45673. topBaseAt?: number;
  45674. bottomBaseAt?: number;
  45675. updatable?: boolean;
  45676. }, scene?: Nullable<Scene>): Mesh;
  45677. }
  45678. }
  45679. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45680. import { Vector4 } from "babylonjs/Maths/math.vector";
  45681. import { Mesh } from "babylonjs/Meshes/mesh";
  45682. import { Scene } from "babylonjs/scene";
  45683. import { Nullable } from "babylonjs/types";
  45684. /**
  45685. * Class containing static functions to help procedurally build meshes
  45686. */
  45687. export class SphereBuilder {
  45688. /**
  45689. * Creates a sphere mesh
  45690. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45691. * * 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`)
  45692. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45693. * * 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
  45694. * * 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)
  45695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45698. * @param name defines the name of the mesh
  45699. * @param options defines the options used to create the mesh
  45700. * @param scene defines the hosting scene
  45701. * @returns the sphere mesh
  45702. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45703. */
  45704. static CreateSphere(name: string, options: {
  45705. segments?: number;
  45706. diameter?: number;
  45707. diameterX?: number;
  45708. diameterY?: number;
  45709. diameterZ?: number;
  45710. arc?: number;
  45711. slice?: number;
  45712. sideOrientation?: number;
  45713. frontUVs?: Vector4;
  45714. backUVs?: Vector4;
  45715. updatable?: boolean;
  45716. }, scene?: Nullable<Scene>): Mesh;
  45717. }
  45718. }
  45719. declare module "babylonjs/Debug/physicsViewer" {
  45720. import { Nullable } from "babylonjs/types";
  45721. import { Scene } from "babylonjs/scene";
  45722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45723. import { Mesh } from "babylonjs/Meshes/mesh";
  45724. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45725. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45726. /**
  45727. * Used to show the physics impostor around the specific mesh
  45728. */
  45729. export class PhysicsViewer {
  45730. /** @hidden */
  45731. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45732. /** @hidden */
  45733. protected _meshes: Array<Nullable<AbstractMesh>>;
  45734. /** @hidden */
  45735. protected _scene: Nullable<Scene>;
  45736. /** @hidden */
  45737. protected _numMeshes: number;
  45738. /** @hidden */
  45739. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45740. private _renderFunction;
  45741. private _utilityLayer;
  45742. private _debugBoxMesh;
  45743. private _debugSphereMesh;
  45744. private _debugCylinderMesh;
  45745. private _debugMaterial;
  45746. private _debugMeshMeshes;
  45747. /**
  45748. * Creates a new PhysicsViewer
  45749. * @param scene defines the hosting scene
  45750. */
  45751. constructor(scene: Scene);
  45752. /** @hidden */
  45753. protected _updateDebugMeshes(): void;
  45754. /**
  45755. * Renders a specified physic impostor
  45756. * @param impostor defines the impostor to render
  45757. * @param targetMesh defines the mesh represented by the impostor
  45758. * @returns the new debug mesh used to render the impostor
  45759. */
  45760. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45761. /**
  45762. * Hides a specified physic impostor
  45763. * @param impostor defines the impostor to hide
  45764. */
  45765. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45766. private _getDebugMaterial;
  45767. private _getDebugBoxMesh;
  45768. private _getDebugSphereMesh;
  45769. private _getDebugCylinderMesh;
  45770. private _getDebugMeshMesh;
  45771. private _getDebugMesh;
  45772. /** Releases all resources */
  45773. dispose(): void;
  45774. }
  45775. }
  45776. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45777. import { Vector3 } from "babylonjs/Maths/math.vector";
  45778. import { Color4 } from "babylonjs/Maths/math.color";
  45779. import { Nullable } from "babylonjs/types";
  45780. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45781. import { Scene } from "babylonjs/scene";
  45782. /**
  45783. * Class containing static functions to help procedurally build meshes
  45784. */
  45785. export class LinesBuilder {
  45786. /**
  45787. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45788. * * 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
  45789. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45790. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45791. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45792. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45793. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45794. * * 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
  45795. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45797. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45798. * @param name defines the name of the new line system
  45799. * @param options defines the options used to create the line system
  45800. * @param scene defines the hosting scene
  45801. * @returns a new line system mesh
  45802. */
  45803. static CreateLineSystem(name: string, options: {
  45804. lines: Vector3[][];
  45805. updatable?: boolean;
  45806. instance?: Nullable<LinesMesh>;
  45807. colors?: Nullable<Color4[][]>;
  45808. useVertexAlpha?: boolean;
  45809. }, scene: Nullable<Scene>): LinesMesh;
  45810. /**
  45811. * Creates a line mesh
  45812. * 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
  45813. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45814. * * The parameter `points` is an array successive Vector3
  45815. * * 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
  45816. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45817. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45818. * * When updating an instance, remember that only point positions can change, not the number of points
  45819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45820. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45821. * @param name defines the name of the new line system
  45822. * @param options defines the options used to create the line system
  45823. * @param scene defines the hosting scene
  45824. * @returns a new line mesh
  45825. */
  45826. static CreateLines(name: string, options: {
  45827. points: Vector3[];
  45828. updatable?: boolean;
  45829. instance?: Nullable<LinesMesh>;
  45830. colors?: Color4[];
  45831. useVertexAlpha?: boolean;
  45832. }, scene?: Nullable<Scene>): LinesMesh;
  45833. /**
  45834. * Creates a dashed line mesh
  45835. * * 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
  45836. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45837. * * The parameter `points` is an array successive Vector3
  45838. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45839. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45840. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45841. * * 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
  45842. * * When updating an instance, remember that only point positions can change, not the number of points
  45843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45844. * @param name defines the name of the mesh
  45845. * @param options defines the options used to create the mesh
  45846. * @param scene defines the hosting scene
  45847. * @returns the dashed line mesh
  45848. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45849. */
  45850. static CreateDashedLines(name: string, options: {
  45851. points: Vector3[];
  45852. dashSize?: number;
  45853. gapSize?: number;
  45854. dashNb?: number;
  45855. updatable?: boolean;
  45856. instance?: LinesMesh;
  45857. }, scene?: Nullable<Scene>): LinesMesh;
  45858. }
  45859. }
  45860. declare module "babylonjs/Debug/rayHelper" {
  45861. import { Nullable } from "babylonjs/types";
  45862. import { Ray } from "babylonjs/Culling/ray";
  45863. import { Vector3 } from "babylonjs/Maths/math.vector";
  45864. import { Color3 } from "babylonjs/Maths/math.color";
  45865. import { Scene } from "babylonjs/scene";
  45866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45867. import "babylonjs/Meshes/Builders/linesBuilder";
  45868. /**
  45869. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45870. * in order to better appreciate the issue one might have.
  45871. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45872. */
  45873. export class RayHelper {
  45874. /**
  45875. * Defines the ray we are currently tryin to visualize.
  45876. */
  45877. ray: Nullable<Ray>;
  45878. private _renderPoints;
  45879. private _renderLine;
  45880. private _renderFunction;
  45881. private _scene;
  45882. private _updateToMeshFunction;
  45883. private _attachedToMesh;
  45884. private _meshSpaceDirection;
  45885. private _meshSpaceOrigin;
  45886. /**
  45887. * Helper function to create a colored helper in a scene in one line.
  45888. * @param ray Defines the ray we are currently tryin to visualize
  45889. * @param scene Defines the scene the ray is used in
  45890. * @param color Defines the color we want to see the ray in
  45891. * @returns The newly created ray helper.
  45892. */
  45893. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45894. /**
  45895. * Instantiate a new ray helper.
  45896. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45897. * in order to better appreciate the issue one might have.
  45898. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45899. * @param ray Defines the ray we are currently tryin to visualize
  45900. */
  45901. constructor(ray: Ray);
  45902. /**
  45903. * Shows the ray we are willing to debug.
  45904. * @param scene Defines the scene the ray needs to be rendered in
  45905. * @param color Defines the color the ray needs to be rendered in
  45906. */
  45907. show(scene: Scene, color?: Color3): void;
  45908. /**
  45909. * Hides the ray we are debugging.
  45910. */
  45911. hide(): void;
  45912. private _render;
  45913. /**
  45914. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45915. * @param mesh Defines the mesh we want the helper attached to
  45916. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45917. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45918. * @param length Defines the length of the ray
  45919. */
  45920. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45921. /**
  45922. * Detach the ray helper from the mesh it has previously been attached to.
  45923. */
  45924. detachFromMesh(): void;
  45925. private _updateToMesh;
  45926. /**
  45927. * Dispose the helper and release its associated resources.
  45928. */
  45929. dispose(): void;
  45930. }
  45931. }
  45932. declare module "babylonjs/Debug/skeletonViewer" {
  45933. import { Color3 } from "babylonjs/Maths/math.color";
  45934. import { Scene } from "babylonjs/scene";
  45935. import { Nullable } from "babylonjs/types";
  45936. import { Skeleton } from "babylonjs/Bones/skeleton";
  45937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45938. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45939. /**
  45940. * Class used to render a debug view of a given skeleton
  45941. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45942. */
  45943. export class SkeletonViewer {
  45944. /** defines the skeleton to render */
  45945. skeleton: Skeleton;
  45946. /** defines the mesh attached to the skeleton */
  45947. mesh: AbstractMesh;
  45948. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45949. autoUpdateBonesMatrices: boolean;
  45950. /** defines the rendering group id to use with the viewer */
  45951. renderingGroupId: number;
  45952. /** Gets or sets the color used to render the skeleton */
  45953. color: Color3;
  45954. private _scene;
  45955. private _debugLines;
  45956. private _debugMesh;
  45957. private _isEnabled;
  45958. private _renderFunction;
  45959. private _utilityLayer;
  45960. /**
  45961. * Returns the mesh used to render the bones
  45962. */
  45963. readonly debugMesh: Nullable<LinesMesh>;
  45964. /**
  45965. * Creates a new SkeletonViewer
  45966. * @param skeleton defines the skeleton to render
  45967. * @param mesh defines the mesh attached to the skeleton
  45968. * @param scene defines the hosting scene
  45969. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45970. * @param renderingGroupId defines the rendering group id to use with the viewer
  45971. */
  45972. constructor(
  45973. /** defines the skeleton to render */
  45974. skeleton: Skeleton,
  45975. /** defines the mesh attached to the skeleton */
  45976. mesh: AbstractMesh, scene: Scene,
  45977. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45978. autoUpdateBonesMatrices?: boolean,
  45979. /** defines the rendering group id to use with the viewer */
  45980. renderingGroupId?: number);
  45981. /** Gets or sets a boolean indicating if the viewer is enabled */
  45982. isEnabled: boolean;
  45983. private _getBonePosition;
  45984. private _getLinesForBonesWithLength;
  45985. private _getLinesForBonesNoLength;
  45986. /** Update the viewer to sync with current skeleton state */
  45987. update(): void;
  45988. /** Release associated resources */
  45989. dispose(): void;
  45990. }
  45991. }
  45992. declare module "babylonjs/Debug/index" {
  45993. export * from "babylonjs/Debug/axesViewer";
  45994. export * from "babylonjs/Debug/boneAxesViewer";
  45995. export * from "babylonjs/Debug/debugLayer";
  45996. export * from "babylonjs/Debug/physicsViewer";
  45997. export * from "babylonjs/Debug/rayHelper";
  45998. export * from "babylonjs/Debug/skeletonViewer";
  45999. }
  46000. declare module "babylonjs/Engines/nullEngine" {
  46001. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  46002. import { Scene } from "babylonjs/scene";
  46003. import { Engine } from "babylonjs/Engines/engine";
  46004. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46005. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46006. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46007. import { Effect } from "babylonjs/Materials/effect";
  46008. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46009. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46010. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  46011. /**
  46012. * Options to create the null engine
  46013. */
  46014. export class NullEngineOptions {
  46015. /**
  46016. * Render width (Default: 512)
  46017. */
  46018. renderWidth: number;
  46019. /**
  46020. * Render height (Default: 256)
  46021. */
  46022. renderHeight: number;
  46023. /**
  46024. * Texture size (Default: 512)
  46025. */
  46026. textureSize: number;
  46027. /**
  46028. * If delta time between frames should be constant
  46029. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46030. */
  46031. deterministicLockstep: boolean;
  46032. /**
  46033. * Maximum about of steps between frames (Default: 4)
  46034. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46035. */
  46036. lockstepMaxSteps: number;
  46037. }
  46038. /**
  46039. * The null engine class provides support for headless version of babylon.js.
  46040. * This can be used in server side scenario or for testing purposes
  46041. */
  46042. export class NullEngine extends Engine {
  46043. private _options;
  46044. /**
  46045. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46046. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46047. * @returns true if engine is in deterministic lock step mode
  46048. */
  46049. isDeterministicLockStep(): boolean;
  46050. /**
  46051. * Gets the max steps when engine is running in deterministic lock step
  46052. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46053. * @returns the max steps
  46054. */
  46055. getLockstepMaxSteps(): number;
  46056. /**
  46057. * Gets the current hardware scaling level.
  46058. * By default the hardware scaling level is computed from the window device ratio.
  46059. * 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.
  46060. * @returns a number indicating the current hardware scaling level
  46061. */
  46062. getHardwareScalingLevel(): number;
  46063. constructor(options?: NullEngineOptions);
  46064. /**
  46065. * Creates a vertex buffer
  46066. * @param vertices the data for the vertex buffer
  46067. * @returns the new WebGL static buffer
  46068. */
  46069. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46070. /**
  46071. * Creates a new index buffer
  46072. * @param indices defines the content of the index buffer
  46073. * @param updatable defines if the index buffer must be updatable
  46074. * @returns a new webGL buffer
  46075. */
  46076. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46077. /**
  46078. * Clear the current render buffer or the current render target (if any is set up)
  46079. * @param color defines the color to use
  46080. * @param backBuffer defines if the back buffer must be cleared
  46081. * @param depth defines if the depth buffer must be cleared
  46082. * @param stencil defines if the stencil buffer must be cleared
  46083. */
  46084. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46085. /**
  46086. * Gets the current render width
  46087. * @param useScreen defines if screen size must be used (or the current render target if any)
  46088. * @returns a number defining the current render width
  46089. */
  46090. getRenderWidth(useScreen?: boolean): number;
  46091. /**
  46092. * Gets the current render height
  46093. * @param useScreen defines if screen size must be used (or the current render target if any)
  46094. * @returns a number defining the current render height
  46095. */
  46096. getRenderHeight(useScreen?: boolean): number;
  46097. /**
  46098. * Set the WebGL's viewport
  46099. * @param viewport defines the viewport element to be used
  46100. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46101. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46102. */
  46103. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46104. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46105. /**
  46106. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46107. * @param pipelineContext defines the pipeline context to use
  46108. * @param uniformsNames defines the list of uniform names
  46109. * @returns an array of webGL uniform locations
  46110. */
  46111. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46112. /**
  46113. * Gets the lsit of active attributes for a given webGL program
  46114. * @param pipelineContext defines the pipeline context to use
  46115. * @param attributesNames defines the list of attribute names to get
  46116. * @returns an array of indices indicating the offset of each attribute
  46117. */
  46118. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46119. /**
  46120. * Binds an effect to the webGL context
  46121. * @param effect defines the effect to bind
  46122. */
  46123. bindSamplers(effect: Effect): void;
  46124. /**
  46125. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46126. * @param effect defines the effect to activate
  46127. */
  46128. enableEffect(effect: Effect): void;
  46129. /**
  46130. * Set various states to the webGL context
  46131. * @param culling defines backface culling state
  46132. * @param zOffset defines the value to apply to zOffset (0 by default)
  46133. * @param force defines if states must be applied even if cache is up to date
  46134. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46135. */
  46136. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46137. /**
  46138. * Set the value of an uniform to an array of int32
  46139. * @param uniform defines the webGL uniform location where to store the value
  46140. * @param array defines the array of int32 to store
  46141. */
  46142. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46143. /**
  46144. * Set the value of an uniform to an array of int32 (stored as vec2)
  46145. * @param uniform defines the webGL uniform location where to store the value
  46146. * @param array defines the array of int32 to store
  46147. */
  46148. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46149. /**
  46150. * Set the value of an uniform to an array of int32 (stored as vec3)
  46151. * @param uniform defines the webGL uniform location where to store the value
  46152. * @param array defines the array of int32 to store
  46153. */
  46154. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46155. /**
  46156. * Set the value of an uniform to an array of int32 (stored as vec4)
  46157. * @param uniform defines the webGL uniform location where to store the value
  46158. * @param array defines the array of int32 to store
  46159. */
  46160. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46161. /**
  46162. * Set the value of an uniform to an array of float32
  46163. * @param uniform defines the webGL uniform location where to store the value
  46164. * @param array defines the array of float32 to store
  46165. */
  46166. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46167. /**
  46168. * Set the value of an uniform to an array of float32 (stored as vec2)
  46169. * @param uniform defines the webGL uniform location where to store the value
  46170. * @param array defines the array of float32 to store
  46171. */
  46172. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46173. /**
  46174. * Set the value of an uniform to an array of float32 (stored as vec3)
  46175. * @param uniform defines the webGL uniform location where to store the value
  46176. * @param array defines the array of float32 to store
  46177. */
  46178. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46179. /**
  46180. * Set the value of an uniform to an array of float32 (stored as vec4)
  46181. * @param uniform defines the webGL uniform location where to store the value
  46182. * @param array defines the array of float32 to store
  46183. */
  46184. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46185. /**
  46186. * Set the value of an uniform to an array of number
  46187. * @param uniform defines the webGL uniform location where to store the value
  46188. * @param array defines the array of number to store
  46189. */
  46190. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46191. /**
  46192. * Set the value of an uniform to an array of number (stored as vec2)
  46193. * @param uniform defines the webGL uniform location where to store the value
  46194. * @param array defines the array of number to store
  46195. */
  46196. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46197. /**
  46198. * Set the value of an uniform to an array of number (stored as vec3)
  46199. * @param uniform defines the webGL uniform location where to store the value
  46200. * @param array defines the array of number to store
  46201. */
  46202. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46203. /**
  46204. * Set the value of an uniform to an array of number (stored as vec4)
  46205. * @param uniform defines the webGL uniform location where to store the value
  46206. * @param array defines the array of number to store
  46207. */
  46208. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46209. /**
  46210. * Set the value of an uniform to an array of float32 (stored as matrices)
  46211. * @param uniform defines the webGL uniform location where to store the value
  46212. * @param matrices defines the array of float32 to store
  46213. */
  46214. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46215. /**
  46216. * Set the value of an uniform to a matrix (3x3)
  46217. * @param uniform defines the webGL uniform location where to store the value
  46218. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46219. */
  46220. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46221. /**
  46222. * Set the value of an uniform to a matrix (2x2)
  46223. * @param uniform defines the webGL uniform location where to store the value
  46224. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46225. */
  46226. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46227. /**
  46228. * Set the value of an uniform to a number (float)
  46229. * @param uniform defines the webGL uniform location where to store the value
  46230. * @param value defines the float number to store
  46231. */
  46232. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46233. /**
  46234. * Set the value of an uniform to a vec2
  46235. * @param uniform defines the webGL uniform location where to store the value
  46236. * @param x defines the 1st component of the value
  46237. * @param y defines the 2nd component of the value
  46238. */
  46239. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46240. /**
  46241. * Set the value of an uniform to a vec3
  46242. * @param uniform defines the webGL uniform location where to store the value
  46243. * @param x defines the 1st component of the value
  46244. * @param y defines the 2nd component of the value
  46245. * @param z defines the 3rd component of the value
  46246. */
  46247. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46248. /**
  46249. * Set the value of an uniform to a boolean
  46250. * @param uniform defines the webGL uniform location where to store the value
  46251. * @param bool defines the boolean to store
  46252. */
  46253. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46254. /**
  46255. * Set the value of an uniform to a vec4
  46256. * @param uniform defines the webGL uniform location where to store the value
  46257. * @param x defines the 1st component of the value
  46258. * @param y defines the 2nd component of the value
  46259. * @param z defines the 3rd component of the value
  46260. * @param w defines the 4th component of the value
  46261. */
  46262. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46263. /**
  46264. * Sets the current alpha mode
  46265. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46266. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46267. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46268. */
  46269. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46270. /**
  46271. * Bind webGl buffers directly to the webGL context
  46272. * @param vertexBuffers defines the vertex buffer to bind
  46273. * @param indexBuffer defines the index buffer to bind
  46274. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46275. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46276. * @param effect defines the effect associated with the vertex buffer
  46277. */
  46278. bindBuffers(vertexBuffers: {
  46279. [key: string]: VertexBuffer;
  46280. }, indexBuffer: DataBuffer, effect: Effect): void;
  46281. /**
  46282. * Force the entire cache to be cleared
  46283. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46284. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46285. */
  46286. wipeCaches(bruteForce?: boolean): void;
  46287. /**
  46288. * Send a draw order
  46289. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46290. * @param indexStart defines the starting index
  46291. * @param indexCount defines the number of index to draw
  46292. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46293. */
  46294. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46295. /**
  46296. * Draw a list of indexed primitives
  46297. * @param fillMode defines the primitive to use
  46298. * @param indexStart defines the starting index
  46299. * @param indexCount defines the number of index to draw
  46300. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46301. */
  46302. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46303. /**
  46304. * Draw a list of unindexed primitives
  46305. * @param fillMode defines the primitive to use
  46306. * @param verticesStart defines the index of first vertex to draw
  46307. * @param verticesCount defines the count of vertices to draw
  46308. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46309. */
  46310. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46311. /** @hidden */
  46312. _createTexture(): WebGLTexture;
  46313. /** @hidden */
  46314. _releaseTexture(texture: InternalTexture): void;
  46315. /**
  46316. * Usually called from Texture.ts.
  46317. * Passed information to create a WebGLTexture
  46318. * @param urlArg defines a value which contains one of the following:
  46319. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46320. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46321. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46322. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46323. * @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)
  46324. * @param scene needed for loading to the correct scene
  46325. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46326. * @param onLoad optional callback to be called upon successful completion
  46327. * @param onError optional callback to be called upon failure
  46328. * @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
  46329. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46330. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46331. * @param forcedExtension defines the extension to use to pick the right loader
  46332. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46333. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46334. */
  46335. 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;
  46336. /**
  46337. * Creates a new render target texture
  46338. * @param size defines the size of the texture
  46339. * @param options defines the options used to create the texture
  46340. * @returns a new render target texture stored in an InternalTexture
  46341. */
  46342. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46343. /**
  46344. * Update the sampling mode of a given texture
  46345. * @param samplingMode defines the required sampling mode
  46346. * @param texture defines the texture to update
  46347. */
  46348. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46349. /**
  46350. * Binds the frame buffer to the specified texture.
  46351. * @param texture The texture to render to or null for the default canvas
  46352. * @param faceIndex The face of the texture to render to in case of cube texture
  46353. * @param requiredWidth The width of the target to render to
  46354. * @param requiredHeight The height of the target to render to
  46355. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46356. * @param depthStencilTexture The depth stencil texture to use to render
  46357. * @param lodLevel defines le lod level to bind to the frame buffer
  46358. */
  46359. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46360. /**
  46361. * Unbind the current render target texture from the webGL context
  46362. * @param texture defines the render target texture to unbind
  46363. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46364. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46365. */
  46366. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46367. /**
  46368. * Creates a dynamic vertex buffer
  46369. * @param vertices the data for the dynamic vertex buffer
  46370. * @returns the new WebGL dynamic buffer
  46371. */
  46372. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46373. /**
  46374. * Update the content of a dynamic texture
  46375. * @param texture defines the texture to update
  46376. * @param canvas defines the canvas containing the source
  46377. * @param invertY defines if data must be stored with Y axis inverted
  46378. * @param premulAlpha defines if alpha is stored as premultiplied
  46379. * @param format defines the format of the data
  46380. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46381. */
  46382. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46383. /**
  46384. * Gets a boolean indicating if all created effects are ready
  46385. * @returns true if all effects are ready
  46386. */
  46387. areAllEffectsReady(): boolean;
  46388. /**
  46389. * @hidden
  46390. * Get the current error code of the webGL context
  46391. * @returns the error code
  46392. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46393. */
  46394. getError(): number;
  46395. /** @hidden */
  46396. _getUnpackAlignement(): number;
  46397. /** @hidden */
  46398. _unpackFlipY(value: boolean): void;
  46399. /**
  46400. * Update a dynamic index buffer
  46401. * @param indexBuffer defines the target index buffer
  46402. * @param indices defines the data to update
  46403. * @param offset defines the offset in the target index buffer where update should start
  46404. */
  46405. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46406. /**
  46407. * Updates a dynamic vertex buffer.
  46408. * @param vertexBuffer the vertex buffer to update
  46409. * @param vertices the data used to update the vertex buffer
  46410. * @param byteOffset the byte offset of the data (optional)
  46411. * @param byteLength the byte length of the data (optional)
  46412. */
  46413. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46414. /** @hidden */
  46415. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46416. /** @hidden */
  46417. _bindTexture(channel: number, texture: InternalTexture): void;
  46418. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46419. /**
  46420. * 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
  46421. */
  46422. releaseEffects(): void;
  46423. displayLoadingUI(): void;
  46424. hideLoadingUI(): void;
  46425. /** @hidden */
  46426. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46427. /** @hidden */
  46428. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46429. /** @hidden */
  46430. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46431. /** @hidden */
  46432. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46433. }
  46434. }
  46435. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  46436. import { Nullable, int } from "babylonjs/types";
  46437. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  46438. /** @hidden */
  46439. export class _OcclusionDataStorage {
  46440. /** @hidden */
  46441. occlusionInternalRetryCounter: number;
  46442. /** @hidden */
  46443. isOcclusionQueryInProgress: boolean;
  46444. /** @hidden */
  46445. isOccluded: boolean;
  46446. /** @hidden */
  46447. occlusionRetryCount: number;
  46448. /** @hidden */
  46449. occlusionType: number;
  46450. /** @hidden */
  46451. occlusionQueryAlgorithmType: number;
  46452. }
  46453. module "babylonjs/Engines/engine" {
  46454. interface Engine {
  46455. /**
  46456. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46457. * @return the new query
  46458. */
  46459. createQuery(): WebGLQuery;
  46460. /**
  46461. * Delete and release a webGL query
  46462. * @param query defines the query to delete
  46463. * @return the current engine
  46464. */
  46465. deleteQuery(query: WebGLQuery): Engine;
  46466. /**
  46467. * Check if a given query has resolved and got its value
  46468. * @param query defines the query to check
  46469. * @returns true if the query got its value
  46470. */
  46471. isQueryResultAvailable(query: WebGLQuery): boolean;
  46472. /**
  46473. * Gets the value of a given query
  46474. * @param query defines the query to check
  46475. * @returns the value of the query
  46476. */
  46477. getQueryResult(query: WebGLQuery): number;
  46478. /**
  46479. * Initiates an occlusion query
  46480. * @param algorithmType defines the algorithm to use
  46481. * @param query defines the query to use
  46482. * @returns the current engine
  46483. * @see http://doc.babylonjs.com/features/occlusionquery
  46484. */
  46485. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46486. /**
  46487. * Ends an occlusion query
  46488. * @see http://doc.babylonjs.com/features/occlusionquery
  46489. * @param algorithmType defines the algorithm to use
  46490. * @returns the current engine
  46491. */
  46492. endOcclusionQuery(algorithmType: number): Engine;
  46493. /**
  46494. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46495. * Please note that only one query can be issued at a time
  46496. * @returns a time token used to track the time span
  46497. */
  46498. startTimeQuery(): Nullable<_TimeToken>;
  46499. /**
  46500. * Ends a time query
  46501. * @param token defines the token used to measure the time span
  46502. * @returns the time spent (in ns)
  46503. */
  46504. endTimeQuery(token: _TimeToken): int;
  46505. /** @hidden */
  46506. _currentNonTimestampToken: Nullable<_TimeToken>;
  46507. /** @hidden */
  46508. _createTimeQuery(): WebGLQuery;
  46509. /** @hidden */
  46510. _deleteTimeQuery(query: WebGLQuery): void;
  46511. /** @hidden */
  46512. _getGlAlgorithmType(algorithmType: number): number;
  46513. /** @hidden */
  46514. _getTimeQueryResult(query: WebGLQuery): any;
  46515. /** @hidden */
  46516. _getTimeQueryAvailability(query: WebGLQuery): any;
  46517. }
  46518. }
  46519. module "babylonjs/Meshes/abstractMesh" {
  46520. interface AbstractMesh {
  46521. /**
  46522. * Backing filed
  46523. * @hidden
  46524. */
  46525. __occlusionDataStorage: _OcclusionDataStorage;
  46526. /**
  46527. * Access property
  46528. * @hidden
  46529. */
  46530. _occlusionDataStorage: _OcclusionDataStorage;
  46531. /**
  46532. * 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.
  46533. * The default value is -1 which means don't break the query and wait till the result
  46534. * @see http://doc.babylonjs.com/features/occlusionquery
  46535. */
  46536. occlusionRetryCount: number;
  46537. /**
  46538. * 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:
  46539. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46540. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46541. * * 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.
  46542. * @see http://doc.babylonjs.com/features/occlusionquery
  46543. */
  46544. occlusionType: number;
  46545. /**
  46546. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46547. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46548. * * 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.
  46549. * @see http://doc.babylonjs.com/features/occlusionquery
  46550. */
  46551. occlusionQueryAlgorithmType: number;
  46552. /**
  46553. * 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
  46554. * @see http://doc.babylonjs.com/features/occlusionquery
  46555. */
  46556. isOccluded: boolean;
  46557. /**
  46558. * Flag to check the progress status of the query
  46559. * @see http://doc.babylonjs.com/features/occlusionquery
  46560. */
  46561. isOcclusionQueryInProgress: boolean;
  46562. }
  46563. }
  46564. }
  46565. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  46566. import { Nullable } from "babylonjs/types";
  46567. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46568. /** @hidden */
  46569. export var _forceTransformFeedbackToBundle: boolean;
  46570. module "babylonjs/Engines/engine" {
  46571. interface Engine {
  46572. /**
  46573. * Creates a webGL transform feedback object
  46574. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46575. * @returns the webGL transform feedback object
  46576. */
  46577. createTransformFeedback(): WebGLTransformFeedback;
  46578. /**
  46579. * Delete a webGL transform feedback object
  46580. * @param value defines the webGL transform feedback object to delete
  46581. */
  46582. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46583. /**
  46584. * Bind a webGL transform feedback object to the webgl context
  46585. * @param value defines the webGL transform feedback object to bind
  46586. */
  46587. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46588. /**
  46589. * Begins a transform feedback operation
  46590. * @param usePoints defines if points or triangles must be used
  46591. */
  46592. beginTransformFeedback(usePoints: boolean): void;
  46593. /**
  46594. * Ends a transform feedback operation
  46595. */
  46596. endTransformFeedback(): void;
  46597. /**
  46598. * Specify the varyings to use with transform feedback
  46599. * @param program defines the associated webGL program
  46600. * @param value defines the list of strings representing the varying names
  46601. */
  46602. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46603. /**
  46604. * Bind a webGL buffer for a transform feedback operation
  46605. * @param value defines the webGL buffer to bind
  46606. */
  46607. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46608. }
  46609. }
  46610. }
  46611. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  46612. import { Scene } from "babylonjs/scene";
  46613. import { Engine } from "babylonjs/Engines/engine";
  46614. import { Texture } from "babylonjs/Materials/Textures/texture";
  46615. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46616. import "babylonjs/Engines/Extensions/engine.multiRender";
  46617. /**
  46618. * Creation options of the multi render target texture.
  46619. */
  46620. export interface IMultiRenderTargetOptions {
  46621. /**
  46622. * Define if the texture needs to create mip maps after render.
  46623. */
  46624. generateMipMaps?: boolean;
  46625. /**
  46626. * Define the types of all the draw buffers we want to create
  46627. */
  46628. types?: number[];
  46629. /**
  46630. * Define the sampling modes of all the draw buffers we want to create
  46631. */
  46632. samplingModes?: number[];
  46633. /**
  46634. * Define if a depth buffer is required
  46635. */
  46636. generateDepthBuffer?: boolean;
  46637. /**
  46638. * Define if a stencil buffer is required
  46639. */
  46640. generateStencilBuffer?: boolean;
  46641. /**
  46642. * Define if a depth texture is required instead of a depth buffer
  46643. */
  46644. generateDepthTexture?: boolean;
  46645. /**
  46646. * Define the number of desired draw buffers
  46647. */
  46648. textureCount?: number;
  46649. /**
  46650. * Define if aspect ratio should be adapted to the texture or stay the scene one
  46651. */
  46652. doNotChangeAspectRatio?: boolean;
  46653. /**
  46654. * Define the default type of the buffers we are creating
  46655. */
  46656. defaultType?: number;
  46657. }
  46658. /**
  46659. * A multi render target, like a render target provides the ability to render to a texture.
  46660. * Unlike the render target, it can render to several draw buffers in one draw.
  46661. * This is specially interesting in deferred rendering or for any effects requiring more than
  46662. * just one color from a single pass.
  46663. */
  46664. export class MultiRenderTarget extends RenderTargetTexture {
  46665. private _internalTextures;
  46666. private _textures;
  46667. private _multiRenderTargetOptions;
  46668. /**
  46669. * Get if draw buffers are currently supported by the used hardware and browser.
  46670. */
  46671. readonly isSupported: boolean;
  46672. /**
  46673. * Get the list of textures generated by the multi render target.
  46674. */
  46675. readonly textures: Texture[];
  46676. /**
  46677. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46678. */
  46679. readonly depthTexture: Texture;
  46680. /**
  46681. * Set the wrapping mode on U of all the textures we are rendering to.
  46682. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46683. */
  46684. wrapU: number;
  46685. /**
  46686. * Set the wrapping mode on V of all the textures we are rendering to.
  46687. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46688. */
  46689. wrapV: number;
  46690. /**
  46691. * Instantiate a new multi render target texture.
  46692. * A multi render target, like a render target provides the ability to render to a texture.
  46693. * Unlike the render target, it can render to several draw buffers in one draw.
  46694. * This is specially interesting in deferred rendering or for any effects requiring more than
  46695. * just one color from a single pass.
  46696. * @param name Define the name of the texture
  46697. * @param size Define the size of the buffers to render to
  46698. * @param count Define the number of target we are rendering into
  46699. * @param scene Define the scene the texture belongs to
  46700. * @param options Define the options used to create the multi render target
  46701. */
  46702. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46703. /** @hidden */
  46704. _rebuild(): void;
  46705. private _createInternalTextures;
  46706. private _createTextures;
  46707. /**
  46708. * Define the number of samples used if MSAA is enabled.
  46709. */
  46710. samples: number;
  46711. /**
  46712. * Resize all the textures in the multi render target.
  46713. * Be carrefull as it will recreate all the data in the new texture.
  46714. * @param size Define the new size
  46715. */
  46716. resize(size: any): void;
  46717. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46718. /**
  46719. * Dispose the render targets and their associated resources
  46720. */
  46721. dispose(): void;
  46722. /**
  46723. * Release all the underlying texture used as draw buffers.
  46724. */
  46725. releaseInternalTextures(): void;
  46726. }
  46727. }
  46728. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46729. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46730. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46731. import { Nullable } from "babylonjs/types";
  46732. module "babylonjs/Engines/thinEngine" {
  46733. interface ThinEngine {
  46734. /**
  46735. * Unbind a list of render target textures from the webGL context
  46736. * This is used only when drawBuffer extension or webGL2 are active
  46737. * @param textures defines the render target textures to unbind
  46738. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46739. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46740. */
  46741. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46742. /**
  46743. * Create a multi render target texture
  46744. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46745. * @param size defines the size of the texture
  46746. * @param options defines the creation options
  46747. * @returns the cube texture as an InternalTexture
  46748. */
  46749. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46750. /**
  46751. * Update the sample count for a given multiple render target texture
  46752. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46753. * @param textures defines the textures to update
  46754. * @param samples defines the sample count to set
  46755. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46756. */
  46757. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46758. }
  46759. }
  46760. }
  46761. declare module "babylonjs/Engines/Extensions/engine.views" {
  46762. import { Camera } from "babylonjs/Cameras/camera";
  46763. import { Nullable } from "babylonjs/types";
  46764. /**
  46765. * Class used to define an additional view for the engine
  46766. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46767. */
  46768. export class EngineView {
  46769. /** Defines the canvas where to render the view */
  46770. target: HTMLCanvasElement;
  46771. /** Defines an optional camera used to render the view (will use active camera else) */
  46772. camera?: Camera;
  46773. }
  46774. module "babylonjs/Engines/engine" {
  46775. interface Engine {
  46776. /**
  46777. * Gets or sets the HTML element to use for attaching events
  46778. */
  46779. inputElement: Nullable<HTMLElement>;
  46780. /**
  46781. * Gets the current engine view
  46782. * @see https://doc.babylonjs.com/how_to/multi_canvases
  46783. */
  46784. activeView: Nullable<EngineView>;
  46785. /** Gets or sets the list of views */
  46786. views: EngineView[];
  46787. /**
  46788. * Register a new child canvas
  46789. * @param canvas defines the canvas to register
  46790. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  46791. * @returns the associated view
  46792. */
  46793. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  46794. /**
  46795. * Remove a registered child canvas
  46796. * @param canvas defines the canvas to remove
  46797. * @returns the current engine
  46798. */
  46799. unRegisterView(canvas: HTMLCanvasElement): Engine;
  46800. }
  46801. }
  46802. }
  46803. declare module "babylonjs/Engines/Extensions/index" {
  46804. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46805. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46806. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46807. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46808. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46809. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46810. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46811. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46812. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46813. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46814. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46815. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46816. export * from "babylonjs/Engines/Extensions/engine.views";
  46817. }
  46818. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46819. import { Nullable } from "babylonjs/types";
  46820. /**
  46821. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46822. */
  46823. export interface CubeMapInfo {
  46824. /**
  46825. * The pixel array for the front face.
  46826. * This is stored in format, left to right, up to down format.
  46827. */
  46828. front: Nullable<ArrayBufferView>;
  46829. /**
  46830. * The pixel array for the back face.
  46831. * This is stored in format, left to right, up to down format.
  46832. */
  46833. back: Nullable<ArrayBufferView>;
  46834. /**
  46835. * The pixel array for the left face.
  46836. * This is stored in format, left to right, up to down format.
  46837. */
  46838. left: Nullable<ArrayBufferView>;
  46839. /**
  46840. * The pixel array for the right face.
  46841. * This is stored in format, left to right, up to down format.
  46842. */
  46843. right: Nullable<ArrayBufferView>;
  46844. /**
  46845. * The pixel array for the up face.
  46846. * This is stored in format, left to right, up to down format.
  46847. */
  46848. up: Nullable<ArrayBufferView>;
  46849. /**
  46850. * The pixel array for the down face.
  46851. * This is stored in format, left to right, up to down format.
  46852. */
  46853. down: Nullable<ArrayBufferView>;
  46854. /**
  46855. * The size of the cubemap stored.
  46856. *
  46857. * Each faces will be size * size pixels.
  46858. */
  46859. size: number;
  46860. /**
  46861. * The format of the texture.
  46862. *
  46863. * RGBA, RGB.
  46864. */
  46865. format: number;
  46866. /**
  46867. * The type of the texture data.
  46868. *
  46869. * UNSIGNED_INT, FLOAT.
  46870. */
  46871. type: number;
  46872. /**
  46873. * Specifies whether the texture is in gamma space.
  46874. */
  46875. gammaSpace: boolean;
  46876. }
  46877. /**
  46878. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46879. */
  46880. export class PanoramaToCubeMapTools {
  46881. private static FACE_FRONT;
  46882. private static FACE_BACK;
  46883. private static FACE_RIGHT;
  46884. private static FACE_LEFT;
  46885. private static FACE_DOWN;
  46886. private static FACE_UP;
  46887. /**
  46888. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46889. *
  46890. * @param float32Array The source data.
  46891. * @param inputWidth The width of the input panorama.
  46892. * @param inputHeight The height of the input panorama.
  46893. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46894. * @return The cubemap data
  46895. */
  46896. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46897. private static CreateCubemapTexture;
  46898. private static CalcProjectionSpherical;
  46899. }
  46900. }
  46901. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46902. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46903. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46904. import { Nullable } from "babylonjs/types";
  46905. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46906. /**
  46907. * Helper class dealing with the extraction of spherical polynomial dataArray
  46908. * from a cube map.
  46909. */
  46910. export class CubeMapToSphericalPolynomialTools {
  46911. private static FileFaces;
  46912. /**
  46913. * Converts a texture to the according Spherical Polynomial data.
  46914. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46915. *
  46916. * @param texture The texture to extract the information from.
  46917. * @return The Spherical Polynomial data.
  46918. */
  46919. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46920. /**
  46921. * Converts a cubemap to the according Spherical Polynomial data.
  46922. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46923. *
  46924. * @param cubeInfo The Cube map to extract the information from.
  46925. * @return The Spherical Polynomial data.
  46926. */
  46927. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46928. }
  46929. }
  46930. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46931. import { Nullable } from "babylonjs/types";
  46932. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46933. module "babylonjs/Materials/Textures/baseTexture" {
  46934. interface BaseTexture {
  46935. /**
  46936. * Get the polynomial representation of the texture data.
  46937. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46938. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46939. */
  46940. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46941. }
  46942. }
  46943. }
  46944. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46945. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46946. /** @hidden */
  46947. export var rgbdEncodePixelShader: {
  46948. name: string;
  46949. shader: string;
  46950. };
  46951. }
  46952. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46953. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46954. /** @hidden */
  46955. export var rgbdDecodePixelShader: {
  46956. name: string;
  46957. shader: string;
  46958. };
  46959. }
  46960. declare module "babylonjs/Misc/environmentTextureTools" {
  46961. import { Nullable } from "babylonjs/types";
  46962. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46963. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46964. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46965. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46966. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46967. import "babylonjs/Shaders/rgbdEncode.fragment";
  46968. import "babylonjs/Shaders/rgbdDecode.fragment";
  46969. /**
  46970. * Raw texture data and descriptor sufficient for WebGL texture upload
  46971. */
  46972. export interface EnvironmentTextureInfo {
  46973. /**
  46974. * Version of the environment map
  46975. */
  46976. version: number;
  46977. /**
  46978. * Width of image
  46979. */
  46980. width: number;
  46981. /**
  46982. * Irradiance information stored in the file.
  46983. */
  46984. irradiance: any;
  46985. /**
  46986. * Specular information stored in the file.
  46987. */
  46988. specular: any;
  46989. }
  46990. /**
  46991. * Defines One Image in the file. It requires only the position in the file
  46992. * as well as the length.
  46993. */
  46994. interface BufferImageData {
  46995. /**
  46996. * Length of the image data.
  46997. */
  46998. length: number;
  46999. /**
  47000. * Position of the data from the null terminator delimiting the end of the JSON.
  47001. */
  47002. position: number;
  47003. }
  47004. /**
  47005. * Defines the specular data enclosed in the file.
  47006. * This corresponds to the version 1 of the data.
  47007. */
  47008. export interface EnvironmentTextureSpecularInfoV1 {
  47009. /**
  47010. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47011. */
  47012. specularDataPosition?: number;
  47013. /**
  47014. * This contains all the images data needed to reconstruct the cubemap.
  47015. */
  47016. mipmaps: Array<BufferImageData>;
  47017. /**
  47018. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47019. */
  47020. lodGenerationScale: number;
  47021. }
  47022. /**
  47023. * Sets of helpers addressing the serialization and deserialization of environment texture
  47024. * stored in a BabylonJS env file.
  47025. * Those files are usually stored as .env files.
  47026. */
  47027. export class EnvironmentTextureTools {
  47028. /**
  47029. * Magic number identifying the env file.
  47030. */
  47031. private static _MagicBytes;
  47032. /**
  47033. * Gets the environment info from an env file.
  47034. * @param data The array buffer containing the .env bytes.
  47035. * @returns the environment file info (the json header) if successfully parsed.
  47036. */
  47037. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47038. /**
  47039. * Creates an environment texture from a loaded cube texture.
  47040. * @param texture defines the cube texture to convert in env file
  47041. * @return a promise containing the environment data if succesfull.
  47042. */
  47043. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47044. /**
  47045. * Creates a JSON representation of the spherical data.
  47046. * @param texture defines the texture containing the polynomials
  47047. * @return the JSON representation of the spherical info
  47048. */
  47049. private static _CreateEnvTextureIrradiance;
  47050. /**
  47051. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47052. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47053. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47054. * @return the views described by info providing access to the underlying buffer
  47055. */
  47056. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47057. /**
  47058. * Uploads the texture info contained in the env file to the GPU.
  47059. * @param texture defines the internal texture to upload to
  47060. * @param arrayBuffer defines the buffer cotaining the data to load
  47061. * @param info defines the texture info retrieved through the GetEnvInfo method
  47062. * @returns a promise
  47063. */
  47064. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47065. private static _OnImageReadyAsync;
  47066. /**
  47067. * Uploads the levels of image data to the GPU.
  47068. * @param texture defines the internal texture to upload to
  47069. * @param imageData defines the array buffer views of image data [mipmap][face]
  47070. * @returns a promise
  47071. */
  47072. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47073. /**
  47074. * Uploads spherical polynomials information to the texture.
  47075. * @param texture defines the texture we are trying to upload the information to
  47076. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47077. */
  47078. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47079. /** @hidden */
  47080. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47081. }
  47082. }
  47083. declare module "babylonjs/Maths/math.vertexFormat" {
  47084. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47085. /**
  47086. * Contains position and normal vectors for a vertex
  47087. */
  47088. export class PositionNormalVertex {
  47089. /** the position of the vertex (defaut: 0,0,0) */
  47090. position: Vector3;
  47091. /** the normal of the vertex (defaut: 0,1,0) */
  47092. normal: Vector3;
  47093. /**
  47094. * Creates a PositionNormalVertex
  47095. * @param position the position of the vertex (defaut: 0,0,0)
  47096. * @param normal the normal of the vertex (defaut: 0,1,0)
  47097. */
  47098. constructor(
  47099. /** the position of the vertex (defaut: 0,0,0) */
  47100. position?: Vector3,
  47101. /** the normal of the vertex (defaut: 0,1,0) */
  47102. normal?: Vector3);
  47103. /**
  47104. * Clones the PositionNormalVertex
  47105. * @returns the cloned PositionNormalVertex
  47106. */
  47107. clone(): PositionNormalVertex;
  47108. }
  47109. /**
  47110. * Contains position, normal and uv vectors for a vertex
  47111. */
  47112. export class PositionNormalTextureVertex {
  47113. /** the position of the vertex (defaut: 0,0,0) */
  47114. position: Vector3;
  47115. /** the normal of the vertex (defaut: 0,1,0) */
  47116. normal: Vector3;
  47117. /** the uv of the vertex (default: 0,0) */
  47118. uv: Vector2;
  47119. /**
  47120. * Creates a PositionNormalTextureVertex
  47121. * @param position the position of the vertex (defaut: 0,0,0)
  47122. * @param normal the normal of the vertex (defaut: 0,1,0)
  47123. * @param uv the uv of the vertex (default: 0,0)
  47124. */
  47125. constructor(
  47126. /** the position of the vertex (defaut: 0,0,0) */
  47127. position?: Vector3,
  47128. /** the normal of the vertex (defaut: 0,1,0) */
  47129. normal?: Vector3,
  47130. /** the uv of the vertex (default: 0,0) */
  47131. uv?: Vector2);
  47132. /**
  47133. * Clones the PositionNormalTextureVertex
  47134. * @returns the cloned PositionNormalTextureVertex
  47135. */
  47136. clone(): PositionNormalTextureVertex;
  47137. }
  47138. }
  47139. declare module "babylonjs/Maths/math" {
  47140. export * from "babylonjs/Maths/math.axis";
  47141. export * from "babylonjs/Maths/math.color";
  47142. export * from "babylonjs/Maths/math.constants";
  47143. export * from "babylonjs/Maths/math.frustum";
  47144. export * from "babylonjs/Maths/math.path";
  47145. export * from "babylonjs/Maths/math.plane";
  47146. export * from "babylonjs/Maths/math.size";
  47147. export * from "babylonjs/Maths/math.vector";
  47148. export * from "babylonjs/Maths/math.vertexFormat";
  47149. export * from "babylonjs/Maths/math.viewport";
  47150. }
  47151. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  47152. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47153. /** @hidden */
  47154. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47155. private _genericAttributeLocation;
  47156. private _varyingLocationCount;
  47157. private _varyingLocationMap;
  47158. private _replacements;
  47159. private _textureCount;
  47160. private _uniforms;
  47161. lineProcessor(line: string): string;
  47162. attributeProcessor(attribute: string): string;
  47163. varyingProcessor(varying: string, isFragment: boolean): string;
  47164. uniformProcessor(uniform: string): string;
  47165. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47166. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47167. }
  47168. }
  47169. declare module "babylonjs/Engines/nativeEngine" {
  47170. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  47171. import { Engine } from "babylonjs/Engines/engine";
  47172. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47173. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47174. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47175. import { Effect } from "babylonjs/Materials/effect";
  47176. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47177. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  47178. import { IColor4Like } from "babylonjs/Maths/math.like";
  47179. import { Scene } from "babylonjs/scene";
  47180. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47181. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47182. /**
  47183. * Container for accessors for natively-stored mesh data buffers.
  47184. */
  47185. class NativeDataBuffer extends DataBuffer {
  47186. /**
  47187. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47188. */
  47189. nativeIndexBuffer?: any;
  47190. /**
  47191. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47192. */
  47193. nativeVertexBuffer?: any;
  47194. }
  47195. /** @hidden */
  47196. class NativeTexture extends InternalTexture {
  47197. getInternalTexture(): InternalTexture;
  47198. getViewCount(): number;
  47199. }
  47200. /** @hidden */
  47201. export class NativeEngine extends Engine {
  47202. private readonly _native;
  47203. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47204. private readonly INVALID_HANDLE;
  47205. getHardwareScalingLevel(): number;
  47206. constructor();
  47207. /**
  47208. * Can be used to override the current requestAnimationFrame requester.
  47209. * @hidden
  47210. */
  47211. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47212. /**
  47213. * Override default engine behavior.
  47214. * @param color
  47215. * @param backBuffer
  47216. * @param depth
  47217. * @param stencil
  47218. */
  47219. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47220. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47221. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47222. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47223. recordVertexArrayObject(vertexBuffers: {
  47224. [key: string]: VertexBuffer;
  47225. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47226. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47227. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47228. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47229. /**
  47230. * Draw a list of indexed primitives
  47231. * @param fillMode defines the primitive to use
  47232. * @param indexStart defines the starting index
  47233. * @param indexCount defines the number of index to draw
  47234. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47235. */
  47236. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47237. /**
  47238. * Draw a list of unindexed primitives
  47239. * @param fillMode defines the primitive to use
  47240. * @param verticesStart defines the index of first vertex to draw
  47241. * @param verticesCount defines the count of vertices to draw
  47242. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47243. */
  47244. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47245. createPipelineContext(): IPipelineContext;
  47246. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47247. /** @hidden */
  47248. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47249. /** @hidden */
  47250. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47251. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47252. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47253. protected _setProgram(program: WebGLProgram): void;
  47254. _releaseEffect(effect: Effect): void;
  47255. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47256. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47257. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47258. bindSamplers(effect: Effect): void;
  47259. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47260. getRenderWidth(useScreen?: boolean): number;
  47261. getRenderHeight(useScreen?: boolean): number;
  47262. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47263. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47264. /**
  47265. * Set the z offset to apply to current rendering
  47266. * @param value defines the offset to apply
  47267. */
  47268. setZOffset(value: number): void;
  47269. /**
  47270. * Gets the current value of the zOffset
  47271. * @returns the current zOffset state
  47272. */
  47273. getZOffset(): number;
  47274. /**
  47275. * Enable or disable depth buffering
  47276. * @param enable defines the state to set
  47277. */
  47278. setDepthBuffer(enable: boolean): void;
  47279. /**
  47280. * Gets a boolean indicating if depth writing is enabled
  47281. * @returns the current depth writing state
  47282. */
  47283. getDepthWrite(): boolean;
  47284. /**
  47285. * Enable or disable depth writing
  47286. * @param enable defines the state to set
  47287. */
  47288. setDepthWrite(enable: boolean): void;
  47289. /**
  47290. * Enable or disable color writing
  47291. * @param enable defines the state to set
  47292. */
  47293. setColorWrite(enable: boolean): void;
  47294. /**
  47295. * Gets a boolean indicating if color writing is enabled
  47296. * @returns the current color writing state
  47297. */
  47298. getColorWrite(): boolean;
  47299. /**
  47300. * Sets alpha constants used by some alpha blending modes
  47301. * @param r defines the red component
  47302. * @param g defines the green component
  47303. * @param b defines the blue component
  47304. * @param a defines the alpha component
  47305. */
  47306. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47307. /**
  47308. * Sets the current alpha mode
  47309. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47310. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47311. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47312. */
  47313. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47314. /**
  47315. * Gets the current alpha mode
  47316. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47317. * @returns the current alpha mode
  47318. */
  47319. getAlphaMode(): number;
  47320. setInt(uniform: WebGLUniformLocation, int: number): void;
  47321. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47322. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47323. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47324. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47325. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47326. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47327. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47328. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47329. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47330. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47331. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47332. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47333. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47334. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47335. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47336. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47337. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47338. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47339. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47340. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47341. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47342. wipeCaches(bruteForce?: boolean): void;
  47343. _createTexture(): WebGLTexture;
  47344. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47345. /**
  47346. * Usually called from BABYLON.Texture.ts.
  47347. * Passed information to create a WebGLTexture
  47348. * @param urlArg defines a value which contains one of the following:
  47349. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47350. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47351. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47352. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47353. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47354. * @param scene needed for loading to the correct scene
  47355. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47356. * @param onLoad optional callback to be called upon successful completion
  47357. * @param onError optional callback to be called upon failure
  47358. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47359. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47360. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47361. * @param forcedExtension defines the extension to use to pick the right loader
  47362. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47363. */
  47364. 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;
  47365. /**
  47366. * Creates a cube texture
  47367. * @param rootUrl defines the url where the files to load is located
  47368. * @param scene defines the current scene
  47369. * @param files defines the list of files to load (1 per face)
  47370. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47371. * @param onLoad defines an optional callback raised when the texture is loaded
  47372. * @param onError defines an optional callback raised if there is an issue to load the texture
  47373. * @param format defines the format of the data
  47374. * @param forcedExtension defines the extension to use to pick the right loader
  47375. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47376. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47377. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47378. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47379. * @returns the cube texture as an InternalTexture
  47380. */
  47381. 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;
  47382. private _getSamplingFilter;
  47383. private static _GetNativeTextureFormat;
  47384. createRenderTargetTexture(size: number | {
  47385. width: number;
  47386. height: number;
  47387. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47388. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47389. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47390. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47391. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47392. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47393. /**
  47394. * Updates a dynamic vertex buffer.
  47395. * @param vertexBuffer the vertex buffer to update
  47396. * @param data the data used to update the vertex buffer
  47397. * @param byteOffset the byte offset of the data (optional)
  47398. * @param byteLength the byte length of the data (optional)
  47399. */
  47400. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47401. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47402. private _updateAnisotropicLevel;
  47403. private _getAddressMode;
  47404. /** @hidden */
  47405. _bindTexture(channel: number, texture: InternalTexture): void;
  47406. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47407. releaseEffects(): void;
  47408. /** @hidden */
  47409. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47410. /** @hidden */
  47411. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47412. /** @hidden */
  47413. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47414. /** @hidden */
  47415. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47416. }
  47417. }
  47418. declare module "babylonjs/Engines/index" {
  47419. export * from "babylonjs/Engines/constants";
  47420. export * from "babylonjs/Engines/engineCapabilities";
  47421. export * from "babylonjs/Engines/instancingAttributeInfo";
  47422. export * from "babylonjs/Engines/thinEngine";
  47423. export * from "babylonjs/Engines/engine";
  47424. export * from "babylonjs/Engines/engineStore";
  47425. export * from "babylonjs/Engines/nullEngine";
  47426. export * from "babylonjs/Engines/Extensions/index";
  47427. export * from "babylonjs/Engines/IPipelineContext";
  47428. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  47429. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  47430. export * from "babylonjs/Engines/nativeEngine";
  47431. }
  47432. declare module "babylonjs/Events/clipboardEvents" {
  47433. /**
  47434. * Gather the list of clipboard event types as constants.
  47435. */
  47436. export class ClipboardEventTypes {
  47437. /**
  47438. * The clipboard event is fired when a copy command is active (pressed).
  47439. */
  47440. static readonly COPY: number;
  47441. /**
  47442. * The clipboard event is fired when a cut command is active (pressed).
  47443. */
  47444. static readonly CUT: number;
  47445. /**
  47446. * The clipboard event is fired when a paste command is active (pressed).
  47447. */
  47448. static readonly PASTE: number;
  47449. }
  47450. /**
  47451. * This class is used to store clipboard related info for the onClipboardObservable event.
  47452. */
  47453. export class ClipboardInfo {
  47454. /**
  47455. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47456. */
  47457. type: number;
  47458. /**
  47459. * Defines the related dom event
  47460. */
  47461. event: ClipboardEvent;
  47462. /**
  47463. *Creates an instance of ClipboardInfo.
  47464. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47465. * @param event Defines the related dom event
  47466. */
  47467. constructor(
  47468. /**
  47469. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47470. */
  47471. type: number,
  47472. /**
  47473. * Defines the related dom event
  47474. */
  47475. event: ClipboardEvent);
  47476. /**
  47477. * Get the clipboard event's type from the keycode.
  47478. * @param keyCode Defines the keyCode for the current keyboard event.
  47479. * @return {number}
  47480. */
  47481. static GetTypeFromCharacter(keyCode: number): number;
  47482. }
  47483. }
  47484. declare module "babylonjs/Events/index" {
  47485. export * from "babylonjs/Events/keyboardEvents";
  47486. export * from "babylonjs/Events/pointerEvents";
  47487. export * from "babylonjs/Events/clipboardEvents";
  47488. }
  47489. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  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. * Google Daydream controller
  47497. */
  47498. export class DaydreamController 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 Daydream Controller.
  47509. */
  47510. static readonly GAMEPAD_ID_PREFIX: string;
  47511. /**
  47512. * Creates a new DaydreamController from a gamepad
  47513. * @param vrGamepad the gamepad that the controller should be created from
  47514. */
  47515. constructor(vrGamepad: any);
  47516. /**
  47517. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47518. * @param scene scene in which to add meshes
  47519. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47520. */
  47521. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47522. /**
  47523. * Called once for each button that changed state since the last frame
  47524. * @param buttonIdx Which button index changed
  47525. * @param state New state of the button
  47526. * @param changes Which properties on the state changed since last frame
  47527. */
  47528. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47529. }
  47530. }
  47531. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  47532. import { Scene } from "babylonjs/scene";
  47533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47534. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  47535. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47536. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47537. /**
  47538. * Gear VR Controller
  47539. */
  47540. export class GearVRController extends WebVRController {
  47541. /**
  47542. * Base Url for the controller model.
  47543. */
  47544. static MODEL_BASE_URL: string;
  47545. /**
  47546. * File name for the controller model.
  47547. */
  47548. static MODEL_FILENAME: string;
  47549. /**
  47550. * Gamepad Id prefix used to identify this controller.
  47551. */
  47552. static readonly GAMEPAD_ID_PREFIX: string;
  47553. private readonly _buttonIndexToObservableNameMap;
  47554. /**
  47555. * Creates a new GearVRController from a gamepad
  47556. * @param vrGamepad the gamepad that the controller should be created from
  47557. */
  47558. constructor(vrGamepad: any);
  47559. /**
  47560. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47561. * @param scene scene in which to add meshes
  47562. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47563. */
  47564. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47565. /**
  47566. * Called once for each button that changed state since the last frame
  47567. * @param buttonIdx Which button index changed
  47568. * @param state New state of the button
  47569. * @param changes Which properties on the state changed since last frame
  47570. */
  47571. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47572. }
  47573. }
  47574. declare module "babylonjs/Gamepads/Controllers/index" {
  47575. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  47576. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  47577. export * from "babylonjs/Gamepads/Controllers/genericController";
  47578. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  47579. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  47580. export * from "babylonjs/Gamepads/Controllers/viveController";
  47581. export * from "babylonjs/Gamepads/Controllers/webVRController";
  47582. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  47583. }
  47584. declare module "babylonjs/Gamepads/index" {
  47585. export * from "babylonjs/Gamepads/Controllers/index";
  47586. export * from "babylonjs/Gamepads/gamepad";
  47587. export * from "babylonjs/Gamepads/gamepadManager";
  47588. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  47589. export * from "babylonjs/Gamepads/xboxGamepad";
  47590. export * from "babylonjs/Gamepads/dualShockGamepad";
  47591. }
  47592. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  47593. import { Scene } from "babylonjs/scene";
  47594. import { Vector4 } from "babylonjs/Maths/math.vector";
  47595. import { Color4 } from "babylonjs/Maths/math.color";
  47596. import { Mesh } from "babylonjs/Meshes/mesh";
  47597. import { Nullable } from "babylonjs/types";
  47598. /**
  47599. * Class containing static functions to help procedurally build meshes
  47600. */
  47601. export class PolyhedronBuilder {
  47602. /**
  47603. * Creates a polyhedron mesh
  47604. * * 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
  47605. * * The parameter `size` (positive float, default 1) sets the polygon size
  47606. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47607. * * 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`
  47608. * * 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
  47609. * * 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)`)
  47610. * * 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
  47611. * * 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
  47612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47615. * @param name defines the name of the mesh
  47616. * @param options defines the options used to create the mesh
  47617. * @param scene defines the hosting scene
  47618. * @returns the polyhedron mesh
  47619. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47620. */
  47621. static CreatePolyhedron(name: string, options: {
  47622. type?: number;
  47623. size?: number;
  47624. sizeX?: number;
  47625. sizeY?: number;
  47626. sizeZ?: number;
  47627. custom?: any;
  47628. faceUV?: Vector4[];
  47629. faceColors?: Color4[];
  47630. flat?: boolean;
  47631. updatable?: boolean;
  47632. sideOrientation?: number;
  47633. frontUVs?: Vector4;
  47634. backUVs?: Vector4;
  47635. }, scene?: Nullable<Scene>): Mesh;
  47636. }
  47637. }
  47638. declare module "babylonjs/Gizmos/scaleGizmo" {
  47639. import { Observable } from "babylonjs/Misc/observable";
  47640. import { Nullable } from "babylonjs/types";
  47641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47642. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47643. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  47644. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47645. /**
  47646. * Gizmo that enables scaling a mesh along 3 axis
  47647. */
  47648. export class ScaleGizmo extends Gizmo {
  47649. /**
  47650. * Internal gizmo used for interactions on the x axis
  47651. */
  47652. xGizmo: AxisScaleGizmo;
  47653. /**
  47654. * Internal gizmo used for interactions on the y axis
  47655. */
  47656. yGizmo: AxisScaleGizmo;
  47657. /**
  47658. * Internal gizmo used for interactions on the z axis
  47659. */
  47660. zGizmo: AxisScaleGizmo;
  47661. /**
  47662. * Internal gizmo used to scale all axis equally
  47663. */
  47664. uniformScaleGizmo: AxisScaleGizmo;
  47665. private _meshAttached;
  47666. private _updateGizmoRotationToMatchAttachedMesh;
  47667. private _snapDistance;
  47668. private _scaleRatio;
  47669. private _uniformScalingMesh;
  47670. private _octahedron;
  47671. private _sensitivity;
  47672. /** Fires an event when any of it's sub gizmos are dragged */
  47673. onDragStartObservable: Observable<unknown>;
  47674. /** Fires an event when any of it's sub gizmos are released from dragging */
  47675. onDragEndObservable: Observable<unknown>;
  47676. attachedMesh: Nullable<AbstractMesh>;
  47677. /**
  47678. * Creates a ScaleGizmo
  47679. * @param gizmoLayer The utility layer the gizmo will be added to
  47680. */
  47681. constructor(gizmoLayer?: UtilityLayerRenderer);
  47682. updateGizmoRotationToMatchAttachedMesh: boolean;
  47683. /**
  47684. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47685. */
  47686. snapDistance: number;
  47687. /**
  47688. * Ratio for the scale of the gizmo (Default: 1)
  47689. */
  47690. scaleRatio: number;
  47691. /**
  47692. * Sensitivity factor for dragging (Default: 1)
  47693. */
  47694. sensitivity: number;
  47695. /**
  47696. * Disposes of the gizmo
  47697. */
  47698. dispose(): void;
  47699. }
  47700. }
  47701. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  47702. import { Observable } from "babylonjs/Misc/observable";
  47703. import { Nullable } from "babylonjs/types";
  47704. import { Vector3 } from "babylonjs/Maths/math.vector";
  47705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47706. import { Mesh } from "babylonjs/Meshes/mesh";
  47707. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47708. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47709. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47710. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47711. import { Color3 } from "babylonjs/Maths/math.color";
  47712. /**
  47713. * Single axis scale gizmo
  47714. */
  47715. export class AxisScaleGizmo extends Gizmo {
  47716. /**
  47717. * Drag behavior responsible for the gizmos dragging interactions
  47718. */
  47719. dragBehavior: PointerDragBehavior;
  47720. private _pointerObserver;
  47721. /**
  47722. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47723. */
  47724. snapDistance: number;
  47725. /**
  47726. * Event that fires each time the gizmo snaps to a new location.
  47727. * * snapDistance is the the change in distance
  47728. */
  47729. onSnapObservable: Observable<{
  47730. snapDistance: number;
  47731. }>;
  47732. /**
  47733. * If the scaling operation should be done on all axis (default: false)
  47734. */
  47735. uniformScaling: boolean;
  47736. /**
  47737. * Custom sensitivity value for the drag strength
  47738. */
  47739. sensitivity: number;
  47740. private _isEnabled;
  47741. private _parent;
  47742. private _arrow;
  47743. private _coloredMaterial;
  47744. private _hoverMaterial;
  47745. /**
  47746. * Creates an AxisScaleGizmo
  47747. * @param gizmoLayer The utility layer the gizmo will be added to
  47748. * @param dragAxis The axis which the gizmo will be able to scale on
  47749. * @param color The color of the gizmo
  47750. */
  47751. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  47752. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47753. /**
  47754. * If the gizmo is enabled
  47755. */
  47756. isEnabled: boolean;
  47757. /**
  47758. * Disposes of the gizmo
  47759. */
  47760. dispose(): void;
  47761. /**
  47762. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47763. * @param mesh The mesh to replace the default mesh of the gizmo
  47764. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  47765. */
  47766. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  47767. }
  47768. }
  47769. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  47770. import { Observable } from "babylonjs/Misc/observable";
  47771. import { Nullable } from "babylonjs/types";
  47772. import { Vector3 } from "babylonjs/Maths/math.vector";
  47773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47774. import { Mesh } from "babylonjs/Meshes/mesh";
  47775. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47776. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47777. import { Color3 } from "babylonjs/Maths/math.color";
  47778. import "babylonjs/Meshes/Builders/boxBuilder";
  47779. /**
  47780. * Bounding box gizmo
  47781. */
  47782. export class BoundingBoxGizmo extends Gizmo {
  47783. private _lineBoundingBox;
  47784. private _rotateSpheresParent;
  47785. private _scaleBoxesParent;
  47786. private _boundingDimensions;
  47787. private _renderObserver;
  47788. private _pointerObserver;
  47789. private _scaleDragSpeed;
  47790. private _tmpQuaternion;
  47791. private _tmpVector;
  47792. private _tmpRotationMatrix;
  47793. /**
  47794. * 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)
  47795. */
  47796. ignoreChildren: boolean;
  47797. /**
  47798. * 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)
  47799. */
  47800. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  47801. /**
  47802. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  47803. */
  47804. rotationSphereSize: number;
  47805. /**
  47806. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  47807. */
  47808. scaleBoxSize: number;
  47809. /**
  47810. * 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)
  47811. */
  47812. fixedDragMeshScreenSize: boolean;
  47813. /**
  47814. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47815. */
  47816. fixedDragMeshScreenSizeDistanceFactor: number;
  47817. /**
  47818. * Fired when a rotation sphere or scale box is dragged
  47819. */
  47820. onDragStartObservable: Observable<{}>;
  47821. /**
  47822. * Fired when a scale box is dragged
  47823. */
  47824. onScaleBoxDragObservable: Observable<{}>;
  47825. /**
  47826. * Fired when a scale box drag is ended
  47827. */
  47828. onScaleBoxDragEndObservable: Observable<{}>;
  47829. /**
  47830. * Fired when a rotation sphere is dragged
  47831. */
  47832. onRotationSphereDragObservable: Observable<{}>;
  47833. /**
  47834. * Fired when a rotation sphere drag is ended
  47835. */
  47836. onRotationSphereDragEndObservable: Observable<{}>;
  47837. /**
  47838. * 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)
  47839. */
  47840. scalePivot: Nullable<Vector3>;
  47841. /**
  47842. * Mesh used as a pivot to rotate the attached mesh
  47843. */
  47844. private _anchorMesh;
  47845. private _existingMeshScale;
  47846. private _dragMesh;
  47847. private pointerDragBehavior;
  47848. private coloredMaterial;
  47849. private hoverColoredMaterial;
  47850. /**
  47851. * Sets the color of the bounding box gizmo
  47852. * @param color the color to set
  47853. */
  47854. setColor(color: Color3): void;
  47855. /**
  47856. * Creates an BoundingBoxGizmo
  47857. * @param gizmoLayer The utility layer the gizmo will be added to
  47858. * @param color The color of the gizmo
  47859. */
  47860. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47861. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47862. private _selectNode;
  47863. /**
  47864. * Updates the bounding box information for the Gizmo
  47865. */
  47866. updateBoundingBox(): void;
  47867. private _updateRotationSpheres;
  47868. private _updateScaleBoxes;
  47869. /**
  47870. * Enables rotation on the specified axis and disables rotation on the others
  47871. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47872. */
  47873. setEnabledRotationAxis(axis: string): void;
  47874. /**
  47875. * Enables/disables scaling
  47876. * @param enable if scaling should be enabled
  47877. */
  47878. setEnabledScaling(enable: boolean): void;
  47879. private _updateDummy;
  47880. /**
  47881. * Enables a pointer drag behavior on the bounding box of the gizmo
  47882. */
  47883. enableDragBehavior(): void;
  47884. /**
  47885. * Disposes of the gizmo
  47886. */
  47887. dispose(): void;
  47888. /**
  47889. * 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)
  47890. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47891. * @returns the bounding box mesh with the passed in mesh as a child
  47892. */
  47893. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47894. /**
  47895. * CustomMeshes are not supported by this gizmo
  47896. * @param mesh The mesh to replace the default mesh of the gizmo
  47897. */
  47898. setCustomMesh(mesh: Mesh): void;
  47899. }
  47900. }
  47901. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47902. import { Observable } from "babylonjs/Misc/observable";
  47903. import { Nullable } from "babylonjs/types";
  47904. import { Vector3 } from "babylonjs/Maths/math.vector";
  47905. import { Color3 } from "babylonjs/Maths/math.color";
  47906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47907. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47908. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47909. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47910. import "babylonjs/Meshes/Builders/linesBuilder";
  47911. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47912. /**
  47913. * Single plane rotation gizmo
  47914. */
  47915. export class PlaneRotationGizmo extends Gizmo {
  47916. /**
  47917. * Drag behavior responsible for the gizmos dragging interactions
  47918. */
  47919. dragBehavior: PointerDragBehavior;
  47920. private _pointerObserver;
  47921. /**
  47922. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47923. */
  47924. snapDistance: number;
  47925. /**
  47926. * Event that fires each time the gizmo snaps to a new location.
  47927. * * snapDistance is the the change in distance
  47928. */
  47929. onSnapObservable: Observable<{
  47930. snapDistance: number;
  47931. }>;
  47932. private _isEnabled;
  47933. private _parent;
  47934. /**
  47935. * Creates a PlaneRotationGizmo
  47936. * @param gizmoLayer The utility layer the gizmo will be added to
  47937. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47938. * @param color The color of the gizmo
  47939. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47940. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47941. */
  47942. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47943. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47944. /**
  47945. * If the gizmo is enabled
  47946. */
  47947. isEnabled: boolean;
  47948. /**
  47949. * Disposes of the gizmo
  47950. */
  47951. dispose(): void;
  47952. }
  47953. }
  47954. declare module "babylonjs/Gizmos/rotationGizmo" {
  47955. import { Observable } from "babylonjs/Misc/observable";
  47956. import { Nullable } from "babylonjs/types";
  47957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47958. import { Mesh } from "babylonjs/Meshes/mesh";
  47959. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47960. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47961. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47962. /**
  47963. * Gizmo that enables rotating a mesh along 3 axis
  47964. */
  47965. export class RotationGizmo extends Gizmo {
  47966. /**
  47967. * Internal gizmo used for interactions on the x axis
  47968. */
  47969. xGizmo: PlaneRotationGizmo;
  47970. /**
  47971. * Internal gizmo used for interactions on the y axis
  47972. */
  47973. yGizmo: PlaneRotationGizmo;
  47974. /**
  47975. * Internal gizmo used for interactions on the z axis
  47976. */
  47977. zGizmo: PlaneRotationGizmo;
  47978. /** Fires an event when any of it's sub gizmos are dragged */
  47979. onDragStartObservable: Observable<unknown>;
  47980. /** Fires an event when any of it's sub gizmos are released from dragging */
  47981. onDragEndObservable: Observable<unknown>;
  47982. private _meshAttached;
  47983. attachedMesh: Nullable<AbstractMesh>;
  47984. /**
  47985. * Creates a RotationGizmo
  47986. * @param gizmoLayer The utility layer the gizmo will be added to
  47987. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47988. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47989. */
  47990. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47991. updateGizmoRotationToMatchAttachedMesh: boolean;
  47992. /**
  47993. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47994. */
  47995. snapDistance: number;
  47996. /**
  47997. * Ratio for the scale of the gizmo (Default: 1)
  47998. */
  47999. scaleRatio: number;
  48000. /**
  48001. * Disposes of the gizmo
  48002. */
  48003. dispose(): void;
  48004. /**
  48005. * CustomMeshes are not supported by this gizmo
  48006. * @param mesh The mesh to replace the default mesh of the gizmo
  48007. */
  48008. setCustomMesh(mesh: Mesh): void;
  48009. }
  48010. }
  48011. declare module "babylonjs/Gizmos/gizmoManager" {
  48012. import { Observable } from "babylonjs/Misc/observable";
  48013. import { Nullable } from "babylonjs/types";
  48014. import { Scene, IDisposable } from "babylonjs/scene";
  48015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48016. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48017. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48018. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  48019. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48020. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  48021. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  48022. /**
  48023. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48024. */
  48025. export class GizmoManager implements IDisposable {
  48026. private scene;
  48027. /**
  48028. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48029. */
  48030. gizmos: {
  48031. positionGizmo: Nullable<PositionGizmo>;
  48032. rotationGizmo: Nullable<RotationGizmo>;
  48033. scaleGizmo: Nullable<ScaleGizmo>;
  48034. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48035. };
  48036. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48037. clearGizmoOnEmptyPointerEvent: boolean;
  48038. /** Fires an event when the manager is attached to a mesh */
  48039. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48040. private _gizmosEnabled;
  48041. private _pointerObserver;
  48042. private _attachedMesh;
  48043. private _boundingBoxColor;
  48044. private _defaultUtilityLayer;
  48045. private _defaultKeepDepthUtilityLayer;
  48046. /**
  48047. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48048. */
  48049. boundingBoxDragBehavior: SixDofDragBehavior;
  48050. /**
  48051. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48052. */
  48053. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48054. /**
  48055. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48056. */
  48057. usePointerToAttachGizmos: boolean;
  48058. /**
  48059. * Utility layer that the bounding box gizmo belongs to
  48060. */
  48061. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  48062. /**
  48063. * Utility layer that all gizmos besides bounding box belong to
  48064. */
  48065. readonly utilityLayer: UtilityLayerRenderer;
  48066. /**
  48067. * Instatiates a gizmo manager
  48068. * @param scene the scene to overlay the gizmos on top of
  48069. */
  48070. constructor(scene: Scene);
  48071. /**
  48072. * Attaches a set of gizmos to the specified mesh
  48073. * @param mesh The mesh the gizmo's should be attached to
  48074. */
  48075. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48076. /**
  48077. * If the position gizmo is enabled
  48078. */
  48079. positionGizmoEnabled: boolean;
  48080. /**
  48081. * If the rotation gizmo is enabled
  48082. */
  48083. rotationGizmoEnabled: boolean;
  48084. /**
  48085. * If the scale gizmo is enabled
  48086. */
  48087. scaleGizmoEnabled: boolean;
  48088. /**
  48089. * If the boundingBox gizmo is enabled
  48090. */
  48091. boundingBoxGizmoEnabled: boolean;
  48092. /**
  48093. * Disposes of the gizmo manager
  48094. */
  48095. dispose(): void;
  48096. }
  48097. }
  48098. declare module "babylonjs/Lights/directionalLight" {
  48099. import { Camera } from "babylonjs/Cameras/camera";
  48100. import { Scene } from "babylonjs/scene";
  48101. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48103. import { Light } from "babylonjs/Lights/light";
  48104. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48105. import { Effect } from "babylonjs/Materials/effect";
  48106. /**
  48107. * A directional light is defined by a direction (what a surprise!).
  48108. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48109. * 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.
  48110. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48111. */
  48112. export class DirectionalLight extends ShadowLight {
  48113. private _shadowFrustumSize;
  48114. /**
  48115. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48116. */
  48117. /**
  48118. * Specifies a fix frustum size for the shadow generation.
  48119. */
  48120. shadowFrustumSize: number;
  48121. private _shadowOrthoScale;
  48122. /**
  48123. * Gets the shadow projection scale against the optimal computed one.
  48124. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48125. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48126. */
  48127. /**
  48128. * Sets the shadow projection scale against the optimal computed one.
  48129. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48130. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48131. */
  48132. shadowOrthoScale: number;
  48133. /**
  48134. * Automatically compute the projection matrix to best fit (including all the casters)
  48135. * on each frame.
  48136. */
  48137. autoUpdateExtends: boolean;
  48138. private _orthoLeft;
  48139. private _orthoRight;
  48140. private _orthoTop;
  48141. private _orthoBottom;
  48142. /**
  48143. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48144. * The directional light is emitted from everywhere in the given direction.
  48145. * It can cast shadows.
  48146. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48147. * @param name The friendly name of the light
  48148. * @param direction The direction of the light
  48149. * @param scene The scene the light belongs to
  48150. */
  48151. constructor(name: string, direction: Vector3, scene: Scene);
  48152. /**
  48153. * Returns the string "DirectionalLight".
  48154. * @return The class name
  48155. */
  48156. getClassName(): string;
  48157. /**
  48158. * Returns the integer 1.
  48159. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48160. */
  48161. getTypeID(): number;
  48162. /**
  48163. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48164. * Returns the DirectionalLight Shadow projection matrix.
  48165. */
  48166. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48167. /**
  48168. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48169. * Returns the DirectionalLight Shadow projection matrix.
  48170. */
  48171. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48172. /**
  48173. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48174. * Returns the DirectionalLight Shadow projection matrix.
  48175. */
  48176. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48177. protected _buildUniformLayout(): void;
  48178. /**
  48179. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48180. * @param effect The effect to update
  48181. * @param lightIndex The index of the light in the effect to update
  48182. * @returns The directional light
  48183. */
  48184. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48185. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48186. /**
  48187. * Gets the minZ used for shadow according to both the scene and the light.
  48188. *
  48189. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48190. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48191. * @param activeCamera The camera we are returning the min for
  48192. * @returns the depth min z
  48193. */
  48194. getDepthMinZ(activeCamera: Camera): number;
  48195. /**
  48196. * Gets the maxZ used for shadow according to both the scene and the light.
  48197. *
  48198. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48199. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48200. * @param activeCamera The camera we are returning the max for
  48201. * @returns the depth max z
  48202. */
  48203. getDepthMaxZ(activeCamera: Camera): number;
  48204. /**
  48205. * Prepares the list of defines specific to the light type.
  48206. * @param defines the list of defines
  48207. * @param lightIndex defines the index of the light for the effect
  48208. */
  48209. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48210. }
  48211. }
  48212. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  48213. import { Mesh } from "babylonjs/Meshes/mesh";
  48214. /**
  48215. * Class containing static functions to help procedurally build meshes
  48216. */
  48217. export class HemisphereBuilder {
  48218. /**
  48219. * Creates a hemisphere mesh
  48220. * @param name defines the name of the mesh
  48221. * @param options defines the options used to create the mesh
  48222. * @param scene defines the hosting scene
  48223. * @returns the hemisphere mesh
  48224. */
  48225. static CreateHemisphere(name: string, options: {
  48226. segments?: number;
  48227. diameter?: number;
  48228. sideOrientation?: number;
  48229. }, scene: any): Mesh;
  48230. }
  48231. }
  48232. declare module "babylonjs/Lights/spotLight" {
  48233. import { Nullable } from "babylonjs/types";
  48234. import { Scene } from "babylonjs/scene";
  48235. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48237. import { Effect } from "babylonjs/Materials/effect";
  48238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48239. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48240. /**
  48241. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48242. * These values define a cone of light starting from the position, emitting toward the direction.
  48243. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48244. * and the exponent defines the speed of the decay of the light with distance (reach).
  48245. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48246. */
  48247. export class SpotLight extends ShadowLight {
  48248. private _angle;
  48249. private _innerAngle;
  48250. private _cosHalfAngle;
  48251. private _lightAngleScale;
  48252. private _lightAngleOffset;
  48253. /**
  48254. * Gets the cone angle of the spot light in Radians.
  48255. */
  48256. /**
  48257. * Sets the cone angle of the spot light in Radians.
  48258. */
  48259. angle: number;
  48260. /**
  48261. * Only used in gltf falloff mode, this defines the angle where
  48262. * the directional falloff will start before cutting at angle which could be seen
  48263. * as outer angle.
  48264. */
  48265. /**
  48266. * Only used in gltf falloff mode, this defines the angle where
  48267. * the directional falloff will start before cutting at angle which could be seen
  48268. * as outer angle.
  48269. */
  48270. innerAngle: number;
  48271. private _shadowAngleScale;
  48272. /**
  48273. * Allows scaling the angle of the light for shadow generation only.
  48274. */
  48275. /**
  48276. * Allows scaling the angle of the light for shadow generation only.
  48277. */
  48278. shadowAngleScale: number;
  48279. /**
  48280. * The light decay speed with the distance from the emission spot.
  48281. */
  48282. exponent: number;
  48283. private _projectionTextureMatrix;
  48284. /**
  48285. * Allows reading the projecton texture
  48286. */
  48287. readonly projectionTextureMatrix: Matrix;
  48288. protected _projectionTextureLightNear: number;
  48289. /**
  48290. * Gets the near clip of the Spotlight for texture projection.
  48291. */
  48292. /**
  48293. * Sets the near clip of the Spotlight for texture projection.
  48294. */
  48295. projectionTextureLightNear: number;
  48296. protected _projectionTextureLightFar: number;
  48297. /**
  48298. * Gets the far clip of the Spotlight for texture projection.
  48299. */
  48300. /**
  48301. * Sets the far clip of the Spotlight for texture projection.
  48302. */
  48303. projectionTextureLightFar: number;
  48304. protected _projectionTextureUpDirection: Vector3;
  48305. /**
  48306. * Gets the Up vector of the Spotlight for texture projection.
  48307. */
  48308. /**
  48309. * Sets the Up vector of the Spotlight for texture projection.
  48310. */
  48311. projectionTextureUpDirection: Vector3;
  48312. private _projectionTexture;
  48313. /**
  48314. * Gets the projection texture of the light.
  48315. */
  48316. /**
  48317. * Sets the projection texture of the light.
  48318. */
  48319. projectionTexture: Nullable<BaseTexture>;
  48320. private _projectionTextureViewLightDirty;
  48321. private _projectionTextureProjectionLightDirty;
  48322. private _projectionTextureDirty;
  48323. private _projectionTextureViewTargetVector;
  48324. private _projectionTextureViewLightMatrix;
  48325. private _projectionTextureProjectionLightMatrix;
  48326. private _projectionTextureScalingMatrix;
  48327. /**
  48328. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48329. * It can cast shadows.
  48330. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48331. * @param name The light friendly name
  48332. * @param position The position of the spot light in the scene
  48333. * @param direction The direction of the light in the scene
  48334. * @param angle The cone angle of the light in Radians
  48335. * @param exponent The light decay speed with the distance from the emission spot
  48336. * @param scene The scene the lights belongs to
  48337. */
  48338. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48339. /**
  48340. * Returns the string "SpotLight".
  48341. * @returns the class name
  48342. */
  48343. getClassName(): string;
  48344. /**
  48345. * Returns the integer 2.
  48346. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48347. */
  48348. getTypeID(): number;
  48349. /**
  48350. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48351. */
  48352. protected _setDirection(value: Vector3): void;
  48353. /**
  48354. * Overrides the position setter to recompute the projection texture view light Matrix.
  48355. */
  48356. protected _setPosition(value: Vector3): void;
  48357. /**
  48358. * 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.
  48359. * Returns the SpotLight.
  48360. */
  48361. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48362. protected _computeProjectionTextureViewLightMatrix(): void;
  48363. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48364. /**
  48365. * Main function for light texture projection matrix computing.
  48366. */
  48367. protected _computeProjectionTextureMatrix(): void;
  48368. protected _buildUniformLayout(): void;
  48369. private _computeAngleValues;
  48370. /**
  48371. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48372. * @param effect The effect to update
  48373. * @param lightIndex The index of the light in the effect to update
  48374. * @returns The spot light
  48375. */
  48376. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48377. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48378. /**
  48379. * Disposes the light and the associated resources.
  48380. */
  48381. dispose(): void;
  48382. /**
  48383. * Prepares the list of defines specific to the light type.
  48384. * @param defines the list of defines
  48385. * @param lightIndex defines the index of the light for the effect
  48386. */
  48387. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48388. }
  48389. }
  48390. declare module "babylonjs/Gizmos/lightGizmo" {
  48391. import { Nullable } from "babylonjs/types";
  48392. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48393. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48394. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48395. import { Light } from "babylonjs/Lights/light";
  48396. /**
  48397. * Gizmo that enables viewing a light
  48398. */
  48399. export class LightGizmo extends Gizmo {
  48400. private _lightMesh;
  48401. private _material;
  48402. private _cachedPosition;
  48403. private _cachedForward;
  48404. private _attachedMeshParent;
  48405. /**
  48406. * Creates a LightGizmo
  48407. * @param gizmoLayer The utility layer the gizmo will be added to
  48408. */
  48409. constructor(gizmoLayer?: UtilityLayerRenderer);
  48410. private _light;
  48411. /**
  48412. * The light that the gizmo is attached to
  48413. */
  48414. light: Nullable<Light>;
  48415. /**
  48416. * Gets the material used to render the light gizmo
  48417. */
  48418. readonly material: StandardMaterial;
  48419. /**
  48420. * @hidden
  48421. * Updates the gizmo to match the attached mesh's position/rotation
  48422. */
  48423. protected _update(): void;
  48424. private static _Scale;
  48425. /**
  48426. * Creates the lines for a light mesh
  48427. */
  48428. private static _CreateLightLines;
  48429. /**
  48430. * Disposes of the light gizmo
  48431. */
  48432. dispose(): void;
  48433. private static _CreateHemisphericLightMesh;
  48434. private static _CreatePointLightMesh;
  48435. private static _CreateSpotLightMesh;
  48436. private static _CreateDirectionalLightMesh;
  48437. }
  48438. }
  48439. declare module "babylonjs/Gizmos/index" {
  48440. export * from "babylonjs/Gizmos/axisDragGizmo";
  48441. export * from "babylonjs/Gizmos/axisScaleGizmo";
  48442. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  48443. export * from "babylonjs/Gizmos/gizmo";
  48444. export * from "babylonjs/Gizmos/gizmoManager";
  48445. export * from "babylonjs/Gizmos/planeRotationGizmo";
  48446. export * from "babylonjs/Gizmos/positionGizmo";
  48447. export * from "babylonjs/Gizmos/rotationGizmo";
  48448. export * from "babylonjs/Gizmos/scaleGizmo";
  48449. export * from "babylonjs/Gizmos/lightGizmo";
  48450. export * from "babylonjs/Gizmos/planeDragGizmo";
  48451. }
  48452. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  48453. /** @hidden */
  48454. export var backgroundFragmentDeclaration: {
  48455. name: string;
  48456. shader: string;
  48457. };
  48458. }
  48459. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  48460. /** @hidden */
  48461. export var backgroundUboDeclaration: {
  48462. name: string;
  48463. shader: string;
  48464. };
  48465. }
  48466. declare module "babylonjs/Shaders/background.fragment" {
  48467. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  48468. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48469. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48470. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48471. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48472. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48473. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48474. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  48475. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48476. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48477. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48478. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48479. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48480. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48481. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48482. /** @hidden */
  48483. export var backgroundPixelShader: {
  48484. name: string;
  48485. shader: string;
  48486. };
  48487. }
  48488. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  48489. /** @hidden */
  48490. export var backgroundVertexDeclaration: {
  48491. name: string;
  48492. shader: string;
  48493. };
  48494. }
  48495. declare module "babylonjs/Shaders/background.vertex" {
  48496. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  48497. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  48498. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48499. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48500. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48501. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48502. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48503. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48504. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48505. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48506. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48507. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48508. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48509. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48510. /** @hidden */
  48511. export var backgroundVertexShader: {
  48512. name: string;
  48513. shader: string;
  48514. };
  48515. }
  48516. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  48517. import { Nullable, int, float } from "babylonjs/types";
  48518. import { Scene } from "babylonjs/scene";
  48519. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  48520. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48522. import { Mesh } from "babylonjs/Meshes/mesh";
  48523. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48524. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48525. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48526. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48527. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  48528. import { Color3 } from "babylonjs/Maths/math.color";
  48529. import "babylonjs/Shaders/background.fragment";
  48530. import "babylonjs/Shaders/background.vertex";
  48531. /**
  48532. * Background material used to create an efficient environement around your scene.
  48533. */
  48534. export class BackgroundMaterial extends PushMaterial {
  48535. /**
  48536. * Standard reflectance value at parallel view angle.
  48537. */
  48538. static StandardReflectance0: number;
  48539. /**
  48540. * Standard reflectance value at grazing angle.
  48541. */
  48542. static StandardReflectance90: number;
  48543. protected _primaryColor: Color3;
  48544. /**
  48545. * Key light Color (multiply against the environement texture)
  48546. */
  48547. primaryColor: Color3;
  48548. protected __perceptualColor: Nullable<Color3>;
  48549. /**
  48550. * Experimental Internal Use Only.
  48551. *
  48552. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  48553. * This acts as a helper to set the primary color to a more "human friendly" value.
  48554. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  48555. * output color as close as possible from the chosen value.
  48556. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  48557. * part of lighting setup.)
  48558. */
  48559. _perceptualColor: Nullable<Color3>;
  48560. protected _primaryColorShadowLevel: float;
  48561. /**
  48562. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  48563. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  48564. */
  48565. primaryColorShadowLevel: float;
  48566. protected _primaryColorHighlightLevel: float;
  48567. /**
  48568. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  48569. * The primary color is used at the level chosen to define what the white area would look.
  48570. */
  48571. primaryColorHighlightLevel: float;
  48572. protected _reflectionTexture: Nullable<BaseTexture>;
  48573. /**
  48574. * Reflection Texture used in the material.
  48575. * Should be author in a specific way for the best result (refer to the documentation).
  48576. */
  48577. reflectionTexture: Nullable<BaseTexture>;
  48578. protected _reflectionBlur: float;
  48579. /**
  48580. * Reflection Texture level of blur.
  48581. *
  48582. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  48583. * texture twice.
  48584. */
  48585. reflectionBlur: float;
  48586. protected _diffuseTexture: Nullable<BaseTexture>;
  48587. /**
  48588. * Diffuse Texture used in the material.
  48589. * Should be author in a specific way for the best result (refer to the documentation).
  48590. */
  48591. diffuseTexture: Nullable<BaseTexture>;
  48592. protected _shadowLights: Nullable<IShadowLight[]>;
  48593. /**
  48594. * Specify the list of lights casting shadow on the material.
  48595. * All scene shadow lights will be included if null.
  48596. */
  48597. shadowLights: Nullable<IShadowLight[]>;
  48598. protected _shadowLevel: float;
  48599. /**
  48600. * Helps adjusting the shadow to a softer level if required.
  48601. * 0 means black shadows and 1 means no shadows.
  48602. */
  48603. shadowLevel: float;
  48604. protected _sceneCenter: Vector3;
  48605. /**
  48606. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  48607. * It is usually zero but might be interesting to modify according to your setup.
  48608. */
  48609. sceneCenter: Vector3;
  48610. protected _opacityFresnel: boolean;
  48611. /**
  48612. * This helps specifying that the material is falling off to the sky box at grazing angle.
  48613. * This helps ensuring a nice transition when the camera goes under the ground.
  48614. */
  48615. opacityFresnel: boolean;
  48616. protected _reflectionFresnel: boolean;
  48617. /**
  48618. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  48619. * This helps adding a mirror texture on the ground.
  48620. */
  48621. reflectionFresnel: boolean;
  48622. protected _reflectionFalloffDistance: number;
  48623. /**
  48624. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  48625. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  48626. */
  48627. reflectionFalloffDistance: number;
  48628. protected _reflectionAmount: number;
  48629. /**
  48630. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  48631. */
  48632. reflectionAmount: number;
  48633. protected _reflectionReflectance0: number;
  48634. /**
  48635. * This specifies the weight of the reflection at grazing angle.
  48636. */
  48637. reflectionReflectance0: number;
  48638. protected _reflectionReflectance90: number;
  48639. /**
  48640. * This specifies the weight of the reflection at a perpendicular point of view.
  48641. */
  48642. reflectionReflectance90: number;
  48643. /**
  48644. * Sets the reflection reflectance fresnel values according to the default standard
  48645. * empirically know to work well :-)
  48646. */
  48647. reflectionStandardFresnelWeight: number;
  48648. protected _useRGBColor: boolean;
  48649. /**
  48650. * Helps to directly use the maps channels instead of their level.
  48651. */
  48652. useRGBColor: boolean;
  48653. protected _enableNoise: boolean;
  48654. /**
  48655. * This helps reducing the banding effect that could occur on the background.
  48656. */
  48657. enableNoise: boolean;
  48658. /**
  48659. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48660. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  48661. * Recommended to be keep at 1.0 except for special cases.
  48662. */
  48663. fovMultiplier: number;
  48664. private _fovMultiplier;
  48665. /**
  48666. * Enable the FOV adjustment feature controlled by fovMultiplier.
  48667. */
  48668. useEquirectangularFOV: boolean;
  48669. private _maxSimultaneousLights;
  48670. /**
  48671. * Number of Simultaneous lights allowed on the material.
  48672. */
  48673. maxSimultaneousLights: int;
  48674. /**
  48675. * Default configuration related to image processing available in the Background Material.
  48676. */
  48677. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48678. /**
  48679. * Keep track of the image processing observer to allow dispose and replace.
  48680. */
  48681. private _imageProcessingObserver;
  48682. /**
  48683. * Attaches a new image processing configuration to the PBR Material.
  48684. * @param configuration (if null the scene configuration will be use)
  48685. */
  48686. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48687. /**
  48688. * Gets the image processing configuration used either in this material.
  48689. */
  48690. /**
  48691. * Sets the Default image processing configuration used either in the this material.
  48692. *
  48693. * If sets to null, the scene one is in use.
  48694. */
  48695. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  48696. /**
  48697. * Gets wether the color curves effect is enabled.
  48698. */
  48699. /**
  48700. * Sets wether the color curves effect is enabled.
  48701. */
  48702. cameraColorCurvesEnabled: boolean;
  48703. /**
  48704. * Gets wether the color grading effect is enabled.
  48705. */
  48706. /**
  48707. * Gets wether the color grading effect is enabled.
  48708. */
  48709. cameraColorGradingEnabled: boolean;
  48710. /**
  48711. * Gets wether tonemapping is enabled or not.
  48712. */
  48713. /**
  48714. * Sets wether tonemapping is enabled or not
  48715. */
  48716. cameraToneMappingEnabled: boolean;
  48717. /**
  48718. * The camera exposure used on this material.
  48719. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48720. * This corresponds to a photographic exposure.
  48721. */
  48722. /**
  48723. * The camera exposure used on this material.
  48724. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48725. * This corresponds to a photographic exposure.
  48726. */
  48727. cameraExposure: float;
  48728. /**
  48729. * Gets The camera contrast used on this material.
  48730. */
  48731. /**
  48732. * Sets The camera contrast used on this material.
  48733. */
  48734. cameraContrast: float;
  48735. /**
  48736. * Gets the Color Grading 2D Lookup Texture.
  48737. */
  48738. /**
  48739. * Sets the Color Grading 2D Lookup Texture.
  48740. */
  48741. cameraColorGradingTexture: Nullable<BaseTexture>;
  48742. /**
  48743. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48744. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48745. * 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;
  48746. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48747. */
  48748. /**
  48749. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48750. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48751. * 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;
  48752. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48753. */
  48754. cameraColorCurves: Nullable<ColorCurves>;
  48755. /**
  48756. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  48757. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  48758. */
  48759. switchToBGR: boolean;
  48760. private _renderTargets;
  48761. private _reflectionControls;
  48762. private _white;
  48763. private _primaryShadowColor;
  48764. private _primaryHighlightColor;
  48765. /**
  48766. * Instantiates a Background Material in the given scene
  48767. * @param name The friendly name of the material
  48768. * @param scene The scene to add the material to
  48769. */
  48770. constructor(name: string, scene: Scene);
  48771. /**
  48772. * Gets a boolean indicating that current material needs to register RTT
  48773. */
  48774. readonly hasRenderTargetTextures: boolean;
  48775. /**
  48776. * The entire material has been created in order to prevent overdraw.
  48777. * @returns false
  48778. */
  48779. needAlphaTesting(): boolean;
  48780. /**
  48781. * The entire material has been created in order to prevent overdraw.
  48782. * @returns true if blending is enable
  48783. */
  48784. needAlphaBlending(): boolean;
  48785. /**
  48786. * Checks wether the material is ready to be rendered for a given mesh.
  48787. * @param mesh The mesh to render
  48788. * @param subMesh The submesh to check against
  48789. * @param useInstances Specify wether or not the material is used with instances
  48790. * @returns true if all the dependencies are ready (Textures, Effects...)
  48791. */
  48792. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48793. /**
  48794. * Compute the primary color according to the chosen perceptual color.
  48795. */
  48796. private _computePrimaryColorFromPerceptualColor;
  48797. /**
  48798. * Compute the highlights and shadow colors according to their chosen levels.
  48799. */
  48800. private _computePrimaryColors;
  48801. /**
  48802. * Build the uniform buffer used in the material.
  48803. */
  48804. buildUniformLayout(): void;
  48805. /**
  48806. * Unbind the material.
  48807. */
  48808. unbind(): void;
  48809. /**
  48810. * Bind only the world matrix to the material.
  48811. * @param world The world matrix to bind.
  48812. */
  48813. bindOnlyWorldMatrix(world: Matrix): void;
  48814. /**
  48815. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48816. * @param world The world matrix to bind.
  48817. * @param subMesh The submesh to bind for.
  48818. */
  48819. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48820. /**
  48821. * Checks to see if a texture is used in the material.
  48822. * @param texture - Base texture to use.
  48823. * @returns - Boolean specifying if a texture is used in the material.
  48824. */
  48825. hasTexture(texture: BaseTexture): boolean;
  48826. /**
  48827. * Dispose the material.
  48828. * @param forceDisposeEffect Force disposal of the associated effect.
  48829. * @param forceDisposeTextures Force disposal of the associated textures.
  48830. */
  48831. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48832. /**
  48833. * Clones the material.
  48834. * @param name The cloned name.
  48835. * @returns The cloned material.
  48836. */
  48837. clone(name: string): BackgroundMaterial;
  48838. /**
  48839. * Serializes the current material to its JSON representation.
  48840. * @returns The JSON representation.
  48841. */
  48842. serialize(): any;
  48843. /**
  48844. * Gets the class name of the material
  48845. * @returns "BackgroundMaterial"
  48846. */
  48847. getClassName(): string;
  48848. /**
  48849. * Parse a JSON input to create back a background material.
  48850. * @param source The JSON data to parse
  48851. * @param scene The scene to create the parsed material in
  48852. * @param rootUrl The root url of the assets the material depends upon
  48853. * @returns the instantiated BackgroundMaterial.
  48854. */
  48855. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48856. }
  48857. }
  48858. declare module "babylonjs/Helpers/environmentHelper" {
  48859. import { Observable } from "babylonjs/Misc/observable";
  48860. import { Nullable } from "babylonjs/types";
  48861. import { Scene } from "babylonjs/scene";
  48862. import { Vector3 } from "babylonjs/Maths/math.vector";
  48863. import { Color3 } from "babylonjs/Maths/math.color";
  48864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48865. import { Mesh } from "babylonjs/Meshes/mesh";
  48866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48867. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48868. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48869. import "babylonjs/Meshes/Builders/planeBuilder";
  48870. import "babylonjs/Meshes/Builders/boxBuilder";
  48871. /**
  48872. * Represents the different options available during the creation of
  48873. * a Environment helper.
  48874. *
  48875. * This can control the default ground, skybox and image processing setup of your scene.
  48876. */
  48877. export interface IEnvironmentHelperOptions {
  48878. /**
  48879. * Specifies wether or not to create a ground.
  48880. * True by default.
  48881. */
  48882. createGround: boolean;
  48883. /**
  48884. * Specifies the ground size.
  48885. * 15 by default.
  48886. */
  48887. groundSize: number;
  48888. /**
  48889. * The texture used on the ground for the main color.
  48890. * Comes from the BabylonJS CDN by default.
  48891. *
  48892. * Remarks: Can be either a texture or a url.
  48893. */
  48894. groundTexture: string | BaseTexture;
  48895. /**
  48896. * The color mixed in the ground texture by default.
  48897. * BabylonJS clearColor by default.
  48898. */
  48899. groundColor: Color3;
  48900. /**
  48901. * Specifies the ground opacity.
  48902. * 1 by default.
  48903. */
  48904. groundOpacity: number;
  48905. /**
  48906. * Enables the ground to receive shadows.
  48907. * True by default.
  48908. */
  48909. enableGroundShadow: boolean;
  48910. /**
  48911. * Helps preventing the shadow to be fully black on the ground.
  48912. * 0.5 by default.
  48913. */
  48914. groundShadowLevel: number;
  48915. /**
  48916. * Creates a mirror texture attach to the ground.
  48917. * false by default.
  48918. */
  48919. enableGroundMirror: boolean;
  48920. /**
  48921. * Specifies the ground mirror size ratio.
  48922. * 0.3 by default as the default kernel is 64.
  48923. */
  48924. groundMirrorSizeRatio: number;
  48925. /**
  48926. * Specifies the ground mirror blur kernel size.
  48927. * 64 by default.
  48928. */
  48929. groundMirrorBlurKernel: number;
  48930. /**
  48931. * Specifies the ground mirror visibility amount.
  48932. * 1 by default
  48933. */
  48934. groundMirrorAmount: number;
  48935. /**
  48936. * Specifies the ground mirror reflectance weight.
  48937. * This uses the standard weight of the background material to setup the fresnel effect
  48938. * of the mirror.
  48939. * 1 by default.
  48940. */
  48941. groundMirrorFresnelWeight: number;
  48942. /**
  48943. * Specifies the ground mirror Falloff distance.
  48944. * This can helps reducing the size of the reflection.
  48945. * 0 by Default.
  48946. */
  48947. groundMirrorFallOffDistance: number;
  48948. /**
  48949. * Specifies the ground mirror texture type.
  48950. * Unsigned Int by Default.
  48951. */
  48952. groundMirrorTextureType: number;
  48953. /**
  48954. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48955. * the shown objects.
  48956. */
  48957. groundYBias: number;
  48958. /**
  48959. * Specifies wether or not to create a skybox.
  48960. * True by default.
  48961. */
  48962. createSkybox: boolean;
  48963. /**
  48964. * Specifies the skybox size.
  48965. * 20 by default.
  48966. */
  48967. skyboxSize: number;
  48968. /**
  48969. * The texture used on the skybox for the main color.
  48970. * Comes from the BabylonJS CDN by default.
  48971. *
  48972. * Remarks: Can be either a texture or a url.
  48973. */
  48974. skyboxTexture: string | BaseTexture;
  48975. /**
  48976. * The color mixed in the skybox texture by default.
  48977. * BabylonJS clearColor by default.
  48978. */
  48979. skyboxColor: Color3;
  48980. /**
  48981. * The background rotation around the Y axis of the scene.
  48982. * This helps aligning the key lights of your scene with the background.
  48983. * 0 by default.
  48984. */
  48985. backgroundYRotation: number;
  48986. /**
  48987. * Compute automatically the size of the elements to best fit with the scene.
  48988. */
  48989. sizeAuto: boolean;
  48990. /**
  48991. * Default position of the rootMesh if autoSize is not true.
  48992. */
  48993. rootPosition: Vector3;
  48994. /**
  48995. * Sets up the image processing in the scene.
  48996. * true by default.
  48997. */
  48998. setupImageProcessing: boolean;
  48999. /**
  49000. * The texture used as your environment texture in the scene.
  49001. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49002. *
  49003. * Remarks: Can be either a texture or a url.
  49004. */
  49005. environmentTexture: string | BaseTexture;
  49006. /**
  49007. * The value of the exposure to apply to the scene.
  49008. * 0.6 by default if setupImageProcessing is true.
  49009. */
  49010. cameraExposure: number;
  49011. /**
  49012. * The value of the contrast to apply to the scene.
  49013. * 1.6 by default if setupImageProcessing is true.
  49014. */
  49015. cameraContrast: number;
  49016. /**
  49017. * Specifies wether or not tonemapping should be enabled in the scene.
  49018. * true by default if setupImageProcessing is true.
  49019. */
  49020. toneMappingEnabled: boolean;
  49021. }
  49022. /**
  49023. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49024. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49025. * It also helps with the default setup of your imageProcessing configuration.
  49026. */
  49027. export class EnvironmentHelper {
  49028. /**
  49029. * Default ground texture URL.
  49030. */
  49031. private static _groundTextureCDNUrl;
  49032. /**
  49033. * Default skybox texture URL.
  49034. */
  49035. private static _skyboxTextureCDNUrl;
  49036. /**
  49037. * Default environment texture URL.
  49038. */
  49039. private static _environmentTextureCDNUrl;
  49040. /**
  49041. * Creates the default options for the helper.
  49042. */
  49043. private static _getDefaultOptions;
  49044. private _rootMesh;
  49045. /**
  49046. * Gets the root mesh created by the helper.
  49047. */
  49048. readonly rootMesh: Mesh;
  49049. private _skybox;
  49050. /**
  49051. * Gets the skybox created by the helper.
  49052. */
  49053. readonly skybox: Nullable<Mesh>;
  49054. private _skyboxTexture;
  49055. /**
  49056. * Gets the skybox texture created by the helper.
  49057. */
  49058. readonly skyboxTexture: Nullable<BaseTexture>;
  49059. private _skyboxMaterial;
  49060. /**
  49061. * Gets the skybox material created by the helper.
  49062. */
  49063. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  49064. private _ground;
  49065. /**
  49066. * Gets the ground mesh created by the helper.
  49067. */
  49068. readonly ground: Nullable<Mesh>;
  49069. private _groundTexture;
  49070. /**
  49071. * Gets the ground texture created by the helper.
  49072. */
  49073. readonly groundTexture: Nullable<BaseTexture>;
  49074. private _groundMirror;
  49075. /**
  49076. * Gets the ground mirror created by the helper.
  49077. */
  49078. readonly groundMirror: Nullable<MirrorTexture>;
  49079. /**
  49080. * Gets the ground mirror render list to helps pushing the meshes
  49081. * you wish in the ground reflection.
  49082. */
  49083. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  49084. private _groundMaterial;
  49085. /**
  49086. * Gets the ground material created by the helper.
  49087. */
  49088. readonly groundMaterial: Nullable<BackgroundMaterial>;
  49089. /**
  49090. * Stores the creation options.
  49091. */
  49092. private readonly _scene;
  49093. private _options;
  49094. /**
  49095. * This observable will be notified with any error during the creation of the environment,
  49096. * mainly texture creation errors.
  49097. */
  49098. onErrorObservable: Observable<{
  49099. message?: string;
  49100. exception?: any;
  49101. }>;
  49102. /**
  49103. * constructor
  49104. * @param options Defines the options we want to customize the helper
  49105. * @param scene The scene to add the material to
  49106. */
  49107. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49108. /**
  49109. * Updates the background according to the new options
  49110. * @param options
  49111. */
  49112. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49113. /**
  49114. * Sets the primary color of all the available elements.
  49115. * @param color the main color to affect to the ground and the background
  49116. */
  49117. setMainColor(color: Color3): void;
  49118. /**
  49119. * Setup the image processing according to the specified options.
  49120. */
  49121. private _setupImageProcessing;
  49122. /**
  49123. * Setup the environment texture according to the specified options.
  49124. */
  49125. private _setupEnvironmentTexture;
  49126. /**
  49127. * Setup the background according to the specified options.
  49128. */
  49129. private _setupBackground;
  49130. /**
  49131. * Get the scene sizes according to the setup.
  49132. */
  49133. private _getSceneSize;
  49134. /**
  49135. * Setup the ground according to the specified options.
  49136. */
  49137. private _setupGround;
  49138. /**
  49139. * Setup the ground material according to the specified options.
  49140. */
  49141. private _setupGroundMaterial;
  49142. /**
  49143. * Setup the ground diffuse texture according to the specified options.
  49144. */
  49145. private _setupGroundDiffuseTexture;
  49146. /**
  49147. * Setup the ground mirror texture according to the specified options.
  49148. */
  49149. private _setupGroundMirrorTexture;
  49150. /**
  49151. * Setup the ground to receive the mirror texture.
  49152. */
  49153. private _setupMirrorInGroundMaterial;
  49154. /**
  49155. * Setup the skybox according to the specified options.
  49156. */
  49157. private _setupSkybox;
  49158. /**
  49159. * Setup the skybox material according to the specified options.
  49160. */
  49161. private _setupSkyboxMaterial;
  49162. /**
  49163. * Setup the skybox reflection texture according to the specified options.
  49164. */
  49165. private _setupSkyboxReflectionTexture;
  49166. private _errorHandler;
  49167. /**
  49168. * Dispose all the elements created by the Helper.
  49169. */
  49170. dispose(): void;
  49171. }
  49172. }
  49173. declare module "babylonjs/Helpers/photoDome" {
  49174. import { Observable } from "babylonjs/Misc/observable";
  49175. import { Nullable } from "babylonjs/types";
  49176. import { Scene } from "babylonjs/scene";
  49177. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49178. import { Mesh } from "babylonjs/Meshes/mesh";
  49179. import { Texture } from "babylonjs/Materials/Textures/texture";
  49180. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49181. import "babylonjs/Meshes/Builders/sphereBuilder";
  49182. /**
  49183. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49184. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49185. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49186. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49187. */
  49188. export class PhotoDome extends TransformNode {
  49189. /**
  49190. * Define the image as a Monoscopic panoramic 360 image.
  49191. */
  49192. static readonly MODE_MONOSCOPIC: number;
  49193. /**
  49194. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49195. */
  49196. static readonly MODE_TOPBOTTOM: number;
  49197. /**
  49198. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49199. */
  49200. static readonly MODE_SIDEBYSIDE: number;
  49201. private _useDirectMapping;
  49202. /**
  49203. * The texture being displayed on the sphere
  49204. */
  49205. protected _photoTexture: Texture;
  49206. /**
  49207. * Gets or sets the texture being displayed on the sphere
  49208. */
  49209. photoTexture: Texture;
  49210. /**
  49211. * Observable raised when an error occured while loading the 360 image
  49212. */
  49213. onLoadErrorObservable: Observable<string>;
  49214. /**
  49215. * The skybox material
  49216. */
  49217. protected _material: BackgroundMaterial;
  49218. /**
  49219. * The surface used for the skybox
  49220. */
  49221. protected _mesh: Mesh;
  49222. /**
  49223. * Gets the mesh used for the skybox.
  49224. */
  49225. readonly mesh: Mesh;
  49226. /**
  49227. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49228. * Also see the options.resolution property.
  49229. */
  49230. fovMultiplier: number;
  49231. private _imageMode;
  49232. /**
  49233. * Gets or set the current video mode for the video. It can be:
  49234. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49235. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49236. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49237. */
  49238. imageMode: number;
  49239. /**
  49240. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49241. * @param name Element's name, child elements will append suffixes for their own names.
  49242. * @param urlsOfPhoto defines the url of the photo to display
  49243. * @param options defines an object containing optional or exposed sub element properties
  49244. * @param onError defines a callback called when an error occured while loading the texture
  49245. */
  49246. constructor(name: string, urlOfPhoto: string, options: {
  49247. resolution?: number;
  49248. size?: number;
  49249. useDirectMapping?: boolean;
  49250. faceForward?: boolean;
  49251. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49252. private _onBeforeCameraRenderObserver;
  49253. private _changeImageMode;
  49254. /**
  49255. * Releases resources associated with this node.
  49256. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49257. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49258. */
  49259. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49260. }
  49261. }
  49262. declare module "babylonjs/Misc/rgbdTextureTools" {
  49263. import "babylonjs/Shaders/rgbdDecode.fragment";
  49264. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49265. import { Texture } from "babylonjs/Materials/Textures/texture";
  49266. /**
  49267. * Class used to host RGBD texture specific utilities
  49268. */
  49269. export class RGBDTextureTools {
  49270. /**
  49271. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49272. * @param texture the texture to expand.
  49273. */
  49274. static ExpandRGBDTexture(texture: Texture): void;
  49275. }
  49276. }
  49277. declare module "babylonjs/Misc/brdfTextureTools" {
  49278. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49279. import { Scene } from "babylonjs/scene";
  49280. /**
  49281. * Class used to host texture specific utilities
  49282. */
  49283. export class BRDFTextureTools {
  49284. /**
  49285. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49286. * @param scene defines the hosting scene
  49287. * @returns the environment BRDF texture
  49288. */
  49289. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49290. private static _environmentBRDFBase64Texture;
  49291. }
  49292. }
  49293. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  49294. import { Nullable } from "babylonjs/types";
  49295. import { Color3 } from "babylonjs/Maths/math.color";
  49296. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49297. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49298. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49299. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49300. import { Engine } from "babylonjs/Engines/engine";
  49301. import { Scene } from "babylonjs/scene";
  49302. /**
  49303. * @hidden
  49304. */
  49305. export interface IMaterialClearCoatDefines {
  49306. CLEARCOAT: boolean;
  49307. CLEARCOAT_DEFAULTIOR: boolean;
  49308. CLEARCOAT_TEXTURE: boolean;
  49309. CLEARCOAT_TEXTUREDIRECTUV: number;
  49310. CLEARCOAT_BUMP: boolean;
  49311. CLEARCOAT_BUMPDIRECTUV: number;
  49312. CLEARCOAT_TINT: boolean;
  49313. CLEARCOAT_TINT_TEXTURE: boolean;
  49314. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49315. /** @hidden */
  49316. _areTexturesDirty: boolean;
  49317. }
  49318. /**
  49319. * Define the code related to the clear coat parameters of the pbr material.
  49320. */
  49321. export class PBRClearCoatConfiguration {
  49322. /**
  49323. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49324. * The default fits with a polyurethane material.
  49325. */
  49326. private static readonly _DefaultIndexOfRefraction;
  49327. private _isEnabled;
  49328. /**
  49329. * Defines if the clear coat is enabled in the material.
  49330. */
  49331. isEnabled: boolean;
  49332. /**
  49333. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49334. */
  49335. intensity: number;
  49336. /**
  49337. * Defines the clear coat layer roughness.
  49338. */
  49339. roughness: number;
  49340. private _indexOfRefraction;
  49341. /**
  49342. * Defines the index of refraction of the clear coat.
  49343. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49344. * The default fits with a polyurethane material.
  49345. * Changing the default value is more performance intensive.
  49346. */
  49347. indexOfRefraction: number;
  49348. private _texture;
  49349. /**
  49350. * Stores the clear coat values in a texture.
  49351. */
  49352. texture: Nullable<BaseTexture>;
  49353. private _bumpTexture;
  49354. /**
  49355. * Define the clear coat specific bump texture.
  49356. */
  49357. bumpTexture: Nullable<BaseTexture>;
  49358. private _isTintEnabled;
  49359. /**
  49360. * Defines if the clear coat tint is enabled in the material.
  49361. */
  49362. isTintEnabled: boolean;
  49363. /**
  49364. * Defines the clear coat tint of the material.
  49365. * This is only use if tint is enabled
  49366. */
  49367. tintColor: Color3;
  49368. /**
  49369. * Defines the distance at which the tint color should be found in the
  49370. * clear coat media.
  49371. * This is only use if tint is enabled
  49372. */
  49373. tintColorAtDistance: number;
  49374. /**
  49375. * Defines the clear coat layer thickness.
  49376. * This is only use if tint is enabled
  49377. */
  49378. tintThickness: number;
  49379. private _tintTexture;
  49380. /**
  49381. * Stores the clear tint values in a texture.
  49382. * rgb is tint
  49383. * a is a thickness factor
  49384. */
  49385. tintTexture: Nullable<BaseTexture>;
  49386. /** @hidden */
  49387. private _internalMarkAllSubMeshesAsTexturesDirty;
  49388. /** @hidden */
  49389. _markAllSubMeshesAsTexturesDirty(): void;
  49390. /**
  49391. * Instantiate a new istance of clear coat configuration.
  49392. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49393. */
  49394. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49395. /**
  49396. * Gets wehter the submesh is ready to be used or not.
  49397. * @param defines the list of "defines" to update.
  49398. * @param scene defines the scene the material belongs to.
  49399. * @param engine defines the engine the material belongs to.
  49400. * @param disableBumpMap defines wether the material disables bump or not.
  49401. * @returns - boolean indicating that the submesh is ready or not.
  49402. */
  49403. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49404. /**
  49405. * Checks to see if a texture is used in the material.
  49406. * @param defines the list of "defines" to update.
  49407. * @param scene defines the scene to the material belongs to.
  49408. */
  49409. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49410. /**
  49411. * Binds the material data.
  49412. * @param uniformBuffer defines the Uniform buffer to fill in.
  49413. * @param scene defines the scene the material belongs to.
  49414. * @param engine defines the engine the material belongs to.
  49415. * @param disableBumpMap defines wether the material disables bump or not.
  49416. * @param isFrozen defines wether the material is frozen or not.
  49417. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49418. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49419. */
  49420. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49421. /**
  49422. * Checks to see if a texture is used in the material.
  49423. * @param texture - Base texture to use.
  49424. * @returns - Boolean specifying if a texture is used in the material.
  49425. */
  49426. hasTexture(texture: BaseTexture): boolean;
  49427. /**
  49428. * Returns an array of the actively used textures.
  49429. * @param activeTextures Array of BaseTextures
  49430. */
  49431. getActiveTextures(activeTextures: BaseTexture[]): void;
  49432. /**
  49433. * Returns the animatable textures.
  49434. * @param animatables Array of animatable textures.
  49435. */
  49436. getAnimatables(animatables: IAnimatable[]): void;
  49437. /**
  49438. * Disposes the resources of the material.
  49439. * @param forceDisposeTextures - Forces the disposal of all textures.
  49440. */
  49441. dispose(forceDisposeTextures?: boolean): void;
  49442. /**
  49443. * Get the current class name of the texture useful for serialization or dynamic coding.
  49444. * @returns "PBRClearCoatConfiguration"
  49445. */
  49446. getClassName(): string;
  49447. /**
  49448. * Add fallbacks to the effect fallbacks list.
  49449. * @param defines defines the Base texture to use.
  49450. * @param fallbacks defines the current fallback list.
  49451. * @param currentRank defines the current fallback rank.
  49452. * @returns the new fallback rank.
  49453. */
  49454. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49455. /**
  49456. * Add the required uniforms to the current list.
  49457. * @param uniforms defines the current uniform list.
  49458. */
  49459. static AddUniforms(uniforms: string[]): void;
  49460. /**
  49461. * Add the required samplers to the current list.
  49462. * @param samplers defines the current sampler list.
  49463. */
  49464. static AddSamplers(samplers: string[]): void;
  49465. /**
  49466. * Add the required uniforms to the current buffer.
  49467. * @param uniformBuffer defines the current uniform buffer.
  49468. */
  49469. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49470. /**
  49471. * Makes a duplicate of the current configuration into another one.
  49472. * @param clearCoatConfiguration define the config where to copy the info
  49473. */
  49474. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49475. /**
  49476. * Serializes this clear coat configuration.
  49477. * @returns - An object with the serialized config.
  49478. */
  49479. serialize(): any;
  49480. /**
  49481. * Parses a anisotropy Configuration from a serialized object.
  49482. * @param source - Serialized object.
  49483. * @param scene Defines the scene we are parsing for
  49484. * @param rootUrl Defines the rootUrl to load from
  49485. */
  49486. parse(source: any, scene: Scene, rootUrl: string): void;
  49487. }
  49488. }
  49489. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  49490. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49492. import { Vector2 } from "babylonjs/Maths/math.vector";
  49493. import { Scene } from "babylonjs/scene";
  49494. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49495. import { Nullable } from "babylonjs/types";
  49496. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49497. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49498. /**
  49499. * @hidden
  49500. */
  49501. export interface IMaterialAnisotropicDefines {
  49502. ANISOTROPIC: boolean;
  49503. ANISOTROPIC_TEXTURE: boolean;
  49504. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49505. MAINUV1: boolean;
  49506. _areTexturesDirty: boolean;
  49507. _needUVs: boolean;
  49508. }
  49509. /**
  49510. * Define the code related to the anisotropic parameters of the pbr material.
  49511. */
  49512. export class PBRAnisotropicConfiguration {
  49513. private _isEnabled;
  49514. /**
  49515. * Defines if the anisotropy is enabled in the material.
  49516. */
  49517. isEnabled: boolean;
  49518. /**
  49519. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  49520. */
  49521. intensity: number;
  49522. /**
  49523. * Defines if the effect is along the tangents, bitangents or in between.
  49524. * By default, the effect is "strectching" the highlights along the tangents.
  49525. */
  49526. direction: Vector2;
  49527. private _texture;
  49528. /**
  49529. * Stores the anisotropy values in a texture.
  49530. * rg is direction (like normal from -1 to 1)
  49531. * b is a intensity
  49532. */
  49533. texture: Nullable<BaseTexture>;
  49534. /** @hidden */
  49535. private _internalMarkAllSubMeshesAsTexturesDirty;
  49536. /** @hidden */
  49537. _markAllSubMeshesAsTexturesDirty(): void;
  49538. /**
  49539. * Instantiate a new istance of anisotropy configuration.
  49540. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49541. */
  49542. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49543. /**
  49544. * Specifies that the submesh is ready to be used.
  49545. * @param defines the list of "defines" to update.
  49546. * @param scene defines the scene the material belongs to.
  49547. * @returns - boolean indicating that the submesh is ready or not.
  49548. */
  49549. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  49550. /**
  49551. * Checks to see if a texture is used in the material.
  49552. * @param defines the list of "defines" to update.
  49553. * @param mesh the mesh we are preparing the defines for.
  49554. * @param scene defines the scene the material belongs to.
  49555. */
  49556. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  49557. /**
  49558. * Binds the material data.
  49559. * @param uniformBuffer defines the Uniform buffer to fill in.
  49560. * @param scene defines the scene the material belongs to.
  49561. * @param isFrozen defines wether the material is frozen or not.
  49562. */
  49563. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49564. /**
  49565. * Checks to see if a texture is used in the material.
  49566. * @param texture - Base texture to use.
  49567. * @returns - Boolean specifying if a texture is used in the material.
  49568. */
  49569. hasTexture(texture: BaseTexture): boolean;
  49570. /**
  49571. * Returns an array of the actively used textures.
  49572. * @param activeTextures Array of BaseTextures
  49573. */
  49574. getActiveTextures(activeTextures: BaseTexture[]): void;
  49575. /**
  49576. * Returns the animatable textures.
  49577. * @param animatables Array of animatable textures.
  49578. */
  49579. getAnimatables(animatables: IAnimatable[]): void;
  49580. /**
  49581. * Disposes the resources of the material.
  49582. * @param forceDisposeTextures - Forces the disposal of all textures.
  49583. */
  49584. dispose(forceDisposeTextures?: boolean): void;
  49585. /**
  49586. * Get the current class name of the texture useful for serialization or dynamic coding.
  49587. * @returns "PBRAnisotropicConfiguration"
  49588. */
  49589. getClassName(): string;
  49590. /**
  49591. * Add fallbacks to the effect fallbacks list.
  49592. * @param defines defines the Base texture to use.
  49593. * @param fallbacks defines the current fallback list.
  49594. * @param currentRank defines the current fallback rank.
  49595. * @returns the new fallback rank.
  49596. */
  49597. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49598. /**
  49599. * Add the required uniforms to the current list.
  49600. * @param uniforms defines the current uniform list.
  49601. */
  49602. static AddUniforms(uniforms: string[]): void;
  49603. /**
  49604. * Add the required uniforms to the current buffer.
  49605. * @param uniformBuffer defines the current uniform buffer.
  49606. */
  49607. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49608. /**
  49609. * Add the required samplers to the current list.
  49610. * @param samplers defines the current sampler list.
  49611. */
  49612. static AddSamplers(samplers: string[]): void;
  49613. /**
  49614. * Makes a duplicate of the current configuration into another one.
  49615. * @param anisotropicConfiguration define the config where to copy the info
  49616. */
  49617. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  49618. /**
  49619. * Serializes this anisotropy configuration.
  49620. * @returns - An object with the serialized config.
  49621. */
  49622. serialize(): any;
  49623. /**
  49624. * Parses a anisotropy Configuration from a serialized object.
  49625. * @param source - Serialized object.
  49626. * @param scene Defines the scene we are parsing for
  49627. * @param rootUrl Defines the rootUrl to load from
  49628. */
  49629. parse(source: any, scene: Scene, rootUrl: string): void;
  49630. }
  49631. }
  49632. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  49633. import { Scene } from "babylonjs/scene";
  49634. /**
  49635. * @hidden
  49636. */
  49637. export interface IMaterialBRDFDefines {
  49638. BRDF_V_HEIGHT_CORRELATED: boolean;
  49639. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49640. SPHERICAL_HARMONICS: boolean;
  49641. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49642. /** @hidden */
  49643. _areMiscDirty: boolean;
  49644. }
  49645. /**
  49646. * Define the code related to the BRDF parameters of the pbr material.
  49647. */
  49648. export class PBRBRDFConfiguration {
  49649. /**
  49650. * Default value used for the energy conservation.
  49651. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49652. */
  49653. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  49654. /**
  49655. * Default value used for the Smith Visibility Height Correlated mode.
  49656. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  49657. */
  49658. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  49659. /**
  49660. * Default value used for the IBL diffuse part.
  49661. * This can help switching back to the polynomials mode globally which is a tiny bit
  49662. * less GPU intensive at the drawback of a lower quality.
  49663. */
  49664. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  49665. /**
  49666. * Default value used for activating energy conservation for the specular workflow.
  49667. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49668. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49669. */
  49670. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  49671. private _useEnergyConservation;
  49672. /**
  49673. * Defines if the material uses energy conservation.
  49674. */
  49675. useEnergyConservation: boolean;
  49676. private _useSmithVisibilityHeightCorrelated;
  49677. /**
  49678. * LEGACY Mode set to false
  49679. * Defines if the material uses height smith correlated visibility term.
  49680. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  49681. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  49682. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  49683. * Not relying on height correlated will also disable energy conservation.
  49684. */
  49685. useSmithVisibilityHeightCorrelated: boolean;
  49686. private _useSphericalHarmonics;
  49687. /**
  49688. * LEGACY Mode set to false
  49689. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  49690. * diffuse part of the IBL.
  49691. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  49692. * to the ground truth.
  49693. */
  49694. useSphericalHarmonics: boolean;
  49695. private _useSpecularGlossinessInputEnergyConservation;
  49696. /**
  49697. * Defines if the material uses energy conservation, when the specular workflow is active.
  49698. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  49699. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  49700. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  49701. */
  49702. useSpecularGlossinessInputEnergyConservation: boolean;
  49703. /** @hidden */
  49704. private _internalMarkAllSubMeshesAsMiscDirty;
  49705. /** @hidden */
  49706. _markAllSubMeshesAsMiscDirty(): void;
  49707. /**
  49708. * Instantiate a new istance of clear coat configuration.
  49709. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  49710. */
  49711. constructor(markAllSubMeshesAsMiscDirty: () => void);
  49712. /**
  49713. * Checks to see if a texture is used in the material.
  49714. * @param defines the list of "defines" to update.
  49715. */
  49716. prepareDefines(defines: IMaterialBRDFDefines): void;
  49717. /**
  49718. * Get the current class name of the texture useful for serialization or dynamic coding.
  49719. * @returns "PBRClearCoatConfiguration"
  49720. */
  49721. getClassName(): string;
  49722. /**
  49723. * Makes a duplicate of the current configuration into another one.
  49724. * @param brdfConfiguration define the config where to copy the info
  49725. */
  49726. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  49727. /**
  49728. * Serializes this BRDF configuration.
  49729. * @returns - An object with the serialized config.
  49730. */
  49731. serialize(): any;
  49732. /**
  49733. * Parses a anisotropy Configuration from a serialized object.
  49734. * @param source - Serialized object.
  49735. * @param scene Defines the scene we are parsing for
  49736. * @param rootUrl Defines the rootUrl to load from
  49737. */
  49738. parse(source: any, scene: Scene, rootUrl: string): void;
  49739. }
  49740. }
  49741. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  49742. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49743. import { Color3 } from "babylonjs/Maths/math.color";
  49744. import { Scene } from "babylonjs/scene";
  49745. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49746. import { Nullable } from "babylonjs/types";
  49747. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49748. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49749. /**
  49750. * @hidden
  49751. */
  49752. export interface IMaterialSheenDefines {
  49753. SHEEN: boolean;
  49754. SHEEN_TEXTURE: boolean;
  49755. SHEEN_TEXTUREDIRECTUV: number;
  49756. SHEEN_LINKWITHALBEDO: boolean;
  49757. /** @hidden */
  49758. _areTexturesDirty: boolean;
  49759. }
  49760. /**
  49761. * Define the code related to the Sheen parameters of the pbr material.
  49762. */
  49763. export class PBRSheenConfiguration {
  49764. private _isEnabled;
  49765. /**
  49766. * Defines if the material uses sheen.
  49767. */
  49768. isEnabled: boolean;
  49769. private _linkSheenWithAlbedo;
  49770. /**
  49771. * Defines if the sheen is linked to the sheen color.
  49772. */
  49773. linkSheenWithAlbedo: boolean;
  49774. /**
  49775. * Defines the sheen intensity.
  49776. */
  49777. intensity: number;
  49778. /**
  49779. * Defines the sheen color.
  49780. */
  49781. color: Color3;
  49782. private _texture;
  49783. /**
  49784. * Stores the sheen tint values in a texture.
  49785. * rgb is tint
  49786. * a is a intensity
  49787. */
  49788. texture: Nullable<BaseTexture>;
  49789. /** @hidden */
  49790. private _internalMarkAllSubMeshesAsTexturesDirty;
  49791. /** @hidden */
  49792. _markAllSubMeshesAsTexturesDirty(): void;
  49793. /**
  49794. * Instantiate a new istance of clear coat configuration.
  49795. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49796. */
  49797. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49798. /**
  49799. * Specifies that the submesh is ready to be used.
  49800. * @param defines the list of "defines" to update.
  49801. * @param scene defines the scene the material belongs to.
  49802. * @returns - boolean indicating that the submesh is ready or not.
  49803. */
  49804. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  49805. /**
  49806. * Checks to see if a texture is used in the material.
  49807. * @param defines the list of "defines" to update.
  49808. * @param scene defines the scene the material belongs to.
  49809. */
  49810. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49811. /**
  49812. * Binds the material data.
  49813. * @param uniformBuffer defines the Uniform buffer to fill in.
  49814. * @param scene defines the scene the material belongs to.
  49815. * @param isFrozen defines wether the material is frozen or not.
  49816. */
  49817. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49818. /**
  49819. * Checks to see if a texture is used in the material.
  49820. * @param texture - Base texture to use.
  49821. * @returns - Boolean specifying if a texture is used in the material.
  49822. */
  49823. hasTexture(texture: BaseTexture): boolean;
  49824. /**
  49825. * Returns an array of the actively used textures.
  49826. * @param activeTextures Array of BaseTextures
  49827. */
  49828. getActiveTextures(activeTextures: BaseTexture[]): void;
  49829. /**
  49830. * Returns the animatable textures.
  49831. * @param animatables Array of animatable textures.
  49832. */
  49833. getAnimatables(animatables: IAnimatable[]): void;
  49834. /**
  49835. * Disposes the resources of the material.
  49836. * @param forceDisposeTextures - Forces the disposal of all textures.
  49837. */
  49838. dispose(forceDisposeTextures?: boolean): void;
  49839. /**
  49840. * Get the current class name of the texture useful for serialization or dynamic coding.
  49841. * @returns "PBRSheenConfiguration"
  49842. */
  49843. getClassName(): string;
  49844. /**
  49845. * Add fallbacks to the effect fallbacks list.
  49846. * @param defines defines the Base texture to use.
  49847. * @param fallbacks defines the current fallback list.
  49848. * @param currentRank defines the current fallback rank.
  49849. * @returns the new fallback rank.
  49850. */
  49851. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49852. /**
  49853. * Add the required uniforms to the current list.
  49854. * @param uniforms defines the current uniform list.
  49855. */
  49856. static AddUniforms(uniforms: string[]): void;
  49857. /**
  49858. * Add the required uniforms to the current buffer.
  49859. * @param uniformBuffer defines the current uniform buffer.
  49860. */
  49861. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49862. /**
  49863. * Add the required samplers to the current list.
  49864. * @param samplers defines the current sampler list.
  49865. */
  49866. static AddSamplers(samplers: string[]): void;
  49867. /**
  49868. * Makes a duplicate of the current configuration into another one.
  49869. * @param sheenConfiguration define the config where to copy the info
  49870. */
  49871. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49872. /**
  49873. * Serializes this BRDF configuration.
  49874. * @returns - An object with the serialized config.
  49875. */
  49876. serialize(): any;
  49877. /**
  49878. * Parses a anisotropy Configuration from a serialized object.
  49879. * @param source - Serialized object.
  49880. * @param scene Defines the scene we are parsing for
  49881. * @param rootUrl Defines the rootUrl to load from
  49882. */
  49883. parse(source: any, scene: Scene, rootUrl: string): void;
  49884. }
  49885. }
  49886. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49887. import { Nullable } from "babylonjs/types";
  49888. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49889. import { Color3 } from "babylonjs/Maths/math.color";
  49890. import { SmartArray } from "babylonjs/Misc/smartArray";
  49891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49892. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49893. import { Effect } from "babylonjs/Materials/effect";
  49894. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49895. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49896. import { Engine } from "babylonjs/Engines/engine";
  49897. import { Scene } from "babylonjs/scene";
  49898. /**
  49899. * @hidden
  49900. */
  49901. export interface IMaterialSubSurfaceDefines {
  49902. SUBSURFACE: boolean;
  49903. SS_REFRACTION: boolean;
  49904. SS_TRANSLUCENCY: boolean;
  49905. SS_SCATERRING: boolean;
  49906. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49907. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49908. SS_REFRACTIONMAP_3D: boolean;
  49909. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49910. SS_LODINREFRACTIONALPHA: boolean;
  49911. SS_GAMMAREFRACTION: boolean;
  49912. SS_RGBDREFRACTION: boolean;
  49913. SS_LINEARSPECULARREFRACTION: boolean;
  49914. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49915. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49916. /** @hidden */
  49917. _areTexturesDirty: boolean;
  49918. }
  49919. /**
  49920. * Define the code related to the sub surface parameters of the pbr material.
  49921. */
  49922. export class PBRSubSurfaceConfiguration {
  49923. private _isRefractionEnabled;
  49924. /**
  49925. * Defines if the refraction is enabled in the material.
  49926. */
  49927. isRefractionEnabled: boolean;
  49928. private _isTranslucencyEnabled;
  49929. /**
  49930. * Defines if the translucency is enabled in the material.
  49931. */
  49932. isTranslucencyEnabled: boolean;
  49933. private _isScatteringEnabled;
  49934. /**
  49935. * Defines the refraction intensity of the material.
  49936. * The refraction when enabled replaces the Diffuse part of the material.
  49937. * The intensity helps transitionning between diffuse and refraction.
  49938. */
  49939. refractionIntensity: number;
  49940. /**
  49941. * Defines the translucency intensity of the material.
  49942. * When translucency has been enabled, this defines how much of the "translucency"
  49943. * is addded to the diffuse part of the material.
  49944. */
  49945. translucencyIntensity: number;
  49946. /**
  49947. * Defines the scattering intensity of the material.
  49948. * When scattering has been enabled, this defines how much of the "scattered light"
  49949. * is addded to the diffuse part of the material.
  49950. */
  49951. scatteringIntensity: number;
  49952. private _thicknessTexture;
  49953. /**
  49954. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49955. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49956. * 0 would mean minimumThickness
  49957. * 1 would mean maximumThickness
  49958. * The other channels might be use as a mask to vary the different effects intensity.
  49959. */
  49960. thicknessTexture: Nullable<BaseTexture>;
  49961. private _refractionTexture;
  49962. /**
  49963. * Defines the texture to use for refraction.
  49964. */
  49965. refractionTexture: Nullable<BaseTexture>;
  49966. private _indexOfRefraction;
  49967. /**
  49968. * Defines the index of refraction used in the material.
  49969. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49970. */
  49971. indexOfRefraction: number;
  49972. private _invertRefractionY;
  49973. /**
  49974. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49975. */
  49976. invertRefractionY: boolean;
  49977. private _linkRefractionWithTransparency;
  49978. /**
  49979. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49980. * Materials half opaque for instance using refraction could benefit from this control.
  49981. */
  49982. linkRefractionWithTransparency: boolean;
  49983. /**
  49984. * Defines the minimum thickness stored in the thickness map.
  49985. * If no thickness map is defined, this value will be used to simulate thickness.
  49986. */
  49987. minimumThickness: number;
  49988. /**
  49989. * Defines the maximum thickness stored in the thickness map.
  49990. */
  49991. maximumThickness: number;
  49992. /**
  49993. * Defines the volume tint of the material.
  49994. * This is used for both translucency and scattering.
  49995. */
  49996. tintColor: Color3;
  49997. /**
  49998. * Defines the distance at which the tint color should be found in the media.
  49999. * This is used for refraction only.
  50000. */
  50001. tintColorAtDistance: number;
  50002. /**
  50003. * Defines how far each channel transmit through the media.
  50004. * It is defined as a color to simplify it selection.
  50005. */
  50006. diffusionDistance: Color3;
  50007. private _useMaskFromThicknessTexture;
  50008. /**
  50009. * Stores the intensity of the different subsurface effects in the thickness texture.
  50010. * * the green channel is the translucency intensity.
  50011. * * the blue channel is the scattering intensity.
  50012. * * the alpha channel is the refraction intensity.
  50013. */
  50014. useMaskFromThicknessTexture: boolean;
  50015. /** @hidden */
  50016. private _internalMarkAllSubMeshesAsTexturesDirty;
  50017. /** @hidden */
  50018. _markAllSubMeshesAsTexturesDirty(): void;
  50019. /**
  50020. * Instantiate a new istance of sub surface configuration.
  50021. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50022. */
  50023. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50024. /**
  50025. * Gets wehter the submesh is ready to be used or not.
  50026. * @param defines the list of "defines" to update.
  50027. * @param scene defines the scene the material belongs to.
  50028. * @returns - boolean indicating that the submesh is ready or not.
  50029. */
  50030. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50031. /**
  50032. * Checks to see if a texture is used in the material.
  50033. * @param defines the list of "defines" to update.
  50034. * @param scene defines the scene to the material belongs to.
  50035. */
  50036. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50037. /**
  50038. * Binds the material data.
  50039. * @param uniformBuffer defines the Uniform buffer to fill in.
  50040. * @param scene defines the scene the material belongs to.
  50041. * @param engine defines the engine the material belongs to.
  50042. * @param isFrozen defines wether the material is frozen or not.
  50043. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50044. */
  50045. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50046. /**
  50047. * Unbinds the material from the mesh.
  50048. * @param activeEffect defines the effect that should be unbound from.
  50049. * @returns true if unbound, otherwise false
  50050. */
  50051. unbind(activeEffect: Effect): boolean;
  50052. /**
  50053. * Returns the texture used for refraction or null if none is used.
  50054. * @param scene defines the scene the material belongs to.
  50055. * @returns - Refraction texture if present. If no refraction texture and refraction
  50056. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50057. */
  50058. private _getRefractionTexture;
  50059. /**
  50060. * Returns true if alpha blending should be disabled.
  50061. */
  50062. readonly disableAlphaBlending: boolean;
  50063. /**
  50064. * Fills the list of render target textures.
  50065. * @param renderTargets the list of render targets to update
  50066. */
  50067. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50068. /**
  50069. * Checks to see if a texture is used in the material.
  50070. * @param texture - Base texture to use.
  50071. * @returns - Boolean specifying if a texture is used in the material.
  50072. */
  50073. hasTexture(texture: BaseTexture): boolean;
  50074. /**
  50075. * Gets a boolean indicating that current material needs to register RTT
  50076. * @returns true if this uses a render target otherwise false.
  50077. */
  50078. hasRenderTargetTextures(): boolean;
  50079. /**
  50080. * Returns an array of the actively used textures.
  50081. * @param activeTextures Array of BaseTextures
  50082. */
  50083. getActiveTextures(activeTextures: BaseTexture[]): void;
  50084. /**
  50085. * Returns the animatable textures.
  50086. * @param animatables Array of animatable textures.
  50087. */
  50088. getAnimatables(animatables: IAnimatable[]): void;
  50089. /**
  50090. * Disposes the resources of the material.
  50091. * @param forceDisposeTextures - Forces the disposal of all textures.
  50092. */
  50093. dispose(forceDisposeTextures?: boolean): void;
  50094. /**
  50095. * Get the current class name of the texture useful for serialization or dynamic coding.
  50096. * @returns "PBRSubSurfaceConfiguration"
  50097. */
  50098. getClassName(): string;
  50099. /**
  50100. * Add fallbacks to the effect fallbacks list.
  50101. * @param defines defines the Base texture to use.
  50102. * @param fallbacks defines the current fallback list.
  50103. * @param currentRank defines the current fallback rank.
  50104. * @returns the new fallback rank.
  50105. */
  50106. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50107. /**
  50108. * Add the required uniforms to the current list.
  50109. * @param uniforms defines the current uniform list.
  50110. */
  50111. static AddUniforms(uniforms: string[]): void;
  50112. /**
  50113. * Add the required samplers to the current list.
  50114. * @param samplers defines the current sampler list.
  50115. */
  50116. static AddSamplers(samplers: string[]): void;
  50117. /**
  50118. * Add the required uniforms to the current buffer.
  50119. * @param uniformBuffer defines the current uniform buffer.
  50120. */
  50121. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50122. /**
  50123. * Makes a duplicate of the current configuration into another one.
  50124. * @param configuration define the config where to copy the info
  50125. */
  50126. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50127. /**
  50128. * Serializes this Sub Surface configuration.
  50129. * @returns - An object with the serialized config.
  50130. */
  50131. serialize(): any;
  50132. /**
  50133. * Parses a anisotropy Configuration from a serialized object.
  50134. * @param source - Serialized object.
  50135. * @param scene Defines the scene we are parsing for
  50136. * @param rootUrl Defines the rootUrl to load from
  50137. */
  50138. parse(source: any, scene: Scene, rootUrl: string): void;
  50139. }
  50140. }
  50141. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  50142. /** @hidden */
  50143. export var pbrFragmentDeclaration: {
  50144. name: string;
  50145. shader: string;
  50146. };
  50147. }
  50148. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  50149. /** @hidden */
  50150. export var pbrUboDeclaration: {
  50151. name: string;
  50152. shader: string;
  50153. };
  50154. }
  50155. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  50156. /** @hidden */
  50157. export var pbrFragmentExtraDeclaration: {
  50158. name: string;
  50159. shader: string;
  50160. };
  50161. }
  50162. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  50163. /** @hidden */
  50164. export var pbrFragmentSamplersDeclaration: {
  50165. name: string;
  50166. shader: string;
  50167. };
  50168. }
  50169. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  50170. /** @hidden */
  50171. export var pbrHelperFunctions: {
  50172. name: string;
  50173. shader: string;
  50174. };
  50175. }
  50176. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  50177. /** @hidden */
  50178. export var harmonicsFunctions: {
  50179. name: string;
  50180. shader: string;
  50181. };
  50182. }
  50183. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  50184. /** @hidden */
  50185. export var pbrDirectLightingSetupFunctions: {
  50186. name: string;
  50187. shader: string;
  50188. };
  50189. }
  50190. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  50191. /** @hidden */
  50192. export var pbrDirectLightingFalloffFunctions: {
  50193. name: string;
  50194. shader: string;
  50195. };
  50196. }
  50197. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  50198. /** @hidden */
  50199. export var pbrBRDFFunctions: {
  50200. name: string;
  50201. shader: string;
  50202. };
  50203. }
  50204. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  50205. /** @hidden */
  50206. export var pbrDirectLightingFunctions: {
  50207. name: string;
  50208. shader: string;
  50209. };
  50210. }
  50211. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  50212. /** @hidden */
  50213. export var pbrIBLFunctions: {
  50214. name: string;
  50215. shader: string;
  50216. };
  50217. }
  50218. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  50219. /** @hidden */
  50220. export var pbrDebug: {
  50221. name: string;
  50222. shader: string;
  50223. };
  50224. }
  50225. declare module "babylonjs/Shaders/pbr.fragment" {
  50226. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  50227. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50228. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  50229. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50230. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50231. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  50232. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50233. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50234. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50235. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50236. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50237. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  50238. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50239. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50240. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50241. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  50242. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  50243. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  50244. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  50245. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  50246. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  50247. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50248. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50249. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  50250. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  50251. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50252. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  50253. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50254. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  50255. /** @hidden */
  50256. export var pbrPixelShader: {
  50257. name: string;
  50258. shader: string;
  50259. };
  50260. }
  50261. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  50262. /** @hidden */
  50263. export var pbrVertexDeclaration: {
  50264. name: string;
  50265. shader: string;
  50266. };
  50267. }
  50268. declare module "babylonjs/Shaders/pbr.vertex" {
  50269. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  50270. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  50271. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50272. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50273. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50274. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  50275. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  50276. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50277. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50278. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50279. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50280. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50281. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50282. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  50283. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50284. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50285. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50286. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  50287. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50288. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50289. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50290. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  50291. /** @hidden */
  50292. export var pbrVertexShader: {
  50293. name: string;
  50294. shader: string;
  50295. };
  50296. }
  50297. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  50298. import { Nullable } from "babylonjs/types";
  50299. import { Scene } from "babylonjs/scene";
  50300. import { Matrix } from "babylonjs/Maths/math.vector";
  50301. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50303. import { Mesh } from "babylonjs/Meshes/mesh";
  50304. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  50305. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  50306. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  50307. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  50308. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  50309. import { Color3 } from "babylonjs/Maths/math.color";
  50310. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  50311. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  50312. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  50313. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50315. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  50316. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  50317. import "babylonjs/Shaders/pbr.fragment";
  50318. import "babylonjs/Shaders/pbr.vertex";
  50319. /**
  50320. * Manages the defines for the PBR Material.
  50321. * @hidden
  50322. */
  50323. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50324. PBR: boolean;
  50325. MAINUV1: boolean;
  50326. MAINUV2: boolean;
  50327. UV1: boolean;
  50328. UV2: boolean;
  50329. ALBEDO: boolean;
  50330. ALBEDODIRECTUV: number;
  50331. VERTEXCOLOR: boolean;
  50332. AMBIENT: boolean;
  50333. AMBIENTDIRECTUV: number;
  50334. AMBIENTINGRAYSCALE: boolean;
  50335. OPACITY: boolean;
  50336. VERTEXALPHA: boolean;
  50337. OPACITYDIRECTUV: number;
  50338. OPACITYRGB: boolean;
  50339. ALPHATEST: boolean;
  50340. DEPTHPREPASS: boolean;
  50341. ALPHABLEND: boolean;
  50342. ALPHAFROMALBEDO: boolean;
  50343. ALPHATESTVALUE: string;
  50344. SPECULAROVERALPHA: boolean;
  50345. RADIANCEOVERALPHA: boolean;
  50346. ALPHAFRESNEL: boolean;
  50347. LINEARALPHAFRESNEL: boolean;
  50348. PREMULTIPLYALPHA: boolean;
  50349. EMISSIVE: boolean;
  50350. EMISSIVEDIRECTUV: number;
  50351. REFLECTIVITY: boolean;
  50352. REFLECTIVITYDIRECTUV: number;
  50353. SPECULARTERM: boolean;
  50354. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50355. MICROSURFACEAUTOMATIC: boolean;
  50356. LODBASEDMICROSFURACE: boolean;
  50357. MICROSURFACEMAP: boolean;
  50358. MICROSURFACEMAPDIRECTUV: number;
  50359. METALLICWORKFLOW: boolean;
  50360. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50361. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50362. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50363. AOSTOREINMETALMAPRED: boolean;
  50364. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50365. ENVIRONMENTBRDF: boolean;
  50366. ENVIRONMENTBRDF_RGBD: boolean;
  50367. NORMAL: boolean;
  50368. TANGENT: boolean;
  50369. BUMP: boolean;
  50370. BUMPDIRECTUV: number;
  50371. OBJECTSPACE_NORMALMAP: boolean;
  50372. PARALLAX: boolean;
  50373. PARALLAXOCCLUSION: boolean;
  50374. NORMALXYSCALE: boolean;
  50375. LIGHTMAP: boolean;
  50376. LIGHTMAPDIRECTUV: number;
  50377. USELIGHTMAPASSHADOWMAP: boolean;
  50378. GAMMALIGHTMAP: boolean;
  50379. RGBDLIGHTMAP: boolean;
  50380. REFLECTION: boolean;
  50381. REFLECTIONMAP_3D: boolean;
  50382. REFLECTIONMAP_SPHERICAL: boolean;
  50383. REFLECTIONMAP_PLANAR: boolean;
  50384. REFLECTIONMAP_CUBIC: boolean;
  50385. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50386. REFLECTIONMAP_PROJECTION: boolean;
  50387. REFLECTIONMAP_SKYBOX: boolean;
  50388. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50389. REFLECTIONMAP_EXPLICIT: boolean;
  50390. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50391. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50392. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50393. INVERTCUBICMAP: boolean;
  50394. USESPHERICALFROMREFLECTIONMAP: boolean;
  50395. USEIRRADIANCEMAP: boolean;
  50396. SPHERICAL_HARMONICS: boolean;
  50397. USESPHERICALINVERTEX: boolean;
  50398. REFLECTIONMAP_OPPOSITEZ: boolean;
  50399. LODINREFLECTIONALPHA: boolean;
  50400. GAMMAREFLECTION: boolean;
  50401. RGBDREFLECTION: boolean;
  50402. LINEARSPECULARREFLECTION: boolean;
  50403. RADIANCEOCCLUSION: boolean;
  50404. HORIZONOCCLUSION: boolean;
  50405. INSTANCES: boolean;
  50406. NUM_BONE_INFLUENCERS: number;
  50407. BonesPerMesh: number;
  50408. BONETEXTURE: boolean;
  50409. NONUNIFORMSCALING: boolean;
  50410. MORPHTARGETS: boolean;
  50411. MORPHTARGETS_NORMAL: boolean;
  50412. MORPHTARGETS_TANGENT: boolean;
  50413. MORPHTARGETS_UV: boolean;
  50414. NUM_MORPH_INFLUENCERS: number;
  50415. IMAGEPROCESSING: boolean;
  50416. VIGNETTE: boolean;
  50417. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50418. VIGNETTEBLENDMODEOPAQUE: boolean;
  50419. TONEMAPPING: boolean;
  50420. TONEMAPPING_ACES: boolean;
  50421. CONTRAST: boolean;
  50422. COLORCURVES: boolean;
  50423. COLORGRADING: boolean;
  50424. COLORGRADING3D: boolean;
  50425. SAMPLER3DGREENDEPTH: boolean;
  50426. SAMPLER3DBGRMAP: boolean;
  50427. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50428. EXPOSURE: boolean;
  50429. MULTIVIEW: boolean;
  50430. USEPHYSICALLIGHTFALLOFF: boolean;
  50431. USEGLTFLIGHTFALLOFF: boolean;
  50432. TWOSIDEDLIGHTING: boolean;
  50433. SHADOWFLOAT: boolean;
  50434. CLIPPLANE: boolean;
  50435. CLIPPLANE2: boolean;
  50436. CLIPPLANE3: boolean;
  50437. CLIPPLANE4: boolean;
  50438. POINTSIZE: boolean;
  50439. FOG: boolean;
  50440. LOGARITHMICDEPTH: boolean;
  50441. FORCENORMALFORWARD: boolean;
  50442. SPECULARAA: boolean;
  50443. CLEARCOAT: boolean;
  50444. CLEARCOAT_DEFAULTIOR: boolean;
  50445. CLEARCOAT_TEXTURE: boolean;
  50446. CLEARCOAT_TEXTUREDIRECTUV: number;
  50447. CLEARCOAT_BUMP: boolean;
  50448. CLEARCOAT_BUMPDIRECTUV: number;
  50449. CLEARCOAT_TINT: boolean;
  50450. CLEARCOAT_TINT_TEXTURE: boolean;
  50451. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50452. ANISOTROPIC: boolean;
  50453. ANISOTROPIC_TEXTURE: boolean;
  50454. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50455. BRDF_V_HEIGHT_CORRELATED: boolean;
  50456. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50457. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50458. SHEEN: boolean;
  50459. SHEEN_TEXTURE: boolean;
  50460. SHEEN_TEXTUREDIRECTUV: number;
  50461. SHEEN_LINKWITHALBEDO: boolean;
  50462. SUBSURFACE: boolean;
  50463. SS_REFRACTION: boolean;
  50464. SS_TRANSLUCENCY: boolean;
  50465. SS_SCATERRING: boolean;
  50466. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50467. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50468. SS_REFRACTIONMAP_3D: boolean;
  50469. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50470. SS_LODINREFRACTIONALPHA: boolean;
  50471. SS_GAMMAREFRACTION: boolean;
  50472. SS_RGBDREFRACTION: boolean;
  50473. SS_LINEARSPECULARREFRACTION: boolean;
  50474. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50475. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50476. UNLIT: boolean;
  50477. DEBUGMODE: number;
  50478. /**
  50479. * Initializes the PBR Material defines.
  50480. */
  50481. constructor();
  50482. /**
  50483. * Resets the PBR Material defines.
  50484. */
  50485. reset(): void;
  50486. }
  50487. /**
  50488. * The Physically based material base class of BJS.
  50489. *
  50490. * This offers the main features of a standard PBR material.
  50491. * For more information, please refer to the documentation :
  50492. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50493. */
  50494. export abstract class PBRBaseMaterial extends PushMaterial {
  50495. /**
  50496. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50497. */
  50498. static readonly PBRMATERIAL_OPAQUE: number;
  50499. /**
  50500. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50501. */
  50502. static readonly PBRMATERIAL_ALPHATEST: number;
  50503. /**
  50504. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50505. */
  50506. static readonly PBRMATERIAL_ALPHABLEND: number;
  50507. /**
  50508. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50509. * They are also discarded below the alpha cutoff threshold to improve performances.
  50510. */
  50511. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50512. /**
  50513. * Defines the default value of how much AO map is occluding the analytical lights
  50514. * (point spot...).
  50515. */
  50516. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50517. /**
  50518. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50519. */
  50520. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50521. /**
  50522. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50523. * to enhance interoperability with other engines.
  50524. */
  50525. static readonly LIGHTFALLOFF_GLTF: number;
  50526. /**
  50527. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50528. * to enhance interoperability with other materials.
  50529. */
  50530. static readonly LIGHTFALLOFF_STANDARD: number;
  50531. /**
  50532. * Intensity of the direct lights e.g. the four lights available in your scene.
  50533. * This impacts both the direct diffuse and specular highlights.
  50534. */
  50535. protected _directIntensity: number;
  50536. /**
  50537. * Intensity of the emissive part of the material.
  50538. * This helps controlling the emissive effect without modifying the emissive color.
  50539. */
  50540. protected _emissiveIntensity: number;
  50541. /**
  50542. * Intensity of the environment e.g. how much the environment will light the object
  50543. * either through harmonics for rough material or through the refelction for shiny ones.
  50544. */
  50545. protected _environmentIntensity: number;
  50546. /**
  50547. * This is a special control allowing the reduction of the specular highlights coming from the
  50548. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50549. */
  50550. protected _specularIntensity: number;
  50551. /**
  50552. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50553. */
  50554. private _lightingInfos;
  50555. /**
  50556. * Debug Control allowing disabling the bump map on this material.
  50557. */
  50558. protected _disableBumpMap: boolean;
  50559. /**
  50560. * AKA Diffuse Texture in standard nomenclature.
  50561. */
  50562. protected _albedoTexture: Nullable<BaseTexture>;
  50563. /**
  50564. * AKA Occlusion Texture in other nomenclature.
  50565. */
  50566. protected _ambientTexture: Nullable<BaseTexture>;
  50567. /**
  50568. * AKA Occlusion Texture Intensity in other nomenclature.
  50569. */
  50570. protected _ambientTextureStrength: number;
  50571. /**
  50572. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50573. * 1 means it completely occludes it
  50574. * 0 mean it has no impact
  50575. */
  50576. protected _ambientTextureImpactOnAnalyticalLights: number;
  50577. /**
  50578. * Stores the alpha values in a texture.
  50579. */
  50580. protected _opacityTexture: Nullable<BaseTexture>;
  50581. /**
  50582. * Stores the reflection values in a texture.
  50583. */
  50584. protected _reflectionTexture: Nullable<BaseTexture>;
  50585. /**
  50586. * Stores the emissive values in a texture.
  50587. */
  50588. protected _emissiveTexture: Nullable<BaseTexture>;
  50589. /**
  50590. * AKA Specular texture in other nomenclature.
  50591. */
  50592. protected _reflectivityTexture: Nullable<BaseTexture>;
  50593. /**
  50594. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50595. */
  50596. protected _metallicTexture: Nullable<BaseTexture>;
  50597. /**
  50598. * Specifies the metallic scalar of the metallic/roughness workflow.
  50599. * Can also be used to scale the metalness values of the metallic texture.
  50600. */
  50601. protected _metallic: Nullable<number>;
  50602. /**
  50603. * Specifies the roughness scalar of the metallic/roughness workflow.
  50604. * Can also be used to scale the roughness values of the metallic texture.
  50605. */
  50606. protected _roughness: Nullable<number>;
  50607. /**
  50608. * Specifies the an F0 factor to help configuring the material F0.
  50609. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  50610. * to 0.5 the previously hard coded value stays the same.
  50611. * Can also be used to scale the F0 values of the metallic texture.
  50612. */
  50613. protected _metallicF0Factor: number;
  50614. /**
  50615. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  50616. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  50617. * your expectation as it multiplies with the texture data.
  50618. */
  50619. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  50620. /**
  50621. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50622. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50623. */
  50624. protected _microSurfaceTexture: Nullable<BaseTexture>;
  50625. /**
  50626. * Stores surface normal data used to displace a mesh in a texture.
  50627. */
  50628. protected _bumpTexture: Nullable<BaseTexture>;
  50629. /**
  50630. * Stores the pre-calculated light information of a mesh in a texture.
  50631. */
  50632. protected _lightmapTexture: Nullable<BaseTexture>;
  50633. /**
  50634. * The color of a material in ambient lighting.
  50635. */
  50636. protected _ambientColor: Color3;
  50637. /**
  50638. * AKA Diffuse Color in other nomenclature.
  50639. */
  50640. protected _albedoColor: Color3;
  50641. /**
  50642. * AKA Specular Color in other nomenclature.
  50643. */
  50644. protected _reflectivityColor: Color3;
  50645. /**
  50646. * The color applied when light is reflected from a material.
  50647. */
  50648. protected _reflectionColor: Color3;
  50649. /**
  50650. * The color applied when light is emitted from a material.
  50651. */
  50652. protected _emissiveColor: Color3;
  50653. /**
  50654. * AKA Glossiness in other nomenclature.
  50655. */
  50656. protected _microSurface: number;
  50657. /**
  50658. * Specifies that the material will use the light map as a show map.
  50659. */
  50660. protected _useLightmapAsShadowmap: boolean;
  50661. /**
  50662. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50663. * makes the reflect vector face the model (under horizon).
  50664. */
  50665. protected _useHorizonOcclusion: boolean;
  50666. /**
  50667. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50668. * too much the area relying on ambient texture to define their ambient occlusion.
  50669. */
  50670. protected _useRadianceOcclusion: boolean;
  50671. /**
  50672. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50673. */
  50674. protected _useAlphaFromAlbedoTexture: boolean;
  50675. /**
  50676. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50677. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50678. */
  50679. protected _useSpecularOverAlpha: boolean;
  50680. /**
  50681. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50682. */
  50683. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50684. /**
  50685. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50686. */
  50687. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  50688. /**
  50689. * Specifies if the metallic texture contains the roughness information in its green channel.
  50690. */
  50691. protected _useRoughnessFromMetallicTextureGreen: boolean;
  50692. /**
  50693. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50694. */
  50695. protected _useMetallnessFromMetallicTextureBlue: boolean;
  50696. /**
  50697. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50698. */
  50699. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  50700. /**
  50701. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50702. */
  50703. protected _useAmbientInGrayScale: boolean;
  50704. /**
  50705. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50706. * The material will try to infer what glossiness each pixel should be.
  50707. */
  50708. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  50709. /**
  50710. * Defines the falloff type used in this material.
  50711. * It by default is Physical.
  50712. */
  50713. protected _lightFalloff: number;
  50714. /**
  50715. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50716. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50717. */
  50718. protected _useRadianceOverAlpha: boolean;
  50719. /**
  50720. * Allows using an object space normal map (instead of tangent space).
  50721. */
  50722. protected _useObjectSpaceNormalMap: boolean;
  50723. /**
  50724. * Allows using the bump map in parallax mode.
  50725. */
  50726. protected _useParallax: boolean;
  50727. /**
  50728. * Allows using the bump map in parallax occlusion mode.
  50729. */
  50730. protected _useParallaxOcclusion: boolean;
  50731. /**
  50732. * Controls the scale bias of the parallax mode.
  50733. */
  50734. protected _parallaxScaleBias: number;
  50735. /**
  50736. * If sets to true, disables all the lights affecting the material.
  50737. */
  50738. protected _disableLighting: boolean;
  50739. /**
  50740. * Number of Simultaneous lights allowed on the material.
  50741. */
  50742. protected _maxSimultaneousLights: number;
  50743. /**
  50744. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50745. */
  50746. protected _invertNormalMapX: boolean;
  50747. /**
  50748. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50749. */
  50750. protected _invertNormalMapY: boolean;
  50751. /**
  50752. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50753. */
  50754. protected _twoSidedLighting: boolean;
  50755. /**
  50756. * Defines the alpha limits in alpha test mode.
  50757. */
  50758. protected _alphaCutOff: number;
  50759. /**
  50760. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50761. */
  50762. protected _forceAlphaTest: boolean;
  50763. /**
  50764. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50765. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50766. */
  50767. protected _useAlphaFresnel: boolean;
  50768. /**
  50769. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50770. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50771. */
  50772. protected _useLinearAlphaFresnel: boolean;
  50773. /**
  50774. * The transparency mode of the material.
  50775. */
  50776. protected _transparencyMode: Nullable<number>;
  50777. /**
  50778. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50779. * from cos thetav and roughness:
  50780. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50781. */
  50782. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  50783. /**
  50784. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50785. */
  50786. protected _forceIrradianceInFragment: boolean;
  50787. /**
  50788. * Force normal to face away from face.
  50789. */
  50790. protected _forceNormalForward: boolean;
  50791. /**
  50792. * Enables specular anti aliasing in the PBR shader.
  50793. * It will both interacts on the Geometry for analytical and IBL lighting.
  50794. * It also prefilter the roughness map based on the bump values.
  50795. */
  50796. protected _enableSpecularAntiAliasing: boolean;
  50797. /**
  50798. * Default configuration related to image processing available in the PBR Material.
  50799. */
  50800. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50801. /**
  50802. * Keep track of the image processing observer to allow dispose and replace.
  50803. */
  50804. private _imageProcessingObserver;
  50805. /**
  50806. * Attaches a new image processing configuration to the PBR Material.
  50807. * @param configuration
  50808. */
  50809. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50810. /**
  50811. * Stores the available render targets.
  50812. */
  50813. private _renderTargets;
  50814. /**
  50815. * Sets the global ambient color for the material used in lighting calculations.
  50816. */
  50817. private _globalAmbientColor;
  50818. /**
  50819. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  50820. */
  50821. private _useLogarithmicDepth;
  50822. /**
  50823. * If set to true, no lighting calculations will be applied.
  50824. */
  50825. private _unlit;
  50826. private _debugMode;
  50827. /**
  50828. * @hidden
  50829. * This is reserved for the inspector.
  50830. * Defines the material debug mode.
  50831. * It helps seeing only some components of the material while troubleshooting.
  50832. */
  50833. debugMode: number;
  50834. /**
  50835. * @hidden
  50836. * This is reserved for the inspector.
  50837. * Specify from where on screen the debug mode should start.
  50838. * The value goes from -1 (full screen) to 1 (not visible)
  50839. * It helps with side by side comparison against the final render
  50840. * This defaults to -1
  50841. */
  50842. private debugLimit;
  50843. /**
  50844. * @hidden
  50845. * This is reserved for the inspector.
  50846. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50847. * You can use the factor to better multiply the final value.
  50848. */
  50849. private debugFactor;
  50850. /**
  50851. * Defines the clear coat layer parameters for the material.
  50852. */
  50853. readonly clearCoat: PBRClearCoatConfiguration;
  50854. /**
  50855. * Defines the anisotropic parameters for the material.
  50856. */
  50857. readonly anisotropy: PBRAnisotropicConfiguration;
  50858. /**
  50859. * Defines the BRDF parameters for the material.
  50860. */
  50861. readonly brdf: PBRBRDFConfiguration;
  50862. /**
  50863. * Defines the Sheen parameters for the material.
  50864. */
  50865. readonly sheen: PBRSheenConfiguration;
  50866. /**
  50867. * Defines the SubSurface parameters for the material.
  50868. */
  50869. readonly subSurface: PBRSubSurfaceConfiguration;
  50870. /**
  50871. * Custom callback helping to override the default shader used in the material.
  50872. */
  50873. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50874. protected _rebuildInParallel: boolean;
  50875. /**
  50876. * Instantiates a new PBRMaterial instance.
  50877. *
  50878. * @param name The material name
  50879. * @param scene The scene the material will be use in.
  50880. */
  50881. constructor(name: string, scene: Scene);
  50882. /**
  50883. * Gets a boolean indicating that current material needs to register RTT
  50884. */
  50885. readonly hasRenderTargetTextures: boolean;
  50886. /**
  50887. * Gets the name of the material class.
  50888. */
  50889. getClassName(): string;
  50890. /**
  50891. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50892. */
  50893. /**
  50894. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50895. */
  50896. useLogarithmicDepth: boolean;
  50897. /**
  50898. * Gets the current transparency mode.
  50899. */
  50900. /**
  50901. * Sets the transparency mode of the material.
  50902. *
  50903. * | Value | Type | Description |
  50904. * | ----- | ----------------------------------- | ----------- |
  50905. * | 0 | OPAQUE | |
  50906. * | 1 | ALPHATEST | |
  50907. * | 2 | ALPHABLEND | |
  50908. * | 3 | ALPHATESTANDBLEND | |
  50909. *
  50910. */
  50911. transparencyMode: Nullable<number>;
  50912. /**
  50913. * Returns true if alpha blending should be disabled.
  50914. */
  50915. private readonly _disableAlphaBlending;
  50916. /**
  50917. * Specifies whether or not this material should be rendered in alpha blend mode.
  50918. */
  50919. needAlphaBlending(): boolean;
  50920. /**
  50921. * Specifies if the mesh will require alpha blending.
  50922. * @param mesh - BJS mesh.
  50923. */
  50924. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50925. /**
  50926. * Specifies whether or not this material should be rendered in alpha test mode.
  50927. */
  50928. needAlphaTesting(): boolean;
  50929. /**
  50930. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50931. */
  50932. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50933. /**
  50934. * Gets the texture used for the alpha test.
  50935. */
  50936. getAlphaTestTexture(): Nullable<BaseTexture>;
  50937. /**
  50938. * Specifies that the submesh is ready to be used.
  50939. * @param mesh - BJS mesh.
  50940. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50941. * @param useInstances - Specifies that instances should be used.
  50942. * @returns - boolean indicating that the submesh is ready or not.
  50943. */
  50944. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50945. /**
  50946. * Specifies if the material uses metallic roughness workflow.
  50947. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50948. */
  50949. isMetallicWorkflow(): boolean;
  50950. private _prepareEffect;
  50951. private _prepareDefines;
  50952. /**
  50953. * Force shader compilation
  50954. */
  50955. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  50956. /**
  50957. * Initializes the uniform buffer layout for the shader.
  50958. */
  50959. buildUniformLayout(): void;
  50960. /**
  50961. * Unbinds the material from the mesh
  50962. */
  50963. unbind(): void;
  50964. /**
  50965. * Binds the submesh data.
  50966. * @param world - The world matrix.
  50967. * @param mesh - The BJS mesh.
  50968. * @param subMesh - A submesh of the BJS mesh.
  50969. */
  50970. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50971. /**
  50972. * Returns the animatable textures.
  50973. * @returns - Array of animatable textures.
  50974. */
  50975. getAnimatables(): IAnimatable[];
  50976. /**
  50977. * Returns the texture used for reflections.
  50978. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50979. */
  50980. private _getReflectionTexture;
  50981. /**
  50982. * Returns an array of the actively used textures.
  50983. * @returns - Array of BaseTextures
  50984. */
  50985. getActiveTextures(): BaseTexture[];
  50986. /**
  50987. * Checks to see if a texture is used in the material.
  50988. * @param texture - Base texture to use.
  50989. * @returns - Boolean specifying if a texture is used in the material.
  50990. */
  50991. hasTexture(texture: BaseTexture): boolean;
  50992. /**
  50993. * Disposes the resources of the material.
  50994. * @param forceDisposeEffect - Forces the disposal of effects.
  50995. * @param forceDisposeTextures - Forces the disposal of all textures.
  50996. */
  50997. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50998. }
  50999. }
  51000. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  51001. import { Nullable } from "babylonjs/types";
  51002. import { Scene } from "babylonjs/scene";
  51003. import { Color3 } from "babylonjs/Maths/math.color";
  51004. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51005. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51006. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51007. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51008. /**
  51009. * The Physically based material of BJS.
  51010. *
  51011. * This offers the main features of a standard PBR material.
  51012. * For more information, please refer to the documentation :
  51013. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51014. */
  51015. export class PBRMaterial extends PBRBaseMaterial {
  51016. /**
  51017. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51018. */
  51019. static readonly PBRMATERIAL_OPAQUE: number;
  51020. /**
  51021. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51022. */
  51023. static readonly PBRMATERIAL_ALPHATEST: number;
  51024. /**
  51025. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51026. */
  51027. static readonly PBRMATERIAL_ALPHABLEND: number;
  51028. /**
  51029. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51030. * They are also discarded below the alpha cutoff threshold to improve performances.
  51031. */
  51032. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51033. /**
  51034. * Defines the default value of how much AO map is occluding the analytical lights
  51035. * (point spot...).
  51036. */
  51037. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51038. /**
  51039. * Intensity of the direct lights e.g. the four lights available in your scene.
  51040. * This impacts both the direct diffuse and specular highlights.
  51041. */
  51042. directIntensity: number;
  51043. /**
  51044. * Intensity of the emissive part of the material.
  51045. * This helps controlling the emissive effect without modifying the emissive color.
  51046. */
  51047. emissiveIntensity: number;
  51048. /**
  51049. * Intensity of the environment e.g. how much the environment will light the object
  51050. * either through harmonics for rough material or through the refelction for shiny ones.
  51051. */
  51052. environmentIntensity: number;
  51053. /**
  51054. * This is a special control allowing the reduction of the specular highlights coming from the
  51055. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51056. */
  51057. specularIntensity: number;
  51058. /**
  51059. * Debug Control allowing disabling the bump map on this material.
  51060. */
  51061. disableBumpMap: boolean;
  51062. /**
  51063. * AKA Diffuse Texture in standard nomenclature.
  51064. */
  51065. albedoTexture: BaseTexture;
  51066. /**
  51067. * AKA Occlusion Texture in other nomenclature.
  51068. */
  51069. ambientTexture: BaseTexture;
  51070. /**
  51071. * AKA Occlusion Texture Intensity in other nomenclature.
  51072. */
  51073. ambientTextureStrength: number;
  51074. /**
  51075. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51076. * 1 means it completely occludes it
  51077. * 0 mean it has no impact
  51078. */
  51079. ambientTextureImpactOnAnalyticalLights: number;
  51080. /**
  51081. * Stores the alpha values in a texture.
  51082. */
  51083. opacityTexture: BaseTexture;
  51084. /**
  51085. * Stores the reflection values in a texture.
  51086. */
  51087. reflectionTexture: Nullable<BaseTexture>;
  51088. /**
  51089. * Stores the emissive values in a texture.
  51090. */
  51091. emissiveTexture: BaseTexture;
  51092. /**
  51093. * AKA Specular texture in other nomenclature.
  51094. */
  51095. reflectivityTexture: BaseTexture;
  51096. /**
  51097. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51098. */
  51099. metallicTexture: BaseTexture;
  51100. /**
  51101. * Specifies the metallic scalar of the metallic/roughness workflow.
  51102. * Can also be used to scale the metalness values of the metallic texture.
  51103. */
  51104. metallic: Nullable<number>;
  51105. /**
  51106. * Specifies the roughness scalar of the metallic/roughness workflow.
  51107. * Can also be used to scale the roughness values of the metallic texture.
  51108. */
  51109. roughness: Nullable<number>;
  51110. /**
  51111. * Specifies the an F0 factor to help configuring the material F0.
  51112. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51113. * to 0.5 the previously hard coded value stays the same.
  51114. * Can also be used to scale the F0 values of the metallic texture.
  51115. */
  51116. metallicF0Factor: number;
  51117. /**
  51118. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51119. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51120. * your expectation as it multiplies with the texture data.
  51121. */
  51122. useMetallicF0FactorFromMetallicTexture: boolean;
  51123. /**
  51124. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51125. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51126. */
  51127. microSurfaceTexture: BaseTexture;
  51128. /**
  51129. * Stores surface normal data used to displace a mesh in a texture.
  51130. */
  51131. bumpTexture: BaseTexture;
  51132. /**
  51133. * Stores the pre-calculated light information of a mesh in a texture.
  51134. */
  51135. lightmapTexture: BaseTexture;
  51136. /**
  51137. * Stores the refracted light information in a texture.
  51138. */
  51139. refractionTexture: Nullable<BaseTexture>;
  51140. /**
  51141. * The color of a material in ambient lighting.
  51142. */
  51143. ambientColor: Color3;
  51144. /**
  51145. * AKA Diffuse Color in other nomenclature.
  51146. */
  51147. albedoColor: Color3;
  51148. /**
  51149. * AKA Specular Color in other nomenclature.
  51150. */
  51151. reflectivityColor: Color3;
  51152. /**
  51153. * The color reflected from the material.
  51154. */
  51155. reflectionColor: Color3;
  51156. /**
  51157. * The color emitted from the material.
  51158. */
  51159. emissiveColor: Color3;
  51160. /**
  51161. * AKA Glossiness in other nomenclature.
  51162. */
  51163. microSurface: number;
  51164. /**
  51165. * source material index of refraction (IOR)' / 'destination material IOR.
  51166. */
  51167. indexOfRefraction: number;
  51168. /**
  51169. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51170. */
  51171. invertRefractionY: boolean;
  51172. /**
  51173. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51174. * Materials half opaque for instance using refraction could benefit from this control.
  51175. */
  51176. linkRefractionWithTransparency: boolean;
  51177. /**
  51178. * If true, the light map contains occlusion information instead of lighting info.
  51179. */
  51180. useLightmapAsShadowmap: boolean;
  51181. /**
  51182. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51183. */
  51184. useAlphaFromAlbedoTexture: boolean;
  51185. /**
  51186. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51187. */
  51188. forceAlphaTest: boolean;
  51189. /**
  51190. * Defines the alpha limits in alpha test mode.
  51191. */
  51192. alphaCutOff: number;
  51193. /**
  51194. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51195. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51196. */
  51197. useSpecularOverAlpha: boolean;
  51198. /**
  51199. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51200. */
  51201. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51202. /**
  51203. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51204. */
  51205. useRoughnessFromMetallicTextureAlpha: boolean;
  51206. /**
  51207. * Specifies if the metallic texture contains the roughness information in its green channel.
  51208. */
  51209. useRoughnessFromMetallicTextureGreen: boolean;
  51210. /**
  51211. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51212. */
  51213. useMetallnessFromMetallicTextureBlue: boolean;
  51214. /**
  51215. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51216. */
  51217. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51218. /**
  51219. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51220. */
  51221. useAmbientInGrayScale: boolean;
  51222. /**
  51223. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51224. * The material will try to infer what glossiness each pixel should be.
  51225. */
  51226. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51227. /**
  51228. * BJS is using an harcoded light falloff based on a manually sets up range.
  51229. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51230. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51231. */
  51232. /**
  51233. * BJS is using an harcoded light falloff based on a manually sets up range.
  51234. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51235. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51236. */
  51237. usePhysicalLightFalloff: boolean;
  51238. /**
  51239. * In order to support the falloff compatibility with gltf, a special mode has been added
  51240. * to reproduce the gltf light falloff.
  51241. */
  51242. /**
  51243. * In order to support the falloff compatibility with gltf, a special mode has been added
  51244. * to reproduce the gltf light falloff.
  51245. */
  51246. useGLTFLightFalloff: boolean;
  51247. /**
  51248. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51249. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51250. */
  51251. useRadianceOverAlpha: boolean;
  51252. /**
  51253. * Allows using an object space normal map (instead of tangent space).
  51254. */
  51255. useObjectSpaceNormalMap: boolean;
  51256. /**
  51257. * Allows using the bump map in parallax mode.
  51258. */
  51259. useParallax: boolean;
  51260. /**
  51261. * Allows using the bump map in parallax occlusion mode.
  51262. */
  51263. useParallaxOcclusion: boolean;
  51264. /**
  51265. * Controls the scale bias of the parallax mode.
  51266. */
  51267. parallaxScaleBias: number;
  51268. /**
  51269. * If sets to true, disables all the lights affecting the material.
  51270. */
  51271. disableLighting: boolean;
  51272. /**
  51273. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51274. */
  51275. forceIrradianceInFragment: boolean;
  51276. /**
  51277. * Number of Simultaneous lights allowed on the material.
  51278. */
  51279. maxSimultaneousLights: number;
  51280. /**
  51281. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51282. */
  51283. invertNormalMapX: boolean;
  51284. /**
  51285. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51286. */
  51287. invertNormalMapY: boolean;
  51288. /**
  51289. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51290. */
  51291. twoSidedLighting: boolean;
  51292. /**
  51293. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51294. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51295. */
  51296. useAlphaFresnel: boolean;
  51297. /**
  51298. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51299. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51300. */
  51301. useLinearAlphaFresnel: boolean;
  51302. /**
  51303. * Let user defines the brdf lookup texture used for IBL.
  51304. * A default 8bit version is embedded but you could point at :
  51305. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51306. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51307. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51308. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51309. */
  51310. environmentBRDFTexture: Nullable<BaseTexture>;
  51311. /**
  51312. * Force normal to face away from face.
  51313. */
  51314. forceNormalForward: boolean;
  51315. /**
  51316. * Enables specular anti aliasing in the PBR shader.
  51317. * It will both interacts on the Geometry for analytical and IBL lighting.
  51318. * It also prefilter the roughness map based on the bump values.
  51319. */
  51320. enableSpecularAntiAliasing: boolean;
  51321. /**
  51322. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51323. * makes the reflect vector face the model (under horizon).
  51324. */
  51325. useHorizonOcclusion: boolean;
  51326. /**
  51327. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51328. * too much the area relying on ambient texture to define their ambient occlusion.
  51329. */
  51330. useRadianceOcclusion: boolean;
  51331. /**
  51332. * If set to true, no lighting calculations will be applied.
  51333. */
  51334. unlit: boolean;
  51335. /**
  51336. * Gets the image processing configuration used either in this material.
  51337. */
  51338. /**
  51339. * Sets the Default image processing configuration used either in the this material.
  51340. *
  51341. * If sets to null, the scene one is in use.
  51342. */
  51343. imageProcessingConfiguration: ImageProcessingConfiguration;
  51344. /**
  51345. * Gets wether the color curves effect is enabled.
  51346. */
  51347. /**
  51348. * Sets wether the color curves effect is enabled.
  51349. */
  51350. cameraColorCurvesEnabled: boolean;
  51351. /**
  51352. * Gets wether the color grading effect is enabled.
  51353. */
  51354. /**
  51355. * Gets wether the color grading effect is enabled.
  51356. */
  51357. cameraColorGradingEnabled: boolean;
  51358. /**
  51359. * Gets wether tonemapping is enabled or not.
  51360. */
  51361. /**
  51362. * Sets wether tonemapping is enabled or not
  51363. */
  51364. cameraToneMappingEnabled: boolean;
  51365. /**
  51366. * The camera exposure used on this material.
  51367. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51368. * This corresponds to a photographic exposure.
  51369. */
  51370. /**
  51371. * The camera exposure used on this material.
  51372. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51373. * This corresponds to a photographic exposure.
  51374. */
  51375. cameraExposure: number;
  51376. /**
  51377. * Gets The camera contrast used on this material.
  51378. */
  51379. /**
  51380. * Sets The camera contrast used on this material.
  51381. */
  51382. cameraContrast: number;
  51383. /**
  51384. * Gets the Color Grading 2D Lookup Texture.
  51385. */
  51386. /**
  51387. * Sets the Color Grading 2D Lookup Texture.
  51388. */
  51389. cameraColorGradingTexture: Nullable<BaseTexture>;
  51390. /**
  51391. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51392. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51393. * 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;
  51394. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51395. */
  51396. /**
  51397. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51398. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51399. * 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;
  51400. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51401. */
  51402. cameraColorCurves: Nullable<ColorCurves>;
  51403. /**
  51404. * Instantiates a new PBRMaterial instance.
  51405. *
  51406. * @param name The material name
  51407. * @param scene The scene the material will be use in.
  51408. */
  51409. constructor(name: string, scene: Scene);
  51410. /**
  51411. * Returns the name of this material class.
  51412. */
  51413. getClassName(): string;
  51414. /**
  51415. * Makes a duplicate of the current material.
  51416. * @param name - name to use for the new material.
  51417. */
  51418. clone(name: string): PBRMaterial;
  51419. /**
  51420. * Serializes this PBR Material.
  51421. * @returns - An object with the serialized material.
  51422. */
  51423. serialize(): any;
  51424. /**
  51425. * Parses a PBR Material from a serialized object.
  51426. * @param source - Serialized object.
  51427. * @param scene - BJS scene instance.
  51428. * @param rootUrl - url for the scene object
  51429. * @returns - PBRMaterial
  51430. */
  51431. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51432. }
  51433. }
  51434. declare module "babylonjs/Misc/dds" {
  51435. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51436. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51437. import { Nullable } from "babylonjs/types";
  51438. import { Scene } from "babylonjs/scene";
  51439. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  51440. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  51441. /**
  51442. * Direct draw surface info
  51443. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51444. */
  51445. export interface DDSInfo {
  51446. /**
  51447. * Width of the texture
  51448. */
  51449. width: number;
  51450. /**
  51451. * Width of the texture
  51452. */
  51453. height: number;
  51454. /**
  51455. * Number of Mipmaps for the texture
  51456. * @see https://en.wikipedia.org/wiki/Mipmap
  51457. */
  51458. mipmapCount: number;
  51459. /**
  51460. * If the textures format is a known fourCC format
  51461. * @see https://www.fourcc.org/
  51462. */
  51463. isFourCC: boolean;
  51464. /**
  51465. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51466. */
  51467. isRGB: boolean;
  51468. /**
  51469. * If the texture is a lumincance format
  51470. */
  51471. isLuminance: boolean;
  51472. /**
  51473. * If this is a cube texture
  51474. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51475. */
  51476. isCube: boolean;
  51477. /**
  51478. * If the texture is a compressed format eg. FOURCC_DXT1
  51479. */
  51480. isCompressed: boolean;
  51481. /**
  51482. * The dxgiFormat of the texture
  51483. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51484. */
  51485. dxgiFormat: number;
  51486. /**
  51487. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51488. */
  51489. textureType: number;
  51490. /**
  51491. * Sphericle polynomial created for the dds texture
  51492. */
  51493. sphericalPolynomial?: SphericalPolynomial;
  51494. }
  51495. /**
  51496. * Class used to provide DDS decompression tools
  51497. */
  51498. export class DDSTools {
  51499. /**
  51500. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51501. */
  51502. static StoreLODInAlphaChannel: boolean;
  51503. /**
  51504. * Gets DDS information from an array buffer
  51505. * @param arrayBuffer defines the array buffer to read data from
  51506. * @returns the DDS information
  51507. */
  51508. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  51509. private static _FloatView;
  51510. private static _Int32View;
  51511. private static _ToHalfFloat;
  51512. private static _FromHalfFloat;
  51513. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51514. private static _GetHalfFloatRGBAArrayBuffer;
  51515. private static _GetFloatRGBAArrayBuffer;
  51516. private static _GetFloatAsUIntRGBAArrayBuffer;
  51517. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51518. private static _GetRGBAArrayBuffer;
  51519. private static _ExtractLongWordOrder;
  51520. private static _GetRGBArrayBuffer;
  51521. private static _GetLuminanceArrayBuffer;
  51522. /**
  51523. * Uploads DDS Levels to a Babylon Texture
  51524. * @hidden
  51525. */
  51526. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51527. }
  51528. module "babylonjs/Engines/thinEngine" {
  51529. interface ThinEngine {
  51530. /**
  51531. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51532. * @param rootUrl defines the url where the file to load is located
  51533. * @param scene defines the current scene
  51534. * @param lodScale defines scale to apply to the mip map selection
  51535. * @param lodOffset defines offset to apply to the mip map selection
  51536. * @param onLoad defines an optional callback raised when the texture is loaded
  51537. * @param onError defines an optional callback raised if there is an issue to load the texture
  51538. * @param format defines the format of the data
  51539. * @param forcedExtension defines the extension to use to pick the right loader
  51540. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51541. * @returns the cube texture as an InternalTexture
  51542. */
  51543. 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;
  51544. }
  51545. }
  51546. }
  51547. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  51548. import { Nullable } from "babylonjs/types";
  51549. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51550. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51551. /**
  51552. * Implementation of the DDS Texture Loader.
  51553. * @hidden
  51554. */
  51555. export class _DDSTextureLoader implements IInternalTextureLoader {
  51556. /**
  51557. * Defines wether the loader supports cascade loading the different faces.
  51558. */
  51559. readonly supportCascades: boolean;
  51560. /**
  51561. * This returns if the loader support the current file information.
  51562. * @param extension defines the file extension of the file being loaded
  51563. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51564. * @param fallback defines the fallback internal texture if any
  51565. * @param isBase64 defines whether the texture is encoded as a base64
  51566. * @param isBuffer defines whether the texture data are stored as a buffer
  51567. * @returns true if the loader can load the specified file
  51568. */
  51569. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51570. /**
  51571. * Transform the url before loading if required.
  51572. * @param rootUrl the url of the texture
  51573. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51574. * @returns the transformed texture
  51575. */
  51576. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51577. /**
  51578. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51579. * @param rootUrl the url of the texture
  51580. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51581. * @returns the fallback texture
  51582. */
  51583. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51584. /**
  51585. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51586. * @param data contains the texture data
  51587. * @param texture defines the BabylonJS internal texture
  51588. * @param createPolynomials will be true if polynomials have been requested
  51589. * @param onLoad defines the callback to trigger once the texture is ready
  51590. * @param onError defines the callback to trigger in case of error
  51591. */
  51592. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51593. /**
  51594. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51595. * @param data contains the texture data
  51596. * @param texture defines the BabylonJS internal texture
  51597. * @param callback defines the method to call once ready to upload
  51598. */
  51599. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51600. }
  51601. }
  51602. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  51603. import { Nullable } from "babylonjs/types";
  51604. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51605. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51606. /**
  51607. * Implementation of the ENV Texture Loader.
  51608. * @hidden
  51609. */
  51610. export class _ENVTextureLoader implements IInternalTextureLoader {
  51611. /**
  51612. * Defines wether the loader supports cascade loading the different faces.
  51613. */
  51614. readonly supportCascades: boolean;
  51615. /**
  51616. * This returns if the loader support the current file information.
  51617. * @param extension defines the file extension of the file being loaded
  51618. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51619. * @param fallback defines the fallback internal texture if any
  51620. * @param isBase64 defines whether the texture is encoded as a base64
  51621. * @param isBuffer defines whether the texture data are stored as a buffer
  51622. * @returns true if the loader can load the specified file
  51623. */
  51624. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51625. /**
  51626. * Transform the url before loading if required.
  51627. * @param rootUrl the url of the texture
  51628. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51629. * @returns the transformed texture
  51630. */
  51631. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51632. /**
  51633. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51634. * @param rootUrl the url of the texture
  51635. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51636. * @returns the fallback texture
  51637. */
  51638. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51639. /**
  51640. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51641. * @param data contains the texture data
  51642. * @param texture defines the BabylonJS internal texture
  51643. * @param createPolynomials will be true if polynomials have been requested
  51644. * @param onLoad defines the callback to trigger once the texture is ready
  51645. * @param onError defines the callback to trigger in case of error
  51646. */
  51647. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51648. /**
  51649. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51650. * @param data contains the texture data
  51651. * @param texture defines the BabylonJS internal texture
  51652. * @param callback defines the method to call once ready to upload
  51653. */
  51654. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51655. }
  51656. }
  51657. declare module "babylonjs/Misc/khronosTextureContainer" {
  51658. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51659. /**
  51660. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51661. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51662. */
  51663. export class KhronosTextureContainer {
  51664. /** contents of the KTX container file */
  51665. arrayBuffer: any;
  51666. private static HEADER_LEN;
  51667. private static COMPRESSED_2D;
  51668. private static COMPRESSED_3D;
  51669. private static TEX_2D;
  51670. private static TEX_3D;
  51671. /**
  51672. * Gets the openGL type
  51673. */
  51674. glType: number;
  51675. /**
  51676. * Gets the openGL type size
  51677. */
  51678. glTypeSize: number;
  51679. /**
  51680. * Gets the openGL format
  51681. */
  51682. glFormat: number;
  51683. /**
  51684. * Gets the openGL internal format
  51685. */
  51686. glInternalFormat: number;
  51687. /**
  51688. * Gets the base internal format
  51689. */
  51690. glBaseInternalFormat: number;
  51691. /**
  51692. * Gets image width in pixel
  51693. */
  51694. pixelWidth: number;
  51695. /**
  51696. * Gets image height in pixel
  51697. */
  51698. pixelHeight: number;
  51699. /**
  51700. * Gets image depth in pixels
  51701. */
  51702. pixelDepth: number;
  51703. /**
  51704. * Gets the number of array elements
  51705. */
  51706. numberOfArrayElements: number;
  51707. /**
  51708. * Gets the number of faces
  51709. */
  51710. numberOfFaces: number;
  51711. /**
  51712. * Gets the number of mipmap levels
  51713. */
  51714. numberOfMipmapLevels: number;
  51715. /**
  51716. * Gets the bytes of key value data
  51717. */
  51718. bytesOfKeyValueData: number;
  51719. /**
  51720. * Gets the load type
  51721. */
  51722. loadType: number;
  51723. /**
  51724. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  51725. */
  51726. isInvalid: boolean;
  51727. /**
  51728. * Creates a new KhronosTextureContainer
  51729. * @param arrayBuffer contents of the KTX container file
  51730. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  51731. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  51732. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  51733. */
  51734. constructor(
  51735. /** contents of the KTX container file */
  51736. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  51737. /**
  51738. * Uploads KTX content to a Babylon Texture.
  51739. * It is assumed that the texture has already been created & is currently bound
  51740. * @hidden
  51741. */
  51742. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  51743. private _upload2DCompressedLevels;
  51744. }
  51745. }
  51746. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  51747. import { Nullable } from "babylonjs/types";
  51748. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51749. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51750. /**
  51751. * Implementation of the KTX Texture Loader.
  51752. * @hidden
  51753. */
  51754. export class _KTXTextureLoader implements IInternalTextureLoader {
  51755. /**
  51756. * Defines wether the loader supports cascade loading the different faces.
  51757. */
  51758. readonly supportCascades: boolean;
  51759. /**
  51760. * This returns if the loader support the current file information.
  51761. * @param extension defines the file extension of the file being loaded
  51762. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51763. * @param fallback defines the fallback internal texture if any
  51764. * @param isBase64 defines whether the texture is encoded as a base64
  51765. * @param isBuffer defines whether the texture data are stored as a buffer
  51766. * @returns true if the loader can load the specified file
  51767. */
  51768. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51769. /**
  51770. * Transform the url before loading if required.
  51771. * @param rootUrl the url of the texture
  51772. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51773. * @returns the transformed texture
  51774. */
  51775. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51776. /**
  51777. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51778. * @param rootUrl the url of the texture
  51779. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51780. * @returns the fallback texture
  51781. */
  51782. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51783. /**
  51784. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51785. * @param data contains the texture data
  51786. * @param texture defines the BabylonJS internal texture
  51787. * @param createPolynomials will be true if polynomials have been requested
  51788. * @param onLoad defines the callback to trigger once the texture is ready
  51789. * @param onError defines the callback to trigger in case of error
  51790. */
  51791. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51792. /**
  51793. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51794. * @param data contains the texture data
  51795. * @param texture defines the BabylonJS internal texture
  51796. * @param callback defines the method to call once ready to upload
  51797. */
  51798. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  51799. }
  51800. }
  51801. declare module "babylonjs/Helpers/sceneHelpers" {
  51802. import { Nullable } from "babylonjs/types";
  51803. import { Mesh } from "babylonjs/Meshes/mesh";
  51804. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51805. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51806. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51807. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51808. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51809. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51810. import "babylonjs/Meshes/Builders/boxBuilder";
  51811. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51812. /** @hidden */
  51813. export var _forceSceneHelpersToBundle: boolean;
  51814. module "babylonjs/scene" {
  51815. interface Scene {
  51816. /**
  51817. * Creates a default light for the scene.
  51818. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51819. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51820. */
  51821. createDefaultLight(replace?: boolean): void;
  51822. /**
  51823. * Creates a default camera for the scene.
  51824. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51825. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51826. * @param replace has default false, when true replaces the active camera in the scene
  51827. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51828. */
  51829. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51830. /**
  51831. * Creates a default camera and a default light.
  51832. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51833. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51834. * @param replace has the default false, when true replaces the active camera/light in the scene
  51835. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51836. */
  51837. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51838. /**
  51839. * Creates a new sky box
  51840. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51841. * @param environmentTexture defines the texture to use as environment texture
  51842. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51843. * @param scale defines the overall scale of the skybox
  51844. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51845. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51846. * @returns a new mesh holding the sky box
  51847. */
  51848. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51849. /**
  51850. * Creates a new environment
  51851. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51852. * @param options defines the options you can use to configure the environment
  51853. * @returns the new EnvironmentHelper
  51854. */
  51855. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51856. /**
  51857. * Creates a new VREXperienceHelper
  51858. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51859. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51860. * @returns a new VREXperienceHelper
  51861. */
  51862. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51863. /**
  51864. * Creates a new WebXRDefaultExperience
  51865. * @see http://doc.babylonjs.com/how_to/webxr
  51866. * @param options experience options
  51867. * @returns a promise for a new WebXRDefaultExperience
  51868. */
  51869. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51870. }
  51871. }
  51872. }
  51873. declare module "babylonjs/Helpers/videoDome" {
  51874. import { Scene } from "babylonjs/scene";
  51875. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51876. import { Mesh } from "babylonjs/Meshes/mesh";
  51877. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51878. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51879. import "babylonjs/Meshes/Builders/sphereBuilder";
  51880. /**
  51881. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51882. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51883. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51884. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51885. */
  51886. export class VideoDome extends TransformNode {
  51887. /**
  51888. * Define the video source as a Monoscopic panoramic 360 video.
  51889. */
  51890. static readonly MODE_MONOSCOPIC: number;
  51891. /**
  51892. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51893. */
  51894. static readonly MODE_TOPBOTTOM: number;
  51895. /**
  51896. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51897. */
  51898. static readonly MODE_SIDEBYSIDE: number;
  51899. private _halfDome;
  51900. private _useDirectMapping;
  51901. /**
  51902. * The video texture being displayed on the sphere
  51903. */
  51904. protected _videoTexture: VideoTexture;
  51905. /**
  51906. * Gets the video texture being displayed on the sphere
  51907. */
  51908. readonly videoTexture: VideoTexture;
  51909. /**
  51910. * The skybox material
  51911. */
  51912. protected _material: BackgroundMaterial;
  51913. /**
  51914. * The surface used for the skybox
  51915. */
  51916. protected _mesh: Mesh;
  51917. /**
  51918. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51919. */
  51920. private _halfDomeMask;
  51921. /**
  51922. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51923. * Also see the options.resolution property.
  51924. */
  51925. fovMultiplier: number;
  51926. private _videoMode;
  51927. /**
  51928. * Gets or set the current video mode for the video. It can be:
  51929. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51930. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51931. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51932. */
  51933. videoMode: number;
  51934. /**
  51935. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51936. *
  51937. */
  51938. /**
  51939. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51940. */
  51941. halfDome: boolean;
  51942. /**
  51943. * Oberserver used in Stereoscopic VR Mode.
  51944. */
  51945. private _onBeforeCameraRenderObserver;
  51946. /**
  51947. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51948. * @param name Element's name, child elements will append suffixes for their own names.
  51949. * @param urlsOrVideo defines the url(s) or the video element to use
  51950. * @param options An object containing optional or exposed sub element properties
  51951. */
  51952. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51953. resolution?: number;
  51954. clickToPlay?: boolean;
  51955. autoPlay?: boolean;
  51956. loop?: boolean;
  51957. size?: number;
  51958. poster?: string;
  51959. faceForward?: boolean;
  51960. useDirectMapping?: boolean;
  51961. halfDomeMode?: boolean;
  51962. }, scene: Scene);
  51963. private _changeVideoMode;
  51964. /**
  51965. * Releases resources associated with this node.
  51966. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51967. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51968. */
  51969. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51970. }
  51971. }
  51972. declare module "babylonjs/Helpers/index" {
  51973. export * from "babylonjs/Helpers/environmentHelper";
  51974. export * from "babylonjs/Helpers/photoDome";
  51975. export * from "babylonjs/Helpers/sceneHelpers";
  51976. export * from "babylonjs/Helpers/videoDome";
  51977. }
  51978. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51979. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51980. import { IDisposable } from "babylonjs/scene";
  51981. import { Engine } from "babylonjs/Engines/engine";
  51982. /**
  51983. * This class can be used to get instrumentation data from a Babylon engine
  51984. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51985. */
  51986. export class EngineInstrumentation implements IDisposable {
  51987. /**
  51988. * Define the instrumented engine.
  51989. */
  51990. engine: Engine;
  51991. private _captureGPUFrameTime;
  51992. private _gpuFrameTimeToken;
  51993. private _gpuFrameTime;
  51994. private _captureShaderCompilationTime;
  51995. private _shaderCompilationTime;
  51996. private _onBeginFrameObserver;
  51997. private _onEndFrameObserver;
  51998. private _onBeforeShaderCompilationObserver;
  51999. private _onAfterShaderCompilationObserver;
  52000. /**
  52001. * Gets the perf counter used for GPU frame time
  52002. */
  52003. readonly gpuFrameTimeCounter: PerfCounter;
  52004. /**
  52005. * Gets the GPU frame time capture status
  52006. */
  52007. /**
  52008. * Enable or disable the GPU frame time capture
  52009. */
  52010. captureGPUFrameTime: boolean;
  52011. /**
  52012. * Gets the perf counter used for shader compilation time
  52013. */
  52014. readonly shaderCompilationTimeCounter: PerfCounter;
  52015. /**
  52016. * Gets the shader compilation time capture status
  52017. */
  52018. /**
  52019. * Enable or disable the shader compilation time capture
  52020. */
  52021. captureShaderCompilationTime: boolean;
  52022. /**
  52023. * Instantiates a new engine instrumentation.
  52024. * This class can be used to get instrumentation data from a Babylon engine
  52025. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52026. * @param engine Defines the engine to instrument
  52027. */
  52028. constructor(
  52029. /**
  52030. * Define the instrumented engine.
  52031. */
  52032. engine: Engine);
  52033. /**
  52034. * Dispose and release associated resources.
  52035. */
  52036. dispose(): void;
  52037. }
  52038. }
  52039. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  52040. import { Scene, IDisposable } from "babylonjs/scene";
  52041. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  52042. /**
  52043. * This class can be used to get instrumentation data from a Babylon engine
  52044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52045. */
  52046. export class SceneInstrumentation implements IDisposable {
  52047. /**
  52048. * Defines the scene to instrument
  52049. */
  52050. scene: Scene;
  52051. private _captureActiveMeshesEvaluationTime;
  52052. private _activeMeshesEvaluationTime;
  52053. private _captureRenderTargetsRenderTime;
  52054. private _renderTargetsRenderTime;
  52055. private _captureFrameTime;
  52056. private _frameTime;
  52057. private _captureRenderTime;
  52058. private _renderTime;
  52059. private _captureInterFrameTime;
  52060. private _interFrameTime;
  52061. private _captureParticlesRenderTime;
  52062. private _particlesRenderTime;
  52063. private _captureSpritesRenderTime;
  52064. private _spritesRenderTime;
  52065. private _capturePhysicsTime;
  52066. private _physicsTime;
  52067. private _captureAnimationsTime;
  52068. private _animationsTime;
  52069. private _captureCameraRenderTime;
  52070. private _cameraRenderTime;
  52071. private _onBeforeActiveMeshesEvaluationObserver;
  52072. private _onAfterActiveMeshesEvaluationObserver;
  52073. private _onBeforeRenderTargetsRenderObserver;
  52074. private _onAfterRenderTargetsRenderObserver;
  52075. private _onAfterRenderObserver;
  52076. private _onBeforeDrawPhaseObserver;
  52077. private _onAfterDrawPhaseObserver;
  52078. private _onBeforeAnimationsObserver;
  52079. private _onBeforeParticlesRenderingObserver;
  52080. private _onAfterParticlesRenderingObserver;
  52081. private _onBeforeSpritesRenderingObserver;
  52082. private _onAfterSpritesRenderingObserver;
  52083. private _onBeforePhysicsObserver;
  52084. private _onAfterPhysicsObserver;
  52085. private _onAfterAnimationsObserver;
  52086. private _onBeforeCameraRenderObserver;
  52087. private _onAfterCameraRenderObserver;
  52088. /**
  52089. * Gets the perf counter used for active meshes evaluation time
  52090. */
  52091. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  52092. /**
  52093. * Gets the active meshes evaluation time capture status
  52094. */
  52095. /**
  52096. * Enable or disable the active meshes evaluation time capture
  52097. */
  52098. captureActiveMeshesEvaluationTime: boolean;
  52099. /**
  52100. * Gets the perf counter used for render targets render time
  52101. */
  52102. readonly renderTargetsRenderTimeCounter: PerfCounter;
  52103. /**
  52104. * Gets the render targets render time capture status
  52105. */
  52106. /**
  52107. * Enable or disable the render targets render time capture
  52108. */
  52109. captureRenderTargetsRenderTime: boolean;
  52110. /**
  52111. * Gets the perf counter used for particles render time
  52112. */
  52113. readonly particlesRenderTimeCounter: PerfCounter;
  52114. /**
  52115. * Gets the particles render time capture status
  52116. */
  52117. /**
  52118. * Enable or disable the particles render time capture
  52119. */
  52120. captureParticlesRenderTime: boolean;
  52121. /**
  52122. * Gets the perf counter used for sprites render time
  52123. */
  52124. readonly spritesRenderTimeCounter: PerfCounter;
  52125. /**
  52126. * Gets the sprites render time capture status
  52127. */
  52128. /**
  52129. * Enable or disable the sprites render time capture
  52130. */
  52131. captureSpritesRenderTime: boolean;
  52132. /**
  52133. * Gets the perf counter used for physics time
  52134. */
  52135. readonly physicsTimeCounter: PerfCounter;
  52136. /**
  52137. * Gets the physics time capture status
  52138. */
  52139. /**
  52140. * Enable or disable the physics time capture
  52141. */
  52142. capturePhysicsTime: boolean;
  52143. /**
  52144. * Gets the perf counter used for animations time
  52145. */
  52146. readonly animationsTimeCounter: PerfCounter;
  52147. /**
  52148. * Gets the animations time capture status
  52149. */
  52150. /**
  52151. * Enable or disable the animations time capture
  52152. */
  52153. captureAnimationsTime: boolean;
  52154. /**
  52155. * Gets the perf counter used for frame time capture
  52156. */
  52157. readonly frameTimeCounter: PerfCounter;
  52158. /**
  52159. * Gets the frame time capture status
  52160. */
  52161. /**
  52162. * Enable or disable the frame time capture
  52163. */
  52164. captureFrameTime: boolean;
  52165. /**
  52166. * Gets the perf counter used for inter-frames time capture
  52167. */
  52168. readonly interFrameTimeCounter: PerfCounter;
  52169. /**
  52170. * Gets the inter-frames time capture status
  52171. */
  52172. /**
  52173. * Enable or disable the inter-frames time capture
  52174. */
  52175. captureInterFrameTime: boolean;
  52176. /**
  52177. * Gets the perf counter used for render time capture
  52178. */
  52179. readonly renderTimeCounter: PerfCounter;
  52180. /**
  52181. * Gets the render time capture status
  52182. */
  52183. /**
  52184. * Enable or disable the render time capture
  52185. */
  52186. captureRenderTime: boolean;
  52187. /**
  52188. * Gets the perf counter used for camera render time capture
  52189. */
  52190. readonly cameraRenderTimeCounter: PerfCounter;
  52191. /**
  52192. * Gets the camera render time capture status
  52193. */
  52194. /**
  52195. * Enable or disable the camera render time capture
  52196. */
  52197. captureCameraRenderTime: boolean;
  52198. /**
  52199. * Gets the perf counter used for draw calls
  52200. */
  52201. readonly drawCallsCounter: PerfCounter;
  52202. /**
  52203. * Instantiates a new scene instrumentation.
  52204. * This class can be used to get instrumentation data from a Babylon engine
  52205. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52206. * @param scene Defines the scene to instrument
  52207. */
  52208. constructor(
  52209. /**
  52210. * Defines the scene to instrument
  52211. */
  52212. scene: Scene);
  52213. /**
  52214. * Dispose and release associated resources.
  52215. */
  52216. dispose(): void;
  52217. }
  52218. }
  52219. declare module "babylonjs/Instrumentation/index" {
  52220. export * from "babylonjs/Instrumentation/engineInstrumentation";
  52221. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  52222. export * from "babylonjs/Instrumentation/timeToken";
  52223. }
  52224. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  52225. /** @hidden */
  52226. export var glowMapGenerationPixelShader: {
  52227. name: string;
  52228. shader: string;
  52229. };
  52230. }
  52231. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  52232. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52233. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52234. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52235. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52236. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52237. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52238. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52239. /** @hidden */
  52240. export var glowMapGenerationVertexShader: {
  52241. name: string;
  52242. shader: string;
  52243. };
  52244. }
  52245. declare module "babylonjs/Layers/effectLayer" {
  52246. import { Observable } from "babylonjs/Misc/observable";
  52247. import { Nullable } from "babylonjs/types";
  52248. import { Camera } from "babylonjs/Cameras/camera";
  52249. import { Scene } from "babylonjs/scene";
  52250. import { ISize } from "babylonjs/Maths/math.size";
  52251. import { Color4 } from "babylonjs/Maths/math.color";
  52252. import { Engine } from "babylonjs/Engines/engine";
  52253. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52255. import { Mesh } from "babylonjs/Meshes/mesh";
  52256. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52257. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52258. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52259. import { Effect } from "babylonjs/Materials/effect";
  52260. import { Material } from "babylonjs/Materials/material";
  52261. import "babylonjs/Shaders/glowMapGeneration.fragment";
  52262. import "babylonjs/Shaders/glowMapGeneration.vertex";
  52263. /**
  52264. * Effect layer options. This helps customizing the behaviour
  52265. * of the effect layer.
  52266. */
  52267. export interface IEffectLayerOptions {
  52268. /**
  52269. * Multiplication factor apply to the canvas size to compute the render target size
  52270. * used to generated the objects (the smaller the faster).
  52271. */
  52272. mainTextureRatio: number;
  52273. /**
  52274. * Enforces a fixed size texture to ensure effect stability across devices.
  52275. */
  52276. mainTextureFixedSize?: number;
  52277. /**
  52278. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52279. */
  52280. alphaBlendingMode: number;
  52281. /**
  52282. * The camera attached to the layer.
  52283. */
  52284. camera: Nullable<Camera>;
  52285. /**
  52286. * The rendering group to draw the layer in.
  52287. */
  52288. renderingGroupId: number;
  52289. }
  52290. /**
  52291. * The effect layer Helps adding post process effect blended with the main pass.
  52292. *
  52293. * This can be for instance use to generate glow or higlight effects on the scene.
  52294. *
  52295. * The effect layer class can not be used directly and is intented to inherited from to be
  52296. * customized per effects.
  52297. */
  52298. export abstract class EffectLayer {
  52299. private _vertexBuffers;
  52300. private _indexBuffer;
  52301. private _cachedDefines;
  52302. private _effectLayerMapGenerationEffect;
  52303. private _effectLayerOptions;
  52304. private _mergeEffect;
  52305. protected _scene: Scene;
  52306. protected _engine: Engine;
  52307. protected _maxSize: number;
  52308. protected _mainTextureDesiredSize: ISize;
  52309. protected _mainTexture: RenderTargetTexture;
  52310. protected _shouldRender: boolean;
  52311. protected _postProcesses: PostProcess[];
  52312. protected _textures: BaseTexture[];
  52313. protected _emissiveTextureAndColor: {
  52314. texture: Nullable<BaseTexture>;
  52315. color: Color4;
  52316. };
  52317. /**
  52318. * The name of the layer
  52319. */
  52320. name: string;
  52321. /**
  52322. * The clear color of the texture used to generate the glow map.
  52323. */
  52324. neutralColor: Color4;
  52325. /**
  52326. * Specifies wether the highlight layer is enabled or not.
  52327. */
  52328. isEnabled: boolean;
  52329. /**
  52330. * Gets the camera attached to the layer.
  52331. */
  52332. readonly camera: Nullable<Camera>;
  52333. /**
  52334. * Gets the rendering group id the layer should render in.
  52335. */
  52336. renderingGroupId: number;
  52337. /**
  52338. * An event triggered when the effect layer has been disposed.
  52339. */
  52340. onDisposeObservable: Observable<EffectLayer>;
  52341. /**
  52342. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52343. */
  52344. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52345. /**
  52346. * An event triggered when the generated texture is being merged in the scene.
  52347. */
  52348. onBeforeComposeObservable: Observable<EffectLayer>;
  52349. /**
  52350. * An event triggered when the mesh is rendered into the effect render target.
  52351. */
  52352. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52353. /**
  52354. * An event triggered after the mesh has been rendered into the effect render target.
  52355. */
  52356. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52357. /**
  52358. * An event triggered when the generated texture has been merged in the scene.
  52359. */
  52360. onAfterComposeObservable: Observable<EffectLayer>;
  52361. /**
  52362. * An event triggered when the efffect layer changes its size.
  52363. */
  52364. onSizeChangedObservable: Observable<EffectLayer>;
  52365. /** @hidden */
  52366. static _SceneComponentInitialization: (scene: Scene) => void;
  52367. /**
  52368. * Instantiates a new effect Layer and references it in the scene.
  52369. * @param name The name of the layer
  52370. * @param scene The scene to use the layer in
  52371. */
  52372. constructor(
  52373. /** The Friendly of the effect in the scene */
  52374. name: string, scene: Scene);
  52375. /**
  52376. * Get the effect name of the layer.
  52377. * @return The effect name
  52378. */
  52379. abstract getEffectName(): string;
  52380. /**
  52381. * Checks for the readiness of the element composing the layer.
  52382. * @param subMesh the mesh to check for
  52383. * @param useInstances specify wether or not to use instances to render the mesh
  52384. * @return true if ready otherwise, false
  52385. */
  52386. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52387. /**
  52388. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52389. * @returns true if the effect requires stencil during the main canvas render pass.
  52390. */
  52391. abstract needStencil(): boolean;
  52392. /**
  52393. * Create the merge effect. This is the shader use to blit the information back
  52394. * to the main canvas at the end of the scene rendering.
  52395. * @returns The effect containing the shader used to merge the effect on the main canvas
  52396. */
  52397. protected abstract _createMergeEffect(): Effect;
  52398. /**
  52399. * Creates the render target textures and post processes used in the effect layer.
  52400. */
  52401. protected abstract _createTextureAndPostProcesses(): void;
  52402. /**
  52403. * Implementation specific of rendering the generating effect on the main canvas.
  52404. * @param effect The effect used to render through
  52405. */
  52406. protected abstract _internalRender(effect: Effect): void;
  52407. /**
  52408. * Sets the required values for both the emissive texture and and the main color.
  52409. */
  52410. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52411. /**
  52412. * Free any resources and references associated to a mesh.
  52413. * Internal use
  52414. * @param mesh The mesh to free.
  52415. */
  52416. abstract _disposeMesh(mesh: Mesh): void;
  52417. /**
  52418. * Serializes this layer (Glow or Highlight for example)
  52419. * @returns a serialized layer object
  52420. */
  52421. abstract serialize?(): any;
  52422. /**
  52423. * Initializes the effect layer with the required options.
  52424. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52425. */
  52426. protected _init(options: Partial<IEffectLayerOptions>): void;
  52427. /**
  52428. * Generates the index buffer of the full screen quad blending to the main canvas.
  52429. */
  52430. private _generateIndexBuffer;
  52431. /**
  52432. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52433. */
  52434. private _generateVertexBuffer;
  52435. /**
  52436. * Sets the main texture desired size which is the closest power of two
  52437. * of the engine canvas size.
  52438. */
  52439. private _setMainTextureSize;
  52440. /**
  52441. * Creates the main texture for the effect layer.
  52442. */
  52443. protected _createMainTexture(): void;
  52444. /**
  52445. * Adds specific effects defines.
  52446. * @param defines The defines to add specifics to.
  52447. */
  52448. protected _addCustomEffectDefines(defines: string[]): void;
  52449. /**
  52450. * Checks for the readiness of the element composing the layer.
  52451. * @param subMesh the mesh to check for
  52452. * @param useInstances specify wether or not to use instances to render the mesh
  52453. * @param emissiveTexture the associated emissive texture used to generate the glow
  52454. * @return true if ready otherwise, false
  52455. */
  52456. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52457. /**
  52458. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52459. */
  52460. render(): void;
  52461. /**
  52462. * Determine if a given mesh will be used in the current effect.
  52463. * @param mesh mesh to test
  52464. * @returns true if the mesh will be used
  52465. */
  52466. hasMesh(mesh: AbstractMesh): boolean;
  52467. /**
  52468. * Returns true if the layer contains information to display, otherwise false.
  52469. * @returns true if the glow layer should be rendered
  52470. */
  52471. shouldRender(): boolean;
  52472. /**
  52473. * Returns true if the mesh should render, otherwise false.
  52474. * @param mesh The mesh to render
  52475. * @returns true if it should render otherwise false
  52476. */
  52477. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52478. /**
  52479. * Returns true if the mesh can be rendered, otherwise false.
  52480. * @param mesh The mesh to render
  52481. * @param material The material used on the mesh
  52482. * @returns true if it can be rendered otherwise false
  52483. */
  52484. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52485. /**
  52486. * Returns true if the mesh should render, otherwise false.
  52487. * @param mesh The mesh to render
  52488. * @returns true if it should render otherwise false
  52489. */
  52490. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52491. /**
  52492. * Renders the submesh passed in parameter to the generation map.
  52493. */
  52494. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52495. /**
  52496. * Defines wether the current material of the mesh should be use to render the effect.
  52497. * @param mesh defines the current mesh to render
  52498. */
  52499. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52500. /**
  52501. * Rebuild the required buffers.
  52502. * @hidden Internal use only.
  52503. */
  52504. _rebuild(): void;
  52505. /**
  52506. * Dispose only the render target textures and post process.
  52507. */
  52508. private _disposeTextureAndPostProcesses;
  52509. /**
  52510. * Dispose the highlight layer and free resources.
  52511. */
  52512. dispose(): void;
  52513. /**
  52514. * Gets the class name of the effect layer
  52515. * @returns the string with the class name of the effect layer
  52516. */
  52517. getClassName(): string;
  52518. /**
  52519. * Creates an effect layer from parsed effect layer data
  52520. * @param parsedEffectLayer defines effect layer data
  52521. * @param scene defines the current scene
  52522. * @param rootUrl defines the root URL containing the effect layer information
  52523. * @returns a parsed effect Layer
  52524. */
  52525. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52526. }
  52527. }
  52528. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  52529. import { Scene } from "babylonjs/scene";
  52530. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52531. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52532. import { AbstractScene } from "babylonjs/abstractScene";
  52533. module "babylonjs/abstractScene" {
  52534. interface AbstractScene {
  52535. /**
  52536. * The list of effect layers (highlights/glow) added to the scene
  52537. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52538. * @see http://doc.babylonjs.com/how_to/glow_layer
  52539. */
  52540. effectLayers: Array<EffectLayer>;
  52541. /**
  52542. * Removes the given effect layer from this scene.
  52543. * @param toRemove defines the effect layer to remove
  52544. * @returns the index of the removed effect layer
  52545. */
  52546. removeEffectLayer(toRemove: EffectLayer): number;
  52547. /**
  52548. * Adds the given effect layer to this scene
  52549. * @param newEffectLayer defines the effect layer to add
  52550. */
  52551. addEffectLayer(newEffectLayer: EffectLayer): void;
  52552. }
  52553. }
  52554. /**
  52555. * Defines the layer scene component responsible to manage any effect layers
  52556. * in a given scene.
  52557. */
  52558. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52559. /**
  52560. * The component name helpfull to identify the component in the list of scene components.
  52561. */
  52562. readonly name: string;
  52563. /**
  52564. * The scene the component belongs to.
  52565. */
  52566. scene: Scene;
  52567. private _engine;
  52568. private _renderEffects;
  52569. private _needStencil;
  52570. private _previousStencilState;
  52571. /**
  52572. * Creates a new instance of the component for the given scene
  52573. * @param scene Defines the scene to register the component in
  52574. */
  52575. constructor(scene: Scene);
  52576. /**
  52577. * Registers the component in a given scene
  52578. */
  52579. register(): void;
  52580. /**
  52581. * Rebuilds the elements related to this component in case of
  52582. * context lost for instance.
  52583. */
  52584. rebuild(): void;
  52585. /**
  52586. * Serializes the component data to the specified json object
  52587. * @param serializationObject The object to serialize to
  52588. */
  52589. serialize(serializationObject: any): void;
  52590. /**
  52591. * Adds all the elements from the container to the scene
  52592. * @param container the container holding the elements
  52593. */
  52594. addFromContainer(container: AbstractScene): void;
  52595. /**
  52596. * Removes all the elements in the container from the scene
  52597. * @param container contains the elements to remove
  52598. * @param dispose if the removed element should be disposed (default: false)
  52599. */
  52600. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52601. /**
  52602. * Disposes the component and the associated ressources.
  52603. */
  52604. dispose(): void;
  52605. private _isReadyForMesh;
  52606. private _renderMainTexture;
  52607. private _setStencil;
  52608. private _setStencilBack;
  52609. private _draw;
  52610. private _drawCamera;
  52611. private _drawRenderingGroup;
  52612. }
  52613. }
  52614. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  52615. /** @hidden */
  52616. export var glowMapMergePixelShader: {
  52617. name: string;
  52618. shader: string;
  52619. };
  52620. }
  52621. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  52622. /** @hidden */
  52623. export var glowMapMergeVertexShader: {
  52624. name: string;
  52625. shader: string;
  52626. };
  52627. }
  52628. declare module "babylonjs/Layers/glowLayer" {
  52629. import { Nullable } from "babylonjs/types";
  52630. import { Camera } from "babylonjs/Cameras/camera";
  52631. import { Scene } from "babylonjs/scene";
  52632. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52634. import { Mesh } from "babylonjs/Meshes/mesh";
  52635. import { Texture } from "babylonjs/Materials/Textures/texture";
  52636. import { Effect } from "babylonjs/Materials/effect";
  52637. import { Material } from "babylonjs/Materials/material";
  52638. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52639. import { Color4 } from "babylonjs/Maths/math.color";
  52640. import "babylonjs/Shaders/glowMapMerge.fragment";
  52641. import "babylonjs/Shaders/glowMapMerge.vertex";
  52642. import "babylonjs/Layers/effectLayerSceneComponent";
  52643. module "babylonjs/abstractScene" {
  52644. interface AbstractScene {
  52645. /**
  52646. * Return a the first highlight layer of the scene with a given name.
  52647. * @param name The name of the highlight layer to look for.
  52648. * @return The highlight layer if found otherwise null.
  52649. */
  52650. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  52651. }
  52652. }
  52653. /**
  52654. * Glow layer options. This helps customizing the behaviour
  52655. * of the glow layer.
  52656. */
  52657. export interface IGlowLayerOptions {
  52658. /**
  52659. * Multiplication factor apply to the canvas size to compute the render target size
  52660. * used to generated the glowing objects (the smaller the faster).
  52661. */
  52662. mainTextureRatio: number;
  52663. /**
  52664. * Enforces a fixed size texture to ensure resize independant blur.
  52665. */
  52666. mainTextureFixedSize?: number;
  52667. /**
  52668. * How big is the kernel of the blur texture.
  52669. */
  52670. blurKernelSize: number;
  52671. /**
  52672. * The camera attached to the layer.
  52673. */
  52674. camera: Nullable<Camera>;
  52675. /**
  52676. * Enable MSAA by chosing the number of samples.
  52677. */
  52678. mainTextureSamples?: number;
  52679. /**
  52680. * The rendering group to draw the layer in.
  52681. */
  52682. renderingGroupId: number;
  52683. }
  52684. /**
  52685. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  52686. *
  52687. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  52688. *
  52689. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  52690. */
  52691. export class GlowLayer extends EffectLayer {
  52692. /**
  52693. * Effect Name of the layer.
  52694. */
  52695. static readonly EffectName: string;
  52696. /**
  52697. * The default blur kernel size used for the glow.
  52698. */
  52699. static DefaultBlurKernelSize: number;
  52700. /**
  52701. * The default texture size ratio used for the glow.
  52702. */
  52703. static DefaultTextureRatio: number;
  52704. /**
  52705. * Sets the kernel size of the blur.
  52706. */
  52707. /**
  52708. * Gets the kernel size of the blur.
  52709. */
  52710. blurKernelSize: number;
  52711. /**
  52712. * Sets the glow intensity.
  52713. */
  52714. /**
  52715. * Gets the glow intensity.
  52716. */
  52717. intensity: number;
  52718. private _options;
  52719. private _intensity;
  52720. private _horizontalBlurPostprocess1;
  52721. private _verticalBlurPostprocess1;
  52722. private _horizontalBlurPostprocess2;
  52723. private _verticalBlurPostprocess2;
  52724. private _blurTexture1;
  52725. private _blurTexture2;
  52726. private _postProcesses1;
  52727. private _postProcesses2;
  52728. private _includedOnlyMeshes;
  52729. private _excludedMeshes;
  52730. private _meshesUsingTheirOwnMaterials;
  52731. /**
  52732. * Callback used to let the user override the color selection on a per mesh basis
  52733. */
  52734. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  52735. /**
  52736. * Callback used to let the user override the texture selection on a per mesh basis
  52737. */
  52738. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  52739. /**
  52740. * Instantiates a new glow Layer and references it to the scene.
  52741. * @param name The name of the layer
  52742. * @param scene The scene to use the layer in
  52743. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  52744. */
  52745. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  52746. /**
  52747. * Get the effect name of the layer.
  52748. * @return The effect name
  52749. */
  52750. getEffectName(): string;
  52751. /**
  52752. * Create the merge effect. This is the shader use to blit the information back
  52753. * to the main canvas at the end of the scene rendering.
  52754. */
  52755. protected _createMergeEffect(): Effect;
  52756. /**
  52757. * Creates the render target textures and post processes used in the glow layer.
  52758. */
  52759. protected _createTextureAndPostProcesses(): void;
  52760. /**
  52761. * Checks for the readiness of the element composing the layer.
  52762. * @param subMesh the mesh to check for
  52763. * @param useInstances specify wether or not to use instances to render the mesh
  52764. * @param emissiveTexture the associated emissive texture used to generate the glow
  52765. * @return true if ready otherwise, false
  52766. */
  52767. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52768. /**
  52769. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52770. */
  52771. needStencil(): boolean;
  52772. /**
  52773. * Returns true if the mesh can be rendered, otherwise false.
  52774. * @param mesh The mesh to render
  52775. * @param material The material used on the mesh
  52776. * @returns true if it can be rendered otherwise false
  52777. */
  52778. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52779. /**
  52780. * Implementation specific of rendering the generating effect on the main canvas.
  52781. * @param effect The effect used to render through
  52782. */
  52783. protected _internalRender(effect: Effect): void;
  52784. /**
  52785. * Sets the required values for both the emissive texture and and the main color.
  52786. */
  52787. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52788. /**
  52789. * Returns true if the mesh should render, otherwise false.
  52790. * @param mesh The mesh to render
  52791. * @returns true if it should render otherwise false
  52792. */
  52793. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52794. /**
  52795. * Adds specific effects defines.
  52796. * @param defines The defines to add specifics to.
  52797. */
  52798. protected _addCustomEffectDefines(defines: string[]): void;
  52799. /**
  52800. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52801. * @param mesh The mesh to exclude from the glow layer
  52802. */
  52803. addExcludedMesh(mesh: Mesh): void;
  52804. /**
  52805. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52806. * @param mesh The mesh to remove
  52807. */
  52808. removeExcludedMesh(mesh: Mesh): void;
  52809. /**
  52810. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52811. * @param mesh The mesh to include in the glow layer
  52812. */
  52813. addIncludedOnlyMesh(mesh: Mesh): void;
  52814. /**
  52815. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52816. * @param mesh The mesh to remove
  52817. */
  52818. removeIncludedOnlyMesh(mesh: Mesh): void;
  52819. /**
  52820. * Determine if a given mesh will be used in the glow layer
  52821. * @param mesh The mesh to test
  52822. * @returns true if the mesh will be highlighted by the current glow layer
  52823. */
  52824. hasMesh(mesh: AbstractMesh): boolean;
  52825. /**
  52826. * Defines wether the current material of the mesh should be use to render the effect.
  52827. * @param mesh defines the current mesh to render
  52828. */
  52829. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52830. /**
  52831. * Add a mesh to be rendered through its own material and not with emissive only.
  52832. * @param mesh The mesh for which we need to use its material
  52833. */
  52834. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  52835. /**
  52836. * Remove a mesh from being rendered through its own material and not with emissive only.
  52837. * @param mesh The mesh for which we need to not use its material
  52838. */
  52839. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  52840. /**
  52841. * Free any resources and references associated to a mesh.
  52842. * Internal use
  52843. * @param mesh The mesh to free.
  52844. * @hidden
  52845. */
  52846. _disposeMesh(mesh: Mesh): void;
  52847. /**
  52848. * Gets the class name of the effect layer
  52849. * @returns the string with the class name of the effect layer
  52850. */
  52851. getClassName(): string;
  52852. /**
  52853. * Serializes this glow layer
  52854. * @returns a serialized glow layer object
  52855. */
  52856. serialize(): any;
  52857. /**
  52858. * Creates a Glow Layer from parsed glow layer data
  52859. * @param parsedGlowLayer defines glow layer data
  52860. * @param scene defines the current scene
  52861. * @param rootUrl defines the root URL containing the glow layer information
  52862. * @returns a parsed Glow Layer
  52863. */
  52864. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52865. }
  52866. }
  52867. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52868. /** @hidden */
  52869. export var glowBlurPostProcessPixelShader: {
  52870. name: string;
  52871. shader: string;
  52872. };
  52873. }
  52874. declare module "babylonjs/Layers/highlightLayer" {
  52875. import { Observable } from "babylonjs/Misc/observable";
  52876. import { Nullable } from "babylonjs/types";
  52877. import { Camera } from "babylonjs/Cameras/camera";
  52878. import { Scene } from "babylonjs/scene";
  52879. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52881. import { Mesh } from "babylonjs/Meshes/mesh";
  52882. import { Effect } from "babylonjs/Materials/effect";
  52883. import { Material } from "babylonjs/Materials/material";
  52884. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52885. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52886. import "babylonjs/Shaders/glowMapMerge.fragment";
  52887. import "babylonjs/Shaders/glowMapMerge.vertex";
  52888. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52889. module "babylonjs/abstractScene" {
  52890. interface AbstractScene {
  52891. /**
  52892. * Return a the first highlight layer of the scene with a given name.
  52893. * @param name The name of the highlight layer to look for.
  52894. * @return The highlight layer if found otherwise null.
  52895. */
  52896. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52897. }
  52898. }
  52899. /**
  52900. * Highlight layer options. This helps customizing the behaviour
  52901. * of the highlight layer.
  52902. */
  52903. export interface IHighlightLayerOptions {
  52904. /**
  52905. * Multiplication factor apply to the canvas size to compute the render target size
  52906. * used to generated the glowing objects (the smaller the faster).
  52907. */
  52908. mainTextureRatio: number;
  52909. /**
  52910. * Enforces a fixed size texture to ensure resize independant blur.
  52911. */
  52912. mainTextureFixedSize?: number;
  52913. /**
  52914. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52915. * of the picture to blur (the smaller the faster).
  52916. */
  52917. blurTextureSizeRatio: number;
  52918. /**
  52919. * How big in texel of the blur texture is the vertical blur.
  52920. */
  52921. blurVerticalSize: number;
  52922. /**
  52923. * How big in texel of the blur texture is the horizontal blur.
  52924. */
  52925. blurHorizontalSize: number;
  52926. /**
  52927. * Alpha blending mode used to apply the blur. Default is combine.
  52928. */
  52929. alphaBlendingMode: number;
  52930. /**
  52931. * The camera attached to the layer.
  52932. */
  52933. camera: Nullable<Camera>;
  52934. /**
  52935. * Should we display highlight as a solid stroke?
  52936. */
  52937. isStroke?: boolean;
  52938. /**
  52939. * The rendering group to draw the layer in.
  52940. */
  52941. renderingGroupId: number;
  52942. }
  52943. /**
  52944. * The highlight layer Helps adding a glow effect around a mesh.
  52945. *
  52946. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  52947. * glowy meshes to your scene.
  52948. *
  52949. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52950. */
  52951. export class HighlightLayer extends EffectLayer {
  52952. name: string;
  52953. /**
  52954. * Effect Name of the highlight layer.
  52955. */
  52956. static readonly EffectName: string;
  52957. /**
  52958. * The neutral color used during the preparation of the glow effect.
  52959. * This is black by default as the blend operation is a blend operation.
  52960. */
  52961. static NeutralColor: Color4;
  52962. /**
  52963. * Stencil value used for glowing meshes.
  52964. */
  52965. static GlowingMeshStencilReference: number;
  52966. /**
  52967. * Stencil value used for the other meshes in the scene.
  52968. */
  52969. static NormalMeshStencilReference: number;
  52970. /**
  52971. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52972. */
  52973. innerGlow: boolean;
  52974. /**
  52975. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52976. */
  52977. outerGlow: boolean;
  52978. /**
  52979. * Specifies the horizontal size of the blur.
  52980. */
  52981. /**
  52982. * Gets the horizontal size of the blur.
  52983. */
  52984. blurHorizontalSize: number;
  52985. /**
  52986. * Specifies the vertical size of the blur.
  52987. */
  52988. /**
  52989. * Gets the vertical size of the blur.
  52990. */
  52991. blurVerticalSize: number;
  52992. /**
  52993. * An event triggered when the highlight layer is being blurred.
  52994. */
  52995. onBeforeBlurObservable: Observable<HighlightLayer>;
  52996. /**
  52997. * An event triggered when the highlight layer has been blurred.
  52998. */
  52999. onAfterBlurObservable: Observable<HighlightLayer>;
  53000. private _instanceGlowingMeshStencilReference;
  53001. private _options;
  53002. private _downSamplePostprocess;
  53003. private _horizontalBlurPostprocess;
  53004. private _verticalBlurPostprocess;
  53005. private _blurTexture;
  53006. private _meshes;
  53007. private _excludedMeshes;
  53008. /**
  53009. * Instantiates a new highlight Layer and references it to the scene..
  53010. * @param name The name of the layer
  53011. * @param scene The scene to use the layer in
  53012. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53013. */
  53014. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53015. /**
  53016. * Get the effect name of the layer.
  53017. * @return The effect name
  53018. */
  53019. getEffectName(): string;
  53020. /**
  53021. * Create the merge effect. This is the shader use to blit the information back
  53022. * to the main canvas at the end of the scene rendering.
  53023. */
  53024. protected _createMergeEffect(): Effect;
  53025. /**
  53026. * Creates the render target textures and post processes used in the highlight layer.
  53027. */
  53028. protected _createTextureAndPostProcesses(): void;
  53029. /**
  53030. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53031. */
  53032. needStencil(): boolean;
  53033. /**
  53034. * Checks for the readiness of the element composing the layer.
  53035. * @param subMesh the mesh to check for
  53036. * @param useInstances specify wether or not to use instances to render the mesh
  53037. * @param emissiveTexture the associated emissive texture used to generate the glow
  53038. * @return true if ready otherwise, false
  53039. */
  53040. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53041. /**
  53042. * Implementation specific of rendering the generating effect on the main canvas.
  53043. * @param effect The effect used to render through
  53044. */
  53045. protected _internalRender(effect: Effect): void;
  53046. /**
  53047. * Returns true if the layer contains information to display, otherwise false.
  53048. */
  53049. shouldRender(): boolean;
  53050. /**
  53051. * Returns true if the mesh should render, otherwise false.
  53052. * @param mesh The mesh to render
  53053. * @returns true if it should render otherwise false
  53054. */
  53055. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53056. /**
  53057. * Sets the required values for both the emissive texture and and the main color.
  53058. */
  53059. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53060. /**
  53061. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53062. * @param mesh The mesh to exclude from the highlight layer
  53063. */
  53064. addExcludedMesh(mesh: Mesh): void;
  53065. /**
  53066. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53067. * @param mesh The mesh to highlight
  53068. */
  53069. removeExcludedMesh(mesh: Mesh): void;
  53070. /**
  53071. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53072. * @param mesh mesh to test
  53073. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53074. */
  53075. hasMesh(mesh: AbstractMesh): boolean;
  53076. /**
  53077. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53078. * @param mesh The mesh to highlight
  53079. * @param color The color of the highlight
  53080. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53081. */
  53082. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53083. /**
  53084. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53085. * @param mesh The mesh to highlight
  53086. */
  53087. removeMesh(mesh: Mesh): void;
  53088. /**
  53089. * Force the stencil to the normal expected value for none glowing parts
  53090. */
  53091. private _defaultStencilReference;
  53092. /**
  53093. * Free any resources and references associated to a mesh.
  53094. * Internal use
  53095. * @param mesh The mesh to free.
  53096. * @hidden
  53097. */
  53098. _disposeMesh(mesh: Mesh): void;
  53099. /**
  53100. * Dispose the highlight layer and free resources.
  53101. */
  53102. dispose(): void;
  53103. /**
  53104. * Gets the class name of the effect layer
  53105. * @returns the string with the class name of the effect layer
  53106. */
  53107. getClassName(): string;
  53108. /**
  53109. * Serializes this Highlight layer
  53110. * @returns a serialized Highlight layer object
  53111. */
  53112. serialize(): any;
  53113. /**
  53114. * Creates a Highlight layer from parsed Highlight layer data
  53115. * @param parsedHightlightLayer defines the Highlight layer data
  53116. * @param scene defines the current scene
  53117. * @param rootUrl defines the root URL containing the Highlight layer information
  53118. * @returns a parsed Highlight layer
  53119. */
  53120. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53121. }
  53122. }
  53123. declare module "babylonjs/Layers/layerSceneComponent" {
  53124. import { Scene } from "babylonjs/scene";
  53125. import { ISceneComponent } from "babylonjs/sceneComponent";
  53126. import { Layer } from "babylonjs/Layers/layer";
  53127. import { AbstractScene } from "babylonjs/abstractScene";
  53128. module "babylonjs/abstractScene" {
  53129. interface AbstractScene {
  53130. /**
  53131. * The list of layers (background and foreground) of the scene
  53132. */
  53133. layers: Array<Layer>;
  53134. }
  53135. }
  53136. /**
  53137. * Defines the layer scene component responsible to manage any layers
  53138. * in a given scene.
  53139. */
  53140. export class LayerSceneComponent implements ISceneComponent {
  53141. /**
  53142. * The component name helpfull to identify the component in the list of scene components.
  53143. */
  53144. readonly name: string;
  53145. /**
  53146. * The scene the component belongs to.
  53147. */
  53148. scene: Scene;
  53149. private _engine;
  53150. /**
  53151. * Creates a new instance of the component for the given scene
  53152. * @param scene Defines the scene to register the component in
  53153. */
  53154. constructor(scene: Scene);
  53155. /**
  53156. * Registers the component in a given scene
  53157. */
  53158. register(): void;
  53159. /**
  53160. * Rebuilds the elements related to this component in case of
  53161. * context lost for instance.
  53162. */
  53163. rebuild(): void;
  53164. /**
  53165. * Disposes the component and the associated ressources.
  53166. */
  53167. dispose(): void;
  53168. private _draw;
  53169. private _drawCameraPredicate;
  53170. private _drawCameraBackground;
  53171. private _drawCameraForeground;
  53172. private _drawRenderTargetPredicate;
  53173. private _drawRenderTargetBackground;
  53174. private _drawRenderTargetForeground;
  53175. /**
  53176. * Adds all the elements from the container to the scene
  53177. * @param container the container holding the elements
  53178. */
  53179. addFromContainer(container: AbstractScene): void;
  53180. /**
  53181. * Removes all the elements in the container from the scene
  53182. * @param container contains the elements to remove
  53183. * @param dispose if the removed element should be disposed (default: false)
  53184. */
  53185. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53186. }
  53187. }
  53188. declare module "babylonjs/Shaders/layer.fragment" {
  53189. /** @hidden */
  53190. export var layerPixelShader: {
  53191. name: string;
  53192. shader: string;
  53193. };
  53194. }
  53195. declare module "babylonjs/Shaders/layer.vertex" {
  53196. /** @hidden */
  53197. export var layerVertexShader: {
  53198. name: string;
  53199. shader: string;
  53200. };
  53201. }
  53202. declare module "babylonjs/Layers/layer" {
  53203. import { Observable } from "babylonjs/Misc/observable";
  53204. import { Nullable } from "babylonjs/types";
  53205. import { Scene } from "babylonjs/scene";
  53206. import { Vector2 } from "babylonjs/Maths/math.vector";
  53207. import { Color4 } from "babylonjs/Maths/math.color";
  53208. import { Texture } from "babylonjs/Materials/Textures/texture";
  53209. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53210. import "babylonjs/Shaders/layer.fragment";
  53211. import "babylonjs/Shaders/layer.vertex";
  53212. /**
  53213. * This represents a full screen 2d layer.
  53214. * This can be useful to display a picture in the background of your scene for instance.
  53215. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53216. */
  53217. export class Layer {
  53218. /**
  53219. * Define the name of the layer.
  53220. */
  53221. name: string;
  53222. /**
  53223. * Define the texture the layer should display.
  53224. */
  53225. texture: Nullable<Texture>;
  53226. /**
  53227. * Is the layer in background or foreground.
  53228. */
  53229. isBackground: boolean;
  53230. /**
  53231. * Define the color of the layer (instead of texture).
  53232. */
  53233. color: Color4;
  53234. /**
  53235. * Define the scale of the layer in order to zoom in out of the texture.
  53236. */
  53237. scale: Vector2;
  53238. /**
  53239. * Define an offset for the layer in order to shift the texture.
  53240. */
  53241. offset: Vector2;
  53242. /**
  53243. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53244. */
  53245. alphaBlendingMode: number;
  53246. /**
  53247. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53248. * Alpha test will not mix with the background color in case of transparency.
  53249. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53250. */
  53251. alphaTest: boolean;
  53252. /**
  53253. * Define a mask to restrict the layer to only some of the scene cameras.
  53254. */
  53255. layerMask: number;
  53256. /**
  53257. * Define the list of render target the layer is visible into.
  53258. */
  53259. renderTargetTextures: RenderTargetTexture[];
  53260. /**
  53261. * Define if the layer is only used in renderTarget or if it also
  53262. * renders in the main frame buffer of the canvas.
  53263. */
  53264. renderOnlyInRenderTargetTextures: boolean;
  53265. private _scene;
  53266. private _vertexBuffers;
  53267. private _indexBuffer;
  53268. private _effect;
  53269. private _alphaTestEffect;
  53270. /**
  53271. * An event triggered when the layer is disposed.
  53272. */
  53273. onDisposeObservable: Observable<Layer>;
  53274. private _onDisposeObserver;
  53275. /**
  53276. * Back compatibility with callback before the onDisposeObservable existed.
  53277. * The set callback will be triggered when the layer has been disposed.
  53278. */
  53279. onDispose: () => void;
  53280. /**
  53281. * An event triggered before rendering the scene
  53282. */
  53283. onBeforeRenderObservable: Observable<Layer>;
  53284. private _onBeforeRenderObserver;
  53285. /**
  53286. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53287. * The set callback will be triggered just before rendering the layer.
  53288. */
  53289. onBeforeRender: () => void;
  53290. /**
  53291. * An event triggered after rendering the scene
  53292. */
  53293. onAfterRenderObservable: Observable<Layer>;
  53294. private _onAfterRenderObserver;
  53295. /**
  53296. * Back compatibility with callback before the onAfterRenderObservable existed.
  53297. * The set callback will be triggered just after rendering the layer.
  53298. */
  53299. onAfterRender: () => void;
  53300. /**
  53301. * Instantiates a new layer.
  53302. * This represents a full screen 2d layer.
  53303. * This can be useful to display a picture in the background of your scene for instance.
  53304. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53305. * @param name Define the name of the layer in the scene
  53306. * @param imgUrl Define the url of the texture to display in the layer
  53307. * @param scene Define the scene the layer belongs to
  53308. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53309. * @param color Defines a color for the layer
  53310. */
  53311. constructor(
  53312. /**
  53313. * Define the name of the layer.
  53314. */
  53315. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53316. private _createIndexBuffer;
  53317. /** @hidden */
  53318. _rebuild(): void;
  53319. /**
  53320. * Renders the layer in the scene.
  53321. */
  53322. render(): void;
  53323. /**
  53324. * Disposes and releases the associated ressources.
  53325. */
  53326. dispose(): void;
  53327. }
  53328. }
  53329. declare module "babylonjs/Layers/index" {
  53330. export * from "babylonjs/Layers/effectLayer";
  53331. export * from "babylonjs/Layers/effectLayerSceneComponent";
  53332. export * from "babylonjs/Layers/glowLayer";
  53333. export * from "babylonjs/Layers/highlightLayer";
  53334. export * from "babylonjs/Layers/layer";
  53335. export * from "babylonjs/Layers/layerSceneComponent";
  53336. }
  53337. declare module "babylonjs/Shaders/lensFlare.fragment" {
  53338. /** @hidden */
  53339. export var lensFlarePixelShader: {
  53340. name: string;
  53341. shader: string;
  53342. };
  53343. }
  53344. declare module "babylonjs/Shaders/lensFlare.vertex" {
  53345. /** @hidden */
  53346. export var lensFlareVertexShader: {
  53347. name: string;
  53348. shader: string;
  53349. };
  53350. }
  53351. declare module "babylonjs/LensFlares/lensFlareSystem" {
  53352. import { Scene } from "babylonjs/scene";
  53353. import { Vector3 } from "babylonjs/Maths/math.vector";
  53354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53355. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  53356. import "babylonjs/Shaders/lensFlare.fragment";
  53357. import "babylonjs/Shaders/lensFlare.vertex";
  53358. import { Viewport } from "babylonjs/Maths/math.viewport";
  53359. /**
  53360. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53361. * It is usually composed of several `lensFlare`.
  53362. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53363. */
  53364. export class LensFlareSystem {
  53365. /**
  53366. * Define the name of the lens flare system
  53367. */
  53368. name: string;
  53369. /**
  53370. * List of lens flares used in this system.
  53371. */
  53372. lensFlares: LensFlare[];
  53373. /**
  53374. * Define a limit from the border the lens flare can be visible.
  53375. */
  53376. borderLimit: number;
  53377. /**
  53378. * Define a viewport border we do not want to see the lens flare in.
  53379. */
  53380. viewportBorder: number;
  53381. /**
  53382. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53383. */
  53384. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53385. /**
  53386. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53387. */
  53388. layerMask: number;
  53389. /**
  53390. * Define the id of the lens flare system in the scene.
  53391. * (equal to name by default)
  53392. */
  53393. id: string;
  53394. private _scene;
  53395. private _emitter;
  53396. private _vertexBuffers;
  53397. private _indexBuffer;
  53398. private _effect;
  53399. private _positionX;
  53400. private _positionY;
  53401. private _isEnabled;
  53402. /** @hidden */
  53403. static _SceneComponentInitialization: (scene: Scene) => void;
  53404. /**
  53405. * Instantiates a lens flare system.
  53406. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53407. * It is usually composed of several `lensFlare`.
  53408. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53409. * @param name Define the name of the lens flare system in the scene
  53410. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53411. * @param scene Define the scene the lens flare system belongs to
  53412. */
  53413. constructor(
  53414. /**
  53415. * Define the name of the lens flare system
  53416. */
  53417. name: string, emitter: any, scene: Scene);
  53418. /**
  53419. * Define if the lens flare system is enabled.
  53420. */
  53421. isEnabled: boolean;
  53422. /**
  53423. * Get the scene the effects belongs to.
  53424. * @returns the scene holding the lens flare system
  53425. */
  53426. getScene(): Scene;
  53427. /**
  53428. * Get the emitter of the lens flare system.
  53429. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53430. * @returns the emitter of the lens flare system
  53431. */
  53432. getEmitter(): any;
  53433. /**
  53434. * Set the emitter of the lens flare system.
  53435. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53436. * @param newEmitter Define the new emitter of the system
  53437. */
  53438. setEmitter(newEmitter: any): void;
  53439. /**
  53440. * Get the lens flare system emitter position.
  53441. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53442. * @returns the position
  53443. */
  53444. getEmitterPosition(): Vector3;
  53445. /**
  53446. * @hidden
  53447. */
  53448. computeEffectivePosition(globalViewport: Viewport): boolean;
  53449. /** @hidden */
  53450. _isVisible(): boolean;
  53451. /**
  53452. * @hidden
  53453. */
  53454. render(): boolean;
  53455. /**
  53456. * Dispose and release the lens flare with its associated resources.
  53457. */
  53458. dispose(): void;
  53459. /**
  53460. * Parse a lens flare system from a JSON repressentation
  53461. * @param parsedLensFlareSystem Define the JSON to parse
  53462. * @param scene Define the scene the parsed system should be instantiated in
  53463. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53464. * @returns the parsed system
  53465. */
  53466. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53467. /**
  53468. * Serialize the current Lens Flare System into a JSON representation.
  53469. * @returns the serialized JSON
  53470. */
  53471. serialize(): any;
  53472. }
  53473. }
  53474. declare module "babylonjs/LensFlares/lensFlare" {
  53475. import { Nullable } from "babylonjs/types";
  53476. import { Color3 } from "babylonjs/Maths/math.color";
  53477. import { Texture } from "babylonjs/Materials/Textures/texture";
  53478. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53479. /**
  53480. * This represents one of the lens effect in a `lensFlareSystem`.
  53481. * It controls one of the indiviual texture used in the effect.
  53482. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53483. */
  53484. export class LensFlare {
  53485. /**
  53486. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53487. */
  53488. size: number;
  53489. /**
  53490. * 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.
  53491. */
  53492. position: number;
  53493. /**
  53494. * Define the lens color.
  53495. */
  53496. color: Color3;
  53497. /**
  53498. * Define the lens texture.
  53499. */
  53500. texture: Nullable<Texture>;
  53501. /**
  53502. * Define the alpha mode to render this particular lens.
  53503. */
  53504. alphaMode: number;
  53505. private _system;
  53506. /**
  53507. * Creates a new Lens Flare.
  53508. * This represents one of the lens effect in a `lensFlareSystem`.
  53509. * It controls one of the indiviual texture used in the effect.
  53510. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53511. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53512. * @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.
  53513. * @param color Define the lens color
  53514. * @param imgUrl Define the lens texture url
  53515. * @param system Define the `lensFlareSystem` this flare is part of
  53516. * @returns The newly created Lens Flare
  53517. */
  53518. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53519. /**
  53520. * Instantiates a new Lens Flare.
  53521. * This represents one of the lens effect in a `lensFlareSystem`.
  53522. * It controls one of the indiviual texture used in the effect.
  53523. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53524. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53525. * @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.
  53526. * @param color Define the lens color
  53527. * @param imgUrl Define the lens texture url
  53528. * @param system Define the `lensFlareSystem` this flare is part of
  53529. */
  53530. constructor(
  53531. /**
  53532. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53533. */
  53534. size: number,
  53535. /**
  53536. * 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.
  53537. */
  53538. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53539. /**
  53540. * Dispose and release the lens flare with its associated resources.
  53541. */
  53542. dispose(): void;
  53543. }
  53544. }
  53545. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  53546. import { Nullable } from "babylonjs/types";
  53547. import { Scene } from "babylonjs/scene";
  53548. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53549. import { AbstractScene } from "babylonjs/abstractScene";
  53550. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  53551. module "babylonjs/abstractScene" {
  53552. interface AbstractScene {
  53553. /**
  53554. * The list of lens flare system added to the scene
  53555. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53556. */
  53557. lensFlareSystems: Array<LensFlareSystem>;
  53558. /**
  53559. * Removes the given lens flare system from this scene.
  53560. * @param toRemove The lens flare system to remove
  53561. * @returns The index of the removed lens flare system
  53562. */
  53563. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53564. /**
  53565. * Adds the given lens flare system to this scene
  53566. * @param newLensFlareSystem The lens flare system to add
  53567. */
  53568. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53569. /**
  53570. * Gets a lens flare system using its name
  53571. * @param name defines the name to look for
  53572. * @returns the lens flare system or null if not found
  53573. */
  53574. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53575. /**
  53576. * Gets a lens flare system using its id
  53577. * @param id defines the id to look for
  53578. * @returns the lens flare system or null if not found
  53579. */
  53580. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53581. }
  53582. }
  53583. /**
  53584. * Defines the lens flare scene component responsible to manage any lens flares
  53585. * in a given scene.
  53586. */
  53587. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53588. /**
  53589. * The component name helpfull to identify the component in the list of scene components.
  53590. */
  53591. readonly name: string;
  53592. /**
  53593. * The scene the component belongs to.
  53594. */
  53595. scene: Scene;
  53596. /**
  53597. * Creates a new instance of the component for the given scene
  53598. * @param scene Defines the scene to register the component in
  53599. */
  53600. constructor(scene: Scene);
  53601. /**
  53602. * Registers the component in a given scene
  53603. */
  53604. register(): void;
  53605. /**
  53606. * Rebuilds the elements related to this component in case of
  53607. * context lost for instance.
  53608. */
  53609. rebuild(): void;
  53610. /**
  53611. * Adds all the elements from the container to the scene
  53612. * @param container the container holding the elements
  53613. */
  53614. addFromContainer(container: AbstractScene): void;
  53615. /**
  53616. * Removes all the elements in the container from the scene
  53617. * @param container contains the elements to remove
  53618. * @param dispose if the removed element should be disposed (default: false)
  53619. */
  53620. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53621. /**
  53622. * Serializes the component data to the specified json object
  53623. * @param serializationObject The object to serialize to
  53624. */
  53625. serialize(serializationObject: any): void;
  53626. /**
  53627. * Disposes the component and the associated ressources.
  53628. */
  53629. dispose(): void;
  53630. private _draw;
  53631. }
  53632. }
  53633. declare module "babylonjs/LensFlares/index" {
  53634. export * from "babylonjs/LensFlares/lensFlare";
  53635. export * from "babylonjs/LensFlares/lensFlareSystem";
  53636. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  53637. }
  53638. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  53639. import { Scene } from "babylonjs/scene";
  53640. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  53641. import { AbstractScene } from "babylonjs/abstractScene";
  53642. /**
  53643. * Defines the shadow generator component responsible to manage any shadow generators
  53644. * in a given scene.
  53645. */
  53646. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  53647. /**
  53648. * The component name helpfull to identify the component in the list of scene components.
  53649. */
  53650. readonly name: string;
  53651. /**
  53652. * The scene the component belongs to.
  53653. */
  53654. scene: Scene;
  53655. /**
  53656. * Creates a new instance of the component for the given scene
  53657. * @param scene Defines the scene to register the component in
  53658. */
  53659. constructor(scene: Scene);
  53660. /**
  53661. * Registers the component in a given scene
  53662. */
  53663. register(): void;
  53664. /**
  53665. * Rebuilds the elements related to this component in case of
  53666. * context lost for instance.
  53667. */
  53668. rebuild(): void;
  53669. /**
  53670. * Serializes the component data to the specified json object
  53671. * @param serializationObject The object to serialize to
  53672. */
  53673. serialize(serializationObject: any): void;
  53674. /**
  53675. * Adds all the elements from the container to the scene
  53676. * @param container the container holding the elements
  53677. */
  53678. addFromContainer(container: AbstractScene): void;
  53679. /**
  53680. * Removes all the elements in the container from the scene
  53681. * @param container contains the elements to remove
  53682. * @param dispose if the removed element should be disposed (default: false)
  53683. */
  53684. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53685. /**
  53686. * Rebuilds the elements related to this component in case of
  53687. * context lost for instance.
  53688. */
  53689. dispose(): void;
  53690. private _gatherRenderTargets;
  53691. }
  53692. }
  53693. declare module "babylonjs/Lights/Shadows/index" {
  53694. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  53695. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  53696. }
  53697. declare module "babylonjs/Lights/pointLight" {
  53698. import { Scene } from "babylonjs/scene";
  53699. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53701. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  53702. import { Effect } from "babylonjs/Materials/effect";
  53703. /**
  53704. * A point light is a light defined by an unique point in world space.
  53705. * The light is emitted in every direction from this point.
  53706. * A good example of a point light is a standard light bulb.
  53707. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53708. */
  53709. export class PointLight extends ShadowLight {
  53710. private _shadowAngle;
  53711. /**
  53712. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53713. * This specifies what angle the shadow will use to be created.
  53714. *
  53715. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53716. */
  53717. /**
  53718. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53719. * This specifies what angle the shadow will use to be created.
  53720. *
  53721. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  53722. */
  53723. shadowAngle: number;
  53724. /**
  53725. * Gets the direction if it has been set.
  53726. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53727. */
  53728. /**
  53729. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  53730. */
  53731. direction: Vector3;
  53732. /**
  53733. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  53734. * A PointLight emits the light in every direction.
  53735. * It can cast shadows.
  53736. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  53737. * ```javascript
  53738. * var pointLight = new PointLight("pl", camera.position, scene);
  53739. * ```
  53740. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53741. * @param name The light friendly name
  53742. * @param position The position of the point light in the scene
  53743. * @param scene The scene the lights belongs to
  53744. */
  53745. constructor(name: string, position: Vector3, scene: Scene);
  53746. /**
  53747. * Returns the string "PointLight"
  53748. * @returns the class name
  53749. */
  53750. getClassName(): string;
  53751. /**
  53752. * Returns the integer 0.
  53753. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53754. */
  53755. getTypeID(): number;
  53756. /**
  53757. * Specifies wether or not the shadowmap should be a cube texture.
  53758. * @returns true if the shadowmap needs to be a cube texture.
  53759. */
  53760. needCube(): boolean;
  53761. /**
  53762. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  53763. * @param faceIndex The index of the face we are computed the direction to generate shadow
  53764. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  53765. */
  53766. getShadowDirection(faceIndex?: number): Vector3;
  53767. /**
  53768. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  53769. * - fov = PI / 2
  53770. * - aspect ratio : 1.0
  53771. * - z-near and far equal to the active camera minZ and maxZ.
  53772. * Returns the PointLight.
  53773. */
  53774. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53775. protected _buildUniformLayout(): void;
  53776. /**
  53777. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  53778. * @param effect The effect to update
  53779. * @param lightIndex The index of the light in the effect to update
  53780. * @returns The point light
  53781. */
  53782. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  53783. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53784. /**
  53785. * Prepares the list of defines specific to the light type.
  53786. * @param defines the list of defines
  53787. * @param lightIndex defines the index of the light for the effect
  53788. */
  53789. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53790. }
  53791. }
  53792. declare module "babylonjs/Lights/index" {
  53793. export * from "babylonjs/Lights/light";
  53794. export * from "babylonjs/Lights/shadowLight";
  53795. export * from "babylonjs/Lights/Shadows/index";
  53796. export * from "babylonjs/Lights/directionalLight";
  53797. export * from "babylonjs/Lights/hemisphericLight";
  53798. export * from "babylonjs/Lights/pointLight";
  53799. export * from "babylonjs/Lights/spotLight";
  53800. }
  53801. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53802. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53803. /**
  53804. * Header information of HDR texture files.
  53805. */
  53806. export interface HDRInfo {
  53807. /**
  53808. * The height of the texture in pixels.
  53809. */
  53810. height: number;
  53811. /**
  53812. * The width of the texture in pixels.
  53813. */
  53814. width: number;
  53815. /**
  53816. * The index of the beginning of the data in the binary file.
  53817. */
  53818. dataPosition: number;
  53819. }
  53820. /**
  53821. * This groups tools to convert HDR texture to native colors array.
  53822. */
  53823. export class HDRTools {
  53824. private static Ldexp;
  53825. private static Rgbe2float;
  53826. private static readStringLine;
  53827. /**
  53828. * Reads header information from an RGBE texture stored in a native array.
  53829. * More information on this format are available here:
  53830. * https://en.wikipedia.org/wiki/RGBE_image_format
  53831. *
  53832. * @param uint8array The binary file stored in native array.
  53833. * @return The header information.
  53834. */
  53835. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53836. /**
  53837. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53838. * This RGBE texture needs to store the information as a panorama.
  53839. *
  53840. * More information on this format are available here:
  53841. * https://en.wikipedia.org/wiki/RGBE_image_format
  53842. *
  53843. * @param buffer The binary file stored in an array buffer.
  53844. * @param size The expected size of the extracted cubemap.
  53845. * @return The Cube Map information.
  53846. */
  53847. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53848. /**
  53849. * Returns the pixels data extracted from an RGBE texture.
  53850. * This pixels will be stored left to right up to down in the R G B order in one array.
  53851. *
  53852. * More information on this format are available here:
  53853. * https://en.wikipedia.org/wiki/RGBE_image_format
  53854. *
  53855. * @param uint8array The binary file stored in an array buffer.
  53856. * @param hdrInfo The header information of the file.
  53857. * @return The pixels data in RGB right to left up to down order.
  53858. */
  53859. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53860. private static RGBE_ReadPixels_RLE;
  53861. }
  53862. }
  53863. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53864. import { Nullable } from "babylonjs/types";
  53865. import { Scene } from "babylonjs/scene";
  53866. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53867. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53868. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53869. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53870. /**
  53871. * This represents a texture coming from an HDR input.
  53872. *
  53873. * The only supported format is currently panorama picture stored in RGBE format.
  53874. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53875. */
  53876. export class HDRCubeTexture extends BaseTexture {
  53877. private static _facesMapping;
  53878. private _generateHarmonics;
  53879. private _noMipmap;
  53880. private _textureMatrix;
  53881. private _size;
  53882. private _onLoad;
  53883. private _onError;
  53884. /**
  53885. * The texture URL.
  53886. */
  53887. url: string;
  53888. /**
  53889. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53890. */
  53891. coordinatesMode: number;
  53892. protected _isBlocking: boolean;
  53893. /**
  53894. * Sets wether or not the texture is blocking during loading.
  53895. */
  53896. /**
  53897. * Gets wether or not the texture is blocking during loading.
  53898. */
  53899. isBlocking: boolean;
  53900. protected _rotationY: number;
  53901. /**
  53902. * Sets texture matrix rotation angle around Y axis in radians.
  53903. */
  53904. /**
  53905. * Gets texture matrix rotation angle around Y axis radians.
  53906. */
  53907. rotationY: number;
  53908. /**
  53909. * Gets or sets the center of the bounding box associated with the cube texture
  53910. * It must define where the camera used to render the texture was set
  53911. */
  53912. boundingBoxPosition: Vector3;
  53913. private _boundingBoxSize;
  53914. /**
  53915. * Gets or sets the size of the bounding box associated with the cube texture
  53916. * When defined, the cubemap will switch to local mode
  53917. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53918. * @example https://www.babylonjs-playground.com/#RNASML
  53919. */
  53920. boundingBoxSize: Vector3;
  53921. /**
  53922. * Instantiates an HDRTexture from the following parameters.
  53923. *
  53924. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53925. * @param scene The scene the texture will be used in
  53926. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53927. * @param noMipmap Forces to not generate the mipmap if true
  53928. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53929. * @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)
  53930. * @param reserved Reserved flag for internal use.
  53931. */
  53932. 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>);
  53933. /**
  53934. * Get the current class name of the texture useful for serialization or dynamic coding.
  53935. * @returns "HDRCubeTexture"
  53936. */
  53937. getClassName(): string;
  53938. /**
  53939. * Occurs when the file is raw .hdr file.
  53940. */
  53941. private loadTexture;
  53942. clone(): HDRCubeTexture;
  53943. delayLoad(): void;
  53944. /**
  53945. * Get the texture reflection matrix used to rotate/transform the reflection.
  53946. * @returns the reflection matrix
  53947. */
  53948. getReflectionTextureMatrix(): Matrix;
  53949. /**
  53950. * Set the texture reflection matrix used to rotate/transform the reflection.
  53951. * @param value Define the reflection matrix to set
  53952. */
  53953. setReflectionTextureMatrix(value: Matrix): void;
  53954. /**
  53955. * Parses a JSON representation of an HDR Texture in order to create the texture
  53956. * @param parsedTexture Define the JSON representation
  53957. * @param scene Define the scene the texture should be created in
  53958. * @param rootUrl Define the root url in case we need to load relative dependencies
  53959. * @returns the newly created texture after parsing
  53960. */
  53961. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53962. serialize(): any;
  53963. }
  53964. }
  53965. declare module "babylonjs/Physics/physicsEngine" {
  53966. import { Nullable } from "babylonjs/types";
  53967. import { Vector3 } from "babylonjs/Maths/math.vector";
  53968. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53969. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53970. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53971. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53972. /**
  53973. * Class used to control physics engine
  53974. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53975. */
  53976. export class PhysicsEngine implements IPhysicsEngine {
  53977. private _physicsPlugin;
  53978. /**
  53979. * Global value used to control the smallest number supported by the simulation
  53980. */
  53981. static Epsilon: number;
  53982. private _impostors;
  53983. private _joints;
  53984. /**
  53985. * Gets the gravity vector used by the simulation
  53986. */
  53987. gravity: Vector3;
  53988. /**
  53989. * Factory used to create the default physics plugin.
  53990. * @returns The default physics plugin
  53991. */
  53992. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53993. /**
  53994. * Creates a new Physics Engine
  53995. * @param gravity defines the gravity vector used by the simulation
  53996. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53997. */
  53998. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53999. /**
  54000. * Sets the gravity vector used by the simulation
  54001. * @param gravity defines the gravity vector to use
  54002. */
  54003. setGravity(gravity: Vector3): void;
  54004. /**
  54005. * Set the time step of the physics engine.
  54006. * Default is 1/60.
  54007. * To slow it down, enter 1/600 for example.
  54008. * To speed it up, 1/30
  54009. * @param newTimeStep defines the new timestep to apply to this world.
  54010. */
  54011. setTimeStep(newTimeStep?: number): void;
  54012. /**
  54013. * Get the time step of the physics engine.
  54014. * @returns the current time step
  54015. */
  54016. getTimeStep(): number;
  54017. /**
  54018. * Release all resources
  54019. */
  54020. dispose(): void;
  54021. /**
  54022. * Gets the name of the current physics plugin
  54023. * @returns the name of the plugin
  54024. */
  54025. getPhysicsPluginName(): string;
  54026. /**
  54027. * Adding a new impostor for the impostor tracking.
  54028. * This will be done by the impostor itself.
  54029. * @param impostor the impostor to add
  54030. */
  54031. addImpostor(impostor: PhysicsImpostor): void;
  54032. /**
  54033. * Remove an impostor from the engine.
  54034. * This impostor and its mesh will not longer be updated by the physics engine.
  54035. * @param impostor the impostor to remove
  54036. */
  54037. removeImpostor(impostor: PhysicsImpostor): void;
  54038. /**
  54039. * Add a joint to the physics engine
  54040. * @param mainImpostor defines the main impostor to which the joint is added.
  54041. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54042. * @param joint defines the joint that will connect both impostors.
  54043. */
  54044. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54045. /**
  54046. * Removes a joint from the simulation
  54047. * @param mainImpostor defines the impostor used with the joint
  54048. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54049. * @param joint defines the joint to remove
  54050. */
  54051. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54052. /**
  54053. * Called by the scene. No need to call it.
  54054. * @param delta defines the timespam between frames
  54055. */
  54056. _step(delta: number): void;
  54057. /**
  54058. * Gets the current plugin used to run the simulation
  54059. * @returns current plugin
  54060. */
  54061. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54062. /**
  54063. * Gets the list of physic impostors
  54064. * @returns an array of PhysicsImpostor
  54065. */
  54066. getImpostors(): Array<PhysicsImpostor>;
  54067. /**
  54068. * Gets the impostor for a physics enabled object
  54069. * @param object defines the object impersonated by the impostor
  54070. * @returns the PhysicsImpostor or null if not found
  54071. */
  54072. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54073. /**
  54074. * Gets the impostor for a physics body object
  54075. * @param body defines physics body used by the impostor
  54076. * @returns the PhysicsImpostor or null if not found
  54077. */
  54078. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54079. /**
  54080. * Does a raycast in the physics world
  54081. * @param from when should the ray start?
  54082. * @param to when should the ray end?
  54083. * @returns PhysicsRaycastResult
  54084. */
  54085. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54086. }
  54087. }
  54088. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  54089. import { Nullable } from "babylonjs/types";
  54090. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54092. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54093. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54094. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54095. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54096. /** @hidden */
  54097. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54098. private _useDeltaForWorldStep;
  54099. world: any;
  54100. name: string;
  54101. private _physicsMaterials;
  54102. private _fixedTimeStep;
  54103. private _cannonRaycastResult;
  54104. private _raycastResult;
  54105. private _physicsBodysToRemoveAfterStep;
  54106. BJSCANNON: any;
  54107. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54108. setGravity(gravity: Vector3): void;
  54109. setTimeStep(timeStep: number): void;
  54110. getTimeStep(): number;
  54111. executeStep(delta: number): void;
  54112. private _removeMarkedPhysicsBodiesFromWorld;
  54113. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54114. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54115. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54116. private _processChildMeshes;
  54117. removePhysicsBody(impostor: PhysicsImpostor): void;
  54118. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54119. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54120. private _addMaterial;
  54121. private _checkWithEpsilon;
  54122. private _createShape;
  54123. private _createHeightmap;
  54124. private _minus90X;
  54125. private _plus90X;
  54126. private _tmpPosition;
  54127. private _tmpDeltaPosition;
  54128. private _tmpUnityRotation;
  54129. private _updatePhysicsBodyTransformation;
  54130. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54131. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54132. isSupported(): boolean;
  54133. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54134. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54135. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54136. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54137. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54138. getBodyMass(impostor: PhysicsImpostor): number;
  54139. getBodyFriction(impostor: PhysicsImpostor): number;
  54140. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54141. getBodyRestitution(impostor: PhysicsImpostor): number;
  54142. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54143. sleepBody(impostor: PhysicsImpostor): void;
  54144. wakeUpBody(impostor: PhysicsImpostor): void;
  54145. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54146. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54147. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54148. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54149. getRadius(impostor: PhysicsImpostor): number;
  54150. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54151. dispose(): void;
  54152. private _extendNamespace;
  54153. /**
  54154. * Does a raycast in the physics world
  54155. * @param from when should the ray start?
  54156. * @param to when should the ray end?
  54157. * @returns PhysicsRaycastResult
  54158. */
  54159. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54160. }
  54161. }
  54162. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  54163. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54164. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54165. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54167. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  54168. import { Nullable } from "babylonjs/types";
  54169. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54170. /** @hidden */
  54171. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54172. world: any;
  54173. name: string;
  54174. BJSOIMO: any;
  54175. private _raycastResult;
  54176. constructor(iterations?: number, oimoInjection?: any);
  54177. setGravity(gravity: Vector3): void;
  54178. setTimeStep(timeStep: number): void;
  54179. getTimeStep(): number;
  54180. private _tmpImpostorsArray;
  54181. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54182. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54183. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54184. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54185. private _tmpPositionVector;
  54186. removePhysicsBody(impostor: PhysicsImpostor): void;
  54187. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54188. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54189. isSupported(): boolean;
  54190. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54191. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54192. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54193. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54194. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54195. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54196. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54197. getBodyMass(impostor: PhysicsImpostor): number;
  54198. getBodyFriction(impostor: PhysicsImpostor): number;
  54199. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54200. getBodyRestitution(impostor: PhysicsImpostor): number;
  54201. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54202. sleepBody(impostor: PhysicsImpostor): void;
  54203. wakeUpBody(impostor: PhysicsImpostor): void;
  54204. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54205. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54206. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54207. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54208. getRadius(impostor: PhysicsImpostor): number;
  54209. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54210. dispose(): void;
  54211. /**
  54212. * Does a raycast in the physics world
  54213. * @param from when should the ray start?
  54214. * @param to when should the ray end?
  54215. * @returns PhysicsRaycastResult
  54216. */
  54217. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54218. }
  54219. }
  54220. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  54221. import { Nullable } from "babylonjs/types";
  54222. import { Scene } from "babylonjs/scene";
  54223. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  54224. import { Color4 } from "babylonjs/Maths/math.color";
  54225. import { Mesh } from "babylonjs/Meshes/mesh";
  54226. /**
  54227. * Class containing static functions to help procedurally build meshes
  54228. */
  54229. export class RibbonBuilder {
  54230. /**
  54231. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54232. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54233. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54234. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54235. * * 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
  54236. * * 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
  54237. * * 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
  54238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54240. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54241. * * 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
  54242. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54243. * * 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
  54244. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54246. * @param name defines the name of the mesh
  54247. * @param options defines the options used to create the mesh
  54248. * @param scene defines the hosting scene
  54249. * @returns the ribbon mesh
  54250. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54251. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54252. */
  54253. static CreateRibbon(name: string, options: {
  54254. pathArray: Vector3[][];
  54255. closeArray?: boolean;
  54256. closePath?: boolean;
  54257. offset?: number;
  54258. updatable?: boolean;
  54259. sideOrientation?: number;
  54260. frontUVs?: Vector4;
  54261. backUVs?: Vector4;
  54262. instance?: Mesh;
  54263. invertUV?: boolean;
  54264. uvs?: Vector2[];
  54265. colors?: Color4[];
  54266. }, scene?: Nullable<Scene>): Mesh;
  54267. }
  54268. }
  54269. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  54270. import { Nullable } from "babylonjs/types";
  54271. import { Scene } from "babylonjs/scene";
  54272. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  54273. import { Mesh } from "babylonjs/Meshes/mesh";
  54274. /**
  54275. * Class containing static functions to help procedurally build meshes
  54276. */
  54277. export class ShapeBuilder {
  54278. /**
  54279. * 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.
  54280. * * 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.
  54281. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54282. * * 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.
  54283. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54284. * * 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
  54285. * * 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
  54286. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54288. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54289. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54291. * @param name defines the name of the mesh
  54292. * @param options defines the options used to create the mesh
  54293. * @param scene defines the hosting scene
  54294. * @returns the extruded shape mesh
  54295. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54296. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54297. */
  54298. static ExtrudeShape(name: string, options: {
  54299. shape: Vector3[];
  54300. path: Vector3[];
  54301. scale?: number;
  54302. rotation?: number;
  54303. cap?: number;
  54304. updatable?: boolean;
  54305. sideOrientation?: number;
  54306. frontUVs?: Vector4;
  54307. backUVs?: Vector4;
  54308. instance?: Mesh;
  54309. invertUV?: boolean;
  54310. }, scene?: Nullable<Scene>): Mesh;
  54311. /**
  54312. * Creates an custom extruded shape mesh.
  54313. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54314. * * 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.
  54315. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54316. * * 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
  54317. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54318. * * 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
  54319. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54320. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54321. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54322. * * 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
  54323. * * 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
  54324. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54326. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54327. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54329. * @param name defines the name of the mesh
  54330. * @param options defines the options used to create the mesh
  54331. * @param scene defines the hosting scene
  54332. * @returns the custom extruded shape mesh
  54333. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54334. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54335. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54336. */
  54337. static ExtrudeShapeCustom(name: string, options: {
  54338. shape: Vector3[];
  54339. path: Vector3[];
  54340. scaleFunction?: any;
  54341. rotationFunction?: any;
  54342. ribbonCloseArray?: boolean;
  54343. ribbonClosePath?: boolean;
  54344. cap?: number;
  54345. updatable?: boolean;
  54346. sideOrientation?: number;
  54347. frontUVs?: Vector4;
  54348. backUVs?: Vector4;
  54349. instance?: Mesh;
  54350. invertUV?: boolean;
  54351. }, scene?: Nullable<Scene>): Mesh;
  54352. private static _ExtrudeShapeGeneric;
  54353. }
  54354. }
  54355. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  54356. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  54357. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  54358. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  54359. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  54360. import { Nullable } from "babylonjs/types";
  54361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54362. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  54363. /**
  54364. * AmmoJS Physics plugin
  54365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  54366. * @see https://github.com/kripken/ammo.js/
  54367. */
  54368. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  54369. private _useDeltaForWorldStep;
  54370. /**
  54371. * Reference to the Ammo library
  54372. */
  54373. bjsAMMO: any;
  54374. /**
  54375. * Created ammoJS world which physics bodies are added to
  54376. */
  54377. world: any;
  54378. /**
  54379. * Name of the plugin
  54380. */
  54381. name: string;
  54382. private _timeStep;
  54383. private _fixedTimeStep;
  54384. private _maxSteps;
  54385. private _tmpQuaternion;
  54386. private _tmpAmmoTransform;
  54387. private _tmpAmmoQuaternion;
  54388. private _tmpAmmoConcreteContactResultCallback;
  54389. private _collisionConfiguration;
  54390. private _dispatcher;
  54391. private _overlappingPairCache;
  54392. private _solver;
  54393. private _softBodySolver;
  54394. private _tmpAmmoVectorA;
  54395. private _tmpAmmoVectorB;
  54396. private _tmpAmmoVectorC;
  54397. private _tmpAmmoVectorD;
  54398. private _tmpContactCallbackResult;
  54399. private _tmpAmmoVectorRCA;
  54400. private _tmpAmmoVectorRCB;
  54401. private _raycastResult;
  54402. private static readonly DISABLE_COLLISION_FLAG;
  54403. private static readonly KINEMATIC_FLAG;
  54404. private static readonly DISABLE_DEACTIVATION_FLAG;
  54405. /**
  54406. * Initializes the ammoJS plugin
  54407. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  54408. * @param ammoInjection can be used to inject your own ammo reference
  54409. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  54410. */
  54411. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  54412. /**
  54413. * Sets the gravity of the physics world (m/(s^2))
  54414. * @param gravity Gravity to set
  54415. */
  54416. setGravity(gravity: Vector3): void;
  54417. /**
  54418. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  54419. * @param timeStep timestep to use in seconds
  54420. */
  54421. setTimeStep(timeStep: number): void;
  54422. /**
  54423. * 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)
  54424. * @param fixedTimeStep fixedTimeStep to use in seconds
  54425. */
  54426. setFixedTimeStep(fixedTimeStep: number): void;
  54427. /**
  54428. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  54429. * @param maxSteps the maximum number of steps by the physics engine per frame
  54430. */
  54431. setMaxSteps(maxSteps: number): void;
  54432. /**
  54433. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  54434. * @returns the current timestep in seconds
  54435. */
  54436. getTimeStep(): number;
  54437. private _isImpostorInContact;
  54438. private _isImpostorPairInContact;
  54439. private _stepSimulation;
  54440. /**
  54441. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  54442. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  54443. * After the step the babylon meshes are set to the position of the physics imposters
  54444. * @param delta amount of time to step forward
  54445. * @param impostors array of imposters to update before/after the step
  54446. */
  54447. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54448. /**
  54449. * Update babylon mesh to match physics world object
  54450. * @param impostor imposter to match
  54451. */
  54452. private _afterSoftStep;
  54453. /**
  54454. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54455. * @param impostor imposter to match
  54456. */
  54457. private _ropeStep;
  54458. /**
  54459. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  54460. * @param impostor imposter to match
  54461. */
  54462. private _softbodyOrClothStep;
  54463. private _tmpVector;
  54464. private _tmpMatrix;
  54465. /**
  54466. * Applies an impulse on the imposter
  54467. * @param impostor imposter to apply impulse to
  54468. * @param force amount of force to be applied to the imposter
  54469. * @param contactPoint the location to apply the impulse on the imposter
  54470. */
  54471. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54472. /**
  54473. * Applies a force on the imposter
  54474. * @param impostor imposter to apply force
  54475. * @param force amount of force to be applied to the imposter
  54476. * @param contactPoint the location to apply the force on the imposter
  54477. */
  54478. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54479. /**
  54480. * Creates a physics body using the plugin
  54481. * @param impostor the imposter to create the physics body on
  54482. */
  54483. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54484. /**
  54485. * Removes the physics body from the imposter and disposes of the body's memory
  54486. * @param impostor imposter to remove the physics body from
  54487. */
  54488. removePhysicsBody(impostor: PhysicsImpostor): void;
  54489. /**
  54490. * Generates a joint
  54491. * @param impostorJoint the imposter joint to create the joint with
  54492. */
  54493. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54494. /**
  54495. * Removes a joint
  54496. * @param impostorJoint the imposter joint to remove the joint from
  54497. */
  54498. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54499. private _addMeshVerts;
  54500. /**
  54501. * Initialise the soft body vertices to match its object's (mesh) vertices
  54502. * Softbody vertices (nodes) are in world space and to match this
  54503. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  54504. * @param impostor to create the softbody for
  54505. */
  54506. private _softVertexData;
  54507. /**
  54508. * Create an impostor's soft body
  54509. * @param impostor to create the softbody for
  54510. */
  54511. private _createSoftbody;
  54512. /**
  54513. * Create cloth for an impostor
  54514. * @param impostor to create the softbody for
  54515. */
  54516. private _createCloth;
  54517. /**
  54518. * Create rope for an impostor
  54519. * @param impostor to create the softbody for
  54520. */
  54521. private _createRope;
  54522. private _addHullVerts;
  54523. private _createShape;
  54524. /**
  54525. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  54526. * @param impostor imposter containing the physics body and babylon object
  54527. */
  54528. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54529. /**
  54530. * Sets the babylon object's position/rotation from the physics body's position/rotation
  54531. * @param impostor imposter containing the physics body and babylon object
  54532. * @param newPosition new position
  54533. * @param newRotation new rotation
  54534. */
  54535. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54536. /**
  54537. * If this plugin is supported
  54538. * @returns true if its supported
  54539. */
  54540. isSupported(): boolean;
  54541. /**
  54542. * Sets the linear velocity of the physics body
  54543. * @param impostor imposter to set the velocity on
  54544. * @param velocity velocity to set
  54545. */
  54546. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54547. /**
  54548. * Sets the angular velocity of the physics body
  54549. * @param impostor imposter to set the velocity on
  54550. * @param velocity velocity to set
  54551. */
  54552. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54553. /**
  54554. * gets the linear velocity
  54555. * @param impostor imposter to get linear velocity from
  54556. * @returns linear velocity
  54557. */
  54558. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54559. /**
  54560. * gets the angular velocity
  54561. * @param impostor imposter to get angular velocity from
  54562. * @returns angular velocity
  54563. */
  54564. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54565. /**
  54566. * Sets the mass of physics body
  54567. * @param impostor imposter to set the mass on
  54568. * @param mass mass to set
  54569. */
  54570. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54571. /**
  54572. * Gets the mass of the physics body
  54573. * @param impostor imposter to get the mass from
  54574. * @returns mass
  54575. */
  54576. getBodyMass(impostor: PhysicsImpostor): number;
  54577. /**
  54578. * Gets friction of the impostor
  54579. * @param impostor impostor to get friction from
  54580. * @returns friction value
  54581. */
  54582. getBodyFriction(impostor: PhysicsImpostor): number;
  54583. /**
  54584. * Sets friction of the impostor
  54585. * @param impostor impostor to set friction on
  54586. * @param friction friction value
  54587. */
  54588. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54589. /**
  54590. * Gets restitution of the impostor
  54591. * @param impostor impostor to get restitution from
  54592. * @returns restitution value
  54593. */
  54594. getBodyRestitution(impostor: PhysicsImpostor): number;
  54595. /**
  54596. * Sets resitution of the impostor
  54597. * @param impostor impostor to set resitution on
  54598. * @param restitution resitution value
  54599. */
  54600. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54601. /**
  54602. * Gets pressure inside the impostor
  54603. * @param impostor impostor to get pressure from
  54604. * @returns pressure value
  54605. */
  54606. getBodyPressure(impostor: PhysicsImpostor): number;
  54607. /**
  54608. * Sets pressure inside a soft body impostor
  54609. * Cloth and rope must remain 0 pressure
  54610. * @param impostor impostor to set pressure on
  54611. * @param pressure pressure value
  54612. */
  54613. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  54614. /**
  54615. * Gets stiffness of the impostor
  54616. * @param impostor impostor to get stiffness from
  54617. * @returns pressure value
  54618. */
  54619. getBodyStiffness(impostor: PhysicsImpostor): number;
  54620. /**
  54621. * Sets stiffness of the impostor
  54622. * @param impostor impostor to set stiffness on
  54623. * @param stiffness stiffness value from 0 to 1
  54624. */
  54625. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  54626. /**
  54627. * Gets velocityIterations of the impostor
  54628. * @param impostor impostor to get velocity iterations from
  54629. * @returns velocityIterations value
  54630. */
  54631. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  54632. /**
  54633. * Sets velocityIterations of the impostor
  54634. * @param impostor impostor to set velocity iterations on
  54635. * @param velocityIterations velocityIterations value
  54636. */
  54637. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  54638. /**
  54639. * Gets positionIterations of the impostor
  54640. * @param impostor impostor to get position iterations from
  54641. * @returns positionIterations value
  54642. */
  54643. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  54644. /**
  54645. * Sets positionIterations of the impostor
  54646. * @param impostor impostor to set position on
  54647. * @param positionIterations positionIterations value
  54648. */
  54649. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  54650. /**
  54651. * Append an anchor to a cloth object
  54652. * @param impostor is the cloth impostor to add anchor to
  54653. * @param otherImpostor is the rigid impostor to anchor to
  54654. * @param width ratio across width from 0 to 1
  54655. * @param height ratio up height from 0 to 1
  54656. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  54657. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54658. */
  54659. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54660. /**
  54661. * Append an hook to a rope object
  54662. * @param impostor is the rope impostor to add hook to
  54663. * @param otherImpostor is the rigid impostor to hook to
  54664. * @param length ratio along the rope from 0 to 1
  54665. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  54666. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  54667. */
  54668. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  54669. /**
  54670. * Sleeps the physics body and stops it from being active
  54671. * @param impostor impostor to sleep
  54672. */
  54673. sleepBody(impostor: PhysicsImpostor): void;
  54674. /**
  54675. * Activates the physics body
  54676. * @param impostor impostor to activate
  54677. */
  54678. wakeUpBody(impostor: PhysicsImpostor): void;
  54679. /**
  54680. * Updates the distance parameters of the joint
  54681. * @param joint joint to update
  54682. * @param maxDistance maximum distance of the joint
  54683. * @param minDistance minimum distance of the joint
  54684. */
  54685. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54686. /**
  54687. * Sets a motor on the joint
  54688. * @param joint joint to set motor on
  54689. * @param speed speed of the motor
  54690. * @param maxForce maximum force of the motor
  54691. * @param motorIndex index of the motor
  54692. */
  54693. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54694. /**
  54695. * Sets the motors limit
  54696. * @param joint joint to set limit on
  54697. * @param upperLimit upper limit
  54698. * @param lowerLimit lower limit
  54699. */
  54700. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54701. /**
  54702. * Syncs the position and rotation of a mesh with the impostor
  54703. * @param mesh mesh to sync
  54704. * @param impostor impostor to update the mesh with
  54705. */
  54706. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54707. /**
  54708. * Gets the radius of the impostor
  54709. * @param impostor impostor to get radius from
  54710. * @returns the radius
  54711. */
  54712. getRadius(impostor: PhysicsImpostor): number;
  54713. /**
  54714. * Gets the box size of the impostor
  54715. * @param impostor impostor to get box size from
  54716. * @param result the resulting box size
  54717. */
  54718. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54719. /**
  54720. * Disposes of the impostor
  54721. */
  54722. dispose(): void;
  54723. /**
  54724. * Does a raycast in the physics world
  54725. * @param from when should the ray start?
  54726. * @param to when should the ray end?
  54727. * @returns PhysicsRaycastResult
  54728. */
  54729. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54730. }
  54731. }
  54732. declare module "babylonjs/Probes/reflectionProbe" {
  54733. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54734. import { Vector3 } from "babylonjs/Maths/math.vector";
  54735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54736. import { Nullable } from "babylonjs/types";
  54737. import { Scene } from "babylonjs/scene";
  54738. module "babylonjs/abstractScene" {
  54739. interface AbstractScene {
  54740. /**
  54741. * The list of reflection probes added to the scene
  54742. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54743. */
  54744. reflectionProbes: Array<ReflectionProbe>;
  54745. /**
  54746. * Removes the given reflection probe from this scene.
  54747. * @param toRemove The reflection probe to remove
  54748. * @returns The index of the removed reflection probe
  54749. */
  54750. removeReflectionProbe(toRemove: ReflectionProbe): number;
  54751. /**
  54752. * Adds the given reflection probe to this scene.
  54753. * @param newReflectionProbe The reflection probe to add
  54754. */
  54755. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  54756. }
  54757. }
  54758. /**
  54759. * Class used to generate realtime reflection / refraction cube textures
  54760. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  54761. */
  54762. export class ReflectionProbe {
  54763. /** defines the name of the probe */
  54764. name: string;
  54765. private _scene;
  54766. private _renderTargetTexture;
  54767. private _projectionMatrix;
  54768. private _viewMatrix;
  54769. private _target;
  54770. private _add;
  54771. private _attachedMesh;
  54772. private _invertYAxis;
  54773. /** Gets or sets probe position (center of the cube map) */
  54774. position: Vector3;
  54775. /**
  54776. * Creates a new reflection probe
  54777. * @param name defines the name of the probe
  54778. * @param size defines the texture resolution (for each face)
  54779. * @param scene defines the hosting scene
  54780. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  54781. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  54782. */
  54783. constructor(
  54784. /** defines the name of the probe */
  54785. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  54786. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  54787. samples: number;
  54788. /** Gets or sets the refresh rate to use (on every frame by default) */
  54789. refreshRate: number;
  54790. /**
  54791. * Gets the hosting scene
  54792. * @returns a Scene
  54793. */
  54794. getScene(): Scene;
  54795. /** Gets the internal CubeTexture used to render to */
  54796. readonly cubeTexture: RenderTargetTexture;
  54797. /** Gets the list of meshes to render */
  54798. readonly renderList: Nullable<AbstractMesh[]>;
  54799. /**
  54800. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54801. * @param mesh defines the mesh to attach to
  54802. */
  54803. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54804. /**
  54805. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54806. * @param renderingGroupId The rendering group id corresponding to its index
  54807. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54808. */
  54809. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54810. /**
  54811. * Clean all associated resources
  54812. */
  54813. dispose(): void;
  54814. /**
  54815. * Converts the reflection probe information to a readable string for debug purpose.
  54816. * @param fullDetails Supports for multiple levels of logging within scene loading
  54817. * @returns the human readable reflection probe info
  54818. */
  54819. toString(fullDetails?: boolean): string;
  54820. /**
  54821. * Get the class name of the relfection probe.
  54822. * @returns "ReflectionProbe"
  54823. */
  54824. getClassName(): string;
  54825. /**
  54826. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54827. * @returns The JSON representation of the texture
  54828. */
  54829. serialize(): any;
  54830. /**
  54831. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54832. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54833. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54834. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54835. * @returns The parsed reflection probe if successful
  54836. */
  54837. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54838. }
  54839. }
  54840. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54841. /** @hidden */
  54842. export var _BabylonLoaderRegistered: boolean;
  54843. /**
  54844. * Helps setting up some configuration for the babylon file loader.
  54845. */
  54846. export class BabylonFileLoaderConfiguration {
  54847. /**
  54848. * The loader does not allow injecting custom physix engine into the plugins.
  54849. * Unfortunately in ES6, we need to manually inject them into the plugin.
  54850. * So you could set this variable to your engine import to make it work.
  54851. */
  54852. static LoaderInjectedPhysicsEngine: any;
  54853. }
  54854. }
  54855. declare module "babylonjs/Loading/Plugins/index" {
  54856. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54857. }
  54858. declare module "babylonjs/Loading/index" {
  54859. export * from "babylonjs/Loading/loadingScreen";
  54860. export * from "babylonjs/Loading/Plugins/index";
  54861. export * from "babylonjs/Loading/sceneLoader";
  54862. export * from "babylonjs/Loading/sceneLoaderFlags";
  54863. }
  54864. declare module "babylonjs/Materials/Background/index" {
  54865. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54866. }
  54867. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54868. import { Scene } from "babylonjs/scene";
  54869. import { Color3 } from "babylonjs/Maths/math.color";
  54870. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54872. /**
  54873. * The Physically based simple base material of BJS.
  54874. *
  54875. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54876. * It is used as the base class for both the specGloss and metalRough conventions.
  54877. */
  54878. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54879. /**
  54880. * Number of Simultaneous lights allowed on the material.
  54881. */
  54882. maxSimultaneousLights: number;
  54883. /**
  54884. * If sets to true, disables all the lights affecting the material.
  54885. */
  54886. disableLighting: boolean;
  54887. /**
  54888. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54889. */
  54890. environmentTexture: BaseTexture;
  54891. /**
  54892. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54893. */
  54894. invertNormalMapX: boolean;
  54895. /**
  54896. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54897. */
  54898. invertNormalMapY: boolean;
  54899. /**
  54900. * Normal map used in the model.
  54901. */
  54902. normalTexture: BaseTexture;
  54903. /**
  54904. * Emissivie color used to self-illuminate the model.
  54905. */
  54906. emissiveColor: Color3;
  54907. /**
  54908. * Emissivie texture used to self-illuminate the model.
  54909. */
  54910. emissiveTexture: BaseTexture;
  54911. /**
  54912. * Occlusion Channel Strenght.
  54913. */
  54914. occlusionStrength: number;
  54915. /**
  54916. * Occlusion Texture of the material (adding extra occlusion effects).
  54917. */
  54918. occlusionTexture: BaseTexture;
  54919. /**
  54920. * Defines the alpha limits in alpha test mode.
  54921. */
  54922. alphaCutOff: number;
  54923. /**
  54924. * Gets the current double sided mode.
  54925. */
  54926. /**
  54927. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54928. */
  54929. doubleSided: boolean;
  54930. /**
  54931. * Stores the pre-calculated light information of a mesh in a texture.
  54932. */
  54933. lightmapTexture: BaseTexture;
  54934. /**
  54935. * If true, the light map contains occlusion information instead of lighting info.
  54936. */
  54937. useLightmapAsShadowmap: boolean;
  54938. /**
  54939. * Instantiates a new PBRMaterial instance.
  54940. *
  54941. * @param name The material name
  54942. * @param scene The scene the material will be use in.
  54943. */
  54944. constructor(name: string, scene: Scene);
  54945. getClassName(): string;
  54946. }
  54947. }
  54948. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54949. import { Scene } from "babylonjs/scene";
  54950. import { Color3 } from "babylonjs/Maths/math.color";
  54951. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54952. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54953. /**
  54954. * The PBR material of BJS following the metal roughness convention.
  54955. *
  54956. * This fits to the PBR convention in the GLTF definition:
  54957. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54958. */
  54959. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54960. /**
  54961. * The base color has two different interpretations depending on the value of metalness.
  54962. * When the material is a metal, the base color is the specific measured reflectance value
  54963. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54964. * of the material.
  54965. */
  54966. baseColor: Color3;
  54967. /**
  54968. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54969. * well as opacity information in the alpha channel.
  54970. */
  54971. baseTexture: BaseTexture;
  54972. /**
  54973. * Specifies the metallic scalar value of the material.
  54974. * Can also be used to scale the metalness values of the metallic texture.
  54975. */
  54976. metallic: number;
  54977. /**
  54978. * Specifies the roughness scalar value of the material.
  54979. * Can also be used to scale the roughness values of the metallic texture.
  54980. */
  54981. roughness: number;
  54982. /**
  54983. * Texture containing both the metallic value in the B channel and the
  54984. * roughness value in the G channel to keep better precision.
  54985. */
  54986. metallicRoughnessTexture: BaseTexture;
  54987. /**
  54988. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54989. *
  54990. * @param name The material name
  54991. * @param scene The scene the material will be use in.
  54992. */
  54993. constructor(name: string, scene: Scene);
  54994. /**
  54995. * Return the currrent class name of the material.
  54996. */
  54997. getClassName(): string;
  54998. /**
  54999. * Makes a duplicate of the current material.
  55000. * @param name - name to use for the new material.
  55001. */
  55002. clone(name: string): PBRMetallicRoughnessMaterial;
  55003. /**
  55004. * Serialize the material to a parsable JSON object.
  55005. */
  55006. serialize(): any;
  55007. /**
  55008. * Parses a JSON object correponding to the serialize function.
  55009. */
  55010. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55011. }
  55012. }
  55013. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  55014. import { Scene } from "babylonjs/scene";
  55015. import { Color3 } from "babylonjs/Maths/math.color";
  55016. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55017. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55018. /**
  55019. * The PBR material of BJS following the specular glossiness convention.
  55020. *
  55021. * This fits to the PBR convention in the GLTF definition:
  55022. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55023. */
  55024. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55025. /**
  55026. * Specifies the diffuse color of the material.
  55027. */
  55028. diffuseColor: Color3;
  55029. /**
  55030. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55031. * channel.
  55032. */
  55033. diffuseTexture: BaseTexture;
  55034. /**
  55035. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55036. */
  55037. specularColor: Color3;
  55038. /**
  55039. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55040. */
  55041. glossiness: number;
  55042. /**
  55043. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55044. */
  55045. specularGlossinessTexture: BaseTexture;
  55046. /**
  55047. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55048. *
  55049. * @param name The material name
  55050. * @param scene The scene the material will be use in.
  55051. */
  55052. constructor(name: string, scene: Scene);
  55053. /**
  55054. * Return the currrent class name of the material.
  55055. */
  55056. getClassName(): string;
  55057. /**
  55058. * Makes a duplicate of the current material.
  55059. * @param name - name to use for the new material.
  55060. */
  55061. clone(name: string): PBRSpecularGlossinessMaterial;
  55062. /**
  55063. * Serialize the material to a parsable JSON object.
  55064. */
  55065. serialize(): any;
  55066. /**
  55067. * Parses a JSON object correponding to the serialize function.
  55068. */
  55069. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55070. }
  55071. }
  55072. declare module "babylonjs/Materials/PBR/index" {
  55073. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  55074. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  55075. export * from "babylonjs/Materials/PBR/pbrMaterial";
  55076. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  55077. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  55078. }
  55079. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  55080. import { Nullable } from "babylonjs/types";
  55081. import { Scene } from "babylonjs/scene";
  55082. import { Matrix } from "babylonjs/Maths/math.vector";
  55083. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55084. /**
  55085. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55086. * It can help converting any input color in a desired output one. This can then be used to create effects
  55087. * from sepia, black and white to sixties or futuristic rendering...
  55088. *
  55089. * The only supported format is currently 3dl.
  55090. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55091. */
  55092. export class ColorGradingTexture extends BaseTexture {
  55093. /**
  55094. * The current texture matrix. (will always be identity in color grading texture)
  55095. */
  55096. private _textureMatrix;
  55097. /**
  55098. * The texture URL.
  55099. */
  55100. url: string;
  55101. /**
  55102. * Empty line regex stored for GC.
  55103. */
  55104. private static _noneEmptyLineRegex;
  55105. private _engine;
  55106. /**
  55107. * Instantiates a ColorGradingTexture from the following parameters.
  55108. *
  55109. * @param url The location of the color gradind data (currently only supporting 3dl)
  55110. * @param scene The scene the texture will be used in
  55111. */
  55112. constructor(url: string, scene: Scene);
  55113. /**
  55114. * Returns the texture matrix used in most of the material.
  55115. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55116. */
  55117. getTextureMatrix(): Matrix;
  55118. /**
  55119. * Occurs when the file being loaded is a .3dl LUT file.
  55120. */
  55121. private load3dlTexture;
  55122. /**
  55123. * Starts the loading process of the texture.
  55124. */
  55125. private loadTexture;
  55126. /**
  55127. * Clones the color gradind texture.
  55128. */
  55129. clone(): ColorGradingTexture;
  55130. /**
  55131. * Called during delayed load for textures.
  55132. */
  55133. delayLoad(): void;
  55134. /**
  55135. * Parses a color grading texture serialized by Babylon.
  55136. * @param parsedTexture The texture information being parsedTexture
  55137. * @param scene The scene to load the texture in
  55138. * @param rootUrl The root url of the data assets to load
  55139. * @return A color gradind texture
  55140. */
  55141. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55142. /**
  55143. * Serializes the LUT texture to json format.
  55144. */
  55145. serialize(): any;
  55146. }
  55147. }
  55148. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  55149. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55150. import { Scene } from "babylonjs/scene";
  55151. import { Nullable } from "babylonjs/types";
  55152. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55153. /**
  55154. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55155. */
  55156. export class EquiRectangularCubeTexture extends BaseTexture {
  55157. /** The six faces of the cube. */
  55158. private static _FacesMapping;
  55159. private _noMipmap;
  55160. private _onLoad;
  55161. private _onError;
  55162. /** The size of the cubemap. */
  55163. private _size;
  55164. /** The buffer of the image. */
  55165. private _buffer;
  55166. /** The width of the input image. */
  55167. private _width;
  55168. /** The height of the input image. */
  55169. private _height;
  55170. /** The URL to the image. */
  55171. url: string;
  55172. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55173. coordinatesMode: number;
  55174. /**
  55175. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55176. * @param url The location of the image
  55177. * @param scene The scene the texture will be used in
  55178. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55179. * @param noMipmap Forces to not generate the mipmap if true
  55180. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55181. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55182. * @param onLoad — defines a callback called when texture is loaded
  55183. * @param onError — defines a callback called if there is an error
  55184. */
  55185. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55186. /**
  55187. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55188. */
  55189. private loadImage;
  55190. /**
  55191. * Convert the image buffer into a cubemap and create a CubeTexture.
  55192. */
  55193. private loadTexture;
  55194. /**
  55195. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55196. * @param buffer The ArrayBuffer that should be converted.
  55197. * @returns The buffer as Float32Array.
  55198. */
  55199. private getFloat32ArrayFromArrayBuffer;
  55200. /**
  55201. * Get the current class name of the texture useful for serialization or dynamic coding.
  55202. * @returns "EquiRectangularCubeTexture"
  55203. */
  55204. getClassName(): string;
  55205. /**
  55206. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55207. * @returns A clone of the current EquiRectangularCubeTexture.
  55208. */
  55209. clone(): EquiRectangularCubeTexture;
  55210. }
  55211. }
  55212. declare module "babylonjs/Misc/tga" {
  55213. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55214. /**
  55215. * Based on jsTGALoader - Javascript loader for TGA file
  55216. * By Vincent Thibault
  55217. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55218. */
  55219. export class TGATools {
  55220. private static _TYPE_INDEXED;
  55221. private static _TYPE_RGB;
  55222. private static _TYPE_GREY;
  55223. private static _TYPE_RLE_INDEXED;
  55224. private static _TYPE_RLE_RGB;
  55225. private static _TYPE_RLE_GREY;
  55226. private static _ORIGIN_MASK;
  55227. private static _ORIGIN_SHIFT;
  55228. private static _ORIGIN_BL;
  55229. private static _ORIGIN_BR;
  55230. private static _ORIGIN_UL;
  55231. private static _ORIGIN_UR;
  55232. /**
  55233. * Gets the header of a TGA file
  55234. * @param data defines the TGA data
  55235. * @returns the header
  55236. */
  55237. static GetTGAHeader(data: Uint8Array): any;
  55238. /**
  55239. * Uploads TGA content to a Babylon Texture
  55240. * @hidden
  55241. */
  55242. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55243. /** @hidden */
  55244. 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;
  55245. /** @hidden */
  55246. 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;
  55247. /** @hidden */
  55248. 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;
  55249. /** @hidden */
  55250. 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;
  55251. /** @hidden */
  55252. 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;
  55253. /** @hidden */
  55254. 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;
  55255. }
  55256. }
  55257. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  55258. import { Nullable } from "babylonjs/types";
  55259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55260. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55261. /**
  55262. * Implementation of the TGA Texture Loader.
  55263. * @hidden
  55264. */
  55265. export class _TGATextureLoader implements IInternalTextureLoader {
  55266. /**
  55267. * Defines wether the loader supports cascade loading the different faces.
  55268. */
  55269. readonly supportCascades: boolean;
  55270. /**
  55271. * This returns if the loader support the current file information.
  55272. * @param extension defines the file extension of the file being loaded
  55273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55274. * @param fallback defines the fallback internal texture if any
  55275. * @param isBase64 defines whether the texture is encoded as a base64
  55276. * @param isBuffer defines whether the texture data are stored as a buffer
  55277. * @returns true if the loader can load the specified file
  55278. */
  55279. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55280. /**
  55281. * Transform the url before loading if required.
  55282. * @param rootUrl the url of the texture
  55283. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55284. * @returns the transformed texture
  55285. */
  55286. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55287. /**
  55288. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55289. * @param rootUrl the url of the texture
  55290. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55291. * @returns the fallback texture
  55292. */
  55293. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55294. /**
  55295. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55296. * @param data contains the texture data
  55297. * @param texture defines the BabylonJS internal texture
  55298. * @param createPolynomials will be true if polynomials have been requested
  55299. * @param onLoad defines the callback to trigger once the texture is ready
  55300. * @param onError defines the callback to trigger in case of error
  55301. */
  55302. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55303. /**
  55304. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55305. * @param data contains the texture data
  55306. * @param texture defines the BabylonJS internal texture
  55307. * @param callback defines the method to call once ready to upload
  55308. */
  55309. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55310. }
  55311. }
  55312. declare module "babylonjs/Misc/basis" {
  55313. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55314. /**
  55315. * Info about the .basis files
  55316. */
  55317. class BasisFileInfo {
  55318. /**
  55319. * If the file has alpha
  55320. */
  55321. hasAlpha: boolean;
  55322. /**
  55323. * Info about each image of the basis file
  55324. */
  55325. images: Array<{
  55326. levels: Array<{
  55327. width: number;
  55328. height: number;
  55329. transcodedPixels: ArrayBufferView;
  55330. }>;
  55331. }>;
  55332. }
  55333. /**
  55334. * Result of transcoding a basis file
  55335. */
  55336. class TranscodeResult {
  55337. /**
  55338. * Info about the .basis file
  55339. */
  55340. fileInfo: BasisFileInfo;
  55341. /**
  55342. * Format to use when loading the file
  55343. */
  55344. format: number;
  55345. }
  55346. /**
  55347. * Configuration options for the Basis transcoder
  55348. */
  55349. export class BasisTranscodeConfiguration {
  55350. /**
  55351. * Supported compression formats used to determine the supported output format of the transcoder
  55352. */
  55353. supportedCompressionFormats?: {
  55354. /**
  55355. * etc1 compression format
  55356. */
  55357. etc1?: boolean;
  55358. /**
  55359. * s3tc compression format
  55360. */
  55361. s3tc?: boolean;
  55362. /**
  55363. * pvrtc compression format
  55364. */
  55365. pvrtc?: boolean;
  55366. /**
  55367. * etc2 compression format
  55368. */
  55369. etc2?: boolean;
  55370. };
  55371. /**
  55372. * If mipmap levels should be loaded for transcoded images (Default: true)
  55373. */
  55374. loadMipmapLevels?: boolean;
  55375. /**
  55376. * Index of a single image to load (Default: all images)
  55377. */
  55378. loadSingleImage?: number;
  55379. }
  55380. /**
  55381. * Used to load .Basis files
  55382. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  55383. */
  55384. export class BasisTools {
  55385. private static _IgnoreSupportedFormats;
  55386. /**
  55387. * URL to use when loading the basis transcoder
  55388. */
  55389. static JSModuleURL: string;
  55390. /**
  55391. * URL to use when loading the wasm module for the transcoder
  55392. */
  55393. static WasmModuleURL: string;
  55394. /**
  55395. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  55396. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  55397. * @returns internal format corresponding to the Basis format
  55398. */
  55399. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  55400. private static _WorkerPromise;
  55401. private static _Worker;
  55402. private static _actionId;
  55403. private static _CreateWorkerAsync;
  55404. /**
  55405. * Transcodes a loaded image file to compressed pixel data
  55406. * @param imageData image data to transcode
  55407. * @param config configuration options for the transcoding
  55408. * @returns a promise resulting in the transcoded image
  55409. */
  55410. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  55411. /**
  55412. * Loads a texture from the transcode result
  55413. * @param texture texture load to
  55414. * @param transcodeResult the result of transcoding the basis file to load from
  55415. */
  55416. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  55417. }
  55418. }
  55419. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  55420. import { Nullable } from "babylonjs/types";
  55421. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55422. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55423. /**
  55424. * Loader for .basis file format
  55425. */
  55426. export class _BasisTextureLoader implements IInternalTextureLoader {
  55427. /**
  55428. * Defines whether the loader supports cascade loading the different faces.
  55429. */
  55430. readonly supportCascades: boolean;
  55431. /**
  55432. * This returns if the loader support the current file information.
  55433. * @param extension defines the file extension of the file being loaded
  55434. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55435. * @param fallback defines the fallback internal texture if any
  55436. * @param isBase64 defines whether the texture is encoded as a base64
  55437. * @param isBuffer defines whether the texture data are stored as a buffer
  55438. * @returns true if the loader can load the specified file
  55439. */
  55440. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55441. /**
  55442. * Transform the url before loading if required.
  55443. * @param rootUrl the url of the texture
  55444. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55445. * @returns the transformed texture
  55446. */
  55447. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55448. /**
  55449. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55450. * @param rootUrl the url of the texture
  55451. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55452. * @returns the fallback texture
  55453. */
  55454. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55455. /**
  55456. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  55457. * @param data contains the texture data
  55458. * @param texture defines the BabylonJS internal texture
  55459. * @param createPolynomials will be true if polynomials have been requested
  55460. * @param onLoad defines the callback to trigger once the texture is ready
  55461. * @param onError defines the callback to trigger in case of error
  55462. */
  55463. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55464. /**
  55465. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55466. * @param data contains the texture data
  55467. * @param texture defines the BabylonJS internal texture
  55468. * @param callback defines the method to call once ready to upload
  55469. */
  55470. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55471. }
  55472. }
  55473. declare module "babylonjs/Materials/Textures/Loaders/index" {
  55474. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55475. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55476. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55477. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  55478. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  55479. }
  55480. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  55481. import { Scene } from "babylonjs/scene";
  55482. import { Texture } from "babylonjs/Materials/Textures/texture";
  55483. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55484. /**
  55485. * 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.
  55486. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55487. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55488. */
  55489. export class CustomProceduralTexture extends ProceduralTexture {
  55490. private _animate;
  55491. private _time;
  55492. private _config;
  55493. private _texturePath;
  55494. /**
  55495. * Instantiates a new Custom Procedural Texture.
  55496. * 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.
  55497. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  55498. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  55499. * @param name Define the name of the texture
  55500. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  55501. * @param size Define the size of the texture to create
  55502. * @param scene Define the scene the texture belongs to
  55503. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  55504. * @param generateMipMaps Define if the texture should creates mip maps or not
  55505. */
  55506. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55507. private _loadJson;
  55508. /**
  55509. * Is the texture ready to be used ? (rendered at least once)
  55510. * @returns true if ready, otherwise, false.
  55511. */
  55512. isReady(): boolean;
  55513. /**
  55514. * Render the texture to its associated render target.
  55515. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  55516. */
  55517. render(useCameraPostProcess?: boolean): void;
  55518. /**
  55519. * Update the list of dependant textures samplers in the shader.
  55520. */
  55521. updateTextures(): void;
  55522. /**
  55523. * Update the uniform values of the procedural texture in the shader.
  55524. */
  55525. updateShaderUniforms(): void;
  55526. /**
  55527. * Define if the texture animates or not.
  55528. */
  55529. animate: boolean;
  55530. }
  55531. }
  55532. declare module "babylonjs/Shaders/noise.fragment" {
  55533. /** @hidden */
  55534. export var noisePixelShader: {
  55535. name: string;
  55536. shader: string;
  55537. };
  55538. }
  55539. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  55540. import { Nullable } from "babylonjs/types";
  55541. import { Scene } from "babylonjs/scene";
  55542. import { Texture } from "babylonjs/Materials/Textures/texture";
  55543. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55544. import "babylonjs/Shaders/noise.fragment";
  55545. /**
  55546. * Class used to generate noise procedural textures
  55547. */
  55548. export class NoiseProceduralTexture extends ProceduralTexture {
  55549. private _time;
  55550. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  55551. brightness: number;
  55552. /** Defines the number of octaves to process */
  55553. octaves: number;
  55554. /** Defines the level of persistence (0.8 by default) */
  55555. persistence: number;
  55556. /** Gets or sets animation speed factor (default is 1) */
  55557. animationSpeedFactor: number;
  55558. /**
  55559. * Creates a new NoiseProceduralTexture
  55560. * @param name defines the name fo the texture
  55561. * @param size defines the size of the texture (default is 256)
  55562. * @param scene defines the hosting scene
  55563. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  55564. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  55565. */
  55566. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  55567. private _updateShaderUniforms;
  55568. protected _getDefines(): string;
  55569. /** Generate the current state of the procedural texture */
  55570. render(useCameraPostProcess?: boolean): void;
  55571. /**
  55572. * Serializes this noise procedural texture
  55573. * @returns a serialized noise procedural texture object
  55574. */
  55575. serialize(): any;
  55576. /**
  55577. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  55578. * @param parsedTexture defines parsed texture data
  55579. * @param scene defines the current scene
  55580. * @param rootUrl defines the root URL containing noise procedural texture information
  55581. * @returns a parsed NoiseProceduralTexture
  55582. */
  55583. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  55584. }
  55585. }
  55586. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  55587. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  55588. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  55589. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  55590. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  55591. }
  55592. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  55593. import { Nullable } from "babylonjs/types";
  55594. import { Scene } from "babylonjs/scene";
  55595. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  55596. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55597. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  55598. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55599. /**
  55600. * Raw cube texture where the raw buffers are passed in
  55601. */
  55602. export class RawCubeTexture extends CubeTexture {
  55603. /**
  55604. * Creates a cube texture where the raw buffers are passed in.
  55605. * @param scene defines the scene the texture is attached to
  55606. * @param data defines the array of data to use to create each face
  55607. * @param size defines the size of the textures
  55608. * @param format defines the format of the data
  55609. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  55610. * @param generateMipMaps defines if the engine should generate the mip levels
  55611. * @param invertY defines if data must be stored with Y axis inverted
  55612. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  55613. * @param compression defines the compression used (null by default)
  55614. */
  55615. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  55616. /**
  55617. * Updates the raw cube texture.
  55618. * @param data defines the data to store
  55619. * @param format defines the data format
  55620. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55621. * @param invertY defines if data must be stored with Y axis inverted
  55622. * @param compression defines the compression used (null by default)
  55623. * @param level defines which level of the texture to update
  55624. */
  55625. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  55626. /**
  55627. * Updates a raw cube texture with RGBD encoded data.
  55628. * @param data defines the array of data [mipmap][face] to use to create each face
  55629. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  55630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55632. * @returns a promsie that resolves when the operation is complete
  55633. */
  55634. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  55635. /**
  55636. * Clones the raw cube texture.
  55637. * @return a new cube texture
  55638. */
  55639. clone(): CubeTexture;
  55640. /** @hidden */
  55641. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55642. }
  55643. }
  55644. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  55645. import { Scene } from "babylonjs/scene";
  55646. import { Texture } from "babylonjs/Materials/Textures/texture";
  55647. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55648. /**
  55649. * Class used to store 3D textures containing user data
  55650. */
  55651. export class RawTexture3D extends Texture {
  55652. /** Gets or sets the texture format to use */
  55653. format: number;
  55654. private _engine;
  55655. /**
  55656. * Create a new RawTexture3D
  55657. * @param data defines the data of the texture
  55658. * @param width defines the width of the texture
  55659. * @param height defines the height of the texture
  55660. * @param depth defines the depth of the texture
  55661. * @param format defines the texture format to use
  55662. * @param scene defines the hosting scene
  55663. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55664. * @param invertY defines if texture must be stored with Y axis inverted
  55665. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55666. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55667. */
  55668. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55669. /** Gets or sets the texture format to use */
  55670. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55671. /**
  55672. * Update the texture with new data
  55673. * @param data defines the data to store in the texture
  55674. */
  55675. update(data: ArrayBufferView): void;
  55676. }
  55677. }
  55678. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  55679. import { Scene } from "babylonjs/scene";
  55680. import { Texture } from "babylonjs/Materials/Textures/texture";
  55681. import "babylonjs/Engines/Extensions/engine.rawTexture";
  55682. /**
  55683. * Class used to store 2D array textures containing user data
  55684. */
  55685. export class RawTexture2DArray extends Texture {
  55686. /** Gets or sets the texture format to use */
  55687. format: number;
  55688. private _engine;
  55689. /**
  55690. * Create a new RawTexture2DArray
  55691. * @param data defines the data of the texture
  55692. * @param width defines the width of the texture
  55693. * @param height defines the height of the texture
  55694. * @param depth defines the number of layers of the texture
  55695. * @param format defines the texture format to use
  55696. * @param scene defines the hosting scene
  55697. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  55698. * @param invertY defines if texture must be stored with Y axis inverted
  55699. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55700. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  55701. */
  55702. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  55703. /** Gets or sets the texture format to use */
  55704. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  55705. /**
  55706. * Update the texture with new data
  55707. * @param data defines the data to store in the texture
  55708. */
  55709. update(data: ArrayBufferView): void;
  55710. }
  55711. }
  55712. declare module "babylonjs/Materials/Textures/refractionTexture" {
  55713. import { Scene } from "babylonjs/scene";
  55714. import { Plane } from "babylonjs/Maths/math.plane";
  55715. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55716. /**
  55717. * Creates a refraction texture used by refraction channel of the standard material.
  55718. * It is like a mirror but to see through a material.
  55719. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55720. */
  55721. export class RefractionTexture extends RenderTargetTexture {
  55722. /**
  55723. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  55724. * 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.
  55725. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55726. */
  55727. refractionPlane: Plane;
  55728. /**
  55729. * Define how deep under the surface we should see.
  55730. */
  55731. depth: number;
  55732. /**
  55733. * Creates a refraction texture used by refraction channel of the standard material.
  55734. * It is like a mirror but to see through a material.
  55735. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  55736. * @param name Define the texture name
  55737. * @param size Define the size of the underlying texture
  55738. * @param scene Define the scene the refraction belongs to
  55739. * @param generateMipMaps Define if we need to generate mips level for the refraction
  55740. */
  55741. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  55742. /**
  55743. * Clone the refraction texture.
  55744. * @returns the cloned texture
  55745. */
  55746. clone(): RefractionTexture;
  55747. /**
  55748. * Serialize the texture to a JSON representation you could use in Parse later on
  55749. * @returns the serialized JSON representation
  55750. */
  55751. serialize(): any;
  55752. }
  55753. }
  55754. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  55755. import { Nullable } from "babylonjs/types";
  55756. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55757. import { Matrix } from "babylonjs/Maths/math.vector";
  55758. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  55759. import "babylonjs/Engines/Extensions/engine.videoTexture";
  55760. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55761. import { Scene } from "babylonjs/scene";
  55762. /**
  55763. * Defines the options related to the creation of an HtmlElementTexture
  55764. */
  55765. export interface IHtmlElementTextureOptions {
  55766. /**
  55767. * Defines wether mip maps should be created or not.
  55768. */
  55769. generateMipMaps?: boolean;
  55770. /**
  55771. * Defines the sampling mode of the texture.
  55772. */
  55773. samplingMode?: number;
  55774. /**
  55775. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  55776. */
  55777. engine: Nullable<ThinEngine>;
  55778. /**
  55779. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  55780. */
  55781. scene: Nullable<Scene>;
  55782. }
  55783. /**
  55784. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  55785. * To be as efficient as possible depending on your constraints nothing aside the first upload
  55786. * is automatically managed.
  55787. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  55788. * in your application.
  55789. *
  55790. * As the update is not automatic, you need to call them manually.
  55791. */
  55792. export class HtmlElementTexture extends BaseTexture {
  55793. /**
  55794. * The texture URL.
  55795. */
  55796. element: HTMLVideoElement | HTMLCanvasElement;
  55797. private static readonly DefaultOptions;
  55798. private _textureMatrix;
  55799. private _engine;
  55800. private _isVideo;
  55801. private _generateMipMaps;
  55802. private _samplingMode;
  55803. /**
  55804. * Instantiates a HtmlElementTexture from the following parameters.
  55805. *
  55806. * @param name Defines the name of the texture
  55807. * @param element Defines the video or canvas the texture is filled with
  55808. * @param options Defines the other none mandatory texture creation options
  55809. */
  55810. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  55811. private _createInternalTexture;
  55812. /**
  55813. * Returns the texture matrix used in most of the material.
  55814. */
  55815. getTextureMatrix(): Matrix;
  55816. /**
  55817. * Updates the content of the texture.
  55818. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  55819. */
  55820. update(invertY?: Nullable<boolean>): void;
  55821. }
  55822. }
  55823. declare module "babylonjs/Materials/Textures/index" {
  55824. export * from "babylonjs/Materials/Textures/baseTexture";
  55825. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  55826. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  55827. export * from "babylonjs/Materials/Textures/cubeTexture";
  55828. export * from "babylonjs/Materials/Textures/dynamicTexture";
  55829. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  55830. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  55831. export * from "babylonjs/Materials/Textures/internalTexture";
  55832. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  55833. export * from "babylonjs/Materials/Textures/Loaders/index";
  55834. export * from "babylonjs/Materials/Textures/mirrorTexture";
  55835. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  55836. export * from "babylonjs/Materials/Textures/Procedurals/index";
  55837. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  55838. export * from "babylonjs/Materials/Textures/rawTexture";
  55839. export * from "babylonjs/Materials/Textures/rawTexture3D";
  55840. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  55841. export * from "babylonjs/Materials/Textures/refractionTexture";
  55842. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  55843. export * from "babylonjs/Materials/Textures/texture";
  55844. export * from "babylonjs/Materials/Textures/videoTexture";
  55845. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55846. }
  55847. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55848. /**
  55849. * Enum used to define the target of a block
  55850. */
  55851. export enum NodeMaterialBlockTargets {
  55852. /** Vertex shader */
  55853. Vertex = 1,
  55854. /** Fragment shader */
  55855. Fragment = 2,
  55856. /** Neutral */
  55857. Neutral = 4,
  55858. /** Vertex and Fragment */
  55859. VertexAndFragment = 3
  55860. }
  55861. }
  55862. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55863. /**
  55864. * Defines the kind of connection point for node based material
  55865. */
  55866. export enum NodeMaterialBlockConnectionPointTypes {
  55867. /** Float */
  55868. Float = 1,
  55869. /** Int */
  55870. Int = 2,
  55871. /** Vector2 */
  55872. Vector2 = 4,
  55873. /** Vector3 */
  55874. Vector3 = 8,
  55875. /** Vector4 */
  55876. Vector4 = 16,
  55877. /** Color3 */
  55878. Color3 = 32,
  55879. /** Color4 */
  55880. Color4 = 64,
  55881. /** Matrix */
  55882. Matrix = 128,
  55883. /** Detect type based on connection */
  55884. AutoDetect = 1024,
  55885. /** Output type that will be defined by input type */
  55886. BasedOnInput = 2048
  55887. }
  55888. }
  55889. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55890. /**
  55891. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55892. */
  55893. export enum NodeMaterialBlockConnectionPointMode {
  55894. /** Value is an uniform */
  55895. Uniform = 0,
  55896. /** Value is a mesh attribute */
  55897. Attribute = 1,
  55898. /** Value is a varying between vertex and fragment shaders */
  55899. Varying = 2,
  55900. /** Mode is undefined */
  55901. Undefined = 3
  55902. }
  55903. }
  55904. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55905. /**
  55906. * Enum used to define system values e.g. values automatically provided by the system
  55907. */
  55908. export enum NodeMaterialSystemValues {
  55909. /** World */
  55910. World = 1,
  55911. /** View */
  55912. View = 2,
  55913. /** Projection */
  55914. Projection = 3,
  55915. /** ViewProjection */
  55916. ViewProjection = 4,
  55917. /** WorldView */
  55918. WorldView = 5,
  55919. /** WorldViewProjection */
  55920. WorldViewProjection = 6,
  55921. /** CameraPosition */
  55922. CameraPosition = 7,
  55923. /** Fog Color */
  55924. FogColor = 8,
  55925. /** Delta time */
  55926. DeltaTime = 9
  55927. }
  55928. }
  55929. declare module "babylonjs/Materials/Node/Enums/index" {
  55930. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55931. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55932. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55933. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55934. }
  55935. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55936. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55937. /**
  55938. * Root class for all node material optimizers
  55939. */
  55940. export class NodeMaterialOptimizer {
  55941. /**
  55942. * Function used to optimize a NodeMaterial graph
  55943. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55944. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55945. */
  55946. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55947. }
  55948. }
  55949. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55950. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55951. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55952. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55953. import { Scene } from "babylonjs/scene";
  55954. /**
  55955. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55956. */
  55957. export class TransformBlock extends NodeMaterialBlock {
  55958. /**
  55959. * Defines the value to use to complement W value to transform it to a Vector4
  55960. */
  55961. complementW: number;
  55962. /**
  55963. * Defines the value to use to complement z value to transform it to a Vector4
  55964. */
  55965. complementZ: number;
  55966. /**
  55967. * Creates a new TransformBlock
  55968. * @param name defines the block name
  55969. */
  55970. constructor(name: string);
  55971. /**
  55972. * Gets the current class name
  55973. * @returns the class name
  55974. */
  55975. getClassName(): string;
  55976. /**
  55977. * Gets the vector input
  55978. */
  55979. readonly vector: NodeMaterialConnectionPoint;
  55980. /**
  55981. * Gets the output component
  55982. */
  55983. readonly output: NodeMaterialConnectionPoint;
  55984. /**
  55985. * Gets the matrix transform input
  55986. */
  55987. readonly transform: NodeMaterialConnectionPoint;
  55988. protected _buildBlock(state: NodeMaterialBuildState): this;
  55989. serialize(): any;
  55990. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55991. protected _dumpPropertiesCode(): string;
  55992. }
  55993. }
  55994. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55998. /**
  55999. * Block used to output the vertex position
  56000. */
  56001. export class VertexOutputBlock extends NodeMaterialBlock {
  56002. /**
  56003. * Creates a new VertexOutputBlock
  56004. * @param name defines the block name
  56005. */
  56006. constructor(name: string);
  56007. /**
  56008. * Gets the current class name
  56009. * @returns the class name
  56010. */
  56011. getClassName(): string;
  56012. /**
  56013. * Gets the vector input component
  56014. */
  56015. readonly vector: NodeMaterialConnectionPoint;
  56016. protected _buildBlock(state: NodeMaterialBuildState): this;
  56017. }
  56018. }
  56019. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  56020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56023. /**
  56024. * Block used to output the final color
  56025. */
  56026. export class FragmentOutputBlock extends NodeMaterialBlock {
  56027. /**
  56028. * Create a new FragmentOutputBlock
  56029. * @param name defines the block name
  56030. */
  56031. constructor(name: string);
  56032. /**
  56033. * Gets the current class name
  56034. * @returns the class name
  56035. */
  56036. getClassName(): string;
  56037. /**
  56038. * Gets the rgba input component
  56039. */
  56040. readonly rgba: NodeMaterialConnectionPoint;
  56041. /**
  56042. * Gets the rgb input component
  56043. */
  56044. readonly rgb: NodeMaterialConnectionPoint;
  56045. /**
  56046. * Gets the a input component
  56047. */
  56048. readonly a: NodeMaterialConnectionPoint;
  56049. protected _buildBlock(state: NodeMaterialBuildState): this;
  56050. }
  56051. }
  56052. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  56053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56054. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56056. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56057. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56058. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56059. import { Effect } from "babylonjs/Materials/effect";
  56060. import { Mesh } from "babylonjs/Meshes/mesh";
  56061. import { Nullable } from "babylonjs/types";
  56062. import { Scene } from "babylonjs/scene";
  56063. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56064. /**
  56065. * Block used to read a reflection texture from a sampler
  56066. */
  56067. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56068. private _define3DName;
  56069. private _defineCubicName;
  56070. private _defineExplicitName;
  56071. private _defineProjectionName;
  56072. private _defineLocalCubicName;
  56073. private _defineSphericalName;
  56074. private _definePlanarName;
  56075. private _defineEquirectangularName;
  56076. private _defineMirroredEquirectangularFixedName;
  56077. private _defineEquirectangularFixedName;
  56078. private _defineSkyboxName;
  56079. private _cubeSamplerName;
  56080. private _2DSamplerName;
  56081. private _positionUVWName;
  56082. private _directionWName;
  56083. private _reflectionCoordsName;
  56084. private _reflection2DCoordsName;
  56085. private _reflectionColorName;
  56086. private _reflectionMatrixName;
  56087. /**
  56088. * Gets or sets the texture associated with the node
  56089. */
  56090. texture: Nullable<BaseTexture>;
  56091. /**
  56092. * Create a new TextureBlock
  56093. * @param name defines the block name
  56094. */
  56095. constructor(name: string);
  56096. /**
  56097. * Gets the current class name
  56098. * @returns the class name
  56099. */
  56100. getClassName(): string;
  56101. /**
  56102. * Gets the world position input component
  56103. */
  56104. readonly position: NodeMaterialConnectionPoint;
  56105. /**
  56106. * Gets the world position input component
  56107. */
  56108. readonly worldPosition: NodeMaterialConnectionPoint;
  56109. /**
  56110. * Gets the world normal input component
  56111. */
  56112. readonly worldNormal: NodeMaterialConnectionPoint;
  56113. /**
  56114. * Gets the world input component
  56115. */
  56116. readonly world: NodeMaterialConnectionPoint;
  56117. /**
  56118. * Gets the camera (or eye) position component
  56119. */
  56120. readonly cameraPosition: NodeMaterialConnectionPoint;
  56121. /**
  56122. * Gets the view input component
  56123. */
  56124. readonly view: NodeMaterialConnectionPoint;
  56125. /**
  56126. * Gets the rgb output component
  56127. */
  56128. readonly rgb: NodeMaterialConnectionPoint;
  56129. /**
  56130. * Gets the r output component
  56131. */
  56132. readonly r: NodeMaterialConnectionPoint;
  56133. /**
  56134. * Gets the g output component
  56135. */
  56136. readonly g: NodeMaterialConnectionPoint;
  56137. /**
  56138. * Gets the b output component
  56139. */
  56140. readonly b: NodeMaterialConnectionPoint;
  56141. autoConfigure(material: NodeMaterial): void;
  56142. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56143. isReady(): boolean;
  56144. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56145. private _injectVertexCode;
  56146. private _writeOutput;
  56147. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56148. protected _dumpPropertiesCode(): string;
  56149. serialize(): any;
  56150. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56151. }
  56152. }
  56153. declare module "babylonjs/Materials/Node/nodeMaterial" {
  56154. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56155. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56156. import { Scene } from "babylonjs/scene";
  56157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56158. import { Matrix } from "babylonjs/Maths/math.vector";
  56159. import { Mesh } from "babylonjs/Meshes/mesh";
  56160. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56161. import { Observable } from "babylonjs/Misc/observable";
  56162. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56163. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  56164. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  56165. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  56166. import { Nullable } from "babylonjs/types";
  56167. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56168. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56169. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56170. /**
  56171. * Interface used to configure the node material editor
  56172. */
  56173. export interface INodeMaterialEditorOptions {
  56174. /** Define the URl to load node editor script */
  56175. editorURL?: string;
  56176. }
  56177. /** @hidden */
  56178. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56179. /** BONES */
  56180. NUM_BONE_INFLUENCERS: number;
  56181. BonesPerMesh: number;
  56182. BONETEXTURE: boolean;
  56183. /** MORPH TARGETS */
  56184. MORPHTARGETS: boolean;
  56185. MORPHTARGETS_NORMAL: boolean;
  56186. MORPHTARGETS_TANGENT: boolean;
  56187. MORPHTARGETS_UV: boolean;
  56188. NUM_MORPH_INFLUENCERS: number;
  56189. /** IMAGE PROCESSING */
  56190. IMAGEPROCESSING: boolean;
  56191. VIGNETTE: boolean;
  56192. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56193. VIGNETTEBLENDMODEOPAQUE: boolean;
  56194. TONEMAPPING: boolean;
  56195. TONEMAPPING_ACES: boolean;
  56196. CONTRAST: boolean;
  56197. EXPOSURE: boolean;
  56198. COLORCURVES: boolean;
  56199. COLORGRADING: boolean;
  56200. COLORGRADING3D: boolean;
  56201. SAMPLER3DGREENDEPTH: boolean;
  56202. SAMPLER3DBGRMAP: boolean;
  56203. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56204. /** MISC. */
  56205. BUMPDIRECTUV: number;
  56206. constructor();
  56207. setValue(name: string, value: boolean): void;
  56208. }
  56209. /**
  56210. * Class used to configure NodeMaterial
  56211. */
  56212. export interface INodeMaterialOptions {
  56213. /**
  56214. * Defines if blocks should emit comments
  56215. */
  56216. emitComments: boolean;
  56217. }
  56218. /**
  56219. * Class used to create a node based material built by assembling shader blocks
  56220. */
  56221. export class NodeMaterial extends PushMaterial {
  56222. private static _BuildIdGenerator;
  56223. private _options;
  56224. private _vertexCompilationState;
  56225. private _fragmentCompilationState;
  56226. private _sharedData;
  56227. private _buildId;
  56228. private _buildWasSuccessful;
  56229. private _cachedWorldViewMatrix;
  56230. private _cachedWorldViewProjectionMatrix;
  56231. private _optimizers;
  56232. private _animationFrame;
  56233. /** Define the URl to load node editor script */
  56234. static EditorURL: string;
  56235. private BJSNODEMATERIALEDITOR;
  56236. /** Get the inspector from bundle or global */
  56237. private _getGlobalNodeMaterialEditor;
  56238. /**
  56239. * Gets or sets data used by visual editor
  56240. * @see https://nme.babylonjs.com
  56241. */
  56242. editorData: any;
  56243. /**
  56244. * 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)
  56245. */
  56246. ignoreAlpha: boolean;
  56247. /**
  56248. * Defines the maximum number of lights that can be used in the material
  56249. */
  56250. maxSimultaneousLights: number;
  56251. /**
  56252. * Observable raised when the material is built
  56253. */
  56254. onBuildObservable: Observable<NodeMaterial>;
  56255. /**
  56256. * Gets or sets the root nodes of the material vertex shader
  56257. */
  56258. _vertexOutputNodes: NodeMaterialBlock[];
  56259. /**
  56260. * Gets or sets the root nodes of the material fragment (pixel) shader
  56261. */
  56262. _fragmentOutputNodes: NodeMaterialBlock[];
  56263. /** Gets or sets options to control the node material overall behavior */
  56264. options: INodeMaterialOptions;
  56265. /**
  56266. * Default configuration related to image processing available in the standard Material.
  56267. */
  56268. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56269. /**
  56270. * Gets the image processing configuration used either in this material.
  56271. */
  56272. /**
  56273. * Sets the Default image processing configuration used either in the this material.
  56274. *
  56275. * If sets to null, the scene one is in use.
  56276. */
  56277. imageProcessingConfiguration: ImageProcessingConfiguration;
  56278. /**
  56279. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  56280. */
  56281. attachedBlocks: NodeMaterialBlock[];
  56282. /**
  56283. * Create a new node based material
  56284. * @param name defines the material name
  56285. * @param scene defines the hosting scene
  56286. * @param options defines creation option
  56287. */
  56288. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  56289. /**
  56290. * Gets the current class name of the material e.g. "NodeMaterial"
  56291. * @returns the class name
  56292. */
  56293. getClassName(): string;
  56294. /**
  56295. * Keep track of the image processing observer to allow dispose and replace.
  56296. */
  56297. private _imageProcessingObserver;
  56298. /**
  56299. * Attaches a new image processing configuration to the Standard Material.
  56300. * @param configuration
  56301. */
  56302. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56303. /**
  56304. * Get a block by its name
  56305. * @param name defines the name of the block to retrieve
  56306. * @returns the required block or null if not found
  56307. */
  56308. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  56309. /**
  56310. * Get a block by its name
  56311. * @param predicate defines the predicate used to find the good candidate
  56312. * @returns the required block or null if not found
  56313. */
  56314. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  56315. /**
  56316. * Get an input block by its name
  56317. * @param predicate defines the predicate used to find the good candidate
  56318. * @returns the required input block or null if not found
  56319. */
  56320. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  56321. /**
  56322. * Gets the list of input blocks attached to this material
  56323. * @returns an array of InputBlocks
  56324. */
  56325. getInputBlocks(): InputBlock[];
  56326. /**
  56327. * Adds a new optimizer to the list of optimizers
  56328. * @param optimizer defines the optimizers to add
  56329. * @returns the current material
  56330. */
  56331. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56332. /**
  56333. * Remove an optimizer from the list of optimizers
  56334. * @param optimizer defines the optimizers to remove
  56335. * @returns the current material
  56336. */
  56337. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  56338. /**
  56339. * Add a new block to the list of output nodes
  56340. * @param node defines the node to add
  56341. * @returns the current material
  56342. */
  56343. addOutputNode(node: NodeMaterialBlock): this;
  56344. /**
  56345. * Remove a block from the list of root nodes
  56346. * @param node defines the node to remove
  56347. * @returns the current material
  56348. */
  56349. removeOutputNode(node: NodeMaterialBlock): this;
  56350. private _addVertexOutputNode;
  56351. private _removeVertexOutputNode;
  56352. private _addFragmentOutputNode;
  56353. private _removeFragmentOutputNode;
  56354. /**
  56355. * Specifies if the material will require alpha blending
  56356. * @returns a boolean specifying if alpha blending is needed
  56357. */
  56358. needAlphaBlending(): boolean;
  56359. /**
  56360. * Specifies if this material should be rendered in alpha test mode
  56361. * @returns a boolean specifying if an alpha test is needed.
  56362. */
  56363. needAlphaTesting(): boolean;
  56364. private _initializeBlock;
  56365. private _resetDualBlocks;
  56366. /**
  56367. * Build the material and generates the inner effect
  56368. * @param verbose defines if the build should log activity
  56369. */
  56370. build(verbose?: boolean): void;
  56371. /**
  56372. * Runs an otpimization phase to try to improve the shader code
  56373. */
  56374. optimize(): void;
  56375. private _prepareDefinesForAttributes;
  56376. /**
  56377. * Get if the submesh is ready to be used and all its information available.
  56378. * Child classes can use it to update shaders
  56379. * @param mesh defines the mesh to check
  56380. * @param subMesh defines which submesh to check
  56381. * @param useInstances specifies that instances should be used
  56382. * @returns a boolean indicating that the submesh is ready or not
  56383. */
  56384. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56385. /**
  56386. * Get a string representing the shaders built by the current node graph
  56387. */
  56388. readonly compiledShaders: string;
  56389. /**
  56390. * Binds the world matrix to the material
  56391. * @param world defines the world transformation matrix
  56392. */
  56393. bindOnlyWorldMatrix(world: Matrix): void;
  56394. /**
  56395. * Binds the submesh to this material by preparing the effect and shader to draw
  56396. * @param world defines the world transformation matrix
  56397. * @param mesh defines the mesh containing the submesh
  56398. * @param subMesh defines the submesh to bind the material to
  56399. */
  56400. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56401. /**
  56402. * Gets the active textures from the material
  56403. * @returns an array of textures
  56404. */
  56405. getActiveTextures(): BaseTexture[];
  56406. /**
  56407. * Gets the list of texture blocks
  56408. * @returns an array of texture blocks
  56409. */
  56410. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  56411. /**
  56412. * Specifies if the material uses a texture
  56413. * @param texture defines the texture to check against the material
  56414. * @returns a boolean specifying if the material uses the texture
  56415. */
  56416. hasTexture(texture: BaseTexture): boolean;
  56417. /**
  56418. * Disposes the material
  56419. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  56420. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  56421. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  56422. */
  56423. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  56424. /** Creates the node editor window. */
  56425. private _createNodeEditor;
  56426. /**
  56427. * Launch the node material editor
  56428. * @param config Define the configuration of the editor
  56429. * @return a promise fulfilled when the node editor is visible
  56430. */
  56431. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  56432. /**
  56433. * Clear the current material
  56434. */
  56435. clear(): void;
  56436. /**
  56437. * Clear the current material and set it to a default state
  56438. */
  56439. setToDefault(): void;
  56440. /**
  56441. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  56442. * @param url defines the url to load from
  56443. * @returns a promise that will fullfil when the material is fully loaded
  56444. */
  56445. loadAsync(url: string): Promise<void>;
  56446. private _gatherBlocks;
  56447. /**
  56448. * Generate a string containing the code declaration required to create an equivalent of this material
  56449. * @returns a string
  56450. */
  56451. generateCode(): string;
  56452. /**
  56453. * Serializes this material in a JSON representation
  56454. * @returns the serialized material object
  56455. */
  56456. serialize(): any;
  56457. private _restoreConnections;
  56458. /**
  56459. * Clear the current graph and load a new one from a serialization object
  56460. * @param source defines the JSON representation of the material
  56461. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56462. */
  56463. loadFromSerialization(source: any, rootUrl?: string): void;
  56464. /**
  56465. * Creates a node material from parsed material data
  56466. * @param source defines the JSON representation of the material
  56467. * @param scene defines the hosting scene
  56468. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56469. * @returns a new node material
  56470. */
  56471. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  56472. /**
  56473. * Creates a new node material set to default basic configuration
  56474. * @param name defines the name of the material
  56475. * @param scene defines the hosting scene
  56476. * @returns a new NodeMaterial
  56477. */
  56478. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  56479. }
  56480. }
  56481. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  56482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56484. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56487. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56488. import { Effect } from "babylonjs/Materials/effect";
  56489. import { Mesh } from "babylonjs/Meshes/mesh";
  56490. import { Nullable } from "babylonjs/types";
  56491. import { Texture } from "babylonjs/Materials/Textures/texture";
  56492. import { Scene } from "babylonjs/scene";
  56493. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56494. /**
  56495. * Block used to read a texture from a sampler
  56496. */
  56497. export class TextureBlock extends NodeMaterialBlock {
  56498. private _defineName;
  56499. private _linearDefineName;
  56500. private _tempTextureRead;
  56501. private _samplerName;
  56502. private _transformedUVName;
  56503. private _textureTransformName;
  56504. private _textureInfoName;
  56505. private _mainUVName;
  56506. private _mainUVDefineName;
  56507. /**
  56508. * Gets or sets the texture associated with the node
  56509. */
  56510. texture: Nullable<Texture>;
  56511. /**
  56512. * Create a new TextureBlock
  56513. * @param name defines the block name
  56514. */
  56515. constructor(name: string);
  56516. /**
  56517. * Gets the current class name
  56518. * @returns the class name
  56519. */
  56520. getClassName(): string;
  56521. /**
  56522. * Gets the uv input component
  56523. */
  56524. readonly uv: NodeMaterialConnectionPoint;
  56525. /**
  56526. * Gets the rgba output component
  56527. */
  56528. readonly rgba: NodeMaterialConnectionPoint;
  56529. /**
  56530. * Gets the rgb output component
  56531. */
  56532. readonly rgb: NodeMaterialConnectionPoint;
  56533. /**
  56534. * Gets the r output component
  56535. */
  56536. readonly r: NodeMaterialConnectionPoint;
  56537. /**
  56538. * Gets the g output component
  56539. */
  56540. readonly g: NodeMaterialConnectionPoint;
  56541. /**
  56542. * Gets the b output component
  56543. */
  56544. readonly b: NodeMaterialConnectionPoint;
  56545. /**
  56546. * Gets the a output component
  56547. */
  56548. readonly a: NodeMaterialConnectionPoint;
  56549. readonly target: NodeMaterialBlockTargets;
  56550. autoConfigure(material: NodeMaterial): void;
  56551. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56552. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56553. isReady(): boolean;
  56554. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56555. private readonly _isMixed;
  56556. private _injectVertexCode;
  56557. private _writeTextureRead;
  56558. private _writeOutput;
  56559. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56560. protected _dumpPropertiesCode(): string;
  56561. serialize(): any;
  56562. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56563. }
  56564. }
  56565. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  56566. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56567. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56568. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56569. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56570. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56571. import { Scene } from "babylonjs/scene";
  56572. /**
  56573. * Class used to store shared data between 2 NodeMaterialBuildState
  56574. */
  56575. export class NodeMaterialBuildStateSharedData {
  56576. /**
  56577. * Gets the list of emitted varyings
  56578. */
  56579. temps: string[];
  56580. /**
  56581. * Gets the list of emitted varyings
  56582. */
  56583. varyings: string[];
  56584. /**
  56585. * Gets the varying declaration string
  56586. */
  56587. varyingDeclaration: string;
  56588. /**
  56589. * Input blocks
  56590. */
  56591. inputBlocks: InputBlock[];
  56592. /**
  56593. * Input blocks
  56594. */
  56595. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  56596. /**
  56597. * Bindable blocks (Blocks that need to set data to the effect)
  56598. */
  56599. bindableBlocks: NodeMaterialBlock[];
  56600. /**
  56601. * List of blocks that can provide a compilation fallback
  56602. */
  56603. blocksWithFallbacks: NodeMaterialBlock[];
  56604. /**
  56605. * List of blocks that can provide a define update
  56606. */
  56607. blocksWithDefines: NodeMaterialBlock[];
  56608. /**
  56609. * List of blocks that can provide a repeatable content
  56610. */
  56611. repeatableContentBlocks: NodeMaterialBlock[];
  56612. /**
  56613. * List of blocks that can provide a dynamic list of uniforms
  56614. */
  56615. dynamicUniformBlocks: NodeMaterialBlock[];
  56616. /**
  56617. * List of blocks that can block the isReady function for the material
  56618. */
  56619. blockingBlocks: NodeMaterialBlock[];
  56620. /**
  56621. * Gets the list of animated inputs
  56622. */
  56623. animatedInputs: InputBlock[];
  56624. /**
  56625. * Build Id used to avoid multiple recompilations
  56626. */
  56627. buildId: number;
  56628. /** List of emitted variables */
  56629. variableNames: {
  56630. [key: string]: number;
  56631. };
  56632. /** List of emitted defines */
  56633. defineNames: {
  56634. [key: string]: number;
  56635. };
  56636. /** Should emit comments? */
  56637. emitComments: boolean;
  56638. /** Emit build activity */
  56639. verbose: boolean;
  56640. /** Gets or sets the hosting scene */
  56641. scene: Scene;
  56642. /**
  56643. * Gets the compilation hints emitted at compilation time
  56644. */
  56645. hints: {
  56646. needWorldViewMatrix: boolean;
  56647. needWorldViewProjectionMatrix: boolean;
  56648. needAlphaBlending: boolean;
  56649. needAlphaTesting: boolean;
  56650. };
  56651. /**
  56652. * List of compilation checks
  56653. */
  56654. checks: {
  56655. emitVertex: boolean;
  56656. emitFragment: boolean;
  56657. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  56658. };
  56659. /** Creates a new shared data */
  56660. constructor();
  56661. /**
  56662. * Emits console errors and exceptions if there is a failing check
  56663. */
  56664. emitErrors(): void;
  56665. }
  56666. }
  56667. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  56668. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56669. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56670. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  56671. /**
  56672. * Class used to store node based material build state
  56673. */
  56674. export class NodeMaterialBuildState {
  56675. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  56676. supportUniformBuffers: boolean;
  56677. /**
  56678. * Gets the list of emitted attributes
  56679. */
  56680. attributes: string[];
  56681. /**
  56682. * Gets the list of emitted uniforms
  56683. */
  56684. uniforms: string[];
  56685. /**
  56686. * Gets the list of emitted constants
  56687. */
  56688. constants: string[];
  56689. /**
  56690. * Gets the list of emitted samplers
  56691. */
  56692. samplers: string[];
  56693. /**
  56694. * Gets the list of emitted functions
  56695. */
  56696. functions: {
  56697. [key: string]: string;
  56698. };
  56699. /**
  56700. * Gets the list of emitted extensions
  56701. */
  56702. extensions: {
  56703. [key: string]: string;
  56704. };
  56705. /**
  56706. * Gets the target of the compilation state
  56707. */
  56708. target: NodeMaterialBlockTargets;
  56709. /**
  56710. * Gets the list of emitted counters
  56711. */
  56712. counters: {
  56713. [key: string]: number;
  56714. };
  56715. /**
  56716. * Shared data between multiple NodeMaterialBuildState instances
  56717. */
  56718. sharedData: NodeMaterialBuildStateSharedData;
  56719. /** @hidden */
  56720. _vertexState: NodeMaterialBuildState;
  56721. /** @hidden */
  56722. _attributeDeclaration: string;
  56723. /** @hidden */
  56724. _uniformDeclaration: string;
  56725. /** @hidden */
  56726. _constantDeclaration: string;
  56727. /** @hidden */
  56728. _samplerDeclaration: string;
  56729. /** @hidden */
  56730. _varyingTransfer: string;
  56731. private _repeatableContentAnchorIndex;
  56732. /** @hidden */
  56733. _builtCompilationString: string;
  56734. /**
  56735. * Gets the emitted compilation strings
  56736. */
  56737. compilationString: string;
  56738. /**
  56739. * Finalize the compilation strings
  56740. * @param state defines the current compilation state
  56741. */
  56742. finalize(state: NodeMaterialBuildState): void;
  56743. /** @hidden */
  56744. readonly _repeatableContentAnchor: string;
  56745. /** @hidden */
  56746. _getFreeVariableName(prefix: string): string;
  56747. /** @hidden */
  56748. _getFreeDefineName(prefix: string): string;
  56749. /** @hidden */
  56750. _excludeVariableName(name: string): void;
  56751. /** @hidden */
  56752. _emit2DSampler(name: string): void;
  56753. /** @hidden */
  56754. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  56755. /** @hidden */
  56756. _emitExtension(name: string, extension: string): void;
  56757. /** @hidden */
  56758. _emitFunction(name: string, code: string, comments: string): void;
  56759. /** @hidden */
  56760. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  56761. replaceStrings?: {
  56762. search: RegExp;
  56763. replace: string;
  56764. }[];
  56765. repeatKey?: string;
  56766. }): string;
  56767. /** @hidden */
  56768. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  56769. repeatKey?: string;
  56770. removeAttributes?: boolean;
  56771. removeUniforms?: boolean;
  56772. removeVaryings?: boolean;
  56773. removeIfDef?: boolean;
  56774. replaceStrings?: {
  56775. search: RegExp;
  56776. replace: string;
  56777. }[];
  56778. }, storeKey?: string): void;
  56779. /** @hidden */
  56780. _registerTempVariable(name: string): boolean;
  56781. /** @hidden */
  56782. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  56783. /** @hidden */
  56784. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  56785. /** @hidden */
  56786. _emitFloat(value: number): string;
  56787. }
  56788. }
  56789. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  56790. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56792. import { Nullable } from "babylonjs/types";
  56793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56794. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56795. import { Effect } from "babylonjs/Materials/effect";
  56796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56797. import { Mesh } from "babylonjs/Meshes/mesh";
  56798. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56799. import { Scene } from "babylonjs/scene";
  56800. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56801. /**
  56802. * Defines a block that can be used inside a node based material
  56803. */
  56804. export class NodeMaterialBlock {
  56805. private _buildId;
  56806. private _buildTarget;
  56807. private _target;
  56808. private _isFinalMerger;
  56809. private _isInput;
  56810. protected _isUnique: boolean;
  56811. /** @hidden */
  56812. _codeVariableName: string;
  56813. /** @hidden */
  56814. _inputs: NodeMaterialConnectionPoint[];
  56815. /** @hidden */
  56816. _outputs: NodeMaterialConnectionPoint[];
  56817. /** @hidden */
  56818. _preparationId: number;
  56819. /**
  56820. * Gets or sets the name of the block
  56821. */
  56822. name: string;
  56823. /**
  56824. * Gets or sets the unique id of the node
  56825. */
  56826. uniqueId: number;
  56827. /**
  56828. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  56829. */
  56830. readonly isUnique: boolean;
  56831. /**
  56832. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  56833. */
  56834. readonly isFinalMerger: boolean;
  56835. /**
  56836. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  56837. */
  56838. readonly isInput: boolean;
  56839. /**
  56840. * Gets or sets the build Id
  56841. */
  56842. buildId: number;
  56843. /**
  56844. * Gets or sets the target of the block
  56845. */
  56846. target: NodeMaterialBlockTargets;
  56847. /**
  56848. * Gets the list of input points
  56849. */
  56850. readonly inputs: NodeMaterialConnectionPoint[];
  56851. /** Gets the list of output points */
  56852. readonly outputs: NodeMaterialConnectionPoint[];
  56853. /**
  56854. * Find an input by its name
  56855. * @param name defines the name of the input to look for
  56856. * @returns the input or null if not found
  56857. */
  56858. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56859. /**
  56860. * Find an output by its name
  56861. * @param name defines the name of the outputto look for
  56862. * @returns the output or null if not found
  56863. */
  56864. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56865. /**
  56866. * Creates a new NodeMaterialBlock
  56867. * @param name defines the block name
  56868. * @param target defines the target of that block (Vertex by default)
  56869. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56870. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56871. */
  56872. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56873. /**
  56874. * Initialize the block and prepare the context for build
  56875. * @param state defines the state that will be used for the build
  56876. */
  56877. initialize(state: NodeMaterialBuildState): void;
  56878. /**
  56879. * Bind data to effect. Will only be called for blocks with isBindable === true
  56880. * @param effect defines the effect to bind data to
  56881. * @param nodeMaterial defines the hosting NodeMaterial
  56882. * @param mesh defines the mesh that will be rendered
  56883. */
  56884. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56885. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56886. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56887. protected _writeFloat(value: number): string;
  56888. /**
  56889. * Gets the current class name e.g. "NodeMaterialBlock"
  56890. * @returns the class name
  56891. */
  56892. getClassName(): string;
  56893. /**
  56894. * Register a new input. Must be called inside a block constructor
  56895. * @param name defines the connection point name
  56896. * @param type defines the connection point type
  56897. * @param isOptional defines a boolean indicating that this input can be omitted
  56898. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56899. * @returns the current block
  56900. */
  56901. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56902. /**
  56903. * Register a new output. Must be called inside a block constructor
  56904. * @param name defines the connection point name
  56905. * @param type defines the connection point type
  56906. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56907. * @returns the current block
  56908. */
  56909. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56910. /**
  56911. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56912. * @param forOutput defines an optional connection point to check compatibility with
  56913. * @returns the first available input or null
  56914. */
  56915. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56916. /**
  56917. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56918. * @param forBlock defines an optional block to check compatibility with
  56919. * @returns the first available input or null
  56920. */
  56921. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56922. /**
  56923. * Gets the sibling of the given output
  56924. * @param current defines the current output
  56925. * @returns the next output in the list or null
  56926. */
  56927. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56928. /**
  56929. * Connect current block with another block
  56930. * @param other defines the block to connect with
  56931. * @param options define the various options to help pick the right connections
  56932. * @returns the current block
  56933. */
  56934. connectTo(other: NodeMaterialBlock, options?: {
  56935. input?: string;
  56936. output?: string;
  56937. outputSwizzle?: string;
  56938. }): this | undefined;
  56939. protected _buildBlock(state: NodeMaterialBuildState): void;
  56940. /**
  56941. * Add uniforms, samplers and uniform buffers at compilation time
  56942. * @param state defines the state to update
  56943. * @param nodeMaterial defines the node material requesting the update
  56944. * @param defines defines the material defines to update
  56945. * @param uniformBuffers defines the list of uniform buffer names
  56946. */
  56947. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  56948. /**
  56949. * Add potential fallbacks if shader compilation fails
  56950. * @param mesh defines the mesh to be rendered
  56951. * @param fallbacks defines the current prioritized list of fallbacks
  56952. */
  56953. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56954. /**
  56955. * Initialize defines for shader compilation
  56956. * @param mesh defines the mesh to be rendered
  56957. * @param nodeMaterial defines the node material requesting the update
  56958. * @param defines defines the material defines to update
  56959. * @param useInstances specifies that instances should be used
  56960. */
  56961. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56962. /**
  56963. * Update defines for shader compilation
  56964. * @param mesh defines the mesh to be rendered
  56965. * @param nodeMaterial defines the node material requesting the update
  56966. * @param defines defines the material defines to update
  56967. * @param useInstances specifies that instances should be used
  56968. */
  56969. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56970. /**
  56971. * Lets the block try to connect some inputs automatically
  56972. * @param material defines the hosting NodeMaterial
  56973. */
  56974. autoConfigure(material: NodeMaterial): void;
  56975. /**
  56976. * Function called when a block is declared as repeatable content generator
  56977. * @param vertexShaderState defines the current compilation state for the vertex shader
  56978. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56979. * @param mesh defines the mesh to be rendered
  56980. * @param defines defines the material defines to update
  56981. */
  56982. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56983. /**
  56984. * Checks if the block is ready
  56985. * @param mesh defines the mesh to be rendered
  56986. * @param nodeMaterial defines the node material requesting the update
  56987. * @param defines defines the material defines to update
  56988. * @param useInstances specifies that instances should be used
  56989. * @returns true if the block is ready
  56990. */
  56991. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56992. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56993. private _processBuild;
  56994. /**
  56995. * Compile the current node and generate the shader code
  56996. * @param state defines the current compilation state (uniforms, samplers, current string)
  56997. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56998. * @returns true if already built
  56999. */
  57000. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57001. protected _inputRename(name: string): string;
  57002. protected _outputRename(name: string): string;
  57003. protected _dumpPropertiesCode(): string;
  57004. /** @hidden */
  57005. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57006. /** @hidden */
  57007. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57008. /**
  57009. * Clone the current block to a new identical block
  57010. * @param scene defines the hosting scene
  57011. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57012. * @returns a copy of the current block
  57013. */
  57014. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57015. /**
  57016. * Serializes this block in a JSON representation
  57017. * @returns the serialized block object
  57018. */
  57019. serialize(): any;
  57020. /** @hidden */
  57021. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57022. /**
  57023. * Release resources
  57024. */
  57025. dispose(): void;
  57026. }
  57027. }
  57028. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  57029. /**
  57030. * Enum defining the type of animations supported by InputBlock
  57031. */
  57032. export enum AnimatedInputBlockTypes {
  57033. /** No animation */
  57034. None = 0,
  57035. /** Time based animation. Will only work for floats */
  57036. Time = 1
  57037. }
  57038. }
  57039. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  57040. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57041. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57042. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  57043. import { Nullable } from "babylonjs/types";
  57044. import { Effect } from "babylonjs/Materials/effect";
  57045. import { Matrix } from "babylonjs/Maths/math.vector";
  57046. import { Scene } from "babylonjs/scene";
  57047. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57049. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57050. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57051. /**
  57052. * Block used to expose an input value
  57053. */
  57054. export class InputBlock extends NodeMaterialBlock {
  57055. private _mode;
  57056. private _associatedVariableName;
  57057. private _storedValue;
  57058. private _valueCallback;
  57059. private _type;
  57060. private _animationType;
  57061. /** Gets or set a value used to limit the range of float values */
  57062. min: number;
  57063. /** Gets or set a value used to limit the range of float values */
  57064. max: number;
  57065. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57066. matrixMode: number;
  57067. /** @hidden */
  57068. _systemValue: Nullable<NodeMaterialSystemValues>;
  57069. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57070. visibleInInspector: boolean;
  57071. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57072. isConstant: boolean;
  57073. /**
  57074. * Gets or sets the connection point type (default is float)
  57075. */
  57076. readonly type: NodeMaterialBlockConnectionPointTypes;
  57077. /**
  57078. * Creates a new InputBlock
  57079. * @param name defines the block name
  57080. * @param target defines the target of that block (Vertex by default)
  57081. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57082. */
  57083. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57084. /**
  57085. * Gets the output component
  57086. */
  57087. readonly output: NodeMaterialConnectionPoint;
  57088. /**
  57089. * Set the source of this connection point to a vertex attribute
  57090. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57091. * @returns the current connection point
  57092. */
  57093. setAsAttribute(attributeName?: string): InputBlock;
  57094. /**
  57095. * Set the source of this connection point to a system value
  57096. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57097. * @returns the current connection point
  57098. */
  57099. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57100. /**
  57101. * Gets or sets the value of that point.
  57102. * Please note that this value will be ignored if valueCallback is defined
  57103. */
  57104. value: any;
  57105. /**
  57106. * Gets or sets a callback used to get the value of that point.
  57107. * Please note that setting this value will force the connection point to ignore the value property
  57108. */
  57109. valueCallback: () => any;
  57110. /**
  57111. * Gets or sets the associated variable name in the shader
  57112. */
  57113. associatedVariableName: string;
  57114. /** Gets or sets the type of animation applied to the input */
  57115. animationType: AnimatedInputBlockTypes;
  57116. /**
  57117. * Gets a boolean indicating that this connection point not defined yet
  57118. */
  57119. readonly isUndefined: boolean;
  57120. /**
  57121. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57122. * In this case the connection point name must be the name of the uniform to use.
  57123. * Can only be set on inputs
  57124. */
  57125. isUniform: boolean;
  57126. /**
  57127. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57128. * In this case the connection point name must be the name of the attribute to use
  57129. * Can only be set on inputs
  57130. */
  57131. isAttribute: boolean;
  57132. /**
  57133. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57134. * Can only be set on exit points
  57135. */
  57136. isVarying: boolean;
  57137. /**
  57138. * Gets a boolean indicating that the current connection point is a system value
  57139. */
  57140. readonly isSystemValue: boolean;
  57141. /**
  57142. * Gets or sets the current well known value or null if not defined as a system value
  57143. */
  57144. systemValue: Nullable<NodeMaterialSystemValues>;
  57145. /**
  57146. * Gets the current class name
  57147. * @returns the class name
  57148. */
  57149. getClassName(): string;
  57150. /**
  57151. * Animate the input if animationType !== None
  57152. * @param scene defines the rendering scene
  57153. */
  57154. animate(scene: Scene): void;
  57155. private _emitDefine;
  57156. initialize(state: NodeMaterialBuildState): void;
  57157. /**
  57158. * Set the input block to its default value (based on its type)
  57159. */
  57160. setDefaultValue(): void;
  57161. private _emitConstant;
  57162. private _emit;
  57163. /** @hidden */
  57164. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57165. /** @hidden */
  57166. _transmit(effect: Effect, scene: Scene): void;
  57167. protected _buildBlock(state: NodeMaterialBuildState): void;
  57168. protected _dumpPropertiesCode(): string;
  57169. serialize(): any;
  57170. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57171. }
  57172. }
  57173. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  57174. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  57175. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  57176. import { Nullable } from "babylonjs/types";
  57177. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57178. import { Observable } from "babylonjs/Misc/observable";
  57179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57180. /**
  57181. * Enum used to define the compatibility state between two connection points
  57182. */
  57183. export enum NodeMaterialConnectionPointCompatibilityStates {
  57184. /** Points are compatibles */
  57185. Compatible = 0,
  57186. /** Points are incompatible because of their types */
  57187. TypeIncompatible = 1,
  57188. /** Points are incompatible because of their targets (vertex vs fragment) */
  57189. TargetIncompatible = 2
  57190. }
  57191. /**
  57192. * Defines a connection point for a block
  57193. */
  57194. export class NodeMaterialConnectionPoint {
  57195. /** @hidden */
  57196. _ownerBlock: NodeMaterialBlock;
  57197. /** @hidden */
  57198. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57199. private _endpoints;
  57200. private _associatedVariableName;
  57201. /** @hidden */
  57202. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57203. /** @hidden */
  57204. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57205. private _type;
  57206. /** @hidden */
  57207. _enforceAssociatedVariableName: boolean;
  57208. /**
  57209. * Gets or sets the additional types supported by this connection point
  57210. */
  57211. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57212. /**
  57213. * Gets or sets the additional types excluded by this connection point
  57214. */
  57215. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  57216. /**
  57217. * Observable triggered when this point is connected
  57218. */
  57219. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  57220. /**
  57221. * Gets or sets the associated variable name in the shader
  57222. */
  57223. associatedVariableName: string;
  57224. /**
  57225. * Gets or sets the connection point type (default is float)
  57226. */
  57227. type: NodeMaterialBlockConnectionPointTypes;
  57228. /**
  57229. * Gets or sets the connection point name
  57230. */
  57231. name: string;
  57232. /**
  57233. * Gets or sets a boolean indicating that this connection point can be omitted
  57234. */
  57235. isOptional: boolean;
  57236. /**
  57237. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  57238. */
  57239. define: string;
  57240. /** @hidden */
  57241. _prioritizeVertex: boolean;
  57242. private _target;
  57243. /** Gets or sets the target of that connection point */
  57244. target: NodeMaterialBlockTargets;
  57245. /**
  57246. * Gets a boolean indicating that the current point is connected
  57247. */
  57248. readonly isConnected: boolean;
  57249. /**
  57250. * Gets a boolean indicating that the current point is connected to an input block
  57251. */
  57252. readonly isConnectedToInputBlock: boolean;
  57253. /**
  57254. * Gets a the connected input block (if any)
  57255. */
  57256. readonly connectInputBlock: Nullable<InputBlock>;
  57257. /** Get the other side of the connection (if any) */
  57258. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57259. /** Get the block that owns this connection point */
  57260. readonly ownerBlock: NodeMaterialBlock;
  57261. /** Get the block connected on the other side of this connection (if any) */
  57262. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  57263. /** Get the block connected on the endpoints of this connection (if any) */
  57264. readonly connectedBlocks: Array<NodeMaterialBlock>;
  57265. /** Gets the list of connected endpoints */
  57266. readonly endpoints: NodeMaterialConnectionPoint[];
  57267. /** Gets a boolean indicating if that output point is connected to at least one input */
  57268. readonly hasEndpoints: boolean;
  57269. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  57270. readonly isConnectedInVertexShader: boolean;
  57271. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  57272. readonly isConnectedInFragmentShader: boolean;
  57273. /**
  57274. * Creates a new connection point
  57275. * @param name defines the connection point name
  57276. * @param ownerBlock defines the block hosting this connection point
  57277. */
  57278. constructor(name: string, ownerBlock: NodeMaterialBlock);
  57279. /**
  57280. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  57281. * @returns the class name
  57282. */
  57283. getClassName(): string;
  57284. /**
  57285. * Gets a boolean indicating if the current point can be connected to another point
  57286. * @param connectionPoint defines the other connection point
  57287. * @returns a boolean
  57288. */
  57289. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  57290. /**
  57291. * Gets a number indicating if the current point can be connected to another point
  57292. * @param connectionPoint defines the other connection point
  57293. * @returns a number defining the compatibility state
  57294. */
  57295. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57296. /**
  57297. * Connect this point to another connection point
  57298. * @param connectionPoint defines the other connection point
  57299. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  57300. * @returns the current connection point
  57301. */
  57302. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  57303. /**
  57304. * Disconnect this point from one of his endpoint
  57305. * @param endpoint defines the other connection point
  57306. * @returns the current connection point
  57307. */
  57308. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  57309. /**
  57310. * Serializes this point in a JSON representation
  57311. * @returns the serialized point object
  57312. */
  57313. serialize(): any;
  57314. /**
  57315. * Release resources
  57316. */
  57317. dispose(): void;
  57318. }
  57319. }
  57320. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  57321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57324. import { Mesh } from "babylonjs/Meshes/mesh";
  57325. import { Effect } from "babylonjs/Materials/effect";
  57326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57327. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57328. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57329. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57330. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57331. /**
  57332. * Block used to add support for vertex skinning (bones)
  57333. */
  57334. export class BonesBlock extends NodeMaterialBlock {
  57335. /**
  57336. * Creates a new BonesBlock
  57337. * @param name defines the block name
  57338. */
  57339. constructor(name: string);
  57340. /**
  57341. * Initialize the block and prepare the context for build
  57342. * @param state defines the state that will be used for the build
  57343. */
  57344. initialize(state: NodeMaterialBuildState): void;
  57345. /**
  57346. * Gets the current class name
  57347. * @returns the class name
  57348. */
  57349. getClassName(): string;
  57350. /**
  57351. * Gets the matrix indices input component
  57352. */
  57353. readonly matricesIndices: NodeMaterialConnectionPoint;
  57354. /**
  57355. * Gets the matrix weights input component
  57356. */
  57357. readonly matricesWeights: NodeMaterialConnectionPoint;
  57358. /**
  57359. * Gets the extra matrix indices input component
  57360. */
  57361. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  57362. /**
  57363. * Gets the extra matrix weights input component
  57364. */
  57365. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  57366. /**
  57367. * Gets the world input component
  57368. */
  57369. readonly world: NodeMaterialConnectionPoint;
  57370. /**
  57371. * Gets the output component
  57372. */
  57373. readonly output: NodeMaterialConnectionPoint;
  57374. autoConfigure(material: NodeMaterial): void;
  57375. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57376. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57377. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57378. protected _buildBlock(state: NodeMaterialBuildState): this;
  57379. }
  57380. }
  57381. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  57382. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57386. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57387. /**
  57388. * Block used to add support for instances
  57389. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  57390. */
  57391. export class InstancesBlock extends NodeMaterialBlock {
  57392. /**
  57393. * Creates a new InstancesBlock
  57394. * @param name defines the block name
  57395. */
  57396. constructor(name: string);
  57397. /**
  57398. * Gets the current class name
  57399. * @returns the class name
  57400. */
  57401. getClassName(): string;
  57402. /**
  57403. * Gets the first world row input component
  57404. */
  57405. readonly world0: NodeMaterialConnectionPoint;
  57406. /**
  57407. * Gets the second world row input component
  57408. */
  57409. readonly world1: NodeMaterialConnectionPoint;
  57410. /**
  57411. * Gets the third world row input component
  57412. */
  57413. readonly world2: NodeMaterialConnectionPoint;
  57414. /**
  57415. * Gets the forth world row input component
  57416. */
  57417. readonly world3: NodeMaterialConnectionPoint;
  57418. /**
  57419. * Gets the world input component
  57420. */
  57421. readonly world: NodeMaterialConnectionPoint;
  57422. /**
  57423. * Gets the output component
  57424. */
  57425. readonly output: NodeMaterialConnectionPoint;
  57426. autoConfigure(material: NodeMaterial): void;
  57427. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57428. protected _buildBlock(state: NodeMaterialBuildState): this;
  57429. }
  57430. }
  57431. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  57432. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57433. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57436. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57437. import { Effect } from "babylonjs/Materials/effect";
  57438. import { Mesh } from "babylonjs/Meshes/mesh";
  57439. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57440. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57441. /**
  57442. * Block used to add morph targets support to vertex shader
  57443. */
  57444. export class MorphTargetsBlock extends NodeMaterialBlock {
  57445. private _repeatableContentAnchor;
  57446. private _repeatebleContentGenerated;
  57447. /**
  57448. * Create a new MorphTargetsBlock
  57449. * @param name defines the block name
  57450. */
  57451. constructor(name: string);
  57452. /**
  57453. * Gets the current class name
  57454. * @returns the class name
  57455. */
  57456. getClassName(): string;
  57457. /**
  57458. * Gets the position input component
  57459. */
  57460. readonly position: NodeMaterialConnectionPoint;
  57461. /**
  57462. * Gets the normal input component
  57463. */
  57464. readonly normal: NodeMaterialConnectionPoint;
  57465. /**
  57466. * Gets the tangent input component
  57467. */
  57468. readonly tangent: NodeMaterialConnectionPoint;
  57469. /**
  57470. * Gets the tangent input component
  57471. */
  57472. readonly uv: NodeMaterialConnectionPoint;
  57473. /**
  57474. * Gets the position output component
  57475. */
  57476. readonly positionOutput: NodeMaterialConnectionPoint;
  57477. /**
  57478. * Gets the normal output component
  57479. */
  57480. readonly normalOutput: NodeMaterialConnectionPoint;
  57481. /**
  57482. * Gets the tangent output component
  57483. */
  57484. readonly tangentOutput: NodeMaterialConnectionPoint;
  57485. /**
  57486. * Gets the tangent output component
  57487. */
  57488. readonly uvOutput: NodeMaterialConnectionPoint;
  57489. initialize(state: NodeMaterialBuildState): void;
  57490. autoConfigure(material: NodeMaterial): void;
  57491. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57492. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57493. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57494. protected _buildBlock(state: NodeMaterialBuildState): this;
  57495. }
  57496. }
  57497. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  57498. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57501. import { Nullable } from "babylonjs/types";
  57502. import { Scene } from "babylonjs/scene";
  57503. import { Effect } from "babylonjs/Materials/effect";
  57504. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57505. import { Mesh } from "babylonjs/Meshes/mesh";
  57506. import { Light } from "babylonjs/Lights/light";
  57507. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57508. /**
  57509. * Block used to get data information from a light
  57510. */
  57511. export class LightInformationBlock extends NodeMaterialBlock {
  57512. private _lightDataUniformName;
  57513. private _lightColorUniformName;
  57514. private _lightTypeDefineName;
  57515. /**
  57516. * Gets or sets the light associated with this block
  57517. */
  57518. light: Nullable<Light>;
  57519. /**
  57520. * Creates a new LightInformationBlock
  57521. * @param name defines the block name
  57522. */
  57523. constructor(name: string);
  57524. /**
  57525. * Gets the current class name
  57526. * @returns the class name
  57527. */
  57528. getClassName(): string;
  57529. /**
  57530. * Gets the world position input component
  57531. */
  57532. readonly worldPosition: NodeMaterialConnectionPoint;
  57533. /**
  57534. * Gets the direction output component
  57535. */
  57536. readonly direction: NodeMaterialConnectionPoint;
  57537. /**
  57538. * Gets the direction output component
  57539. */
  57540. readonly color: NodeMaterialConnectionPoint;
  57541. /**
  57542. * Gets the direction output component
  57543. */
  57544. readonly intensity: NodeMaterialConnectionPoint;
  57545. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57546. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57547. protected _buildBlock(state: NodeMaterialBuildState): this;
  57548. serialize(): any;
  57549. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57550. }
  57551. }
  57552. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  57553. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  57554. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  57555. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  57556. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  57557. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  57558. }
  57559. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  57560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57561. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57562. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57564. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57565. import { Effect } from "babylonjs/Materials/effect";
  57566. import { Mesh } from "babylonjs/Meshes/mesh";
  57567. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57568. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57569. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57570. /**
  57571. * Block used to add image processing support to fragment shader
  57572. */
  57573. export class ImageProcessingBlock extends NodeMaterialBlock {
  57574. /**
  57575. * Create a new ImageProcessingBlock
  57576. * @param name defines the block name
  57577. */
  57578. constructor(name: string);
  57579. /**
  57580. * Gets the current class name
  57581. * @returns the class name
  57582. */
  57583. getClassName(): string;
  57584. /**
  57585. * Gets the color input component
  57586. */
  57587. readonly color: NodeMaterialConnectionPoint;
  57588. /**
  57589. * Gets the output component
  57590. */
  57591. readonly output: NodeMaterialConnectionPoint;
  57592. /**
  57593. * Initialize the block and prepare the context for build
  57594. * @param state defines the state that will be used for the build
  57595. */
  57596. initialize(state: NodeMaterialBuildState): void;
  57597. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  57598. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57599. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57600. protected _buildBlock(state: NodeMaterialBuildState): this;
  57601. }
  57602. }
  57603. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  57604. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57605. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57606. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57607. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57609. import { Effect } from "babylonjs/Materials/effect";
  57610. import { Mesh } from "babylonjs/Meshes/mesh";
  57611. import { Scene } from "babylonjs/scene";
  57612. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57613. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57614. /**
  57615. * Block used to pertub normals based on a normal map
  57616. */
  57617. export class PerturbNormalBlock extends NodeMaterialBlock {
  57618. private _tangentSpaceParameterName;
  57619. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  57620. invertX: boolean;
  57621. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  57622. invertY: boolean;
  57623. /**
  57624. * Create a new PerturbNormalBlock
  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 world position input component
  57635. */
  57636. readonly worldPosition: NodeMaterialConnectionPoint;
  57637. /**
  57638. * Gets the world normal input component
  57639. */
  57640. readonly worldNormal: NodeMaterialConnectionPoint;
  57641. /**
  57642. * Gets the uv input component
  57643. */
  57644. readonly uv: NodeMaterialConnectionPoint;
  57645. /**
  57646. * Gets the normal map color input component
  57647. */
  57648. readonly normalMapColor: NodeMaterialConnectionPoint;
  57649. /**
  57650. * Gets the strength input component
  57651. */
  57652. readonly strength: NodeMaterialConnectionPoint;
  57653. /**
  57654. * Gets the output component
  57655. */
  57656. readonly output: NodeMaterialConnectionPoint;
  57657. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57658. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57659. autoConfigure(material: NodeMaterial): void;
  57660. protected _buildBlock(state: NodeMaterialBuildState): this;
  57661. protected _dumpPropertiesCode(): string;
  57662. serialize(): any;
  57663. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57664. }
  57665. }
  57666. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  57667. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57668. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57669. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57670. /**
  57671. * Block used to discard a pixel if a value is smaller than a cutoff
  57672. */
  57673. export class DiscardBlock extends NodeMaterialBlock {
  57674. /**
  57675. * Create a new DiscardBlock
  57676. * @param name defines the block name
  57677. */
  57678. constructor(name: string);
  57679. /**
  57680. * Gets the current class name
  57681. * @returns the class name
  57682. */
  57683. getClassName(): string;
  57684. /**
  57685. * Gets the color input component
  57686. */
  57687. readonly value: NodeMaterialConnectionPoint;
  57688. /**
  57689. * Gets the cutoff input component
  57690. */
  57691. readonly cutoff: NodeMaterialConnectionPoint;
  57692. protected _buildBlock(state: NodeMaterialBuildState): this;
  57693. }
  57694. }
  57695. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  57696. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57697. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57698. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57699. /**
  57700. * Block used to test if the fragment shader is front facing
  57701. */
  57702. export class FrontFacingBlock extends NodeMaterialBlock {
  57703. /**
  57704. * Creates a new FrontFacingBlock
  57705. * @param name defines the block name
  57706. */
  57707. constructor(name: string);
  57708. /**
  57709. * Gets the current class name
  57710. * @returns the class name
  57711. */
  57712. getClassName(): string;
  57713. /**
  57714. * Gets the output component
  57715. */
  57716. readonly output: NodeMaterialConnectionPoint;
  57717. protected _buildBlock(state: NodeMaterialBuildState): this;
  57718. }
  57719. }
  57720. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  57721. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  57722. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  57723. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  57724. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  57725. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  57726. }
  57727. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  57728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57730. import { Mesh } from "babylonjs/Meshes/mesh";
  57731. import { Effect } from "babylonjs/Materials/effect";
  57732. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57734. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57735. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57736. /**
  57737. * Block used to add support for scene fog
  57738. */
  57739. export class FogBlock extends NodeMaterialBlock {
  57740. private _fogDistanceName;
  57741. private _fogParameters;
  57742. /**
  57743. * Create a new FogBlock
  57744. * @param name defines the block name
  57745. */
  57746. constructor(name: string);
  57747. /**
  57748. * Gets the current class name
  57749. * @returns the class name
  57750. */
  57751. getClassName(): string;
  57752. /**
  57753. * Gets the world position input component
  57754. */
  57755. readonly worldPosition: NodeMaterialConnectionPoint;
  57756. /**
  57757. * Gets the view input component
  57758. */
  57759. readonly view: NodeMaterialConnectionPoint;
  57760. /**
  57761. * Gets the color input component
  57762. */
  57763. readonly input: NodeMaterialConnectionPoint;
  57764. /**
  57765. * Gets the fog color input component
  57766. */
  57767. readonly fogColor: NodeMaterialConnectionPoint;
  57768. /**
  57769. * Gets the output component
  57770. */
  57771. readonly output: NodeMaterialConnectionPoint;
  57772. autoConfigure(material: NodeMaterial): void;
  57773. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57774. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57775. protected _buildBlock(state: NodeMaterialBuildState): this;
  57776. }
  57777. }
  57778. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  57779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57783. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  57784. import { Effect } from "babylonjs/Materials/effect";
  57785. import { Mesh } from "babylonjs/Meshes/mesh";
  57786. import { Light } from "babylonjs/Lights/light";
  57787. import { Nullable } from "babylonjs/types";
  57788. import { Scene } from "babylonjs/scene";
  57789. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57790. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57791. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57792. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57793. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57794. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57795. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57796. /**
  57797. * Block used to add light in the fragment shader
  57798. */
  57799. export class LightBlock extends NodeMaterialBlock {
  57800. private _lightId;
  57801. /**
  57802. * Gets or sets the light associated with this block
  57803. */
  57804. light: Nullable<Light>;
  57805. /**
  57806. * Create a new LightBlock
  57807. * @param name defines the block name
  57808. */
  57809. constructor(name: string);
  57810. /**
  57811. * Gets the current class name
  57812. * @returns the class name
  57813. */
  57814. getClassName(): string;
  57815. /**
  57816. * Gets the world position input component
  57817. */
  57818. readonly worldPosition: NodeMaterialConnectionPoint;
  57819. /**
  57820. * Gets the world normal input component
  57821. */
  57822. readonly worldNormal: NodeMaterialConnectionPoint;
  57823. /**
  57824. * Gets the camera (or eye) position component
  57825. */
  57826. readonly cameraPosition: NodeMaterialConnectionPoint;
  57827. /**
  57828. * Gets the glossiness component
  57829. */
  57830. readonly glossiness: NodeMaterialConnectionPoint;
  57831. /**
  57832. * Gets the glossinness power component
  57833. */
  57834. readonly glossPower: NodeMaterialConnectionPoint;
  57835. /**
  57836. * Gets the diffuse color component
  57837. */
  57838. readonly diffuseColor: NodeMaterialConnectionPoint;
  57839. /**
  57840. * Gets the specular color component
  57841. */
  57842. readonly specularColor: NodeMaterialConnectionPoint;
  57843. /**
  57844. * Gets the diffuse output component
  57845. */
  57846. readonly diffuseOutput: NodeMaterialConnectionPoint;
  57847. /**
  57848. * Gets the specular output component
  57849. */
  57850. readonly specularOutput: NodeMaterialConnectionPoint;
  57851. autoConfigure(material: NodeMaterial): void;
  57852. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57853. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57854. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57855. private _injectVertexCode;
  57856. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57857. serialize(): any;
  57858. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57859. }
  57860. }
  57861. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  57862. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  57863. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  57864. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  57865. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  57866. }
  57867. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  57868. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  57869. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  57870. }
  57871. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  57872. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57873. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57874. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57875. /**
  57876. * Block used to multiply 2 values
  57877. */
  57878. export class MultiplyBlock extends NodeMaterialBlock {
  57879. /**
  57880. * Creates a new MultiplyBlock
  57881. * @param name defines the block name
  57882. */
  57883. constructor(name: string);
  57884. /**
  57885. * Gets the current class name
  57886. * @returns the class name
  57887. */
  57888. getClassName(): string;
  57889. /**
  57890. * Gets the left operand input component
  57891. */
  57892. readonly left: NodeMaterialConnectionPoint;
  57893. /**
  57894. * Gets the right operand input component
  57895. */
  57896. readonly right: NodeMaterialConnectionPoint;
  57897. /**
  57898. * Gets the output component
  57899. */
  57900. readonly output: NodeMaterialConnectionPoint;
  57901. protected _buildBlock(state: NodeMaterialBuildState): this;
  57902. }
  57903. }
  57904. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  57905. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57906. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57907. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57908. /**
  57909. * Block used to add 2 vectors
  57910. */
  57911. export class AddBlock extends NodeMaterialBlock {
  57912. /**
  57913. * Creates a new AddBlock
  57914. * @param name defines the block name
  57915. */
  57916. constructor(name: string);
  57917. /**
  57918. * Gets the current class name
  57919. * @returns the class name
  57920. */
  57921. getClassName(): string;
  57922. /**
  57923. * Gets the left operand input component
  57924. */
  57925. readonly left: NodeMaterialConnectionPoint;
  57926. /**
  57927. * Gets the right operand input component
  57928. */
  57929. readonly right: NodeMaterialConnectionPoint;
  57930. /**
  57931. * Gets the output component
  57932. */
  57933. readonly output: NodeMaterialConnectionPoint;
  57934. protected _buildBlock(state: NodeMaterialBuildState): this;
  57935. }
  57936. }
  57937. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57938. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57939. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57940. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57941. /**
  57942. * Block used to scale a vector by a float
  57943. */
  57944. export class ScaleBlock extends NodeMaterialBlock {
  57945. /**
  57946. * Creates a new ScaleBlock
  57947. * @param name defines the block name
  57948. */
  57949. constructor(name: string);
  57950. /**
  57951. * Gets the current class name
  57952. * @returns the class name
  57953. */
  57954. getClassName(): string;
  57955. /**
  57956. * Gets the input component
  57957. */
  57958. readonly input: NodeMaterialConnectionPoint;
  57959. /**
  57960. * Gets the factor input component
  57961. */
  57962. readonly factor: NodeMaterialConnectionPoint;
  57963. /**
  57964. * Gets the output component
  57965. */
  57966. readonly output: NodeMaterialConnectionPoint;
  57967. protected _buildBlock(state: NodeMaterialBuildState): this;
  57968. }
  57969. }
  57970. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57974. import { Scene } from "babylonjs/scene";
  57975. /**
  57976. * Block used to clamp a float
  57977. */
  57978. export class ClampBlock extends NodeMaterialBlock {
  57979. /** Gets or sets the minimum range */
  57980. minimum: number;
  57981. /** Gets or sets the maximum range */
  57982. maximum: number;
  57983. /**
  57984. * Creates a new ClampBlock
  57985. * @param name defines the block name
  57986. */
  57987. constructor(name: string);
  57988. /**
  57989. * Gets the current class name
  57990. * @returns the class name
  57991. */
  57992. getClassName(): string;
  57993. /**
  57994. * Gets the value input component
  57995. */
  57996. readonly value: NodeMaterialConnectionPoint;
  57997. /**
  57998. * Gets the output component
  57999. */
  58000. readonly output: NodeMaterialConnectionPoint;
  58001. protected _buildBlock(state: NodeMaterialBuildState): this;
  58002. protected _dumpPropertiesCode(): string;
  58003. serialize(): any;
  58004. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58005. }
  58006. }
  58007. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  58008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58009. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58010. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58011. /**
  58012. * Block used to apply a cross product between 2 vectors
  58013. */
  58014. export class CrossBlock extends NodeMaterialBlock {
  58015. /**
  58016. * Creates a new CrossBlock
  58017. * @param name defines the block name
  58018. */
  58019. constructor(name: string);
  58020. /**
  58021. * Gets the current class name
  58022. * @returns the class name
  58023. */
  58024. getClassName(): string;
  58025. /**
  58026. * Gets the left operand input component
  58027. */
  58028. readonly left: NodeMaterialConnectionPoint;
  58029. /**
  58030. * Gets the right operand input component
  58031. */
  58032. readonly right: NodeMaterialConnectionPoint;
  58033. /**
  58034. * Gets the output component
  58035. */
  58036. readonly output: NodeMaterialConnectionPoint;
  58037. protected _buildBlock(state: NodeMaterialBuildState): this;
  58038. }
  58039. }
  58040. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  58041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58044. /**
  58045. * Block used to apply a dot product between 2 vectors
  58046. */
  58047. export class DotBlock extends NodeMaterialBlock {
  58048. /**
  58049. * Creates a new DotBlock
  58050. * @param name defines the block name
  58051. */
  58052. constructor(name: string);
  58053. /**
  58054. * Gets the current class name
  58055. * @returns the class name
  58056. */
  58057. getClassName(): string;
  58058. /**
  58059. * Gets the left operand input component
  58060. */
  58061. readonly left: NodeMaterialConnectionPoint;
  58062. /**
  58063. * Gets the right operand input component
  58064. */
  58065. readonly right: NodeMaterialConnectionPoint;
  58066. /**
  58067. * Gets the output component
  58068. */
  58069. readonly output: NodeMaterialConnectionPoint;
  58070. protected _buildBlock(state: NodeMaterialBuildState): this;
  58071. }
  58072. }
  58073. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  58074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58077. import { Vector2 } from "babylonjs/Maths/math.vector";
  58078. import { Scene } from "babylonjs/scene";
  58079. /**
  58080. * Block used to remap a float from a range to a new one
  58081. */
  58082. export class RemapBlock extends NodeMaterialBlock {
  58083. /**
  58084. * Gets or sets the source range
  58085. */
  58086. sourceRange: Vector2;
  58087. /**
  58088. * Gets or sets the target range
  58089. */
  58090. targetRange: Vector2;
  58091. /**
  58092. * Creates a new RemapBlock
  58093. * @param name defines the block name
  58094. */
  58095. constructor(name: string);
  58096. /**
  58097. * Gets the current class name
  58098. * @returns the class name
  58099. */
  58100. getClassName(): string;
  58101. /**
  58102. * Gets the input component
  58103. */
  58104. readonly input: NodeMaterialConnectionPoint;
  58105. /**
  58106. * Gets the source min input component
  58107. */
  58108. readonly sourceMin: NodeMaterialConnectionPoint;
  58109. /**
  58110. * Gets the source max input component
  58111. */
  58112. readonly sourceMax: NodeMaterialConnectionPoint;
  58113. /**
  58114. * Gets the target min input component
  58115. */
  58116. readonly targetMin: NodeMaterialConnectionPoint;
  58117. /**
  58118. * Gets the target max input component
  58119. */
  58120. readonly targetMax: NodeMaterialConnectionPoint;
  58121. /**
  58122. * Gets the output component
  58123. */
  58124. readonly output: NodeMaterialConnectionPoint;
  58125. protected _buildBlock(state: NodeMaterialBuildState): this;
  58126. protected _dumpPropertiesCode(): string;
  58127. serialize(): any;
  58128. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58129. }
  58130. }
  58131. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  58132. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58133. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58134. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58135. /**
  58136. * Block used to normalize a vector
  58137. */
  58138. export class NormalizeBlock extends NodeMaterialBlock {
  58139. /**
  58140. * Creates a new NormalizeBlock
  58141. * @param name defines the block name
  58142. */
  58143. constructor(name: string);
  58144. /**
  58145. * Gets the current class name
  58146. * @returns the class name
  58147. */
  58148. getClassName(): string;
  58149. /**
  58150. * Gets the input component
  58151. */
  58152. readonly input: NodeMaterialConnectionPoint;
  58153. /**
  58154. * Gets the output component
  58155. */
  58156. readonly output: NodeMaterialConnectionPoint;
  58157. protected _buildBlock(state: NodeMaterialBuildState): this;
  58158. }
  58159. }
  58160. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  58161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58164. import { Scene } from "babylonjs/scene";
  58165. /**
  58166. * Operations supported by the Trigonometry block
  58167. */
  58168. export enum TrigonometryBlockOperations {
  58169. /** Cos */
  58170. Cos = 0,
  58171. /** Sin */
  58172. Sin = 1,
  58173. /** Abs */
  58174. Abs = 2,
  58175. /** Exp */
  58176. Exp = 3,
  58177. /** Exp2 */
  58178. Exp2 = 4,
  58179. /** Round */
  58180. Round = 5,
  58181. /** Floor */
  58182. Floor = 6,
  58183. /** Ceiling */
  58184. Ceiling = 7,
  58185. /** Square root */
  58186. Sqrt = 8,
  58187. /** Log */
  58188. Log = 9,
  58189. /** Tangent */
  58190. Tan = 10,
  58191. /** Arc tangent */
  58192. ArcTan = 11,
  58193. /** Arc cosinus */
  58194. ArcCos = 12,
  58195. /** Arc sinus */
  58196. ArcSin = 13,
  58197. /** Fraction */
  58198. Fract = 14,
  58199. /** Sign */
  58200. Sign = 15,
  58201. /** To radians (from degrees) */
  58202. Radians = 16,
  58203. /** To degrees (from radians) */
  58204. Degrees = 17
  58205. }
  58206. /**
  58207. * Block used to apply trigonometry operation to floats
  58208. */
  58209. export class TrigonometryBlock extends NodeMaterialBlock {
  58210. /**
  58211. * Gets or sets the operation applied by the block
  58212. */
  58213. operation: TrigonometryBlockOperations;
  58214. /**
  58215. * Creates a new TrigonometryBlock
  58216. * @param name defines the block name
  58217. */
  58218. constructor(name: string);
  58219. /**
  58220. * Gets the current class name
  58221. * @returns the class name
  58222. */
  58223. getClassName(): string;
  58224. /**
  58225. * Gets the input component
  58226. */
  58227. readonly input: NodeMaterialConnectionPoint;
  58228. /**
  58229. * Gets the output component
  58230. */
  58231. readonly output: NodeMaterialConnectionPoint;
  58232. protected _buildBlock(state: NodeMaterialBuildState): this;
  58233. serialize(): any;
  58234. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58235. protected _dumpPropertiesCode(): string;
  58236. }
  58237. }
  58238. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  58239. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58240. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58242. /**
  58243. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58244. */
  58245. export class ColorMergerBlock extends NodeMaterialBlock {
  58246. /**
  58247. * Create a new ColorMergerBlock
  58248. * @param name defines the block name
  58249. */
  58250. constructor(name: string);
  58251. /**
  58252. * Gets the current class name
  58253. * @returns the class name
  58254. */
  58255. getClassName(): string;
  58256. /**
  58257. * Gets the r component (input)
  58258. */
  58259. readonly r: NodeMaterialConnectionPoint;
  58260. /**
  58261. * Gets the g component (input)
  58262. */
  58263. readonly g: NodeMaterialConnectionPoint;
  58264. /**
  58265. * Gets the b component (input)
  58266. */
  58267. readonly b: NodeMaterialConnectionPoint;
  58268. /**
  58269. * Gets the a component (input)
  58270. */
  58271. readonly a: NodeMaterialConnectionPoint;
  58272. /**
  58273. * Gets the rgba component (output)
  58274. */
  58275. readonly rgba: NodeMaterialConnectionPoint;
  58276. /**
  58277. * Gets the rgb component (output)
  58278. */
  58279. readonly rgb: NodeMaterialConnectionPoint;
  58280. protected _buildBlock(state: NodeMaterialBuildState): this;
  58281. }
  58282. }
  58283. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  58284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58287. /**
  58288. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58289. */
  58290. export class VectorMergerBlock extends NodeMaterialBlock {
  58291. /**
  58292. * Create a new VectorMergerBlock
  58293. * @param name defines the block name
  58294. */
  58295. constructor(name: string);
  58296. /**
  58297. * Gets the current class name
  58298. * @returns the class name
  58299. */
  58300. getClassName(): string;
  58301. /**
  58302. * Gets the x component (input)
  58303. */
  58304. readonly x: NodeMaterialConnectionPoint;
  58305. /**
  58306. * Gets the y component (input)
  58307. */
  58308. readonly y: NodeMaterialConnectionPoint;
  58309. /**
  58310. * Gets the z component (input)
  58311. */
  58312. readonly z: NodeMaterialConnectionPoint;
  58313. /**
  58314. * Gets the w component (input)
  58315. */
  58316. readonly w: NodeMaterialConnectionPoint;
  58317. /**
  58318. * Gets the xyzw component (output)
  58319. */
  58320. readonly xyzw: NodeMaterialConnectionPoint;
  58321. /**
  58322. * Gets the xyz component (output)
  58323. */
  58324. readonly xyz: NodeMaterialConnectionPoint;
  58325. /**
  58326. * Gets the xy component (output)
  58327. */
  58328. readonly xy: NodeMaterialConnectionPoint;
  58329. protected _buildBlock(state: NodeMaterialBuildState): this;
  58330. }
  58331. }
  58332. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  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 Color3/4 into 4 outputs (one for each component)
  58338. */
  58339. export class ColorSplitterBlock extends NodeMaterialBlock {
  58340. /**
  58341. * Create a new ColorSplitterBlock
  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 rgba component (input)
  58352. */
  58353. readonly rgba: NodeMaterialConnectionPoint;
  58354. /**
  58355. * Gets the rgb component (input)
  58356. */
  58357. readonly rgbIn: NodeMaterialConnectionPoint;
  58358. /**
  58359. * Gets the rgb component (output)
  58360. */
  58361. readonly rgbOut: NodeMaterialConnectionPoint;
  58362. /**
  58363. * Gets the r component (output)
  58364. */
  58365. readonly r: NodeMaterialConnectionPoint;
  58366. /**
  58367. * Gets the g component (output)
  58368. */
  58369. readonly g: NodeMaterialConnectionPoint;
  58370. /**
  58371. * Gets the b component (output)
  58372. */
  58373. readonly b: NodeMaterialConnectionPoint;
  58374. /**
  58375. * Gets the a component (output)
  58376. */
  58377. readonly a: NodeMaterialConnectionPoint;
  58378. protected _inputRename(name: string): string;
  58379. protected _outputRename(name: string): string;
  58380. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58381. }
  58382. }
  58383. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  58384. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58385. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58386. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58387. /**
  58388. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  58389. */
  58390. export class VectorSplitterBlock extends NodeMaterialBlock {
  58391. /**
  58392. * Create a new VectorSplitterBlock
  58393. * @param name defines the block name
  58394. */
  58395. constructor(name: string);
  58396. /**
  58397. * Gets the current class name
  58398. * @returns the class name
  58399. */
  58400. getClassName(): string;
  58401. /**
  58402. * Gets the xyzw component (input)
  58403. */
  58404. readonly xyzw: NodeMaterialConnectionPoint;
  58405. /**
  58406. * Gets the xyz component (input)
  58407. */
  58408. readonly xyzIn: NodeMaterialConnectionPoint;
  58409. /**
  58410. * Gets the xy component (input)
  58411. */
  58412. readonly xyIn: NodeMaterialConnectionPoint;
  58413. /**
  58414. * Gets the xyz component (output)
  58415. */
  58416. readonly xyzOut: NodeMaterialConnectionPoint;
  58417. /**
  58418. * Gets the xy component (output)
  58419. */
  58420. readonly xyOut: NodeMaterialConnectionPoint;
  58421. /**
  58422. * Gets the x component (output)
  58423. */
  58424. readonly x: NodeMaterialConnectionPoint;
  58425. /**
  58426. * Gets the y component (output)
  58427. */
  58428. readonly y: NodeMaterialConnectionPoint;
  58429. /**
  58430. * Gets the z component (output)
  58431. */
  58432. readonly z: NodeMaterialConnectionPoint;
  58433. /**
  58434. * Gets the w component (output)
  58435. */
  58436. readonly w: NodeMaterialConnectionPoint;
  58437. protected _inputRename(name: string): string;
  58438. protected _outputRename(name: string): string;
  58439. protected _buildBlock(state: NodeMaterialBuildState): this;
  58440. }
  58441. }
  58442. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  58443. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58444. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58445. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58446. /**
  58447. * Block used to lerp between 2 values
  58448. */
  58449. export class LerpBlock extends NodeMaterialBlock {
  58450. /**
  58451. * Creates a new LerpBlock
  58452. * @param name defines the block name
  58453. */
  58454. constructor(name: string);
  58455. /**
  58456. * Gets the current class name
  58457. * @returns the class name
  58458. */
  58459. getClassName(): string;
  58460. /**
  58461. * Gets the left operand input component
  58462. */
  58463. readonly left: NodeMaterialConnectionPoint;
  58464. /**
  58465. * Gets the right operand input component
  58466. */
  58467. readonly right: NodeMaterialConnectionPoint;
  58468. /**
  58469. * Gets the gradient operand input component
  58470. */
  58471. readonly gradient: NodeMaterialConnectionPoint;
  58472. /**
  58473. * Gets the output component
  58474. */
  58475. readonly output: NodeMaterialConnectionPoint;
  58476. protected _buildBlock(state: NodeMaterialBuildState): this;
  58477. }
  58478. }
  58479. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  58480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58481. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58482. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58483. /**
  58484. * Block used to divide 2 vectors
  58485. */
  58486. export class DivideBlock extends NodeMaterialBlock {
  58487. /**
  58488. * Creates a new DivideBlock
  58489. * @param name defines the block name
  58490. */
  58491. constructor(name: string);
  58492. /**
  58493. * Gets the current class name
  58494. * @returns the class name
  58495. */
  58496. getClassName(): string;
  58497. /**
  58498. * Gets the left operand input component
  58499. */
  58500. readonly left: NodeMaterialConnectionPoint;
  58501. /**
  58502. * Gets the right operand input component
  58503. */
  58504. readonly right: NodeMaterialConnectionPoint;
  58505. /**
  58506. * Gets the output component
  58507. */
  58508. readonly output: NodeMaterialConnectionPoint;
  58509. protected _buildBlock(state: NodeMaterialBuildState): this;
  58510. }
  58511. }
  58512. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  58513. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58514. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58515. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58516. /**
  58517. * Block used to subtract 2 vectors
  58518. */
  58519. export class SubtractBlock extends NodeMaterialBlock {
  58520. /**
  58521. * Creates a new SubtractBlock
  58522. * @param name defines the block name
  58523. */
  58524. constructor(name: string);
  58525. /**
  58526. * Gets the current class name
  58527. * @returns the class name
  58528. */
  58529. getClassName(): string;
  58530. /**
  58531. * Gets the left operand input component
  58532. */
  58533. readonly left: NodeMaterialConnectionPoint;
  58534. /**
  58535. * Gets the right operand input component
  58536. */
  58537. readonly right: NodeMaterialConnectionPoint;
  58538. /**
  58539. * Gets the output component
  58540. */
  58541. readonly output: NodeMaterialConnectionPoint;
  58542. protected _buildBlock(state: NodeMaterialBuildState): this;
  58543. }
  58544. }
  58545. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  58546. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58547. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58548. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58549. /**
  58550. * Block used to step a value
  58551. */
  58552. export class StepBlock extends NodeMaterialBlock {
  58553. /**
  58554. * Creates a new StepBlock
  58555. * @param name defines the block name
  58556. */
  58557. constructor(name: string);
  58558. /**
  58559. * Gets the current class name
  58560. * @returns the class name
  58561. */
  58562. getClassName(): string;
  58563. /**
  58564. * Gets the value operand input component
  58565. */
  58566. readonly value: NodeMaterialConnectionPoint;
  58567. /**
  58568. * Gets the edge operand input component
  58569. */
  58570. readonly edge: NodeMaterialConnectionPoint;
  58571. /**
  58572. * Gets the output component
  58573. */
  58574. readonly output: NodeMaterialConnectionPoint;
  58575. protected _buildBlock(state: NodeMaterialBuildState): this;
  58576. }
  58577. }
  58578. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  58579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58582. /**
  58583. * Block used to get the opposite (1 - x) of a value
  58584. */
  58585. export class OneMinusBlock extends NodeMaterialBlock {
  58586. /**
  58587. * Creates a new OneMinusBlock
  58588. * @param name defines the block name
  58589. */
  58590. constructor(name: string);
  58591. /**
  58592. * Gets the current class name
  58593. * @returns the class name
  58594. */
  58595. getClassName(): string;
  58596. /**
  58597. * Gets the input component
  58598. */
  58599. readonly input: NodeMaterialConnectionPoint;
  58600. /**
  58601. * Gets the output component
  58602. */
  58603. readonly output: NodeMaterialConnectionPoint;
  58604. protected _buildBlock(state: NodeMaterialBuildState): this;
  58605. }
  58606. }
  58607. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  58608. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58609. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58610. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58611. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58612. /**
  58613. * Block used to get the view direction
  58614. */
  58615. export class ViewDirectionBlock extends NodeMaterialBlock {
  58616. /**
  58617. * Creates a new ViewDirectionBlock
  58618. * @param name defines the block name
  58619. */
  58620. constructor(name: string);
  58621. /**
  58622. * Gets the current class name
  58623. * @returns the class name
  58624. */
  58625. getClassName(): string;
  58626. /**
  58627. * Gets the world position component
  58628. */
  58629. readonly worldPosition: NodeMaterialConnectionPoint;
  58630. /**
  58631. * Gets the camera position component
  58632. */
  58633. readonly cameraPosition: NodeMaterialConnectionPoint;
  58634. /**
  58635. * Gets the output component
  58636. */
  58637. readonly output: NodeMaterialConnectionPoint;
  58638. autoConfigure(material: NodeMaterial): void;
  58639. protected _buildBlock(state: NodeMaterialBuildState): this;
  58640. }
  58641. }
  58642. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  58643. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58644. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58645. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58646. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  58647. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  58648. /**
  58649. * Block used to compute fresnel value
  58650. */
  58651. export class FresnelBlock extends NodeMaterialBlock {
  58652. /**
  58653. * Create a new FresnelBlock
  58654. * @param name defines the block name
  58655. */
  58656. constructor(name: string);
  58657. /**
  58658. * Gets the current class name
  58659. * @returns the class name
  58660. */
  58661. getClassName(): string;
  58662. /**
  58663. * Gets the world normal input component
  58664. */
  58665. readonly worldNormal: NodeMaterialConnectionPoint;
  58666. /**
  58667. * Gets the view direction input component
  58668. */
  58669. readonly viewDirection: NodeMaterialConnectionPoint;
  58670. /**
  58671. * Gets the bias input component
  58672. */
  58673. readonly bias: NodeMaterialConnectionPoint;
  58674. /**
  58675. * Gets the camera (or eye) position component
  58676. */
  58677. readonly power: NodeMaterialConnectionPoint;
  58678. /**
  58679. * Gets the fresnel output component
  58680. */
  58681. readonly fresnel: NodeMaterialConnectionPoint;
  58682. autoConfigure(material: NodeMaterial): void;
  58683. protected _buildBlock(state: NodeMaterialBuildState): this;
  58684. }
  58685. }
  58686. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  58687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58688. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58690. /**
  58691. * Block used to get the max of 2 values
  58692. */
  58693. export class MaxBlock extends NodeMaterialBlock {
  58694. /**
  58695. * Creates a new MaxBlock
  58696. * @param name defines the block name
  58697. */
  58698. constructor(name: string);
  58699. /**
  58700. * Gets the current class name
  58701. * @returns the class name
  58702. */
  58703. getClassName(): string;
  58704. /**
  58705. * Gets the left operand input component
  58706. */
  58707. readonly left: NodeMaterialConnectionPoint;
  58708. /**
  58709. * Gets the right operand input component
  58710. */
  58711. readonly right: NodeMaterialConnectionPoint;
  58712. /**
  58713. * Gets the output component
  58714. */
  58715. readonly output: NodeMaterialConnectionPoint;
  58716. protected _buildBlock(state: NodeMaterialBuildState): this;
  58717. }
  58718. }
  58719. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  58720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58721. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58722. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58723. /**
  58724. * Block used to get the min of 2 values
  58725. */
  58726. export class MinBlock extends NodeMaterialBlock {
  58727. /**
  58728. * Creates a new MinBlock
  58729. * @param name defines the block name
  58730. */
  58731. constructor(name: string);
  58732. /**
  58733. * Gets the current class name
  58734. * @returns the class name
  58735. */
  58736. getClassName(): string;
  58737. /**
  58738. * Gets the left operand input component
  58739. */
  58740. readonly left: NodeMaterialConnectionPoint;
  58741. /**
  58742. * Gets the right operand input component
  58743. */
  58744. readonly right: NodeMaterialConnectionPoint;
  58745. /**
  58746. * Gets the output component
  58747. */
  58748. readonly output: NodeMaterialConnectionPoint;
  58749. protected _buildBlock(state: NodeMaterialBuildState): this;
  58750. }
  58751. }
  58752. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  58753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58756. /**
  58757. * Block used to get the distance between 2 values
  58758. */
  58759. export class DistanceBlock extends NodeMaterialBlock {
  58760. /**
  58761. * Creates a new DistanceBlock
  58762. * @param name defines the block name
  58763. */
  58764. constructor(name: string);
  58765. /**
  58766. * Gets the current class name
  58767. * @returns the class name
  58768. */
  58769. getClassName(): string;
  58770. /**
  58771. * Gets the left operand input component
  58772. */
  58773. readonly left: NodeMaterialConnectionPoint;
  58774. /**
  58775. * Gets the right operand input component
  58776. */
  58777. readonly right: NodeMaterialConnectionPoint;
  58778. /**
  58779. * Gets the output component
  58780. */
  58781. readonly output: NodeMaterialConnectionPoint;
  58782. protected _buildBlock(state: NodeMaterialBuildState): this;
  58783. }
  58784. }
  58785. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  58786. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58787. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58788. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58789. /**
  58790. * Block used to get the length of a vector
  58791. */
  58792. export class LengthBlock extends NodeMaterialBlock {
  58793. /**
  58794. * Creates a new LengthBlock
  58795. * @param name defines the block name
  58796. */
  58797. constructor(name: string);
  58798. /**
  58799. * Gets the current class name
  58800. * @returns the class name
  58801. */
  58802. getClassName(): string;
  58803. /**
  58804. * Gets the value input component
  58805. */
  58806. readonly value: NodeMaterialConnectionPoint;
  58807. /**
  58808. * Gets the output component
  58809. */
  58810. readonly output: NodeMaterialConnectionPoint;
  58811. protected _buildBlock(state: NodeMaterialBuildState): this;
  58812. }
  58813. }
  58814. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  58815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58818. /**
  58819. * Block used to get negative version of a value (i.e. x * -1)
  58820. */
  58821. export class NegateBlock extends NodeMaterialBlock {
  58822. /**
  58823. * Creates a new NegateBlock
  58824. * @param name defines the block name
  58825. */
  58826. constructor(name: string);
  58827. /**
  58828. * Gets the current class name
  58829. * @returns the class name
  58830. */
  58831. getClassName(): string;
  58832. /**
  58833. * Gets the value input component
  58834. */
  58835. readonly value: NodeMaterialConnectionPoint;
  58836. /**
  58837. * Gets the output component
  58838. */
  58839. readonly output: NodeMaterialConnectionPoint;
  58840. protected _buildBlock(state: NodeMaterialBuildState): this;
  58841. }
  58842. }
  58843. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  58844. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58845. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58846. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58847. /**
  58848. * Block used to get the value of the first parameter raised to the power of the second
  58849. */
  58850. export class PowBlock extends NodeMaterialBlock {
  58851. /**
  58852. * Creates a new PowBlock
  58853. * @param name defines the block name
  58854. */
  58855. constructor(name: string);
  58856. /**
  58857. * Gets the current class name
  58858. * @returns the class name
  58859. */
  58860. getClassName(): string;
  58861. /**
  58862. * Gets the value operand input component
  58863. */
  58864. readonly value: NodeMaterialConnectionPoint;
  58865. /**
  58866. * Gets the power operand input component
  58867. */
  58868. readonly power: NodeMaterialConnectionPoint;
  58869. /**
  58870. * Gets the output component
  58871. */
  58872. readonly output: NodeMaterialConnectionPoint;
  58873. protected _buildBlock(state: NodeMaterialBuildState): this;
  58874. }
  58875. }
  58876. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  58877. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58878. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58879. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58880. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58881. /**
  58882. * Block used to get a random number
  58883. */
  58884. export class RandomNumberBlock extends NodeMaterialBlock {
  58885. /**
  58886. * Creates a new RandomNumberBlock
  58887. * @param name defines the block name
  58888. */
  58889. constructor(name: string);
  58890. /**
  58891. * Gets the current class name
  58892. * @returns the class name
  58893. */
  58894. getClassName(): string;
  58895. /**
  58896. * Gets the seed input component
  58897. */
  58898. readonly seed: NodeMaterialConnectionPoint;
  58899. /**
  58900. * Gets the output component
  58901. */
  58902. readonly output: NodeMaterialConnectionPoint;
  58903. protected _buildBlock(state: NodeMaterialBuildState): this;
  58904. }
  58905. }
  58906. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  58907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58908. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58909. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58910. /**
  58911. * Block used to compute arc tangent of 2 values
  58912. */
  58913. export class ArcTan2Block extends NodeMaterialBlock {
  58914. /**
  58915. * Creates a new ArcTan2Block
  58916. * @param name defines the block name
  58917. */
  58918. constructor(name: string);
  58919. /**
  58920. * Gets the current class name
  58921. * @returns the class name
  58922. */
  58923. getClassName(): string;
  58924. /**
  58925. * Gets the x operand input component
  58926. */
  58927. readonly x: NodeMaterialConnectionPoint;
  58928. /**
  58929. * Gets the y operand input component
  58930. */
  58931. readonly y: NodeMaterialConnectionPoint;
  58932. /**
  58933. * Gets the output component
  58934. */
  58935. readonly output: NodeMaterialConnectionPoint;
  58936. protected _buildBlock(state: NodeMaterialBuildState): this;
  58937. }
  58938. }
  58939. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58943. /**
  58944. * Block used to smooth step a value
  58945. */
  58946. export class SmoothStepBlock extends NodeMaterialBlock {
  58947. /**
  58948. * Creates a new SmoothStepBlock
  58949. * @param name defines the block name
  58950. */
  58951. constructor(name: string);
  58952. /**
  58953. * Gets the current class name
  58954. * @returns the class name
  58955. */
  58956. getClassName(): string;
  58957. /**
  58958. * Gets the value operand input component
  58959. */
  58960. readonly value: NodeMaterialConnectionPoint;
  58961. /**
  58962. * Gets the first edge operand input component
  58963. */
  58964. readonly edge0: NodeMaterialConnectionPoint;
  58965. /**
  58966. * Gets the second edge operand input component
  58967. */
  58968. readonly edge1: NodeMaterialConnectionPoint;
  58969. /**
  58970. * Gets the output component
  58971. */
  58972. readonly output: NodeMaterialConnectionPoint;
  58973. protected _buildBlock(state: NodeMaterialBuildState): this;
  58974. }
  58975. }
  58976. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58977. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58978. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58979. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58980. /**
  58981. * Block used to get the reciprocal (1 / x) of a value
  58982. */
  58983. export class ReciprocalBlock extends NodeMaterialBlock {
  58984. /**
  58985. * Creates a new ReciprocalBlock
  58986. * @param name defines the block name
  58987. */
  58988. constructor(name: string);
  58989. /**
  58990. * Gets the current class name
  58991. * @returns the class name
  58992. */
  58993. getClassName(): string;
  58994. /**
  58995. * Gets the input component
  58996. */
  58997. readonly input: NodeMaterialConnectionPoint;
  58998. /**
  58999. * Gets the output component
  59000. */
  59001. readonly output: NodeMaterialConnectionPoint;
  59002. protected _buildBlock(state: NodeMaterialBuildState): this;
  59003. }
  59004. }
  59005. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  59006. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59007. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59009. /**
  59010. * Block used to replace a color by another one
  59011. */
  59012. export class ReplaceColorBlock extends NodeMaterialBlock {
  59013. /**
  59014. * Creates a new ReplaceColorBlock
  59015. * @param name defines the block name
  59016. */
  59017. constructor(name: string);
  59018. /**
  59019. * Gets the current class name
  59020. * @returns the class name
  59021. */
  59022. getClassName(): string;
  59023. /**
  59024. * Gets the value input component
  59025. */
  59026. readonly value: NodeMaterialConnectionPoint;
  59027. /**
  59028. * Gets the reference input component
  59029. */
  59030. readonly reference: NodeMaterialConnectionPoint;
  59031. /**
  59032. * Gets the distance input component
  59033. */
  59034. readonly distance: NodeMaterialConnectionPoint;
  59035. /**
  59036. * Gets the replacement input component
  59037. */
  59038. readonly replacement: NodeMaterialConnectionPoint;
  59039. /**
  59040. * Gets the output component
  59041. */
  59042. readonly output: NodeMaterialConnectionPoint;
  59043. protected _buildBlock(state: NodeMaterialBuildState): this;
  59044. }
  59045. }
  59046. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  59047. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59048. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59049. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59050. /**
  59051. * Block used to posterize a value
  59052. * @see https://en.wikipedia.org/wiki/Posterization
  59053. */
  59054. export class PosterizeBlock extends NodeMaterialBlock {
  59055. /**
  59056. * Creates a new PosterizeBlock
  59057. * @param name defines the block name
  59058. */
  59059. constructor(name: string);
  59060. /**
  59061. * Gets the current class name
  59062. * @returns the class name
  59063. */
  59064. getClassName(): string;
  59065. /**
  59066. * Gets the value input component
  59067. */
  59068. readonly value: NodeMaterialConnectionPoint;
  59069. /**
  59070. * Gets the steps input component
  59071. */
  59072. readonly steps: NodeMaterialConnectionPoint;
  59073. /**
  59074. * Gets the output component
  59075. */
  59076. readonly output: NodeMaterialConnectionPoint;
  59077. protected _buildBlock(state: NodeMaterialBuildState): this;
  59078. }
  59079. }
  59080. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  59081. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59082. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59083. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59084. import { Scene } from "babylonjs/scene";
  59085. /**
  59086. * Operations supported by the Wave block
  59087. */
  59088. export enum WaveBlockKind {
  59089. /** SawTooth */
  59090. SawTooth = 0,
  59091. /** Square */
  59092. Square = 1,
  59093. /** Triangle */
  59094. Triangle = 2
  59095. }
  59096. /**
  59097. * Block used to apply wave operation to floats
  59098. */
  59099. export class WaveBlock extends NodeMaterialBlock {
  59100. /**
  59101. * Gets or sets the kibnd of wave to be applied by the block
  59102. */
  59103. kind: WaveBlockKind;
  59104. /**
  59105. * Creates a new WaveBlock
  59106. * @param name defines the block name
  59107. */
  59108. constructor(name: string);
  59109. /**
  59110. * Gets the current class name
  59111. * @returns the class name
  59112. */
  59113. getClassName(): string;
  59114. /**
  59115. * Gets the input component
  59116. */
  59117. readonly input: NodeMaterialConnectionPoint;
  59118. /**
  59119. * Gets the output component
  59120. */
  59121. readonly output: NodeMaterialConnectionPoint;
  59122. protected _buildBlock(state: NodeMaterialBuildState): this;
  59123. serialize(): any;
  59124. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59125. }
  59126. }
  59127. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  59128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59131. import { Color3 } from "babylonjs/Maths/math.color";
  59132. import { Scene } from "babylonjs/scene";
  59133. /**
  59134. * Class used to store a color step for the GradientBlock
  59135. */
  59136. export class GradientBlockColorStep {
  59137. /**
  59138. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59139. */
  59140. step: number;
  59141. /**
  59142. * Gets or sets the color associated with this step
  59143. */
  59144. color: Color3;
  59145. /**
  59146. * Creates a new GradientBlockColorStep
  59147. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59148. * @param color defines the color associated with this step
  59149. */
  59150. constructor(
  59151. /**
  59152. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59153. */
  59154. step: number,
  59155. /**
  59156. * Gets or sets the color associated with this step
  59157. */
  59158. color: Color3);
  59159. }
  59160. /**
  59161. * Block used to return a color from a gradient based on an input value between 0 and 1
  59162. */
  59163. export class GradientBlock extends NodeMaterialBlock {
  59164. /**
  59165. * Gets or sets the list of color steps
  59166. */
  59167. colorSteps: GradientBlockColorStep[];
  59168. /**
  59169. * Creates a new GradientBlock
  59170. * @param name defines the block name
  59171. */
  59172. constructor(name: string);
  59173. /**
  59174. * Gets the current class name
  59175. * @returns the class name
  59176. */
  59177. getClassName(): string;
  59178. /**
  59179. * Gets the gradient input component
  59180. */
  59181. readonly gradient: NodeMaterialConnectionPoint;
  59182. /**
  59183. * Gets the output component
  59184. */
  59185. readonly output: NodeMaterialConnectionPoint;
  59186. private _writeColorConstant;
  59187. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59188. serialize(): any;
  59189. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59190. protected _dumpPropertiesCode(): string;
  59191. }
  59192. }
  59193. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  59194. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59195. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59196. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59197. /**
  59198. * Block used to normalize lerp between 2 values
  59199. */
  59200. export class NLerpBlock extends NodeMaterialBlock {
  59201. /**
  59202. * Creates a new NLerpBlock
  59203. * @param name defines the block name
  59204. */
  59205. constructor(name: string);
  59206. /**
  59207. * Gets the current class name
  59208. * @returns the class name
  59209. */
  59210. getClassName(): string;
  59211. /**
  59212. * Gets the left operand input component
  59213. */
  59214. readonly left: NodeMaterialConnectionPoint;
  59215. /**
  59216. * Gets the right operand input component
  59217. */
  59218. readonly right: NodeMaterialConnectionPoint;
  59219. /**
  59220. * Gets the gradient operand input component
  59221. */
  59222. readonly gradient: NodeMaterialConnectionPoint;
  59223. /**
  59224. * Gets the output component
  59225. */
  59226. readonly output: NodeMaterialConnectionPoint;
  59227. protected _buildBlock(state: NodeMaterialBuildState): this;
  59228. }
  59229. }
  59230. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  59231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59234. import { Scene } from "babylonjs/scene";
  59235. /**
  59236. * block used to Generate a Worley Noise 3D Noise Pattern
  59237. */
  59238. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59239. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59240. manhattanDistance: boolean;
  59241. /**
  59242. * Creates a new WorleyNoise3DBlock
  59243. * @param name defines the block name
  59244. */
  59245. constructor(name: string);
  59246. /**
  59247. * Gets the current class name
  59248. * @returns the class name
  59249. */
  59250. getClassName(): string;
  59251. /**
  59252. * Gets the seed input component
  59253. */
  59254. readonly seed: NodeMaterialConnectionPoint;
  59255. /**
  59256. * Gets the jitter input component
  59257. */
  59258. readonly jitter: NodeMaterialConnectionPoint;
  59259. /**
  59260. * Gets the output component
  59261. */
  59262. readonly output: NodeMaterialConnectionPoint;
  59263. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59264. /**
  59265. * Exposes the properties to the UI?
  59266. */
  59267. protected _dumpPropertiesCode(): string;
  59268. /**
  59269. * Exposes the properties to the Seralize?
  59270. */
  59271. serialize(): any;
  59272. /**
  59273. * Exposes the properties to the deseralize?
  59274. */
  59275. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59276. }
  59277. }
  59278. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  59279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59280. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59281. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59282. /**
  59283. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59284. */
  59285. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59286. /**
  59287. * Creates a new SimplexPerlin3DBlock
  59288. * @param name defines the block name
  59289. */
  59290. constructor(name: string);
  59291. /**
  59292. * Gets the current class name
  59293. * @returns the class name
  59294. */
  59295. getClassName(): string;
  59296. /**
  59297. * Gets the seed operand input component
  59298. */
  59299. readonly seed: NodeMaterialConnectionPoint;
  59300. /**
  59301. * Gets the output component
  59302. */
  59303. readonly output: NodeMaterialConnectionPoint;
  59304. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59305. }
  59306. }
  59307. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  59308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59311. /**
  59312. * Block used to blend normals
  59313. */
  59314. export class NormalBlendBlock extends NodeMaterialBlock {
  59315. /**
  59316. * Creates a new NormalBlendBlock
  59317. * @param name defines the block name
  59318. */
  59319. constructor(name: string);
  59320. /**
  59321. * Gets the current class name
  59322. * @returns the class name
  59323. */
  59324. getClassName(): string;
  59325. /**
  59326. * Gets the first input component
  59327. */
  59328. readonly input0: NodeMaterialConnectionPoint;
  59329. /**
  59330. * Gets the second input component
  59331. */
  59332. readonly input1: NodeMaterialConnectionPoint;
  59333. /**
  59334. * Gets the output component
  59335. */
  59336. readonly output: NodeMaterialConnectionPoint;
  59337. protected _buildBlock(state: NodeMaterialBuildState): this;
  59338. }
  59339. }
  59340. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  59341. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59342. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59343. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59344. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  59345. /**
  59346. * Block used to rotate a 2d vector by a given angle
  59347. */
  59348. export class Rotate2dBlock extends NodeMaterialBlock {
  59349. /**
  59350. * Creates a new Rotate2dBlock
  59351. * @param name defines the block name
  59352. */
  59353. constructor(name: string);
  59354. /**
  59355. * Gets the current class name
  59356. * @returns the class name
  59357. */
  59358. getClassName(): string;
  59359. /**
  59360. * Gets the input vector
  59361. */
  59362. readonly input: NodeMaterialConnectionPoint;
  59363. /**
  59364. * Gets the input angle
  59365. */
  59366. readonly angle: NodeMaterialConnectionPoint;
  59367. /**
  59368. * Gets the output component
  59369. */
  59370. readonly output: NodeMaterialConnectionPoint;
  59371. autoConfigure(material: NodeMaterial): void;
  59372. protected _buildBlock(state: NodeMaterialBuildState): this;
  59373. }
  59374. }
  59375. declare module "babylonjs/Materials/Node/Blocks/index" {
  59376. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  59377. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  59378. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  59379. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  59380. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  59381. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  59382. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  59383. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  59384. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  59385. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  59386. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  59387. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  59388. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  59389. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  59390. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  59391. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  59392. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  59393. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  59394. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  59395. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  59396. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  59397. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  59398. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  59399. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  59400. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  59401. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  59402. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  59403. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  59404. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  59405. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  59406. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  59407. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  59408. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  59409. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  59410. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  59411. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  59412. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  59413. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  59414. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  59415. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  59416. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  59417. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  59418. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  59419. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  59420. }
  59421. declare module "babylonjs/Materials/Node/Optimizers/index" {
  59422. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59423. }
  59424. declare module "babylonjs/Materials/Node/index" {
  59425. export * from "babylonjs/Materials/Node/Enums/index";
  59426. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59427. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  59428. export * from "babylonjs/Materials/Node/nodeMaterial";
  59429. export * from "babylonjs/Materials/Node/Blocks/index";
  59430. export * from "babylonjs/Materials/Node/Optimizers/index";
  59431. }
  59432. declare module "babylonjs/Materials/effectRenderer" {
  59433. import { Nullable } from "babylonjs/types";
  59434. import { Texture } from "babylonjs/Materials/Textures/texture";
  59435. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59436. import { Viewport } from "babylonjs/Maths/math.viewport";
  59437. import { Observable } from "babylonjs/Misc/observable";
  59438. import { Effect } from "babylonjs/Materials/effect";
  59439. import "babylonjs/Engines/Extensions/engine.renderTarget";
  59440. import "babylonjs/Shaders/postprocess.vertex";
  59441. /**
  59442. * Effect Render Options
  59443. */
  59444. export interface IEffectRendererOptions {
  59445. /**
  59446. * Defines the vertices positions.
  59447. */
  59448. positions?: number[];
  59449. /**
  59450. * Defines the indices.
  59451. */
  59452. indices?: number[];
  59453. }
  59454. /**
  59455. * Helper class to render one or more effects
  59456. */
  59457. export class EffectRenderer {
  59458. private engine;
  59459. private static _DefaultOptions;
  59460. private _vertexBuffers;
  59461. private _indexBuffer;
  59462. private _ringBufferIndex;
  59463. private _ringScreenBuffer;
  59464. private _fullscreenViewport;
  59465. private _getNextFrameBuffer;
  59466. /**
  59467. * Creates an effect renderer
  59468. * @param engine the engine to use for rendering
  59469. * @param options defines the options of the effect renderer
  59470. */
  59471. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59472. /**
  59473. * Sets the current viewport in normalized coordinates 0-1
  59474. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59475. */
  59476. setViewport(viewport?: Viewport): void;
  59477. /**
  59478. * Binds the embedded attributes buffer to the effect.
  59479. * @param effect Defines the effect to bind the attributes for
  59480. */
  59481. bindBuffers(effect: Effect): void;
  59482. /**
  59483. * Sets the current effect wrapper to use during draw.
  59484. * The effect needs to be ready before calling this api.
  59485. * This also sets the default full screen position attribute.
  59486. * @param effectWrapper Defines the effect to draw with
  59487. */
  59488. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59489. /**
  59490. * Draws a full screen quad.
  59491. */
  59492. draw(): void;
  59493. /**
  59494. * renders one or more effects to a specified texture
  59495. * @param effectWrappers list of effects to renderer
  59496. * @param outputTexture texture to draw to, if null it will render to the screen
  59497. */
  59498. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  59499. /**
  59500. * Disposes of the effect renderer
  59501. */
  59502. dispose(): void;
  59503. }
  59504. /**
  59505. * Options to create an EffectWrapper
  59506. */
  59507. interface EffectWrapperCreationOptions {
  59508. /**
  59509. * Engine to use to create the effect
  59510. */
  59511. engine: ThinEngine;
  59512. /**
  59513. * Fragment shader for the effect
  59514. */
  59515. fragmentShader: string;
  59516. /**
  59517. * Vertex shader for the effect
  59518. */
  59519. vertexShader?: string;
  59520. /**
  59521. * Attributes to use in the shader
  59522. */
  59523. attributeNames?: Array<string>;
  59524. /**
  59525. * Uniforms to use in the shader
  59526. */
  59527. uniformNames?: Array<string>;
  59528. /**
  59529. * Texture sampler names to use in the shader
  59530. */
  59531. samplerNames?: Array<string>;
  59532. /**
  59533. * The friendly name of the effect displayed in Spector.
  59534. */
  59535. name?: string;
  59536. }
  59537. /**
  59538. * Wraps an effect to be used for rendering
  59539. */
  59540. export class EffectWrapper {
  59541. /**
  59542. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59543. */
  59544. onApplyObservable: Observable<{}>;
  59545. /**
  59546. * The underlying effect
  59547. */
  59548. effect: Effect;
  59549. /**
  59550. * Creates an effect to be renderer
  59551. * @param creationOptions options to create the effect
  59552. */
  59553. constructor(creationOptions: EffectWrapperCreationOptions);
  59554. /**
  59555. * Disposes of the effect wrapper
  59556. */
  59557. dispose(): void;
  59558. }
  59559. }
  59560. declare module "babylonjs/Materials/index" {
  59561. export * from "babylonjs/Materials/Background/index";
  59562. export * from "babylonjs/Materials/colorCurves";
  59563. export * from "babylonjs/Materials/iEffectFallbacks";
  59564. export * from "babylonjs/Materials/effectFallbacks";
  59565. export * from "babylonjs/Materials/effect";
  59566. export * from "babylonjs/Materials/fresnelParameters";
  59567. export * from "babylonjs/Materials/imageProcessingConfiguration";
  59568. export * from "babylonjs/Materials/material";
  59569. export * from "babylonjs/Materials/materialDefines";
  59570. export * from "babylonjs/Materials/materialHelper";
  59571. export * from "babylonjs/Materials/multiMaterial";
  59572. export * from "babylonjs/Materials/PBR/index";
  59573. export * from "babylonjs/Materials/pushMaterial";
  59574. export * from "babylonjs/Materials/shaderMaterial";
  59575. export * from "babylonjs/Materials/standardMaterial";
  59576. export * from "babylonjs/Materials/Textures/index";
  59577. export * from "babylonjs/Materials/uniformBuffer";
  59578. export * from "babylonjs/Materials/materialFlags";
  59579. export * from "babylonjs/Materials/Node/index";
  59580. export * from "babylonjs/Materials/effectRenderer";
  59581. }
  59582. declare module "babylonjs/Maths/index" {
  59583. export * from "babylonjs/Maths/math.scalar";
  59584. export * from "babylonjs/Maths/math";
  59585. export * from "babylonjs/Maths/sphericalPolynomial";
  59586. }
  59587. declare module "babylonjs/Misc/workerPool" {
  59588. import { IDisposable } from "babylonjs/scene";
  59589. /**
  59590. * Helper class to push actions to a pool of workers.
  59591. */
  59592. export class WorkerPool implements IDisposable {
  59593. private _workerInfos;
  59594. private _pendingActions;
  59595. /**
  59596. * Constructor
  59597. * @param workers Array of workers to use for actions
  59598. */
  59599. constructor(workers: Array<Worker>);
  59600. /**
  59601. * Terminates all workers and clears any pending actions.
  59602. */
  59603. dispose(): void;
  59604. /**
  59605. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59606. * pended until a worker has completed its action.
  59607. * @param action The action to perform. Call onComplete when the action is complete.
  59608. */
  59609. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59610. private _execute;
  59611. }
  59612. }
  59613. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  59614. import { IDisposable } from "babylonjs/scene";
  59615. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59616. /**
  59617. * Configuration for Draco compression
  59618. */
  59619. export interface IDracoCompressionConfiguration {
  59620. /**
  59621. * Configuration for the decoder.
  59622. */
  59623. decoder: {
  59624. /**
  59625. * The url to the WebAssembly module.
  59626. */
  59627. wasmUrl?: string;
  59628. /**
  59629. * The url to the WebAssembly binary.
  59630. */
  59631. wasmBinaryUrl?: string;
  59632. /**
  59633. * The url to the fallback JavaScript module.
  59634. */
  59635. fallbackUrl?: string;
  59636. };
  59637. }
  59638. /**
  59639. * Draco compression (https://google.github.io/draco/)
  59640. *
  59641. * This class wraps the Draco module.
  59642. *
  59643. * **Encoder**
  59644. *
  59645. * The encoder is not currently implemented.
  59646. *
  59647. * **Decoder**
  59648. *
  59649. * 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.
  59650. *
  59651. * To update the configuration, use the following code:
  59652. * ```javascript
  59653. * DracoCompression.Configuration = {
  59654. * decoder: {
  59655. * wasmUrl: "<url to the WebAssembly library>",
  59656. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  59657. * fallbackUrl: "<url to the fallback JavaScript library>",
  59658. * }
  59659. * };
  59660. * ```
  59661. *
  59662. * 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.
  59663. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  59664. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  59665. *
  59666. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  59667. * ```javascript
  59668. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  59669. * ```
  59670. *
  59671. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  59672. */
  59673. export class DracoCompression implements IDisposable {
  59674. private _workerPoolPromise?;
  59675. private _decoderModulePromise?;
  59676. /**
  59677. * The configuration. Defaults to the following urls:
  59678. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  59679. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  59680. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  59681. */
  59682. static Configuration: IDracoCompressionConfiguration;
  59683. /**
  59684. * Returns true if the decoder configuration is available.
  59685. */
  59686. static readonly DecoderAvailable: boolean;
  59687. /**
  59688. * Default number of workers to create when creating the draco compression object.
  59689. */
  59690. static DefaultNumWorkers: number;
  59691. private static GetDefaultNumWorkers;
  59692. private static _Default;
  59693. /**
  59694. * Default instance for the draco compression object.
  59695. */
  59696. static readonly Default: DracoCompression;
  59697. /**
  59698. * Constructor
  59699. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59700. */
  59701. constructor(numWorkers?: number);
  59702. /**
  59703. * Stop all async operations and release resources.
  59704. */
  59705. dispose(): void;
  59706. /**
  59707. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  59708. * @returns a promise that resolves when ready
  59709. */
  59710. whenReadyAsync(): Promise<void>;
  59711. /**
  59712. * Decode Draco compressed mesh data to vertex data.
  59713. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  59714. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  59715. * @returns A promise that resolves with the decoded vertex data
  59716. */
  59717. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  59718. [kind: string]: number;
  59719. }): Promise<VertexData>;
  59720. }
  59721. }
  59722. declare module "babylonjs/Meshes/Compression/index" {
  59723. export * from "babylonjs/Meshes/Compression/dracoCompression";
  59724. }
  59725. declare module "babylonjs/Meshes/csg" {
  59726. import { Nullable } from "babylonjs/types";
  59727. import { Scene } from "babylonjs/scene";
  59728. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59729. import { Mesh } from "babylonjs/Meshes/mesh";
  59730. import { Material } from "babylonjs/Materials/material";
  59731. /**
  59732. * Class for building Constructive Solid Geometry
  59733. */
  59734. export class CSG {
  59735. private polygons;
  59736. /**
  59737. * The world matrix
  59738. */
  59739. matrix: Matrix;
  59740. /**
  59741. * Stores the position
  59742. */
  59743. position: Vector3;
  59744. /**
  59745. * Stores the rotation
  59746. */
  59747. rotation: Vector3;
  59748. /**
  59749. * Stores the rotation quaternion
  59750. */
  59751. rotationQuaternion: Nullable<Quaternion>;
  59752. /**
  59753. * Stores the scaling vector
  59754. */
  59755. scaling: Vector3;
  59756. /**
  59757. * Convert the Mesh to CSG
  59758. * @param mesh The Mesh to convert to CSG
  59759. * @returns A new CSG from the Mesh
  59760. */
  59761. static FromMesh(mesh: Mesh): CSG;
  59762. /**
  59763. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  59764. * @param polygons Polygons used to construct a CSG solid
  59765. */
  59766. private static FromPolygons;
  59767. /**
  59768. * Clones, or makes a deep copy, of the CSG
  59769. * @returns A new CSG
  59770. */
  59771. clone(): CSG;
  59772. /**
  59773. * Unions this CSG with another CSG
  59774. * @param csg The CSG to union against this CSG
  59775. * @returns The unioned CSG
  59776. */
  59777. union(csg: CSG): CSG;
  59778. /**
  59779. * Unions this CSG with another CSG in place
  59780. * @param csg The CSG to union against this CSG
  59781. */
  59782. unionInPlace(csg: CSG): void;
  59783. /**
  59784. * Subtracts this CSG with another CSG
  59785. * @param csg The CSG to subtract against this CSG
  59786. * @returns A new CSG
  59787. */
  59788. subtract(csg: CSG): CSG;
  59789. /**
  59790. * Subtracts this CSG with another CSG in place
  59791. * @param csg The CSG to subtact against this CSG
  59792. */
  59793. subtractInPlace(csg: CSG): void;
  59794. /**
  59795. * Intersect this CSG with another CSG
  59796. * @param csg The CSG to intersect against this CSG
  59797. * @returns A new CSG
  59798. */
  59799. intersect(csg: CSG): CSG;
  59800. /**
  59801. * Intersects this CSG with another CSG in place
  59802. * @param csg The CSG to intersect against this CSG
  59803. */
  59804. intersectInPlace(csg: CSG): void;
  59805. /**
  59806. * Return a new CSG solid with solid and empty space switched. This solid is
  59807. * not modified.
  59808. * @returns A new CSG solid with solid and empty space switched
  59809. */
  59810. inverse(): CSG;
  59811. /**
  59812. * Inverses the CSG in place
  59813. */
  59814. inverseInPlace(): void;
  59815. /**
  59816. * This is used to keep meshes transformations so they can be restored
  59817. * when we build back a Babylon Mesh
  59818. * NB : All CSG operations are performed in world coordinates
  59819. * @param csg The CSG to copy the transform attributes from
  59820. * @returns This CSG
  59821. */
  59822. copyTransformAttributes(csg: CSG): CSG;
  59823. /**
  59824. * Build Raw mesh from CSG
  59825. * Coordinates here are in world space
  59826. * @param name The name of the mesh geometry
  59827. * @param scene The Scene
  59828. * @param keepSubMeshes Specifies if the submeshes should be kept
  59829. * @returns A new Mesh
  59830. */
  59831. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59832. /**
  59833. * Build Mesh from CSG taking material and transforms into account
  59834. * @param name The name of the Mesh
  59835. * @param material The material of the Mesh
  59836. * @param scene The Scene
  59837. * @param keepSubMeshes Specifies if submeshes should be kept
  59838. * @returns The new Mesh
  59839. */
  59840. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  59841. }
  59842. }
  59843. declare module "babylonjs/Meshes/trailMesh" {
  59844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59845. import { Mesh } from "babylonjs/Meshes/mesh";
  59846. import { Scene } from "babylonjs/scene";
  59847. /**
  59848. * Class used to create a trail following a mesh
  59849. */
  59850. export class TrailMesh extends Mesh {
  59851. private _generator;
  59852. private _autoStart;
  59853. private _running;
  59854. private _diameter;
  59855. private _length;
  59856. private _sectionPolygonPointsCount;
  59857. private _sectionVectors;
  59858. private _sectionNormalVectors;
  59859. private _beforeRenderObserver;
  59860. /**
  59861. * @constructor
  59862. * @param name The value used by scene.getMeshByName() to do a lookup.
  59863. * @param generator The mesh to generate a trail.
  59864. * @param scene The scene to add this mesh to.
  59865. * @param diameter Diameter of trailing mesh. Default is 1.
  59866. * @param length Length of trailing mesh. Default is 60.
  59867. * @param autoStart Automatically start trailing mesh. Default true.
  59868. */
  59869. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  59870. /**
  59871. * "TrailMesh"
  59872. * @returns "TrailMesh"
  59873. */
  59874. getClassName(): string;
  59875. private _createMesh;
  59876. /**
  59877. * Start trailing mesh.
  59878. */
  59879. start(): void;
  59880. /**
  59881. * Stop trailing mesh.
  59882. */
  59883. stop(): void;
  59884. /**
  59885. * Update trailing mesh geometry.
  59886. */
  59887. update(): void;
  59888. /**
  59889. * Returns a new TrailMesh object.
  59890. * @param name is a string, the name given to the new mesh
  59891. * @param newGenerator use new generator object for cloned trail mesh
  59892. * @returns a new mesh
  59893. */
  59894. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  59895. /**
  59896. * Serializes this trail mesh
  59897. * @param serializationObject object to write serialization to
  59898. */
  59899. serialize(serializationObject: any): void;
  59900. /**
  59901. * Parses a serialized trail mesh
  59902. * @param parsedMesh the serialized mesh
  59903. * @param scene the scene to create the trail mesh in
  59904. * @returns the created trail mesh
  59905. */
  59906. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  59907. }
  59908. }
  59909. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  59910. import { Nullable } from "babylonjs/types";
  59911. import { Scene } from "babylonjs/scene";
  59912. import { Vector4 } from "babylonjs/Maths/math.vector";
  59913. import { Color4 } from "babylonjs/Maths/math.color";
  59914. import { Mesh } from "babylonjs/Meshes/mesh";
  59915. /**
  59916. * Class containing static functions to help procedurally build meshes
  59917. */
  59918. export class TiledBoxBuilder {
  59919. /**
  59920. * Creates a box mesh
  59921. * 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)
  59922. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59926. * @param name defines the name of the mesh
  59927. * @param options defines the options used to create the mesh
  59928. * @param scene defines the hosting scene
  59929. * @returns the box mesh
  59930. */
  59931. static CreateTiledBox(name: string, options: {
  59932. pattern?: number;
  59933. width?: number;
  59934. height?: number;
  59935. depth?: number;
  59936. tileSize?: number;
  59937. tileWidth?: number;
  59938. tileHeight?: number;
  59939. alignHorizontal?: number;
  59940. alignVertical?: number;
  59941. faceUV?: Vector4[];
  59942. faceColors?: Color4[];
  59943. sideOrientation?: number;
  59944. updatable?: boolean;
  59945. }, scene?: Nullable<Scene>): Mesh;
  59946. }
  59947. }
  59948. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  59949. import { Vector4 } from "babylonjs/Maths/math.vector";
  59950. import { Mesh } from "babylonjs/Meshes/mesh";
  59951. /**
  59952. * Class containing static functions to help procedurally build meshes
  59953. */
  59954. export class TorusKnotBuilder {
  59955. /**
  59956. * Creates a torus knot mesh
  59957. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59958. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59959. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59960. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59962. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59964. * @param name defines the name of the mesh
  59965. * @param options defines the options used to create the mesh
  59966. * @param scene defines the hosting scene
  59967. * @returns the torus knot mesh
  59968. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59969. */
  59970. static CreateTorusKnot(name: string, options: {
  59971. radius?: number;
  59972. tube?: number;
  59973. radialSegments?: number;
  59974. tubularSegments?: number;
  59975. p?: number;
  59976. q?: number;
  59977. updatable?: boolean;
  59978. sideOrientation?: number;
  59979. frontUVs?: Vector4;
  59980. backUVs?: Vector4;
  59981. }, scene: any): Mesh;
  59982. }
  59983. }
  59984. declare module "babylonjs/Meshes/polygonMesh" {
  59985. import { Scene } from "babylonjs/scene";
  59986. import { Vector2 } from "babylonjs/Maths/math.vector";
  59987. import { Mesh } from "babylonjs/Meshes/mesh";
  59988. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  59989. import { Path2 } from "babylonjs/Maths/math.path";
  59990. /**
  59991. * Polygon
  59992. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  59993. */
  59994. export class Polygon {
  59995. /**
  59996. * Creates a rectangle
  59997. * @param xmin bottom X coord
  59998. * @param ymin bottom Y coord
  59999. * @param xmax top X coord
  60000. * @param ymax top Y coord
  60001. * @returns points that make the resulting rectation
  60002. */
  60003. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60004. /**
  60005. * Creates a circle
  60006. * @param radius radius of circle
  60007. * @param cx scale in x
  60008. * @param cy scale in y
  60009. * @param numberOfSides number of sides that make up the circle
  60010. * @returns points that make the resulting circle
  60011. */
  60012. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60013. /**
  60014. * Creates a polygon from input string
  60015. * @param input Input polygon data
  60016. * @returns the parsed points
  60017. */
  60018. static Parse(input: string): Vector2[];
  60019. /**
  60020. * Starts building a polygon from x and y coordinates
  60021. * @param x x coordinate
  60022. * @param y y coordinate
  60023. * @returns the started path2
  60024. */
  60025. static StartingAt(x: number, y: number): Path2;
  60026. }
  60027. /**
  60028. * Builds a polygon
  60029. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60030. */
  60031. export class PolygonMeshBuilder {
  60032. private _points;
  60033. private _outlinepoints;
  60034. private _holes;
  60035. private _name;
  60036. private _scene;
  60037. private _epoints;
  60038. private _eholes;
  60039. private _addToepoint;
  60040. /**
  60041. * Babylon reference to the earcut plugin.
  60042. */
  60043. bjsEarcut: any;
  60044. /**
  60045. * Creates a PolygonMeshBuilder
  60046. * @param name name of the builder
  60047. * @param contours Path of the polygon
  60048. * @param scene scene to add to when creating the mesh
  60049. * @param earcutInjection can be used to inject your own earcut reference
  60050. */
  60051. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60052. /**
  60053. * Adds a whole within the polygon
  60054. * @param hole Array of points defining the hole
  60055. * @returns this
  60056. */
  60057. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60058. /**
  60059. * Creates the polygon
  60060. * @param updatable If the mesh should be updatable
  60061. * @param depth The depth of the mesh created
  60062. * @returns the created mesh
  60063. */
  60064. build(updatable?: boolean, depth?: number): Mesh;
  60065. /**
  60066. * Creates the polygon
  60067. * @param depth The depth of the mesh created
  60068. * @returns the created VertexData
  60069. */
  60070. buildVertexData(depth?: number): VertexData;
  60071. /**
  60072. * Adds a side to the polygon
  60073. * @param positions points that make the polygon
  60074. * @param normals normals of the polygon
  60075. * @param uvs uvs of the polygon
  60076. * @param indices indices of the polygon
  60077. * @param bounds bounds of the polygon
  60078. * @param points points of the polygon
  60079. * @param depth depth of the polygon
  60080. * @param flip flip of the polygon
  60081. */
  60082. private addSide;
  60083. }
  60084. }
  60085. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  60086. import { Scene } from "babylonjs/scene";
  60087. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60088. import { Color4 } from "babylonjs/Maths/math.color";
  60089. import { Mesh } from "babylonjs/Meshes/mesh";
  60090. import { Nullable } from "babylonjs/types";
  60091. /**
  60092. * Class containing static functions to help procedurally build meshes
  60093. */
  60094. export class PolygonBuilder {
  60095. /**
  60096. * Creates a polygon mesh
  60097. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60098. * * 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
  60099. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60100. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60101. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60102. * * Remember you can only change the shape positions, not their number when updating a polygon
  60103. * @param name defines the name of the mesh
  60104. * @param options defines the options used to create the mesh
  60105. * @param scene defines the hosting scene
  60106. * @param earcutInjection can be used to inject your own earcut reference
  60107. * @returns the polygon mesh
  60108. */
  60109. static CreatePolygon(name: string, options: {
  60110. shape: Vector3[];
  60111. holes?: Vector3[][];
  60112. depth?: number;
  60113. faceUV?: Vector4[];
  60114. faceColors?: Color4[];
  60115. updatable?: boolean;
  60116. sideOrientation?: number;
  60117. frontUVs?: Vector4;
  60118. backUVs?: Vector4;
  60119. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60120. /**
  60121. * Creates an extruded polygon mesh, with depth in the Y direction.
  60122. * * 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)
  60123. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60124. * @param name defines the name of the mesh
  60125. * @param options defines the options used to create the mesh
  60126. * @param scene defines the hosting scene
  60127. * @param earcutInjection can be used to inject your own earcut reference
  60128. * @returns the polygon mesh
  60129. */
  60130. static ExtrudePolygon(name: string, options: {
  60131. shape: Vector3[];
  60132. holes?: Vector3[][];
  60133. depth?: number;
  60134. faceUV?: Vector4[];
  60135. faceColors?: Color4[];
  60136. updatable?: boolean;
  60137. sideOrientation?: number;
  60138. frontUVs?: Vector4;
  60139. backUVs?: Vector4;
  60140. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60141. }
  60142. }
  60143. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  60144. import { Scene } from "babylonjs/scene";
  60145. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60146. import { Mesh } from "babylonjs/Meshes/mesh";
  60147. import { Nullable } from "babylonjs/types";
  60148. /**
  60149. * Class containing static functions to help procedurally build meshes
  60150. */
  60151. export class LatheBuilder {
  60152. /**
  60153. * Creates lathe mesh.
  60154. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60155. * * 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
  60156. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60157. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60158. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60159. * * 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
  60160. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60161. * * 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
  60162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60164. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60166. * @param name defines the name of the mesh
  60167. * @param options defines the options used to create the mesh
  60168. * @param scene defines the hosting scene
  60169. * @returns the lathe mesh
  60170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60171. */
  60172. static CreateLathe(name: string, options: {
  60173. shape: Vector3[];
  60174. radius?: number;
  60175. tessellation?: number;
  60176. clip?: number;
  60177. arc?: number;
  60178. closed?: boolean;
  60179. updatable?: boolean;
  60180. sideOrientation?: number;
  60181. frontUVs?: Vector4;
  60182. backUVs?: Vector4;
  60183. cap?: number;
  60184. invertUV?: boolean;
  60185. }, scene?: Nullable<Scene>): Mesh;
  60186. }
  60187. }
  60188. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  60189. import { Nullable } from "babylonjs/types";
  60190. import { Scene } from "babylonjs/scene";
  60191. import { Vector4 } from "babylonjs/Maths/math.vector";
  60192. import { Mesh } from "babylonjs/Meshes/mesh";
  60193. /**
  60194. * Class containing static functions to help procedurally build meshes
  60195. */
  60196. export class TiledPlaneBuilder {
  60197. /**
  60198. * Creates a tiled plane mesh
  60199. * * The parameter `pattern` will, depending on value, do nothing or
  60200. * * * flip (reflect about central vertical) alternate tiles across and up
  60201. * * * flip every tile on alternate rows
  60202. * * * rotate (180 degs) alternate tiles across and up
  60203. * * * rotate every tile on alternate rows
  60204. * * * flip and rotate alternate tiles across and up
  60205. * * * flip and rotate every tile on alternate rows
  60206. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60207. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60210. * * 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)
  60211. * * 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)
  60212. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60213. * @param name defines the name of the mesh
  60214. * @param options defines the options used to create the mesh
  60215. * @param scene defines the hosting scene
  60216. * @returns the box mesh
  60217. */
  60218. static CreateTiledPlane(name: string, options: {
  60219. pattern?: number;
  60220. tileSize?: number;
  60221. tileWidth?: number;
  60222. tileHeight?: number;
  60223. size?: number;
  60224. width?: number;
  60225. height?: number;
  60226. alignHorizontal?: number;
  60227. alignVertical?: 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/tubeBuilder" {
  60236. import { Nullable } from "babylonjs/types";
  60237. import { Scene } from "babylonjs/scene";
  60238. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  60239. import { Mesh } from "babylonjs/Meshes/mesh";
  60240. /**
  60241. * Class containing static functions to help procedurally build meshes
  60242. */
  60243. export class TubeBuilder {
  60244. /**
  60245. * Creates a tube mesh.
  60246. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60247. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60248. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60249. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60250. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60251. * * 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)
  60252. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60253. * * 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
  60254. * * 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
  60255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60257. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60259. * @param name defines the name of the mesh
  60260. * @param options defines the options used to create the mesh
  60261. * @param scene defines the hosting scene
  60262. * @returns the tube mesh
  60263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60264. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60265. */
  60266. static CreateTube(name: string, options: {
  60267. path: Vector3[];
  60268. radius?: number;
  60269. tessellation?: number;
  60270. radiusFunction?: {
  60271. (i: number, distance: number): number;
  60272. };
  60273. cap?: number;
  60274. arc?: number;
  60275. updatable?: boolean;
  60276. sideOrientation?: number;
  60277. frontUVs?: Vector4;
  60278. backUVs?: Vector4;
  60279. instance?: Mesh;
  60280. invertUV?: boolean;
  60281. }, scene?: Nullable<Scene>): Mesh;
  60282. }
  60283. }
  60284. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  60285. import { Scene } from "babylonjs/scene";
  60286. import { Vector4 } from "babylonjs/Maths/math.vector";
  60287. import { Mesh } from "babylonjs/Meshes/mesh";
  60288. import { Nullable } from "babylonjs/types";
  60289. /**
  60290. * Class containing static functions to help procedurally build meshes
  60291. */
  60292. export class IcoSphereBuilder {
  60293. /**
  60294. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60295. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60296. * * 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`)
  60297. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60298. * * 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
  60299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60302. * @param name defines the name of the mesh
  60303. * @param options defines the options used to create the mesh
  60304. * @param scene defines the hosting scene
  60305. * @returns the icosahedron mesh
  60306. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60307. */
  60308. static CreateIcoSphere(name: string, options: {
  60309. radius?: number;
  60310. radiusX?: number;
  60311. radiusY?: number;
  60312. radiusZ?: number;
  60313. flat?: boolean;
  60314. subdivisions?: number;
  60315. sideOrientation?: number;
  60316. frontUVs?: Vector4;
  60317. backUVs?: Vector4;
  60318. updatable?: boolean;
  60319. }, scene?: Nullable<Scene>): Mesh;
  60320. }
  60321. }
  60322. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  60323. import { Vector3 } from "babylonjs/Maths/math.vector";
  60324. import { Mesh } from "babylonjs/Meshes/mesh";
  60325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60326. /**
  60327. * Class containing static functions to help procedurally build meshes
  60328. */
  60329. export class DecalBuilder {
  60330. /**
  60331. * Creates a decal mesh.
  60332. * 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
  60333. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60334. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60335. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60336. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60337. * @param name defines the name of the mesh
  60338. * @param sourceMesh defines the mesh where the decal must be applied
  60339. * @param options defines the options used to create the mesh
  60340. * @param scene defines the hosting scene
  60341. * @returns the decal mesh
  60342. * @see https://doc.babylonjs.com/how_to/decals
  60343. */
  60344. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60345. position?: Vector3;
  60346. normal?: Vector3;
  60347. size?: Vector3;
  60348. angle?: number;
  60349. }): Mesh;
  60350. }
  60351. }
  60352. declare module "babylonjs/Meshes/meshBuilder" {
  60353. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  60354. import { Nullable } from "babylonjs/types";
  60355. import { Scene } from "babylonjs/scene";
  60356. import { Mesh } from "babylonjs/Meshes/mesh";
  60357. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  60358. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  60359. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60360. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60361. import { Plane } from "babylonjs/Maths/math.plane";
  60362. /**
  60363. * Class containing static functions to help procedurally build meshes
  60364. */
  60365. export class MeshBuilder {
  60366. /**
  60367. * Creates a box mesh
  60368. * * The parameter `size` sets the size (float) of each box side (default 1)
  60369. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60370. * * 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)
  60371. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60375. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60376. * @param name defines the name of the mesh
  60377. * @param options defines the options used to create the mesh
  60378. * @param scene defines the hosting scene
  60379. * @returns the box mesh
  60380. */
  60381. static CreateBox(name: string, options: {
  60382. size?: number;
  60383. width?: number;
  60384. height?: number;
  60385. depth?: number;
  60386. faceUV?: Vector4[];
  60387. faceColors?: Color4[];
  60388. sideOrientation?: number;
  60389. frontUVs?: Vector4;
  60390. backUVs?: Vector4;
  60391. updatable?: boolean;
  60392. }, scene?: Nullable<Scene>): Mesh;
  60393. /**
  60394. * Creates a tiled box mesh
  60395. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60397. * @param name defines the name of the mesh
  60398. * @param options defines the options used to create the mesh
  60399. * @param scene defines the hosting scene
  60400. * @returns the tiled box mesh
  60401. */
  60402. static CreateTiledBox(name: string, options: {
  60403. pattern?: number;
  60404. size?: number;
  60405. width?: number;
  60406. height?: number;
  60407. depth: number;
  60408. tileSize?: number;
  60409. tileWidth?: number;
  60410. tileHeight?: number;
  60411. faceUV?: Vector4[];
  60412. faceColors?: Color4[];
  60413. alignHorizontal?: number;
  60414. alignVertical?: number;
  60415. sideOrientation?: number;
  60416. updatable?: boolean;
  60417. }, scene?: Nullable<Scene>): Mesh;
  60418. /**
  60419. * Creates a sphere mesh
  60420. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60421. * * 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`)
  60422. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60423. * * 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
  60424. * * 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)
  60425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60428. * @param name defines the name of the mesh
  60429. * @param options defines the options used to create the mesh
  60430. * @param scene defines the hosting scene
  60431. * @returns the sphere mesh
  60432. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  60433. */
  60434. static CreateSphere(name: string, options: {
  60435. segments?: number;
  60436. diameter?: number;
  60437. diameterX?: number;
  60438. diameterY?: number;
  60439. diameterZ?: number;
  60440. arc?: number;
  60441. slice?: number;
  60442. sideOrientation?: number;
  60443. frontUVs?: Vector4;
  60444. backUVs?: Vector4;
  60445. updatable?: boolean;
  60446. }, scene?: Nullable<Scene>): Mesh;
  60447. /**
  60448. * Creates a plane polygonal mesh. By default, this is a disc
  60449. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  60450. * * 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
  60451. * * 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
  60452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60455. * @param name defines the name of the mesh
  60456. * @param options defines the options used to create the mesh
  60457. * @param scene defines the hosting scene
  60458. * @returns the plane polygonal mesh
  60459. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  60460. */
  60461. static CreateDisc(name: string, options: {
  60462. radius?: number;
  60463. tessellation?: number;
  60464. arc?: number;
  60465. updatable?: boolean;
  60466. sideOrientation?: number;
  60467. frontUVs?: Vector4;
  60468. backUVs?: Vector4;
  60469. }, scene?: Nullable<Scene>): Mesh;
  60470. /**
  60471. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60472. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60473. * * 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`)
  60474. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60475. * * 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
  60476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60479. * @param name defines the name of the mesh
  60480. * @param options defines the options used to create the mesh
  60481. * @param scene defines the hosting scene
  60482. * @returns the icosahedron mesh
  60483. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60484. */
  60485. static CreateIcoSphere(name: string, options: {
  60486. radius?: number;
  60487. radiusX?: number;
  60488. radiusY?: number;
  60489. radiusZ?: number;
  60490. flat?: boolean;
  60491. subdivisions?: number;
  60492. sideOrientation?: number;
  60493. frontUVs?: Vector4;
  60494. backUVs?: Vector4;
  60495. updatable?: boolean;
  60496. }, scene?: Nullable<Scene>): Mesh;
  60497. /**
  60498. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60499. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60500. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60501. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60502. * * 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
  60503. * * 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
  60504. * * 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
  60505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60506. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60507. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60508. * * 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
  60509. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60510. * * 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
  60511. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60513. * @param name defines the name of the mesh
  60514. * @param options defines the options used to create the mesh
  60515. * @param scene defines the hosting scene
  60516. * @returns the ribbon mesh
  60517. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60518. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60519. */
  60520. static CreateRibbon(name: string, options: {
  60521. pathArray: Vector3[][];
  60522. closeArray?: boolean;
  60523. closePath?: boolean;
  60524. offset?: number;
  60525. updatable?: boolean;
  60526. sideOrientation?: number;
  60527. frontUVs?: Vector4;
  60528. backUVs?: Vector4;
  60529. instance?: Mesh;
  60530. invertUV?: boolean;
  60531. uvs?: Vector2[];
  60532. colors?: Color4[];
  60533. }, scene?: Nullable<Scene>): Mesh;
  60534. /**
  60535. * Creates a cylinder or a cone mesh
  60536. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  60537. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  60538. * * 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.
  60539. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  60540. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  60541. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  60542. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  60543. * * 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).
  60544. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  60545. * * 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).
  60546. * * 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
  60547. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  60548. * * 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
  60549. * * 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.
  60550. * * If `enclose` is false, a ring surface is one element.
  60551. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  60552. * * 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
  60553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60554. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60556. * @param name defines the name of the mesh
  60557. * @param options defines the options used to create the mesh
  60558. * @param scene defines the hosting scene
  60559. * @returns the cylinder mesh
  60560. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  60561. */
  60562. static CreateCylinder(name: string, options: {
  60563. height?: number;
  60564. diameterTop?: number;
  60565. diameterBottom?: number;
  60566. diameter?: number;
  60567. tessellation?: number;
  60568. subdivisions?: number;
  60569. arc?: number;
  60570. faceColors?: Color4[];
  60571. faceUV?: Vector4[];
  60572. updatable?: boolean;
  60573. hasRings?: boolean;
  60574. enclose?: boolean;
  60575. cap?: number;
  60576. sideOrientation?: number;
  60577. frontUVs?: Vector4;
  60578. backUVs?: Vector4;
  60579. }, scene?: Nullable<Scene>): Mesh;
  60580. /**
  60581. * Creates a torus mesh
  60582. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  60583. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  60584. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  60585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60588. * @param name defines the name of the mesh
  60589. * @param options defines the options used to create the mesh
  60590. * @param scene defines the hosting scene
  60591. * @returns the torus mesh
  60592. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  60593. */
  60594. static CreateTorus(name: string, options: {
  60595. diameter?: number;
  60596. thickness?: number;
  60597. tessellation?: number;
  60598. updatable?: boolean;
  60599. sideOrientation?: number;
  60600. frontUVs?: Vector4;
  60601. backUVs?: Vector4;
  60602. }, scene?: Nullable<Scene>): Mesh;
  60603. /**
  60604. * Creates a torus knot mesh
  60605. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60606. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60607. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60608. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60612. * @param name defines the name of the mesh
  60613. * @param options defines the options used to create the mesh
  60614. * @param scene defines the hosting scene
  60615. * @returns the torus knot mesh
  60616. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60617. */
  60618. static CreateTorusKnot(name: string, options: {
  60619. radius?: number;
  60620. tube?: number;
  60621. radialSegments?: number;
  60622. tubularSegments?: number;
  60623. p?: number;
  60624. q?: number;
  60625. updatable?: boolean;
  60626. sideOrientation?: number;
  60627. frontUVs?: Vector4;
  60628. backUVs?: Vector4;
  60629. }, scene?: Nullable<Scene>): Mesh;
  60630. /**
  60631. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  60632. * * 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
  60633. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  60634. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  60635. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  60636. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  60637. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  60638. * * 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
  60639. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  60640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  60642. * @param name defines the name of the new line system
  60643. * @param options defines the options used to create the line system
  60644. * @param scene defines the hosting scene
  60645. * @returns a new line system mesh
  60646. */
  60647. static CreateLineSystem(name: string, options: {
  60648. lines: Vector3[][];
  60649. updatable?: boolean;
  60650. instance?: Nullable<LinesMesh>;
  60651. colors?: Nullable<Color4[][]>;
  60652. useVertexAlpha?: boolean;
  60653. }, scene: Nullable<Scene>): LinesMesh;
  60654. /**
  60655. * Creates a line mesh
  60656. * 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
  60657. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60658. * * The parameter `points` is an array successive Vector3
  60659. * * 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
  60660. * * The optional parameter `colors` is an array of successive Color4, one per line point
  60661. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  60662. * * When updating an instance, remember that only point positions can change, not the number of points
  60663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  60665. * @param name defines the name of the new line system
  60666. * @param options defines the options used to create the line system
  60667. * @param scene defines the hosting scene
  60668. * @returns a new line mesh
  60669. */
  60670. static CreateLines(name: string, options: {
  60671. points: Vector3[];
  60672. updatable?: boolean;
  60673. instance?: Nullable<LinesMesh>;
  60674. colors?: Color4[];
  60675. useVertexAlpha?: boolean;
  60676. }, scene?: Nullable<Scene>): LinesMesh;
  60677. /**
  60678. * Creates a dashed line mesh
  60679. * * 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
  60680. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  60681. * * The parameter `points` is an array successive Vector3
  60682. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  60683. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  60684. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  60685. * * 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
  60686. * * When updating an instance, remember that only point positions can change, not the number of points
  60687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60688. * @param name defines the name of the mesh
  60689. * @param options defines the options used to create the mesh
  60690. * @param scene defines the hosting scene
  60691. * @returns the dashed line mesh
  60692. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  60693. */
  60694. static CreateDashedLines(name: string, options: {
  60695. points: Vector3[];
  60696. dashSize?: number;
  60697. gapSize?: number;
  60698. dashNb?: number;
  60699. updatable?: boolean;
  60700. instance?: LinesMesh;
  60701. }, scene?: Nullable<Scene>): LinesMesh;
  60702. /**
  60703. * 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.
  60704. * * 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.
  60705. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60706. * * 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.
  60707. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60708. * * 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
  60709. * * 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
  60710. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60712. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60713. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60715. * @param name defines the name of the mesh
  60716. * @param options defines the options used to create the mesh
  60717. * @param scene defines the hosting scene
  60718. * @returns the extruded shape mesh
  60719. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60720. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60721. */
  60722. static ExtrudeShape(name: string, options: {
  60723. shape: Vector3[];
  60724. path: Vector3[];
  60725. scale?: number;
  60726. rotation?: number;
  60727. cap?: number;
  60728. updatable?: boolean;
  60729. sideOrientation?: number;
  60730. frontUVs?: Vector4;
  60731. backUVs?: Vector4;
  60732. instance?: Mesh;
  60733. invertUV?: boolean;
  60734. }, scene?: Nullable<Scene>): Mesh;
  60735. /**
  60736. * Creates an custom extruded shape mesh.
  60737. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60738. * * 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.
  60739. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60740. * * 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
  60741. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60742. * * 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
  60743. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60744. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60745. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60746. * * 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
  60747. * * 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
  60748. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60751. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60753. * @param name defines the name of the mesh
  60754. * @param options defines the options used to create the mesh
  60755. * @param scene defines the hosting scene
  60756. * @returns the custom extruded shape mesh
  60757. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60758. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60759. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60760. */
  60761. static ExtrudeShapeCustom(name: string, options: {
  60762. shape: Vector3[];
  60763. path: Vector3[];
  60764. scaleFunction?: any;
  60765. rotationFunction?: any;
  60766. ribbonCloseArray?: boolean;
  60767. ribbonClosePath?: boolean;
  60768. cap?: number;
  60769. updatable?: boolean;
  60770. sideOrientation?: number;
  60771. frontUVs?: Vector4;
  60772. backUVs?: Vector4;
  60773. instance?: Mesh;
  60774. invertUV?: boolean;
  60775. }, scene?: Nullable<Scene>): Mesh;
  60776. /**
  60777. * Creates lathe mesh.
  60778. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60779. * * 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
  60780. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60781. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60782. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60783. * * 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
  60784. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60785. * * 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
  60786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60788. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60790. * @param name defines the name of the mesh
  60791. * @param options defines the options used to create the mesh
  60792. * @param scene defines the hosting scene
  60793. * @returns the lathe mesh
  60794. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60795. */
  60796. static CreateLathe(name: string, options: {
  60797. shape: Vector3[];
  60798. radius?: number;
  60799. tessellation?: number;
  60800. clip?: number;
  60801. arc?: number;
  60802. closed?: boolean;
  60803. updatable?: boolean;
  60804. sideOrientation?: number;
  60805. frontUVs?: Vector4;
  60806. backUVs?: Vector4;
  60807. cap?: number;
  60808. invertUV?: boolean;
  60809. }, scene?: Nullable<Scene>): Mesh;
  60810. /**
  60811. * Creates a tiled plane mesh
  60812. * * You can set a limited pattern arrangement with the tiles
  60813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60814. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60816. * @param name defines the name of the mesh
  60817. * @param options defines the options used to create the mesh
  60818. * @param scene defines the hosting scene
  60819. * @returns the plane mesh
  60820. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60821. */
  60822. static CreateTiledPlane(name: string, options: {
  60823. pattern?: number;
  60824. tileSize?: number;
  60825. tileWidth?: number;
  60826. tileHeight?: number;
  60827. size?: number;
  60828. width?: number;
  60829. height?: number;
  60830. alignHorizontal?: number;
  60831. alignVertical?: number;
  60832. sideOrientation?: number;
  60833. frontUVs?: Vector4;
  60834. backUVs?: Vector4;
  60835. updatable?: boolean;
  60836. }, scene?: Nullable<Scene>): Mesh;
  60837. /**
  60838. * Creates a plane mesh
  60839. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  60840. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  60841. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  60842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60845. * @param name defines the name of the mesh
  60846. * @param options defines the options used to create the mesh
  60847. * @param scene defines the hosting scene
  60848. * @returns the plane mesh
  60849. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  60850. */
  60851. static CreatePlane(name: string, options: {
  60852. size?: number;
  60853. width?: number;
  60854. height?: number;
  60855. sideOrientation?: number;
  60856. frontUVs?: Vector4;
  60857. backUVs?: Vector4;
  60858. updatable?: boolean;
  60859. sourcePlane?: Plane;
  60860. }, scene?: Nullable<Scene>): Mesh;
  60861. /**
  60862. * Creates a ground mesh
  60863. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  60864. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  60865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60866. * @param name defines the name of the mesh
  60867. * @param options defines the options used to create the mesh
  60868. * @param scene defines the hosting scene
  60869. * @returns the ground mesh
  60870. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  60871. */
  60872. static CreateGround(name: string, options: {
  60873. width?: number;
  60874. height?: number;
  60875. subdivisions?: number;
  60876. subdivisionsX?: number;
  60877. subdivisionsY?: number;
  60878. updatable?: boolean;
  60879. }, scene?: Nullable<Scene>): Mesh;
  60880. /**
  60881. * Creates a tiled ground mesh
  60882. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  60883. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  60884. * * 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
  60885. * * 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
  60886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60887. * @param name defines the name of the mesh
  60888. * @param options defines the options used to create the mesh
  60889. * @param scene defines the hosting scene
  60890. * @returns the tiled ground mesh
  60891. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  60892. */
  60893. static CreateTiledGround(name: string, options: {
  60894. xmin: number;
  60895. zmin: number;
  60896. xmax: number;
  60897. zmax: number;
  60898. subdivisions?: {
  60899. w: number;
  60900. h: number;
  60901. };
  60902. precision?: {
  60903. w: number;
  60904. h: number;
  60905. };
  60906. updatable?: boolean;
  60907. }, scene?: Nullable<Scene>): Mesh;
  60908. /**
  60909. * Creates a ground mesh from a height map
  60910. * * The parameter `url` sets the URL of the height map image resource.
  60911. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  60912. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  60913. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  60914. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  60915. * * 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.
  60916. * * 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).
  60917. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  60918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60919. * @param name defines the name of the mesh
  60920. * @param url defines the url to the height map
  60921. * @param options defines the options used to create the mesh
  60922. * @param scene defines the hosting scene
  60923. * @returns the ground mesh
  60924. * @see https://doc.babylonjs.com/babylon101/height_map
  60925. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  60926. */
  60927. static CreateGroundFromHeightMap(name: string, url: string, options: {
  60928. width?: number;
  60929. height?: number;
  60930. subdivisions?: number;
  60931. minHeight?: number;
  60932. maxHeight?: number;
  60933. colorFilter?: Color3;
  60934. alphaFilter?: number;
  60935. updatable?: boolean;
  60936. onReady?: (mesh: GroundMesh) => void;
  60937. }, scene?: Nullable<Scene>): GroundMesh;
  60938. /**
  60939. * Creates a polygon mesh
  60940. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60941. * * 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
  60942. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  60945. * * Remember you can only change the shape positions, not their number when updating a polygon
  60946. * @param name defines the name of the mesh
  60947. * @param options defines the options used to create the mesh
  60948. * @param scene defines the hosting scene
  60949. * @param earcutInjection can be used to inject your own earcut reference
  60950. * @returns the polygon mesh
  60951. */
  60952. static CreatePolygon(name: string, options: {
  60953. shape: Vector3[];
  60954. holes?: Vector3[][];
  60955. depth?: number;
  60956. faceUV?: Vector4[];
  60957. faceColors?: Color4[];
  60958. updatable?: boolean;
  60959. sideOrientation?: number;
  60960. frontUVs?: Vector4;
  60961. backUVs?: Vector4;
  60962. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60963. /**
  60964. * Creates an extruded polygon mesh, with depth in the Y direction.
  60965. * * 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)
  60966. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60967. * @param name defines the name of the mesh
  60968. * @param options defines the options used to create the mesh
  60969. * @param scene defines the hosting scene
  60970. * @param earcutInjection can be used to inject your own earcut reference
  60971. * @returns the polygon mesh
  60972. */
  60973. static ExtrudePolygon(name: string, options: {
  60974. shape: Vector3[];
  60975. holes?: Vector3[][];
  60976. depth?: number;
  60977. faceUV?: Vector4[];
  60978. faceColors?: Color4[];
  60979. updatable?: boolean;
  60980. sideOrientation?: number;
  60981. frontUVs?: Vector4;
  60982. backUVs?: Vector4;
  60983. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60984. /**
  60985. * Creates a tube mesh.
  60986. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60987. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60988. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60989. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60990. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60991. * * 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)
  60992. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60993. * * 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
  60994. * * 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
  60995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  60997. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60999. * @param name defines the name of the mesh
  61000. * @param options defines the options used to create the mesh
  61001. * @param scene defines the hosting scene
  61002. * @returns the tube mesh
  61003. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61004. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61005. */
  61006. static CreateTube(name: string, options: {
  61007. path: Vector3[];
  61008. radius?: number;
  61009. tessellation?: number;
  61010. radiusFunction?: {
  61011. (i: number, distance: number): number;
  61012. };
  61013. cap?: number;
  61014. arc?: number;
  61015. updatable?: boolean;
  61016. sideOrientation?: number;
  61017. frontUVs?: Vector4;
  61018. backUVs?: Vector4;
  61019. instance?: Mesh;
  61020. invertUV?: boolean;
  61021. }, scene?: Nullable<Scene>): Mesh;
  61022. /**
  61023. * Creates a polyhedron mesh
  61024. * * 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
  61025. * * The parameter `size` (positive float, default 1) sets the polygon size
  61026. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61027. * * 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`
  61028. * * 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
  61029. * * 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)`)
  61030. * * 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
  61031. * * 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
  61032. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61033. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61035. * @param name defines the name of the mesh
  61036. * @param options defines the options used to create the mesh
  61037. * @param scene defines the hosting scene
  61038. * @returns the polyhedron mesh
  61039. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61040. */
  61041. static CreatePolyhedron(name: string, options: {
  61042. type?: number;
  61043. size?: number;
  61044. sizeX?: number;
  61045. sizeY?: number;
  61046. sizeZ?: number;
  61047. custom?: any;
  61048. faceUV?: Vector4[];
  61049. faceColors?: Color4[];
  61050. flat?: boolean;
  61051. updatable?: boolean;
  61052. sideOrientation?: number;
  61053. frontUVs?: Vector4;
  61054. backUVs?: Vector4;
  61055. }, scene?: Nullable<Scene>): Mesh;
  61056. /**
  61057. * Creates a decal mesh.
  61058. * 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
  61059. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61060. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61061. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61062. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61063. * @param name defines the name of the mesh
  61064. * @param sourceMesh defines the mesh where the decal must be applied
  61065. * @param options defines the options used to create the mesh
  61066. * @param scene defines the hosting scene
  61067. * @returns the decal mesh
  61068. * @see https://doc.babylonjs.com/how_to/decals
  61069. */
  61070. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61071. position?: Vector3;
  61072. normal?: Vector3;
  61073. size?: Vector3;
  61074. angle?: number;
  61075. }): Mesh;
  61076. }
  61077. }
  61078. declare module "babylonjs/Meshes/meshSimplification" {
  61079. import { Mesh } from "babylonjs/Meshes/mesh";
  61080. /**
  61081. * A simplifier interface for future simplification implementations
  61082. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61083. */
  61084. export interface ISimplifier {
  61085. /**
  61086. * Simplification of a given mesh according to the given settings.
  61087. * Since this requires computation, it is assumed that the function runs async.
  61088. * @param settings The settings of the simplification, including quality and distance
  61089. * @param successCallback A callback that will be called after the mesh was simplified.
  61090. * @param errorCallback in case of an error, this callback will be called. optional.
  61091. */
  61092. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61093. }
  61094. /**
  61095. * Expected simplification settings.
  61096. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61097. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61098. */
  61099. export interface ISimplificationSettings {
  61100. /**
  61101. * Gets or sets the expected quality
  61102. */
  61103. quality: number;
  61104. /**
  61105. * Gets or sets the distance when this optimized version should be used
  61106. */
  61107. distance: number;
  61108. /**
  61109. * Gets an already optimized mesh
  61110. */
  61111. optimizeMesh?: boolean;
  61112. }
  61113. /**
  61114. * Class used to specify simplification options
  61115. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61116. */
  61117. export class SimplificationSettings implements ISimplificationSettings {
  61118. /** expected quality */
  61119. quality: number;
  61120. /** distance when this optimized version should be used */
  61121. distance: number;
  61122. /** already optimized mesh */
  61123. optimizeMesh?: boolean | undefined;
  61124. /**
  61125. * Creates a SimplificationSettings
  61126. * @param quality expected quality
  61127. * @param distance distance when this optimized version should be used
  61128. * @param optimizeMesh already optimized mesh
  61129. */
  61130. constructor(
  61131. /** expected quality */
  61132. quality: number,
  61133. /** distance when this optimized version should be used */
  61134. distance: number,
  61135. /** already optimized mesh */
  61136. optimizeMesh?: boolean | undefined);
  61137. }
  61138. /**
  61139. * Interface used to define a simplification task
  61140. */
  61141. export interface ISimplificationTask {
  61142. /**
  61143. * Array of settings
  61144. */
  61145. settings: Array<ISimplificationSettings>;
  61146. /**
  61147. * Simplification type
  61148. */
  61149. simplificationType: SimplificationType;
  61150. /**
  61151. * Mesh to simplify
  61152. */
  61153. mesh: Mesh;
  61154. /**
  61155. * Callback called on success
  61156. */
  61157. successCallback?: () => void;
  61158. /**
  61159. * Defines if parallel processing can be used
  61160. */
  61161. parallelProcessing: boolean;
  61162. }
  61163. /**
  61164. * Queue used to order the simplification tasks
  61165. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61166. */
  61167. export class SimplificationQueue {
  61168. private _simplificationArray;
  61169. /**
  61170. * Gets a boolean indicating that the process is still running
  61171. */
  61172. running: boolean;
  61173. /**
  61174. * Creates a new queue
  61175. */
  61176. constructor();
  61177. /**
  61178. * Adds a new simplification task
  61179. * @param task defines a task to add
  61180. */
  61181. addTask(task: ISimplificationTask): void;
  61182. /**
  61183. * Execute next task
  61184. */
  61185. executeNext(): void;
  61186. /**
  61187. * Execute a simplification task
  61188. * @param task defines the task to run
  61189. */
  61190. runSimplification(task: ISimplificationTask): void;
  61191. private getSimplifier;
  61192. }
  61193. /**
  61194. * The implemented types of simplification
  61195. * At the moment only Quadratic Error Decimation is implemented
  61196. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61197. */
  61198. export enum SimplificationType {
  61199. /** Quadratic error decimation */
  61200. QUADRATIC = 0
  61201. }
  61202. }
  61203. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  61204. import { Scene } from "babylonjs/scene";
  61205. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  61206. import { ISceneComponent } from "babylonjs/sceneComponent";
  61207. module "babylonjs/scene" {
  61208. interface Scene {
  61209. /** @hidden (Backing field) */
  61210. _simplificationQueue: SimplificationQueue;
  61211. /**
  61212. * Gets or sets the simplification queue attached to the scene
  61213. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61214. */
  61215. simplificationQueue: SimplificationQueue;
  61216. }
  61217. }
  61218. module "babylonjs/Meshes/mesh" {
  61219. interface Mesh {
  61220. /**
  61221. * Simplify the mesh according to the given array of settings.
  61222. * Function will return immediately and will simplify async
  61223. * @param settings a collection of simplification settings
  61224. * @param parallelProcessing should all levels calculate parallel or one after the other
  61225. * @param simplificationType the type of simplification to run
  61226. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61227. * @returns the current mesh
  61228. */
  61229. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61230. }
  61231. }
  61232. /**
  61233. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61234. * created in a scene
  61235. */
  61236. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61237. /**
  61238. * The component name helpfull to identify the component in the list of scene components.
  61239. */
  61240. readonly name: string;
  61241. /**
  61242. * The scene the component belongs to.
  61243. */
  61244. scene: Scene;
  61245. /**
  61246. * Creates a new instance of the component for the given scene
  61247. * @param scene Defines the scene to register the component in
  61248. */
  61249. constructor(scene: Scene);
  61250. /**
  61251. * Registers the component in a given scene
  61252. */
  61253. register(): void;
  61254. /**
  61255. * Rebuilds the elements related to this component in case of
  61256. * context lost for instance.
  61257. */
  61258. rebuild(): void;
  61259. /**
  61260. * Disposes the component and the associated ressources
  61261. */
  61262. dispose(): void;
  61263. private _beforeCameraUpdate;
  61264. }
  61265. }
  61266. declare module "babylonjs/Meshes/Builders/index" {
  61267. export * from "babylonjs/Meshes/Builders/boxBuilder";
  61268. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  61269. export * from "babylonjs/Meshes/Builders/discBuilder";
  61270. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  61271. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  61272. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  61273. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  61274. export * from "babylonjs/Meshes/Builders/torusBuilder";
  61275. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  61276. export * from "babylonjs/Meshes/Builders/linesBuilder";
  61277. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  61278. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  61279. export * from "babylonjs/Meshes/Builders/latheBuilder";
  61280. export * from "babylonjs/Meshes/Builders/planeBuilder";
  61281. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  61282. export * from "babylonjs/Meshes/Builders/groundBuilder";
  61283. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  61284. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  61285. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  61286. export * from "babylonjs/Meshes/Builders/decalBuilder";
  61287. }
  61288. declare module "babylonjs/Meshes/index" {
  61289. export * from "babylonjs/Meshes/abstractMesh";
  61290. export * from "babylonjs/Meshes/buffer";
  61291. export * from "babylonjs/Meshes/Compression/index";
  61292. export * from "babylonjs/Meshes/csg";
  61293. export * from "babylonjs/Meshes/geometry";
  61294. export * from "babylonjs/Meshes/groundMesh";
  61295. export * from "babylonjs/Meshes/trailMesh";
  61296. export * from "babylonjs/Meshes/instancedMesh";
  61297. export * from "babylonjs/Meshes/linesMesh";
  61298. export * from "babylonjs/Meshes/mesh";
  61299. export * from "babylonjs/Meshes/mesh.vertexData";
  61300. export * from "babylonjs/Meshes/meshBuilder";
  61301. export * from "babylonjs/Meshes/meshSimplification";
  61302. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  61303. export * from "babylonjs/Meshes/polygonMesh";
  61304. export * from "babylonjs/Meshes/subMesh";
  61305. export * from "babylonjs/Meshes/meshLODLevel";
  61306. export * from "babylonjs/Meshes/transformNode";
  61307. export * from "babylonjs/Meshes/Builders/index";
  61308. export * from "babylonjs/Meshes/dataBuffer";
  61309. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  61310. }
  61311. declare module "babylonjs/Morph/index" {
  61312. export * from "babylonjs/Morph/morphTarget";
  61313. export * from "babylonjs/Morph/morphTargetManager";
  61314. }
  61315. declare module "babylonjs/Navigation/INavigationEngine" {
  61316. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61317. import { Vector3 } from "babylonjs/Maths/math";
  61318. import { Mesh } from "babylonjs/Meshes/mesh";
  61319. import { Scene } from "babylonjs/scene";
  61320. /**
  61321. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61322. */
  61323. export interface INavigationEnginePlugin {
  61324. /**
  61325. * plugin name
  61326. */
  61327. name: string;
  61328. /**
  61329. * Creates a navigation mesh
  61330. * @param meshes array of all the geometry used to compute the navigatio mesh
  61331. * @param parameters bunch of parameters used to filter geometry
  61332. */
  61333. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61334. /**
  61335. * Create a navigation mesh debug mesh
  61336. * @param scene is where the mesh will be added
  61337. * @returns debug display mesh
  61338. */
  61339. createDebugNavMesh(scene: Scene): Mesh;
  61340. /**
  61341. * Get a navigation mesh constrained position, closest to the parameter position
  61342. * @param position world position
  61343. * @returns the closest point to position constrained by the navigation mesh
  61344. */
  61345. getClosestPoint(position: Vector3): Vector3;
  61346. /**
  61347. * Get a navigation mesh constrained position, within a particular radius
  61348. * @param position world position
  61349. * @param maxRadius the maximum distance to the constrained world position
  61350. * @returns the closest point to position constrained by the navigation mesh
  61351. */
  61352. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61353. /**
  61354. * Compute the final position from a segment made of destination-position
  61355. * @param position world position
  61356. * @param destination world position
  61357. * @returns the resulting point along the navmesh
  61358. */
  61359. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61360. /**
  61361. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61362. * @param start world position
  61363. * @param end world position
  61364. * @returns array containing world position composing the path
  61365. */
  61366. computePath(start: Vector3, end: Vector3): Vector3[];
  61367. /**
  61368. * If this plugin is supported
  61369. * @returns true if plugin is supported
  61370. */
  61371. isSupported(): boolean;
  61372. /**
  61373. * Create a new Crowd so you can add agents
  61374. * @param maxAgents the maximum agent count in the crowd
  61375. * @param maxAgentRadius the maximum radius an agent can have
  61376. * @param scene to attach the crowd to
  61377. * @returns the crowd you can add agents to
  61378. */
  61379. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61380. /**
  61381. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61382. * The queries will try to find a solution within those bounds
  61383. * default is (1,1,1)
  61384. * @param extent x,y,z value that define the extent around the queries point of reference
  61385. */
  61386. setDefaultQueryExtent(extent: Vector3): void;
  61387. /**
  61388. * Get the Bounding box extent specified by setDefaultQueryExtent
  61389. * @returns the box extent values
  61390. */
  61391. getDefaultQueryExtent(): Vector3;
  61392. /**
  61393. * Release all resources
  61394. */
  61395. dispose(): void;
  61396. }
  61397. /**
  61398. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61399. */
  61400. export interface ICrowd {
  61401. /**
  61402. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61403. * You can attach anything to that node. The node position is updated in the scene update tick.
  61404. * @param pos world position that will be constrained by the navigation mesh
  61405. * @param parameters agent parameters
  61406. * @param transform hooked to the agent that will be update by the scene
  61407. * @returns agent index
  61408. */
  61409. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61410. /**
  61411. * Returns the agent position in world space
  61412. * @param index agent index returned by addAgent
  61413. * @returns world space position
  61414. */
  61415. getAgentPosition(index: number): Vector3;
  61416. /**
  61417. * Gets the agent velocity in world space
  61418. * @param index agent index returned by addAgent
  61419. * @returns world space velocity
  61420. */
  61421. getAgentVelocity(index: number): Vector3;
  61422. /**
  61423. * remove a particular agent previously created
  61424. * @param index agent index returned by addAgent
  61425. */
  61426. removeAgent(index: number): void;
  61427. /**
  61428. * get the list of all agents attached to this crowd
  61429. * @returns list of agent indices
  61430. */
  61431. getAgents(): number[];
  61432. /**
  61433. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61434. * @param deltaTime in seconds
  61435. */
  61436. update(deltaTime: number): void;
  61437. /**
  61438. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61439. * @param index agent index returned by addAgent
  61440. * @param destination targeted world position
  61441. */
  61442. agentGoto(index: number, destination: Vector3): void;
  61443. /**
  61444. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61445. * The queries will try to find a solution within those bounds
  61446. * default is (1,1,1)
  61447. * @param extent x,y,z value that define the extent around the queries point of reference
  61448. */
  61449. setDefaultQueryExtent(extent: Vector3): void;
  61450. /**
  61451. * Get the Bounding box extent specified by setDefaultQueryExtent
  61452. * @returns the box extent values
  61453. */
  61454. getDefaultQueryExtent(): Vector3;
  61455. /**
  61456. * Release all resources
  61457. */
  61458. dispose(): void;
  61459. }
  61460. /**
  61461. * Configures an agent
  61462. */
  61463. export interface IAgentParameters {
  61464. /**
  61465. * Agent radius. [Limit: >= 0]
  61466. */
  61467. radius: number;
  61468. /**
  61469. * Agent height. [Limit: > 0]
  61470. */
  61471. height: number;
  61472. /**
  61473. * Maximum allowed acceleration. [Limit: >= 0]
  61474. */
  61475. maxAcceleration: number;
  61476. /**
  61477. * Maximum allowed speed. [Limit: >= 0]
  61478. */
  61479. maxSpeed: number;
  61480. /**
  61481. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  61482. */
  61483. collisionQueryRange: number;
  61484. /**
  61485. * The path visibility optimization range. [Limit: > 0]
  61486. */
  61487. pathOptimizationRange: number;
  61488. /**
  61489. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  61490. */
  61491. separationWeight: number;
  61492. }
  61493. /**
  61494. * Configures the navigation mesh creation
  61495. */
  61496. export interface INavMeshParameters {
  61497. /**
  61498. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  61499. */
  61500. cs: number;
  61501. /**
  61502. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  61503. */
  61504. ch: number;
  61505. /**
  61506. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  61507. */
  61508. walkableSlopeAngle: number;
  61509. /**
  61510. * Minimum floor to 'ceiling' height that will still allow the floor area to
  61511. * be considered walkable. [Limit: >= 3] [Units: vx]
  61512. */
  61513. walkableHeight: number;
  61514. /**
  61515. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  61516. */
  61517. walkableClimb: number;
  61518. /**
  61519. * The distance to erode/shrink the walkable area of the heightfield away from
  61520. * obstructions. [Limit: >=0] [Units: vx]
  61521. */
  61522. walkableRadius: number;
  61523. /**
  61524. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  61525. */
  61526. maxEdgeLen: number;
  61527. /**
  61528. * The maximum distance a simplfied contour's border edges should deviate
  61529. * the original raw contour. [Limit: >=0] [Units: vx]
  61530. */
  61531. maxSimplificationError: number;
  61532. /**
  61533. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  61534. */
  61535. minRegionArea: number;
  61536. /**
  61537. * Any regions with a span count smaller than this value will, if possible,
  61538. * be merged with larger regions. [Limit: >=0] [Units: vx]
  61539. */
  61540. mergeRegionArea: number;
  61541. /**
  61542. * The maximum number of vertices allowed for polygons generated during the
  61543. * contour to polygon conversion process. [Limit: >= 3]
  61544. */
  61545. maxVertsPerPoly: number;
  61546. /**
  61547. * Sets the sampling distance to use when generating the detail mesh.
  61548. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  61549. */
  61550. detailSampleDist: number;
  61551. /**
  61552. * The maximum distance the detail mesh surface should deviate from heightfield
  61553. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  61554. */
  61555. detailSampleMaxError: number;
  61556. }
  61557. }
  61558. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  61559. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  61560. import { Mesh } from "babylonjs/Meshes/mesh";
  61561. import { Scene } from "babylonjs/scene";
  61562. import { Vector3 } from "babylonjs/Maths/math";
  61563. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61564. /**
  61565. * RecastJS navigation plugin
  61566. */
  61567. export class RecastJSPlugin implements INavigationEnginePlugin {
  61568. /**
  61569. * Reference to the Recast library
  61570. */
  61571. bjsRECAST: any;
  61572. /**
  61573. * plugin name
  61574. */
  61575. name: string;
  61576. /**
  61577. * the first navmesh created. We might extend this to support multiple navmeshes
  61578. */
  61579. navMesh: any;
  61580. /**
  61581. * Initializes the recastJS plugin
  61582. * @param recastInjection can be used to inject your own recast reference
  61583. */
  61584. constructor(recastInjection?: any);
  61585. /**
  61586. * Creates a navigation mesh
  61587. * @param meshes array of all the geometry used to compute the navigatio mesh
  61588. * @param parameters bunch of parameters used to filter geometry
  61589. */
  61590. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61591. /**
  61592. * Create a navigation mesh debug mesh
  61593. * @param scene is where the mesh will be added
  61594. * @returns debug display mesh
  61595. */
  61596. createDebugNavMesh(scene: Scene): Mesh;
  61597. /**
  61598. * Get a navigation mesh constrained position, closest to the parameter position
  61599. * @param position world position
  61600. * @returns the closest point to position constrained by the navigation mesh
  61601. */
  61602. getClosestPoint(position: Vector3): Vector3;
  61603. /**
  61604. * Get a navigation mesh constrained position, within a particular radius
  61605. * @param position world position
  61606. * @param maxRadius the maximum distance to the constrained world position
  61607. * @returns the closest point to position constrained by the navigation mesh
  61608. */
  61609. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61610. /**
  61611. * Compute the final position from a segment made of destination-position
  61612. * @param position world position
  61613. * @param destination world position
  61614. * @returns the resulting point along the navmesh
  61615. */
  61616. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61617. /**
  61618. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61619. * @param start world position
  61620. * @param end world position
  61621. * @returns array containing world position composing the path
  61622. */
  61623. computePath(start: Vector3, end: Vector3): Vector3[];
  61624. /**
  61625. * Create a new Crowd so you can add agents
  61626. * @param maxAgents the maximum agent count in the crowd
  61627. * @param maxAgentRadius the maximum radius an agent can have
  61628. * @param scene to attach the crowd to
  61629. * @returns the crowd you can add agents to
  61630. */
  61631. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61632. /**
  61633. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61634. * The queries will try to find a solution within those bounds
  61635. * default is (1,1,1)
  61636. * @param extent x,y,z value that define the extent around the queries point of reference
  61637. */
  61638. setDefaultQueryExtent(extent: Vector3): void;
  61639. /**
  61640. * Get the Bounding box extent specified by setDefaultQueryExtent
  61641. * @returns the box extent values
  61642. */
  61643. getDefaultQueryExtent(): Vector3;
  61644. /**
  61645. * Disposes
  61646. */
  61647. dispose(): void;
  61648. /**
  61649. * If this plugin is supported
  61650. * @returns true if plugin is supported
  61651. */
  61652. isSupported(): boolean;
  61653. }
  61654. /**
  61655. * Recast detour crowd implementation
  61656. */
  61657. export class RecastJSCrowd implements ICrowd {
  61658. /**
  61659. * Recast/detour plugin
  61660. */
  61661. bjsRECASTPlugin: RecastJSPlugin;
  61662. /**
  61663. * Link to the detour crowd
  61664. */
  61665. recastCrowd: any;
  61666. /**
  61667. * One transform per agent
  61668. */
  61669. transforms: TransformNode[];
  61670. /**
  61671. * All agents created
  61672. */
  61673. agents: number[];
  61674. /**
  61675. * Link to the scene is kept to unregister the crowd from the scene
  61676. */
  61677. private _scene;
  61678. /**
  61679. * Observer for crowd updates
  61680. */
  61681. private _onBeforeAnimationsObserver;
  61682. /**
  61683. * Constructor
  61684. * @param plugin recastJS plugin
  61685. * @param maxAgents the maximum agent count in the crowd
  61686. * @param maxAgentRadius the maximum radius an agent can have
  61687. * @param scene to attach the crowd to
  61688. * @returns the crowd you can add agents to
  61689. */
  61690. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  61691. /**
  61692. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61693. * You can attach anything to that node. The node position is updated in the scene update tick.
  61694. * @param pos world position that will be constrained by the navigation mesh
  61695. * @param parameters agent parameters
  61696. * @param transform hooked to the agent that will be update by the scene
  61697. * @returns agent index
  61698. */
  61699. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61700. /**
  61701. * Returns the agent position in world space
  61702. * @param index agent index returned by addAgent
  61703. * @returns world space position
  61704. */
  61705. getAgentPosition(index: number): Vector3;
  61706. /**
  61707. * Returns the agent velocity in world space
  61708. * @param index agent index returned by addAgent
  61709. * @returns world space velocity
  61710. */
  61711. getAgentVelocity(index: number): Vector3;
  61712. /**
  61713. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61714. * @param index agent index returned by addAgent
  61715. * @param destination targeted world position
  61716. */
  61717. agentGoto(index: number, destination: Vector3): void;
  61718. /**
  61719. * remove a particular agent previously created
  61720. * @param index agent index returned by addAgent
  61721. */
  61722. removeAgent(index: number): void;
  61723. /**
  61724. * get the list of all agents attached to this crowd
  61725. * @returns list of agent indices
  61726. */
  61727. getAgents(): number[];
  61728. /**
  61729. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61730. * @param deltaTime in seconds
  61731. */
  61732. update(deltaTime: number): void;
  61733. /**
  61734. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61735. * The queries will try to find a solution within those bounds
  61736. * default is (1,1,1)
  61737. * @param extent x,y,z value that define the extent around the queries point of reference
  61738. */
  61739. setDefaultQueryExtent(extent: Vector3): void;
  61740. /**
  61741. * Get the Bounding box extent specified by setDefaultQueryExtent
  61742. * @returns the box extent values
  61743. */
  61744. getDefaultQueryExtent(): Vector3;
  61745. /**
  61746. * Release all resources
  61747. */
  61748. dispose(): void;
  61749. }
  61750. }
  61751. declare module "babylonjs/Navigation/Plugins/index" {
  61752. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  61753. }
  61754. declare module "babylonjs/Navigation/index" {
  61755. export * from "babylonjs/Navigation/INavigationEngine";
  61756. export * from "babylonjs/Navigation/Plugins/index";
  61757. }
  61758. declare module "babylonjs/Offline/database" {
  61759. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  61760. /**
  61761. * Class used to enable access to IndexedDB
  61762. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  61763. */
  61764. export class Database implements IOfflineProvider {
  61765. private _callbackManifestChecked;
  61766. private _currentSceneUrl;
  61767. private _db;
  61768. private _enableSceneOffline;
  61769. private _enableTexturesOffline;
  61770. private _manifestVersionFound;
  61771. private _mustUpdateRessources;
  61772. private _hasReachedQuota;
  61773. private _isSupported;
  61774. private _idbFactory;
  61775. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  61776. private static IsUASupportingBlobStorage;
  61777. /**
  61778. * Gets a boolean indicating if Database storate is enabled (off by default)
  61779. */
  61780. static IDBStorageEnabled: boolean;
  61781. /**
  61782. * Gets a boolean indicating if scene must be saved in the database
  61783. */
  61784. readonly enableSceneOffline: boolean;
  61785. /**
  61786. * Gets a boolean indicating if textures must be saved in the database
  61787. */
  61788. readonly enableTexturesOffline: boolean;
  61789. /**
  61790. * Creates a new Database
  61791. * @param urlToScene defines the url to load the scene
  61792. * @param callbackManifestChecked defines the callback to use when manifest is checked
  61793. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  61794. */
  61795. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  61796. private static _ParseURL;
  61797. private static _ReturnFullUrlLocation;
  61798. private _checkManifestFile;
  61799. /**
  61800. * Open the database and make it available
  61801. * @param successCallback defines the callback to call on success
  61802. * @param errorCallback defines the callback to call on error
  61803. */
  61804. open(successCallback: () => void, errorCallback: () => void): void;
  61805. /**
  61806. * Loads an image from the database
  61807. * @param url defines the url to load from
  61808. * @param image defines the target DOM image
  61809. */
  61810. loadImage(url: string, image: HTMLImageElement): void;
  61811. private _loadImageFromDBAsync;
  61812. private _saveImageIntoDBAsync;
  61813. private _checkVersionFromDB;
  61814. private _loadVersionFromDBAsync;
  61815. private _saveVersionIntoDBAsync;
  61816. /**
  61817. * Loads a file from database
  61818. * @param url defines the URL to load from
  61819. * @param sceneLoaded defines a callback to call on success
  61820. * @param progressCallBack defines a callback to call when progress changed
  61821. * @param errorCallback defines a callback to call on error
  61822. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  61823. */
  61824. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  61825. private _loadFileAsync;
  61826. private _saveFileAsync;
  61827. /**
  61828. * Validates if xhr data is correct
  61829. * @param xhr defines the request to validate
  61830. * @param dataType defines the expected data type
  61831. * @returns true if data is correct
  61832. */
  61833. private static _ValidateXHRData;
  61834. }
  61835. }
  61836. declare module "babylonjs/Offline/index" {
  61837. export * from "babylonjs/Offline/database";
  61838. export * from "babylonjs/Offline/IOfflineProvider";
  61839. }
  61840. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  61841. /** @hidden */
  61842. export var gpuUpdateParticlesPixelShader: {
  61843. name: string;
  61844. shader: string;
  61845. };
  61846. }
  61847. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  61848. /** @hidden */
  61849. export var gpuUpdateParticlesVertexShader: {
  61850. name: string;
  61851. shader: string;
  61852. };
  61853. }
  61854. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  61855. /** @hidden */
  61856. export var clipPlaneFragmentDeclaration2: {
  61857. name: string;
  61858. shader: string;
  61859. };
  61860. }
  61861. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  61862. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  61863. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61864. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61865. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61866. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  61867. /** @hidden */
  61868. export var gpuRenderParticlesPixelShader: {
  61869. name: string;
  61870. shader: string;
  61871. };
  61872. }
  61873. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  61874. /** @hidden */
  61875. export var clipPlaneVertexDeclaration2: {
  61876. name: string;
  61877. shader: string;
  61878. };
  61879. }
  61880. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  61881. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  61882. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  61883. /** @hidden */
  61884. export var gpuRenderParticlesVertexShader: {
  61885. name: string;
  61886. shader: string;
  61887. };
  61888. }
  61889. declare module "babylonjs/Particles/gpuParticleSystem" {
  61890. import { Nullable } from "babylonjs/types";
  61891. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  61892. import { Observable } from "babylonjs/Misc/observable";
  61893. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61894. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61895. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  61896. import { Scene, IDisposable } from "babylonjs/scene";
  61897. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  61898. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61899. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  61900. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  61901. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  61902. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  61903. /**
  61904. * This represents a GPU particle system in Babylon
  61905. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  61906. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  61907. */
  61908. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  61909. /**
  61910. * The layer mask we are rendering the particles through.
  61911. */
  61912. layerMask: number;
  61913. private _capacity;
  61914. private _activeCount;
  61915. private _currentActiveCount;
  61916. private _accumulatedCount;
  61917. private _renderEffect;
  61918. private _updateEffect;
  61919. private _buffer0;
  61920. private _buffer1;
  61921. private _spriteBuffer;
  61922. private _updateVAO;
  61923. private _renderVAO;
  61924. private _targetIndex;
  61925. private _sourceBuffer;
  61926. private _targetBuffer;
  61927. private _engine;
  61928. private _currentRenderId;
  61929. private _started;
  61930. private _stopped;
  61931. private _timeDelta;
  61932. private _randomTexture;
  61933. private _randomTexture2;
  61934. private _attributesStrideSize;
  61935. private _updateEffectOptions;
  61936. private _randomTextureSize;
  61937. private _actualFrame;
  61938. private readonly _rawTextureWidth;
  61939. /**
  61940. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  61941. */
  61942. static readonly IsSupported: boolean;
  61943. /**
  61944. * An event triggered when the system is disposed.
  61945. */
  61946. onDisposeObservable: Observable<GPUParticleSystem>;
  61947. /**
  61948. * Gets the maximum number of particles active at the same time.
  61949. * @returns The max number of active particles.
  61950. */
  61951. getCapacity(): number;
  61952. /**
  61953. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  61954. * to override the particles.
  61955. */
  61956. forceDepthWrite: boolean;
  61957. /**
  61958. * Gets or set the number of active particles
  61959. */
  61960. activeParticleCount: number;
  61961. private _preWarmDone;
  61962. /**
  61963. * Is this system ready to be used/rendered
  61964. * @return true if the system is ready
  61965. */
  61966. isReady(): boolean;
  61967. /**
  61968. * Gets if the system has been started. (Note: this will still be true after stop is called)
  61969. * @returns True if it has been started, otherwise false.
  61970. */
  61971. isStarted(): boolean;
  61972. /**
  61973. * Starts the particle system and begins to emit
  61974. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  61975. */
  61976. start(delay?: number): void;
  61977. /**
  61978. * Stops the particle system.
  61979. */
  61980. stop(): void;
  61981. /**
  61982. * Remove all active particles
  61983. */
  61984. reset(): void;
  61985. /**
  61986. * Returns the string "GPUParticleSystem"
  61987. * @returns a string containing the class name
  61988. */
  61989. getClassName(): string;
  61990. private _colorGradientsTexture;
  61991. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  61992. /**
  61993. * Adds a new color gradient
  61994. * @param gradient defines the gradient to use (between 0 and 1)
  61995. * @param color1 defines the color to affect to the specified gradient
  61996. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  61997. * @returns the current particle system
  61998. */
  61999. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62000. /**
  62001. * Remove a specific color gradient
  62002. * @param gradient defines the gradient to remove
  62003. * @returns the current particle system
  62004. */
  62005. removeColorGradient(gradient: number): GPUParticleSystem;
  62006. private _angularSpeedGradientsTexture;
  62007. private _sizeGradientsTexture;
  62008. private _velocityGradientsTexture;
  62009. private _limitVelocityGradientsTexture;
  62010. private _dragGradientsTexture;
  62011. private _addFactorGradient;
  62012. /**
  62013. * Adds a new size gradient
  62014. * @param gradient defines the gradient to use (between 0 and 1)
  62015. * @param factor defines the size factor to affect to the specified gradient
  62016. * @returns the current particle system
  62017. */
  62018. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62019. /**
  62020. * Remove a specific size gradient
  62021. * @param gradient defines the gradient to remove
  62022. * @returns the current particle system
  62023. */
  62024. removeSizeGradient(gradient: number): GPUParticleSystem;
  62025. /**
  62026. * Adds a new angular speed gradient
  62027. * @param gradient defines the gradient to use (between 0 and 1)
  62028. * @param factor defines the angular speed to affect to the specified gradient
  62029. * @returns the current particle system
  62030. */
  62031. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62032. /**
  62033. * Remove a specific angular speed gradient
  62034. * @param gradient defines the gradient to remove
  62035. * @returns the current particle system
  62036. */
  62037. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62038. /**
  62039. * Adds a new velocity gradient
  62040. * @param gradient defines the gradient to use (between 0 and 1)
  62041. * @param factor defines the velocity to affect to the specified gradient
  62042. * @returns the current particle system
  62043. */
  62044. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62045. /**
  62046. * Remove a specific velocity gradient
  62047. * @param gradient defines the gradient to remove
  62048. * @returns the current particle system
  62049. */
  62050. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62051. /**
  62052. * Adds a new limit velocity gradient
  62053. * @param gradient defines the gradient to use (between 0 and 1)
  62054. * @param factor defines the limit velocity value to affect to the specified gradient
  62055. * @returns the current particle system
  62056. */
  62057. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62058. /**
  62059. * Remove a specific limit velocity gradient
  62060. * @param gradient defines the gradient to remove
  62061. * @returns the current particle system
  62062. */
  62063. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62064. /**
  62065. * Adds a new drag gradient
  62066. * @param gradient defines the gradient to use (between 0 and 1)
  62067. * @param factor defines the drag value to affect to the specified gradient
  62068. * @returns the current particle system
  62069. */
  62070. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62071. /**
  62072. * Remove a specific drag gradient
  62073. * @param gradient defines the gradient to remove
  62074. * @returns the current particle system
  62075. */
  62076. removeDragGradient(gradient: number): GPUParticleSystem;
  62077. /**
  62078. * Not supported by GPUParticleSystem
  62079. * @param gradient defines the gradient to use (between 0 and 1)
  62080. * @param factor defines the emit rate value to affect to the specified gradient
  62081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62082. * @returns the current particle system
  62083. */
  62084. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62085. /**
  62086. * Not supported by GPUParticleSystem
  62087. * @param gradient defines the gradient to remove
  62088. * @returns the current particle system
  62089. */
  62090. removeEmitRateGradient(gradient: number): IParticleSystem;
  62091. /**
  62092. * Not supported by GPUParticleSystem
  62093. * @param gradient defines the gradient to use (between 0 and 1)
  62094. * @param factor defines the start size value to affect to the specified gradient
  62095. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62096. * @returns the current particle system
  62097. */
  62098. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62099. /**
  62100. * Not supported by GPUParticleSystem
  62101. * @param gradient defines the gradient to remove
  62102. * @returns the current particle system
  62103. */
  62104. removeStartSizeGradient(gradient: number): IParticleSystem;
  62105. /**
  62106. * Not supported by GPUParticleSystem
  62107. * @param gradient defines the gradient to use (between 0 and 1)
  62108. * @param min defines the color remap minimal range
  62109. * @param max defines the color remap maximal range
  62110. * @returns the current particle system
  62111. */
  62112. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62113. /**
  62114. * Not supported by GPUParticleSystem
  62115. * @param gradient defines the gradient to remove
  62116. * @returns the current particle system
  62117. */
  62118. removeColorRemapGradient(): IParticleSystem;
  62119. /**
  62120. * Not supported by GPUParticleSystem
  62121. * @param gradient defines the gradient to use (between 0 and 1)
  62122. * @param min defines the alpha remap minimal range
  62123. * @param max defines the alpha remap maximal range
  62124. * @returns the current particle system
  62125. */
  62126. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62127. /**
  62128. * Not supported by GPUParticleSystem
  62129. * @param gradient defines the gradient to remove
  62130. * @returns the current particle system
  62131. */
  62132. removeAlphaRemapGradient(): IParticleSystem;
  62133. /**
  62134. * Not supported by GPUParticleSystem
  62135. * @param gradient defines the gradient to use (between 0 and 1)
  62136. * @param color defines the color to affect to the specified gradient
  62137. * @returns the current particle system
  62138. */
  62139. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62140. /**
  62141. * Not supported by GPUParticleSystem
  62142. * @param gradient defines the gradient to remove
  62143. * @returns the current particle system
  62144. */
  62145. removeRampGradient(): IParticleSystem;
  62146. /**
  62147. * Not supported by GPUParticleSystem
  62148. * @returns the list of ramp gradients
  62149. */
  62150. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62151. /**
  62152. * Not supported by GPUParticleSystem
  62153. * Gets or sets a boolean indicating that ramp gradients must be used
  62154. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62155. */
  62156. useRampGradients: boolean;
  62157. /**
  62158. * Not supported by GPUParticleSystem
  62159. * @param gradient defines the gradient to use (between 0 and 1)
  62160. * @param factor defines the life time factor to affect to the specified gradient
  62161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62162. * @returns the current particle system
  62163. */
  62164. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62165. /**
  62166. * Not supported by GPUParticleSystem
  62167. * @param gradient defines the gradient to remove
  62168. * @returns the current particle system
  62169. */
  62170. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62171. /**
  62172. * Instantiates a GPU particle system.
  62173. * 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.
  62174. * @param name The name of the particle system
  62175. * @param options The options used to create the system
  62176. * @param scene The scene the particle system belongs to
  62177. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62178. */
  62179. constructor(name: string, options: Partial<{
  62180. capacity: number;
  62181. randomTextureSize: number;
  62182. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62183. protected _reset(): void;
  62184. private _createUpdateVAO;
  62185. private _createRenderVAO;
  62186. private _initialize;
  62187. /** @hidden */
  62188. _recreateUpdateEffect(): void;
  62189. /** @hidden */
  62190. _recreateRenderEffect(): void;
  62191. /**
  62192. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62193. * @param preWarm defines if we are in the pre-warmimg phase
  62194. */
  62195. animate(preWarm?: boolean): void;
  62196. private _createFactorGradientTexture;
  62197. private _createSizeGradientTexture;
  62198. private _createAngularSpeedGradientTexture;
  62199. private _createVelocityGradientTexture;
  62200. private _createLimitVelocityGradientTexture;
  62201. private _createDragGradientTexture;
  62202. private _createColorGradientTexture;
  62203. /**
  62204. * Renders the particle system in its current state
  62205. * @param preWarm defines if the system should only update the particles but not render them
  62206. * @returns the current number of particles
  62207. */
  62208. render(preWarm?: boolean): number;
  62209. /**
  62210. * Rebuilds the particle system
  62211. */
  62212. rebuild(): void;
  62213. private _releaseBuffers;
  62214. private _releaseVAOs;
  62215. /**
  62216. * Disposes the particle system and free the associated resources
  62217. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62218. */
  62219. dispose(disposeTexture?: boolean): void;
  62220. /**
  62221. * Clones the particle system.
  62222. * @param name The name of the cloned object
  62223. * @param newEmitter The new emitter to use
  62224. * @returns the cloned particle system
  62225. */
  62226. clone(name: string, newEmitter: any): GPUParticleSystem;
  62227. /**
  62228. * Serializes the particle system to a JSON object.
  62229. * @returns the JSON object
  62230. */
  62231. serialize(): any;
  62232. /**
  62233. * Parses a JSON object to create a GPU particle system.
  62234. * @param parsedParticleSystem The JSON object to parse
  62235. * @param scene The scene to create the particle system in
  62236. * @param rootUrl The root url to use to load external dependencies like texture
  62237. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62238. * @returns the parsed GPU particle system
  62239. */
  62240. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62241. }
  62242. }
  62243. declare module "babylonjs/Particles/particleSystemSet" {
  62244. import { Nullable } from "babylonjs/types";
  62245. import { Color3 } from "babylonjs/Maths/math.color";
  62246. import { TransformNode } from "babylonjs/Meshes/transformNode";
  62247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62248. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62249. import { Scene, IDisposable } from "babylonjs/scene";
  62250. /**
  62251. * Represents a set of particle systems working together to create a specific effect
  62252. */
  62253. export class ParticleSystemSet implements IDisposable {
  62254. /**
  62255. * Gets or sets base Assets URL
  62256. */
  62257. static BaseAssetsUrl: string;
  62258. private _emitterCreationOptions;
  62259. private _emitterNode;
  62260. /**
  62261. * Gets the particle system list
  62262. */
  62263. systems: IParticleSystem[];
  62264. /**
  62265. * Gets the emitter node used with this set
  62266. */
  62267. readonly emitterNode: Nullable<TransformNode>;
  62268. /**
  62269. * Creates a new emitter mesh as a sphere
  62270. * @param options defines the options used to create the sphere
  62271. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62272. * @param scene defines the hosting scene
  62273. */
  62274. setEmitterAsSphere(options: {
  62275. diameter: number;
  62276. segments: number;
  62277. color: Color3;
  62278. }, renderingGroupId: number, scene: Scene): void;
  62279. /**
  62280. * Starts all particle systems of the set
  62281. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62282. */
  62283. start(emitter?: AbstractMesh): void;
  62284. /**
  62285. * Release all associated resources
  62286. */
  62287. dispose(): void;
  62288. /**
  62289. * Serialize the set into a JSON compatible object
  62290. * @returns a JSON compatible representation of the set
  62291. */
  62292. serialize(): any;
  62293. /**
  62294. * Parse a new ParticleSystemSet from a serialized source
  62295. * @param data defines a JSON compatible representation of the set
  62296. * @param scene defines the hosting scene
  62297. * @param gpu defines if we want GPU particles or CPU particles
  62298. * @returns a new ParticleSystemSet
  62299. */
  62300. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62301. }
  62302. }
  62303. declare module "babylonjs/Particles/particleHelper" {
  62304. import { Nullable } from "babylonjs/types";
  62305. import { Scene } from "babylonjs/scene";
  62306. import { Vector3 } from "babylonjs/Maths/math.vector";
  62307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62308. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62309. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  62310. /**
  62311. * This class is made for on one-liner static method to help creating particle system set.
  62312. */
  62313. export class ParticleHelper {
  62314. /**
  62315. * Gets or sets base Assets URL
  62316. */
  62317. static BaseAssetsUrl: string;
  62318. /**
  62319. * Create a default particle system that you can tweak
  62320. * @param emitter defines the emitter to use
  62321. * @param capacity defines the system capacity (default is 500 particles)
  62322. * @param scene defines the hosting scene
  62323. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62324. * @returns the new Particle system
  62325. */
  62326. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62327. /**
  62328. * This is the main static method (one-liner) of this helper to create different particle systems
  62329. * @param type This string represents the type to the particle system to create
  62330. * @param scene The scene where the particle system should live
  62331. * @param gpu If the system will use gpu
  62332. * @returns the ParticleSystemSet created
  62333. */
  62334. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62335. /**
  62336. * Static function used to export a particle system to a ParticleSystemSet variable.
  62337. * Please note that the emitter shape is not exported
  62338. * @param systems defines the particle systems to export
  62339. * @returns the created particle system set
  62340. */
  62341. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62342. }
  62343. }
  62344. declare module "babylonjs/Particles/particleSystemComponent" {
  62345. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62346. import { Effect } from "babylonjs/Materials/effect";
  62347. import "babylonjs/Shaders/particles.vertex";
  62348. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  62349. module "babylonjs/Engines/engine" {
  62350. interface Engine {
  62351. /**
  62352. * Create an effect to use with particle systems.
  62353. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62354. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62355. * @param uniformsNames defines a list of attribute names
  62356. * @param samplers defines an array of string used to represent textures
  62357. * @param defines defines the string containing the defines to use to compile the shaders
  62358. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62359. * @param onCompiled defines a function to call when the effect creation is successful
  62360. * @param onError defines a function to call when the effect creation has failed
  62361. * @returns the new Effect
  62362. */
  62363. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62364. }
  62365. }
  62366. module "babylonjs/Meshes/mesh" {
  62367. interface Mesh {
  62368. /**
  62369. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62370. * @returns an array of IParticleSystem
  62371. */
  62372. getEmittedParticleSystems(): IParticleSystem[];
  62373. /**
  62374. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62375. * @returns an array of IParticleSystem
  62376. */
  62377. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62378. }
  62379. }
  62380. /**
  62381. * @hidden
  62382. */
  62383. export var _IDoNeedToBeInTheBuild: number;
  62384. }
  62385. declare module "babylonjs/Particles/pointsCloudSystem" {
  62386. import { Color4 } from "babylonjs/Maths/math";
  62387. import { Mesh } from "babylonjs/Meshes/mesh";
  62388. import { Scene, IDisposable } from "babylonjs/scene";
  62389. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  62390. /** Defines the 4 color options */
  62391. export enum PointColor {
  62392. /** color value */
  62393. Color = 2,
  62394. /** uv value */
  62395. UV = 1,
  62396. /** random value */
  62397. Random = 0,
  62398. /** stated value */
  62399. Stated = 3
  62400. }
  62401. /**
  62402. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62403. * 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.
  62404. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62405. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62406. *
  62407. * Full documentation here : TO BE ENTERED
  62408. */
  62409. export class PointsCloudSystem implements IDisposable {
  62410. /**
  62411. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62412. * Example : var p = SPS.particles[i];
  62413. */
  62414. particles: CloudPoint[];
  62415. /**
  62416. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62417. */
  62418. nbParticles: number;
  62419. /**
  62420. * This a counter for your own usage. It's not set by any SPS functions.
  62421. */
  62422. counter: number;
  62423. /**
  62424. * The PCS name. This name is also given to the underlying mesh.
  62425. */
  62426. name: string;
  62427. /**
  62428. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62429. */
  62430. mesh: Mesh;
  62431. /**
  62432. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62433. * Please read :
  62434. */
  62435. vars: any;
  62436. /**
  62437. * @hidden
  62438. */
  62439. _size: number;
  62440. private _scene;
  62441. private _promises;
  62442. private _positions;
  62443. private _indices;
  62444. private _normals;
  62445. private _colors;
  62446. private _uvs;
  62447. private _indices32;
  62448. private _positions32;
  62449. private _colors32;
  62450. private _uvs32;
  62451. private _updatable;
  62452. private _isVisibilityBoxLocked;
  62453. private _alwaysVisible;
  62454. private _groups;
  62455. private _groupCounter;
  62456. private _computeParticleColor;
  62457. private _computeParticleTexture;
  62458. private _computeParticleRotation;
  62459. private _computeBoundingBox;
  62460. private _isReady;
  62461. /**
  62462. * Creates a PCS (Points Cloud System) object
  62463. * @param name (String) is the PCS name, this will be the underlying mesh name
  62464. * @param pointSize (number) is the size for each point
  62465. * @param scene (Scene) is the scene in which the PCS is added
  62466. * @param options defines the options of the PCS e.g.
  62467. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62468. */
  62469. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62470. updatable?: boolean;
  62471. });
  62472. /**
  62473. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62474. * If no points were added to the PCS, the returned mesh is just a single point.
  62475. * @returns a promise for the created mesh
  62476. */
  62477. buildMeshAsync(): Promise<Mesh>;
  62478. /**
  62479. * @hidden
  62480. */
  62481. private _buildMesh;
  62482. private _addParticle;
  62483. private _randomUnitVector;
  62484. private _getColorIndicesForCoord;
  62485. private _setPointsColorOrUV;
  62486. private _colorFromTexture;
  62487. private _calculateDensity;
  62488. /**
  62489. * Adds points to the PCS in random positions within a unit sphere
  62490. * @param nb (positive integer) the number of particles to be created from this model
  62491. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62492. * @returns the number of groups in the system
  62493. */
  62494. addPoints(nb: number, pointFunction?: any): number;
  62495. /**
  62496. * Adds points to the PCS from the surface of the model shape
  62497. * @param mesh is any Mesh object that will be used as a surface model for the points
  62498. * @param nb (positive integer) the number of particles to be created from this model
  62499. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62500. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62501. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62502. * @returns the number of groups in the system
  62503. */
  62504. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62505. /**
  62506. * Adds points to the PCS inside the model shape
  62507. * @param mesh is any Mesh object that will be used as a surface model for the points
  62508. * @param nb (positive integer) the number of particles to be created from this model
  62509. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62510. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62511. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62512. * @returns the number of groups in the system
  62513. */
  62514. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62515. /**
  62516. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62517. * This method calls `updateParticle()` for each particle of the SPS.
  62518. * For an animated SPS, it is usually called within the render loop.
  62519. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62520. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62521. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62522. * @returns the PCS.
  62523. */
  62524. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  62525. /**
  62526. * Disposes the PCS.
  62527. */
  62528. dispose(): void;
  62529. /**
  62530. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  62531. * doc :
  62532. * @returns the PCS.
  62533. */
  62534. refreshVisibleSize(): PointsCloudSystem;
  62535. /**
  62536. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  62537. * @param size the size (float) of the visibility box
  62538. * note : this doesn't lock the PCS mesh bounding box.
  62539. * doc :
  62540. */
  62541. setVisibilityBox(size: number): void;
  62542. /**
  62543. * Gets whether the PCS is always visible or not
  62544. * doc :
  62545. */
  62546. /**
  62547. * Sets the PCS as always visible or not
  62548. * doc :
  62549. */
  62550. isAlwaysVisible: boolean;
  62551. /**
  62552. * Tells to `setParticles()` to compute the particle rotations or not
  62553. * Default value : false. The PCS is faster when it's set to false
  62554. * Note : particle rotations are only applied to parent particles
  62555. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  62556. */
  62557. computeParticleRotation: boolean;
  62558. /**
  62559. * Tells to `setParticles()` to compute the particle colors or not.
  62560. * Default value : true. The PCS is faster when it's set to false.
  62561. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62562. */
  62563. /**
  62564. * Gets if `setParticles()` computes the particle colors or not.
  62565. * Default value : false. The PCS is faster when it's set to false.
  62566. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  62567. */
  62568. computeParticleColor: boolean;
  62569. /**
  62570. * Gets if `setParticles()` computes the particle textures or not.
  62571. * Default value : false. The PCS is faster when it's set to false.
  62572. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  62573. */
  62574. computeParticleTexture: boolean;
  62575. /**
  62576. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  62577. */
  62578. /**
  62579. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  62580. */
  62581. computeBoundingBox: boolean;
  62582. /**
  62583. * This function does nothing. It may be overwritten to set all the particle first values.
  62584. * The PCS doesn't call this function, you may have to call it by your own.
  62585. * doc :
  62586. */
  62587. initParticles(): void;
  62588. /**
  62589. * This function does nothing. It may be overwritten to recycle a particle
  62590. * The PCS doesn't call this function, you can to call it
  62591. * doc :
  62592. * @param particle The particle to recycle
  62593. * @returns the recycled particle
  62594. */
  62595. recycleParticle(particle: CloudPoint): CloudPoint;
  62596. /**
  62597. * Updates a particle : this function should be overwritten by the user.
  62598. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  62599. * doc :
  62600. * @example : just set a particle position or velocity and recycle conditions
  62601. * @param particle The particle to update
  62602. * @returns the updated particle
  62603. */
  62604. updateParticle(particle: CloudPoint): CloudPoint;
  62605. /**
  62606. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  62607. * This does nothing and may be overwritten by the user.
  62608. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62609. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62610. * @param update the boolean update value actually passed to setParticles()
  62611. */
  62612. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62613. /**
  62614. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  62615. * This will be passed three parameters.
  62616. * This does nothing and may be overwritten by the user.
  62617. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  62618. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  62619. * @param update the boolean update value actually passed to setParticles()
  62620. */
  62621. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  62622. }
  62623. }
  62624. declare module "babylonjs/Particles/cloudPoint" {
  62625. import { Nullable } from "babylonjs/types";
  62626. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  62627. import { Mesh } from "babylonjs/Meshes/mesh";
  62628. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62629. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  62630. /**
  62631. * Represents one particle of a points cloud system.
  62632. */
  62633. export class CloudPoint {
  62634. /**
  62635. * particle global index
  62636. */
  62637. idx: number;
  62638. /**
  62639. * The color of the particle
  62640. */
  62641. color: Nullable<Color4>;
  62642. /**
  62643. * The world space position of the particle.
  62644. */
  62645. position: Vector3;
  62646. /**
  62647. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  62648. */
  62649. rotation: Vector3;
  62650. /**
  62651. * The world space rotation quaternion of the particle.
  62652. */
  62653. rotationQuaternion: Nullable<Quaternion>;
  62654. /**
  62655. * The uv of the particle.
  62656. */
  62657. uv: Nullable<Vector2>;
  62658. /**
  62659. * The current speed of the particle.
  62660. */
  62661. velocity: Vector3;
  62662. /**
  62663. * The pivot point in the particle local space.
  62664. */
  62665. pivot: Vector3;
  62666. /**
  62667. * Must the particle be translated from its pivot point in its local space ?
  62668. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  62669. * Default : false
  62670. */
  62671. translateFromPivot: boolean;
  62672. /**
  62673. * Index of this particle in the global "positions" array (Internal use)
  62674. * @hidden
  62675. */
  62676. _pos: number;
  62677. /**
  62678. * @hidden Index of this particle in the global "indices" array (Internal use)
  62679. */
  62680. _ind: number;
  62681. /**
  62682. * Group this particle belongs to
  62683. */
  62684. _group: PointsGroup;
  62685. /**
  62686. * Group id of this particle
  62687. */
  62688. groupId: number;
  62689. /**
  62690. * Index of the particle in its group id (Internal use)
  62691. */
  62692. idxInGroup: number;
  62693. /**
  62694. * @hidden Particle BoundingInfo object (Internal use)
  62695. */
  62696. _boundingInfo: BoundingInfo;
  62697. /**
  62698. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  62699. */
  62700. _pcs: PointsCloudSystem;
  62701. /**
  62702. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  62703. */
  62704. _stillInvisible: boolean;
  62705. /**
  62706. * @hidden Last computed particle rotation matrix
  62707. */
  62708. _rotationMatrix: number[];
  62709. /**
  62710. * Parent particle Id, if any.
  62711. * Default null.
  62712. */
  62713. parentId: Nullable<number>;
  62714. /**
  62715. * @hidden Internal global position in the PCS.
  62716. */
  62717. _globalPosition: Vector3;
  62718. /**
  62719. * Creates a Point Cloud object.
  62720. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  62721. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  62722. * @param group (PointsGroup) is the group the particle belongs to
  62723. * @param groupId (integer) is the group identifier in the PCS.
  62724. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  62725. * @param pcs defines the PCS it is associated to
  62726. */
  62727. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  62728. /**
  62729. * get point size
  62730. */
  62731. /**
  62732. * Set point size
  62733. */
  62734. size: Vector3;
  62735. /**
  62736. * Legacy support, changed quaternion to rotationQuaternion
  62737. */
  62738. /**
  62739. * Legacy support, changed quaternion to rotationQuaternion
  62740. */
  62741. quaternion: Nullable<Quaternion>;
  62742. /**
  62743. * Returns a boolean. True if the particle intersects a mesh, else false
  62744. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  62745. * @param target is the object (point or mesh) what the intersection is computed against
  62746. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  62747. * @returns true if it intersects
  62748. */
  62749. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  62750. /**
  62751. * get the rotation matrix of the particle
  62752. * @hidden
  62753. */
  62754. getRotationMatrix(m: Matrix): void;
  62755. }
  62756. /**
  62757. * Represents a group of points in a points cloud system
  62758. * * PCS internal tool, don't use it manually.
  62759. */
  62760. export class PointsGroup {
  62761. /**
  62762. * The group id
  62763. * @hidden
  62764. */
  62765. groupID: number;
  62766. /**
  62767. * image data for group (internal use)
  62768. * @hidden
  62769. */
  62770. _groupImageData: Nullable<ArrayBufferView>;
  62771. /**
  62772. * Image Width (internal use)
  62773. * @hidden
  62774. */
  62775. _groupImgWidth: number;
  62776. /**
  62777. * Image Height (internal use)
  62778. * @hidden
  62779. */
  62780. _groupImgHeight: number;
  62781. /**
  62782. * Custom position function (internal use)
  62783. * @hidden
  62784. */
  62785. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  62786. /**
  62787. * density per facet for surface points
  62788. * @hidden
  62789. */
  62790. _groupDensity: number[];
  62791. /**
  62792. * Only when points are colored by texture carries pointer to texture list array
  62793. * @hidden
  62794. */
  62795. _textureNb: number;
  62796. /**
  62797. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  62798. * PCS internal tool, don't use it manually.
  62799. * @hidden
  62800. */
  62801. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  62802. }
  62803. }
  62804. declare module "babylonjs/Particles/index" {
  62805. export * from "babylonjs/Particles/baseParticleSystem";
  62806. export * from "babylonjs/Particles/EmitterTypes/index";
  62807. export * from "babylonjs/Particles/gpuParticleSystem";
  62808. export * from "babylonjs/Particles/IParticleSystem";
  62809. export * from "babylonjs/Particles/particle";
  62810. export * from "babylonjs/Particles/particleHelper";
  62811. export * from "babylonjs/Particles/particleSystem";
  62812. export * from "babylonjs/Particles/particleSystemComponent";
  62813. export * from "babylonjs/Particles/particleSystemSet";
  62814. export * from "babylonjs/Particles/solidParticle";
  62815. export * from "babylonjs/Particles/solidParticleSystem";
  62816. export * from "babylonjs/Particles/cloudPoint";
  62817. export * from "babylonjs/Particles/pointsCloudSystem";
  62818. export * from "babylonjs/Particles/subEmitter";
  62819. }
  62820. declare module "babylonjs/Physics/physicsEngineComponent" {
  62821. import { Nullable } from "babylonjs/types";
  62822. import { Observable, Observer } from "babylonjs/Misc/observable";
  62823. import { Vector3 } from "babylonjs/Maths/math.vector";
  62824. import { Mesh } from "babylonjs/Meshes/mesh";
  62825. import { ISceneComponent } from "babylonjs/sceneComponent";
  62826. import { Scene } from "babylonjs/scene";
  62827. import { Node } from "babylonjs/node";
  62828. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62829. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62830. module "babylonjs/scene" {
  62831. interface Scene {
  62832. /** @hidden (Backing field) */
  62833. _physicsEngine: Nullable<IPhysicsEngine>;
  62834. /**
  62835. * Gets the current physics engine
  62836. * @returns a IPhysicsEngine or null if none attached
  62837. */
  62838. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  62839. /**
  62840. * Enables physics to the current scene
  62841. * @param gravity defines the scene's gravity for the physics engine
  62842. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  62843. * @return a boolean indicating if the physics engine was initialized
  62844. */
  62845. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  62846. /**
  62847. * Disables and disposes the physics engine associated with the scene
  62848. */
  62849. disablePhysicsEngine(): void;
  62850. /**
  62851. * Gets a boolean indicating if there is an active physics engine
  62852. * @returns a boolean indicating if there is an active physics engine
  62853. */
  62854. isPhysicsEnabled(): boolean;
  62855. /**
  62856. * Deletes a physics compound impostor
  62857. * @param compound defines the compound to delete
  62858. */
  62859. deleteCompoundImpostor(compound: any): void;
  62860. /**
  62861. * An event triggered when physic simulation is about to be run
  62862. */
  62863. onBeforePhysicsObservable: Observable<Scene>;
  62864. /**
  62865. * An event triggered when physic simulation has been done
  62866. */
  62867. onAfterPhysicsObservable: Observable<Scene>;
  62868. }
  62869. }
  62870. module "babylonjs/Meshes/abstractMesh" {
  62871. interface AbstractMesh {
  62872. /** @hidden */
  62873. _physicsImpostor: Nullable<PhysicsImpostor>;
  62874. /**
  62875. * Gets or sets impostor used for physic simulation
  62876. * @see http://doc.babylonjs.com/features/physics_engine
  62877. */
  62878. physicsImpostor: Nullable<PhysicsImpostor>;
  62879. /**
  62880. * Gets the current physics impostor
  62881. * @see http://doc.babylonjs.com/features/physics_engine
  62882. * @returns a physics impostor or null
  62883. */
  62884. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  62885. /** Apply a physic impulse to the mesh
  62886. * @param force defines the force to apply
  62887. * @param contactPoint defines where to apply the force
  62888. * @returns the current mesh
  62889. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  62890. */
  62891. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  62892. /**
  62893. * Creates a physic joint between two meshes
  62894. * @param otherMesh defines the other mesh to use
  62895. * @param pivot1 defines the pivot to use on this mesh
  62896. * @param pivot2 defines the pivot to use on the other mesh
  62897. * @param options defines additional options (can be plugin dependent)
  62898. * @returns the current mesh
  62899. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  62900. */
  62901. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  62902. /** @hidden */
  62903. _disposePhysicsObserver: Nullable<Observer<Node>>;
  62904. }
  62905. }
  62906. /**
  62907. * Defines the physics engine scene component responsible to manage a physics engine
  62908. */
  62909. export class PhysicsEngineSceneComponent implements ISceneComponent {
  62910. /**
  62911. * The component name helpful to identify the component in the list of scene components.
  62912. */
  62913. readonly name: string;
  62914. /**
  62915. * The scene the component belongs to.
  62916. */
  62917. scene: Scene;
  62918. /**
  62919. * Creates a new instance of the component for the given scene
  62920. * @param scene Defines the scene to register the component in
  62921. */
  62922. constructor(scene: Scene);
  62923. /**
  62924. * Registers the component in a given scene
  62925. */
  62926. register(): void;
  62927. /**
  62928. * Rebuilds the elements related to this component in case of
  62929. * context lost for instance.
  62930. */
  62931. rebuild(): void;
  62932. /**
  62933. * Disposes the component and the associated ressources
  62934. */
  62935. dispose(): void;
  62936. }
  62937. }
  62938. declare module "babylonjs/Physics/physicsHelper" {
  62939. import { Nullable } from "babylonjs/types";
  62940. import { Vector3 } from "babylonjs/Maths/math.vector";
  62941. import { Mesh } from "babylonjs/Meshes/mesh";
  62942. import { Scene } from "babylonjs/scene";
  62943. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62944. /**
  62945. * A helper for physics simulations
  62946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  62947. */
  62948. export class PhysicsHelper {
  62949. private _scene;
  62950. private _physicsEngine;
  62951. /**
  62952. * Initializes the Physics helper
  62953. * @param scene Babylon.js scene
  62954. */
  62955. constructor(scene: Scene);
  62956. /**
  62957. * Applies a radial explosion impulse
  62958. * @param origin the origin of the explosion
  62959. * @param radiusOrEventOptions the radius or the options of radial explosion
  62960. * @param strength the explosion strength
  62961. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62962. * @returns A physics radial explosion event, or null
  62963. */
  62964. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62965. /**
  62966. * Applies a radial explosion force
  62967. * @param origin the origin of the explosion
  62968. * @param radiusOrEventOptions the radius or the options of radial explosion
  62969. * @param strength the explosion strength
  62970. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62971. * @returns A physics radial explosion event, or null
  62972. */
  62973. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  62974. /**
  62975. * Creates a gravitational field
  62976. * @param origin the origin of the explosion
  62977. * @param radiusOrEventOptions the radius or the options of radial explosion
  62978. * @param strength the explosion strength
  62979. * @param falloff possible options: Constant & Linear. Defaults to Constant
  62980. * @returns A physics gravitational field event, or null
  62981. */
  62982. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  62983. /**
  62984. * Creates a physics updraft event
  62985. * @param origin the origin of the updraft
  62986. * @param radiusOrEventOptions the radius or the options of the updraft
  62987. * @param strength the strength of the updraft
  62988. * @param height the height of the updraft
  62989. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  62990. * @returns A physics updraft event, or null
  62991. */
  62992. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  62993. /**
  62994. * Creates a physics vortex event
  62995. * @param origin the of the vortex
  62996. * @param radiusOrEventOptions the radius or the options of the vortex
  62997. * @param strength the strength of the vortex
  62998. * @param height the height of the vortex
  62999. * @returns a Physics vortex event, or null
  63000. * A physics vortex event or null
  63001. */
  63002. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63003. }
  63004. /**
  63005. * Represents a physics radial explosion event
  63006. */
  63007. class PhysicsRadialExplosionEvent {
  63008. private _scene;
  63009. private _options;
  63010. private _sphere;
  63011. private _dataFetched;
  63012. /**
  63013. * Initializes a radial explosioin event
  63014. * @param _scene BabylonJS scene
  63015. * @param _options The options for the vortex event
  63016. */
  63017. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63018. /**
  63019. * Returns the data related to the radial explosion event (sphere).
  63020. * @returns The radial explosion event data
  63021. */
  63022. getData(): PhysicsRadialExplosionEventData;
  63023. /**
  63024. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63025. * @param impostor A physics imposter
  63026. * @param origin the origin of the explosion
  63027. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63028. */
  63029. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63030. /**
  63031. * Triggers affecterd impostors callbacks
  63032. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63033. */
  63034. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63035. /**
  63036. * Disposes the sphere.
  63037. * @param force Specifies if the sphere should be disposed by force
  63038. */
  63039. dispose(force?: boolean): void;
  63040. /*** Helpers ***/
  63041. private _prepareSphere;
  63042. private _intersectsWithSphere;
  63043. }
  63044. /**
  63045. * Represents a gravitational field event
  63046. */
  63047. class PhysicsGravitationalFieldEvent {
  63048. private _physicsHelper;
  63049. private _scene;
  63050. private _origin;
  63051. private _options;
  63052. private _tickCallback;
  63053. private _sphere;
  63054. private _dataFetched;
  63055. /**
  63056. * Initializes the physics gravitational field event
  63057. * @param _physicsHelper A physics helper
  63058. * @param _scene BabylonJS scene
  63059. * @param _origin The origin position of the gravitational field event
  63060. * @param _options The options for the vortex event
  63061. */
  63062. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63063. /**
  63064. * Returns the data related to the gravitational field event (sphere).
  63065. * @returns A gravitational field event
  63066. */
  63067. getData(): PhysicsGravitationalFieldEventData;
  63068. /**
  63069. * Enables the gravitational field.
  63070. */
  63071. enable(): void;
  63072. /**
  63073. * Disables the gravitational field.
  63074. */
  63075. disable(): void;
  63076. /**
  63077. * Disposes the sphere.
  63078. * @param force The force to dispose from the gravitational field event
  63079. */
  63080. dispose(force?: boolean): void;
  63081. private _tick;
  63082. }
  63083. /**
  63084. * Represents a physics updraft event
  63085. */
  63086. class PhysicsUpdraftEvent {
  63087. private _scene;
  63088. private _origin;
  63089. private _options;
  63090. private _physicsEngine;
  63091. private _originTop;
  63092. private _originDirection;
  63093. private _tickCallback;
  63094. private _cylinder;
  63095. private _cylinderPosition;
  63096. private _dataFetched;
  63097. /**
  63098. * Initializes the physics updraft event
  63099. * @param _scene BabylonJS scene
  63100. * @param _origin The origin position of the updraft
  63101. * @param _options The options for the updraft event
  63102. */
  63103. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63104. /**
  63105. * Returns the data related to the updraft event (cylinder).
  63106. * @returns A physics updraft event
  63107. */
  63108. getData(): PhysicsUpdraftEventData;
  63109. /**
  63110. * Enables the updraft.
  63111. */
  63112. enable(): void;
  63113. /**
  63114. * Disables the updraft.
  63115. */
  63116. disable(): void;
  63117. /**
  63118. * Disposes the cylinder.
  63119. * @param force Specifies if the updraft should be disposed by force
  63120. */
  63121. dispose(force?: boolean): void;
  63122. private getImpostorHitData;
  63123. private _tick;
  63124. /*** Helpers ***/
  63125. private _prepareCylinder;
  63126. private _intersectsWithCylinder;
  63127. }
  63128. /**
  63129. * Represents a physics vortex event
  63130. */
  63131. class PhysicsVortexEvent {
  63132. private _scene;
  63133. private _origin;
  63134. private _options;
  63135. private _physicsEngine;
  63136. private _originTop;
  63137. private _tickCallback;
  63138. private _cylinder;
  63139. private _cylinderPosition;
  63140. private _dataFetched;
  63141. /**
  63142. * Initializes the physics vortex event
  63143. * @param _scene The BabylonJS scene
  63144. * @param _origin The origin position of the vortex
  63145. * @param _options The options for the vortex event
  63146. */
  63147. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63148. /**
  63149. * Returns the data related to the vortex event (cylinder).
  63150. * @returns The physics vortex event data
  63151. */
  63152. getData(): PhysicsVortexEventData;
  63153. /**
  63154. * Enables the vortex.
  63155. */
  63156. enable(): void;
  63157. /**
  63158. * Disables the cortex.
  63159. */
  63160. disable(): void;
  63161. /**
  63162. * Disposes the sphere.
  63163. * @param force
  63164. */
  63165. dispose(force?: boolean): void;
  63166. private getImpostorHitData;
  63167. private _tick;
  63168. /*** Helpers ***/
  63169. private _prepareCylinder;
  63170. private _intersectsWithCylinder;
  63171. }
  63172. /**
  63173. * Options fot the radial explosion event
  63174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63175. */
  63176. export class PhysicsRadialExplosionEventOptions {
  63177. /**
  63178. * The radius of the sphere for the radial explosion.
  63179. */
  63180. radius: number;
  63181. /**
  63182. * The strenth of the explosion.
  63183. */
  63184. strength: number;
  63185. /**
  63186. * The strenght of the force in correspondence to the distance of the affected object
  63187. */
  63188. falloff: PhysicsRadialImpulseFalloff;
  63189. /**
  63190. * Sphere options for the radial explosion.
  63191. */
  63192. sphere: {
  63193. segments: number;
  63194. diameter: number;
  63195. };
  63196. /**
  63197. * Sphere options for the radial explosion.
  63198. */
  63199. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63200. }
  63201. /**
  63202. * Options fot the updraft event
  63203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63204. */
  63205. export class PhysicsUpdraftEventOptions {
  63206. /**
  63207. * The radius of the cylinder for the vortex
  63208. */
  63209. radius: number;
  63210. /**
  63211. * The strenth of the updraft.
  63212. */
  63213. strength: number;
  63214. /**
  63215. * The height of the cylinder for the updraft.
  63216. */
  63217. height: number;
  63218. /**
  63219. * The mode for the the updraft.
  63220. */
  63221. updraftMode: PhysicsUpdraftMode;
  63222. }
  63223. /**
  63224. * Options fot the vortex event
  63225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63226. */
  63227. export class PhysicsVortexEventOptions {
  63228. /**
  63229. * The radius of the cylinder for the vortex
  63230. */
  63231. radius: number;
  63232. /**
  63233. * The strenth of the vortex.
  63234. */
  63235. strength: number;
  63236. /**
  63237. * The height of the cylinder for the vortex.
  63238. */
  63239. height: number;
  63240. /**
  63241. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63242. */
  63243. centripetalForceThreshold: number;
  63244. /**
  63245. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63246. */
  63247. centripetalForceMultiplier: number;
  63248. /**
  63249. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63250. */
  63251. centrifugalForceMultiplier: number;
  63252. /**
  63253. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63254. */
  63255. updraftForceMultiplier: number;
  63256. }
  63257. /**
  63258. * The strenght of the force in correspondence to the distance of the affected object
  63259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63260. */
  63261. export enum PhysicsRadialImpulseFalloff {
  63262. /** Defines that impulse is constant in strength across it's whole radius */
  63263. Constant = 0,
  63264. /** Defines that impulse gets weaker if it's further from the origin */
  63265. Linear = 1
  63266. }
  63267. /**
  63268. * The strength of the force in correspondence to the distance of the affected object
  63269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63270. */
  63271. export enum PhysicsUpdraftMode {
  63272. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63273. Center = 0,
  63274. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63275. Perpendicular = 1
  63276. }
  63277. /**
  63278. * Interface for a physics hit data
  63279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63280. */
  63281. export interface PhysicsHitData {
  63282. /**
  63283. * The force applied at the contact point
  63284. */
  63285. force: Vector3;
  63286. /**
  63287. * The contact point
  63288. */
  63289. contactPoint: Vector3;
  63290. /**
  63291. * The distance from the origin to the contact point
  63292. */
  63293. distanceFromOrigin: number;
  63294. }
  63295. /**
  63296. * Interface for radial explosion event data
  63297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63298. */
  63299. export interface PhysicsRadialExplosionEventData {
  63300. /**
  63301. * A sphere used for the radial explosion event
  63302. */
  63303. sphere: Mesh;
  63304. }
  63305. /**
  63306. * Interface for gravitational field event data
  63307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63308. */
  63309. export interface PhysicsGravitationalFieldEventData {
  63310. /**
  63311. * A sphere mesh used for the gravitational field event
  63312. */
  63313. sphere: Mesh;
  63314. }
  63315. /**
  63316. * Interface for updraft event data
  63317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63318. */
  63319. export interface PhysicsUpdraftEventData {
  63320. /**
  63321. * A cylinder used for the updraft event
  63322. */
  63323. cylinder: Mesh;
  63324. }
  63325. /**
  63326. * Interface for vortex event data
  63327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63328. */
  63329. export interface PhysicsVortexEventData {
  63330. /**
  63331. * A cylinder used for the vortex event
  63332. */
  63333. cylinder: Mesh;
  63334. }
  63335. /**
  63336. * Interface for an affected physics impostor
  63337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63338. */
  63339. export interface PhysicsAffectedImpostorWithData {
  63340. /**
  63341. * The impostor affected by the effect
  63342. */
  63343. impostor: PhysicsImpostor;
  63344. /**
  63345. * The data about the hit/horce from the explosion
  63346. */
  63347. hitData: PhysicsHitData;
  63348. }
  63349. }
  63350. declare module "babylonjs/Physics/Plugins/index" {
  63351. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  63352. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  63353. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  63354. }
  63355. declare module "babylonjs/Physics/index" {
  63356. export * from "babylonjs/Physics/IPhysicsEngine";
  63357. export * from "babylonjs/Physics/physicsEngine";
  63358. export * from "babylonjs/Physics/physicsEngineComponent";
  63359. export * from "babylonjs/Physics/physicsHelper";
  63360. export * from "babylonjs/Physics/physicsImpostor";
  63361. export * from "babylonjs/Physics/physicsJoint";
  63362. export * from "babylonjs/Physics/Plugins/index";
  63363. }
  63364. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  63365. /** @hidden */
  63366. export var blackAndWhitePixelShader: {
  63367. name: string;
  63368. shader: string;
  63369. };
  63370. }
  63371. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  63372. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63373. import { Camera } from "babylonjs/Cameras/camera";
  63374. import { Engine } from "babylonjs/Engines/engine";
  63375. import "babylonjs/Shaders/blackAndWhite.fragment";
  63376. /**
  63377. * Post process used to render in black and white
  63378. */
  63379. export class BlackAndWhitePostProcess extends PostProcess {
  63380. /**
  63381. * Linear about to convert he result to black and white (default: 1)
  63382. */
  63383. degree: number;
  63384. /**
  63385. * Creates a black and white post process
  63386. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63387. * @param name The name of the effect.
  63388. * @param options The required width/height ratio to downsize to before computing the render pass.
  63389. * @param camera The camera to apply the render pass to.
  63390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63391. * @param engine The engine which the post process will be applied. (default: current engine)
  63392. * @param reusable If the post process can be reused on the same frame. (default: false)
  63393. */
  63394. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63395. }
  63396. }
  63397. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  63398. import { Nullable } from "babylonjs/types";
  63399. import { Camera } from "babylonjs/Cameras/camera";
  63400. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63401. import { Engine } from "babylonjs/Engines/engine";
  63402. /**
  63403. * This represents a set of one or more post processes in Babylon.
  63404. * A post process can be used to apply a shader to a texture after it is rendered.
  63405. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63406. */
  63407. export class PostProcessRenderEffect {
  63408. private _postProcesses;
  63409. private _getPostProcesses;
  63410. private _singleInstance;
  63411. private _cameras;
  63412. private _indicesForCamera;
  63413. /**
  63414. * Name of the effect
  63415. * @hidden
  63416. */
  63417. _name: string;
  63418. /**
  63419. * Instantiates a post process render effect.
  63420. * A post process can be used to apply a shader to a texture after it is rendered.
  63421. * @param engine The engine the effect is tied to
  63422. * @param name The name of the effect
  63423. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63424. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63425. */
  63426. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63427. /**
  63428. * Checks if all the post processes in the effect are supported.
  63429. */
  63430. readonly isSupported: boolean;
  63431. /**
  63432. * Updates the current state of the effect
  63433. * @hidden
  63434. */
  63435. _update(): void;
  63436. /**
  63437. * Attaches the effect on cameras
  63438. * @param cameras The camera to attach to.
  63439. * @hidden
  63440. */
  63441. _attachCameras(cameras: Camera): void;
  63442. /**
  63443. * Attaches the effect on cameras
  63444. * @param cameras The camera to attach to.
  63445. * @hidden
  63446. */
  63447. _attachCameras(cameras: Camera[]): void;
  63448. /**
  63449. * Detaches the effect on cameras
  63450. * @param cameras The camera to detatch from.
  63451. * @hidden
  63452. */
  63453. _detachCameras(cameras: Camera): void;
  63454. /**
  63455. * Detatches the effect on cameras
  63456. * @param cameras The camera to detatch from.
  63457. * @hidden
  63458. */
  63459. _detachCameras(cameras: Camera[]): void;
  63460. /**
  63461. * Enables the effect on given cameras
  63462. * @param cameras The camera to enable.
  63463. * @hidden
  63464. */
  63465. _enable(cameras: Camera): void;
  63466. /**
  63467. * Enables the effect on given cameras
  63468. * @param cameras The camera to enable.
  63469. * @hidden
  63470. */
  63471. _enable(cameras: Nullable<Camera[]>): void;
  63472. /**
  63473. * Disables the effect on the given cameras
  63474. * @param cameras The camera to disable.
  63475. * @hidden
  63476. */
  63477. _disable(cameras: Camera): void;
  63478. /**
  63479. * Disables the effect on the given cameras
  63480. * @param cameras The camera to disable.
  63481. * @hidden
  63482. */
  63483. _disable(cameras: Nullable<Camera[]>): void;
  63484. /**
  63485. * Gets a list of the post processes contained in the effect.
  63486. * @param camera The camera to get the post processes on.
  63487. * @returns The list of the post processes in the effect.
  63488. */
  63489. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63490. }
  63491. }
  63492. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  63493. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63494. /** @hidden */
  63495. export var extractHighlightsPixelShader: {
  63496. name: string;
  63497. shader: string;
  63498. };
  63499. }
  63500. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  63501. import { Nullable } from "babylonjs/types";
  63502. import { Camera } from "babylonjs/Cameras/camera";
  63503. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63504. import { Engine } from "babylonjs/Engines/engine";
  63505. import "babylonjs/Shaders/extractHighlights.fragment";
  63506. /**
  63507. * 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.
  63508. */
  63509. export class ExtractHighlightsPostProcess extends PostProcess {
  63510. /**
  63511. * The luminance threshold, pixels below this value will be set to black.
  63512. */
  63513. threshold: number;
  63514. /** @hidden */
  63515. _exposure: number;
  63516. /**
  63517. * Post process which has the input texture to be used when performing highlight extraction
  63518. * @hidden
  63519. */
  63520. _inputPostProcess: Nullable<PostProcess>;
  63521. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63522. }
  63523. }
  63524. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  63525. /** @hidden */
  63526. export var bloomMergePixelShader: {
  63527. name: string;
  63528. shader: string;
  63529. };
  63530. }
  63531. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  63532. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63533. import { Nullable } from "babylonjs/types";
  63534. import { Engine } from "babylonjs/Engines/engine";
  63535. import { Camera } from "babylonjs/Cameras/camera";
  63536. import "babylonjs/Shaders/bloomMerge.fragment";
  63537. /**
  63538. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63539. */
  63540. export class BloomMergePostProcess extends PostProcess {
  63541. /** Weight of the bloom to be added to the original input. */
  63542. weight: number;
  63543. /**
  63544. * Creates a new instance of @see BloomMergePostProcess
  63545. * @param name The name of the effect.
  63546. * @param originalFromInput Post process which's input will be used for the merge.
  63547. * @param blurred Blurred highlights post process which's output will be used.
  63548. * @param weight Weight of the bloom to be added to the original input.
  63549. * @param options The required width/height ratio to downsize to before computing the render pass.
  63550. * @param camera The camera to apply the render pass to.
  63551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63552. * @param engine The engine which the post process will be applied. (default: current engine)
  63553. * @param reusable If the post process can be reused on the same frame. (default: false)
  63554. * @param textureType Type of textures used when performing the post process. (default: 0)
  63555. * @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)
  63556. */
  63557. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63558. /** Weight of the bloom to be added to the original input. */
  63559. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63560. }
  63561. }
  63562. declare module "babylonjs/PostProcesses/bloomEffect" {
  63563. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63564. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63565. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63566. import { Camera } from "babylonjs/Cameras/camera";
  63567. import { Scene } from "babylonjs/scene";
  63568. /**
  63569. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63570. */
  63571. export class BloomEffect extends PostProcessRenderEffect {
  63572. private bloomScale;
  63573. /**
  63574. * @hidden Internal
  63575. */
  63576. _effects: Array<PostProcess>;
  63577. /**
  63578. * @hidden Internal
  63579. */
  63580. _downscale: ExtractHighlightsPostProcess;
  63581. private _blurX;
  63582. private _blurY;
  63583. private _merge;
  63584. /**
  63585. * The luminance threshold to find bright areas of the image to bloom.
  63586. */
  63587. threshold: number;
  63588. /**
  63589. * The strength of the bloom.
  63590. */
  63591. weight: number;
  63592. /**
  63593. * Specifies the size of the bloom blur kernel, relative to the final output size
  63594. */
  63595. kernel: number;
  63596. /**
  63597. * Creates a new instance of @see BloomEffect
  63598. * @param scene The scene the effect belongs to.
  63599. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  63600. * @param bloomKernel The size of the kernel to be used when applying the blur.
  63601. * @param bloomWeight The the strength of bloom.
  63602. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63603. * @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)
  63604. */
  63605. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  63606. /**
  63607. * Disposes each of the internal effects for a given camera.
  63608. * @param camera The camera to dispose the effect on.
  63609. */
  63610. disposeEffects(camera: Camera): void;
  63611. /**
  63612. * @hidden Internal
  63613. */
  63614. _updateEffects(): void;
  63615. /**
  63616. * Internal
  63617. * @returns if all the contained post processes are ready.
  63618. * @hidden
  63619. */
  63620. _isReady(): boolean;
  63621. }
  63622. }
  63623. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  63624. /** @hidden */
  63625. export var chromaticAberrationPixelShader: {
  63626. name: string;
  63627. shader: string;
  63628. };
  63629. }
  63630. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  63631. import { Vector2 } from "babylonjs/Maths/math.vector";
  63632. import { Nullable } from "babylonjs/types";
  63633. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63634. import { Camera } from "babylonjs/Cameras/camera";
  63635. import { Engine } from "babylonjs/Engines/engine";
  63636. import "babylonjs/Shaders/chromaticAberration.fragment";
  63637. /**
  63638. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  63639. */
  63640. export class ChromaticAberrationPostProcess extends PostProcess {
  63641. /**
  63642. * The amount of seperation of rgb channels (default: 30)
  63643. */
  63644. aberrationAmount: number;
  63645. /**
  63646. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  63647. */
  63648. radialIntensity: number;
  63649. /**
  63650. * 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))
  63651. */
  63652. direction: Vector2;
  63653. /**
  63654. * 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))
  63655. */
  63656. centerPosition: Vector2;
  63657. /**
  63658. * Creates a new instance ChromaticAberrationPostProcess
  63659. * @param name The name of the effect.
  63660. * @param screenWidth The width of the screen to apply the effect on.
  63661. * @param screenHeight The height of the screen to apply the effect on.
  63662. * @param options The required width/height ratio to downsize to before computing the render pass.
  63663. * @param camera The camera to apply the render pass to.
  63664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63665. * @param engine The engine which the post process will be applied. (default: current engine)
  63666. * @param reusable If the post process can be reused on the same frame. (default: false)
  63667. * @param textureType Type of textures used when performing the post process. (default: 0)
  63668. * @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)
  63669. */
  63670. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63671. }
  63672. }
  63673. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  63674. /** @hidden */
  63675. export var circleOfConfusionPixelShader: {
  63676. name: string;
  63677. shader: string;
  63678. };
  63679. }
  63680. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  63681. import { Nullable } from "babylonjs/types";
  63682. import { Engine } from "babylonjs/Engines/engine";
  63683. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63684. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63685. import { Camera } from "babylonjs/Cameras/camera";
  63686. import "babylonjs/Shaders/circleOfConfusion.fragment";
  63687. /**
  63688. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  63689. */
  63690. export class CircleOfConfusionPostProcess extends PostProcess {
  63691. /**
  63692. * 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.
  63693. */
  63694. lensSize: number;
  63695. /**
  63696. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63697. */
  63698. fStop: number;
  63699. /**
  63700. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63701. */
  63702. focusDistance: number;
  63703. /**
  63704. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  63705. */
  63706. focalLength: number;
  63707. private _depthTexture;
  63708. /**
  63709. * Creates a new instance CircleOfConfusionPostProcess
  63710. * @param name The name of the effect.
  63711. * @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.
  63712. * @param options The required width/height ratio to downsize to before computing the render pass.
  63713. * @param camera The camera to apply the render pass to.
  63714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63715. * @param engine The engine which the post process will be applied. (default: current engine)
  63716. * @param reusable If the post process can be reused on the same frame. (default: false)
  63717. * @param textureType Type of textures used when performing the post process. (default: 0)
  63718. * @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)
  63719. */
  63720. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63721. /**
  63722. * 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.
  63723. */
  63724. depthTexture: RenderTargetTexture;
  63725. }
  63726. }
  63727. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  63728. /** @hidden */
  63729. export var colorCorrectionPixelShader: {
  63730. name: string;
  63731. shader: string;
  63732. };
  63733. }
  63734. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  63735. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63736. import { Engine } from "babylonjs/Engines/engine";
  63737. import { Camera } from "babylonjs/Cameras/camera";
  63738. import "babylonjs/Shaders/colorCorrection.fragment";
  63739. /**
  63740. *
  63741. * This post-process allows the modification of rendered colors by using
  63742. * a 'look-up table' (LUT). This effect is also called Color Grading.
  63743. *
  63744. * The object needs to be provided an url to a texture containing the color
  63745. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  63746. * Use an image editing software to tweak the LUT to match your needs.
  63747. *
  63748. * For an example of a color LUT, see here:
  63749. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  63750. * For explanations on color grading, see here:
  63751. * @see http://udn.epicgames.com/Three/ColorGrading.html
  63752. *
  63753. */
  63754. export class ColorCorrectionPostProcess extends PostProcess {
  63755. private _colorTableTexture;
  63756. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63757. }
  63758. }
  63759. declare module "babylonjs/Shaders/convolution.fragment" {
  63760. /** @hidden */
  63761. export var convolutionPixelShader: {
  63762. name: string;
  63763. shader: string;
  63764. };
  63765. }
  63766. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  63767. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63768. import { Nullable } from "babylonjs/types";
  63769. import { Camera } from "babylonjs/Cameras/camera";
  63770. import { Engine } from "babylonjs/Engines/engine";
  63771. import "babylonjs/Shaders/convolution.fragment";
  63772. /**
  63773. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  63774. * input texture to perform effects such as edge detection or sharpening
  63775. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63776. */
  63777. export class ConvolutionPostProcess extends PostProcess {
  63778. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63779. kernel: number[];
  63780. /**
  63781. * Creates a new instance ConvolutionPostProcess
  63782. * @param name The name of the effect.
  63783. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  63784. * @param options The required width/height ratio to downsize to before computing the render pass.
  63785. * @param camera The camera to apply the render pass to.
  63786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63787. * @param engine The engine which the post process will be applied. (default: current engine)
  63788. * @param reusable If the post process can be reused on the same frame. (default: false)
  63789. * @param textureType Type of textures used when performing the post process. (default: 0)
  63790. */
  63791. constructor(name: string,
  63792. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  63793. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  63794. /**
  63795. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63796. */
  63797. static EdgeDetect0Kernel: number[];
  63798. /**
  63799. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63800. */
  63801. static EdgeDetect1Kernel: number[];
  63802. /**
  63803. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63804. */
  63805. static EdgeDetect2Kernel: number[];
  63806. /**
  63807. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63808. */
  63809. static SharpenKernel: number[];
  63810. /**
  63811. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63812. */
  63813. static EmbossKernel: number[];
  63814. /**
  63815. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  63816. */
  63817. static GaussianKernel: number[];
  63818. }
  63819. }
  63820. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  63821. import { Nullable } from "babylonjs/types";
  63822. import { Vector2 } from "babylonjs/Maths/math.vector";
  63823. import { Camera } from "babylonjs/Cameras/camera";
  63824. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63825. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63826. import { Engine } from "babylonjs/Engines/engine";
  63827. import { Scene } from "babylonjs/scene";
  63828. /**
  63829. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  63830. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  63831. * based on samples that have a large difference in distance than the center pixel.
  63832. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  63833. */
  63834. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  63835. direction: Vector2;
  63836. /**
  63837. * Creates a new instance CircleOfConfusionPostProcess
  63838. * @param name The name of the effect.
  63839. * @param scene The scene the effect belongs to.
  63840. * @param direction The direction the blur should be applied.
  63841. * @param kernel The size of the kernel used to blur.
  63842. * @param options The required width/height ratio to downsize to before computing the render pass.
  63843. * @param camera The camera to apply the render pass to.
  63844. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  63845. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  63846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63847. * @param engine The engine which the post process will be applied. (default: current engine)
  63848. * @param reusable If the post process can be reused on the same frame. (default: false)
  63849. * @param textureType Type of textures used when performing the post process. (default: 0)
  63850. * @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)
  63851. */
  63852. 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);
  63853. }
  63854. }
  63855. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  63856. /** @hidden */
  63857. export var depthOfFieldMergePixelShader: {
  63858. name: string;
  63859. shader: string;
  63860. };
  63861. }
  63862. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  63863. import { Nullable } from "babylonjs/types";
  63864. import { Camera } from "babylonjs/Cameras/camera";
  63865. import { Effect } from "babylonjs/Materials/effect";
  63866. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63867. import { Engine } from "babylonjs/Engines/engine";
  63868. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  63869. /**
  63870. * Options to be set when merging outputs from the default pipeline.
  63871. */
  63872. export class DepthOfFieldMergePostProcessOptions {
  63873. /**
  63874. * The original image to merge on top of
  63875. */
  63876. originalFromInput: PostProcess;
  63877. /**
  63878. * Parameters to perform the merge of the depth of field effect
  63879. */
  63880. depthOfField?: {
  63881. circleOfConfusion: PostProcess;
  63882. blurSteps: Array<PostProcess>;
  63883. };
  63884. /**
  63885. * Parameters to perform the merge of bloom effect
  63886. */
  63887. bloom?: {
  63888. blurred: PostProcess;
  63889. weight: number;
  63890. };
  63891. }
  63892. /**
  63893. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63894. */
  63895. export class DepthOfFieldMergePostProcess extends PostProcess {
  63896. private blurSteps;
  63897. /**
  63898. * Creates a new instance of DepthOfFieldMergePostProcess
  63899. * @param name The name of the effect.
  63900. * @param originalFromInput Post process which's input will be used for the merge.
  63901. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  63902. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  63903. * @param options The required width/height ratio to downsize to before computing the render pass.
  63904. * @param camera The camera to apply the render pass to.
  63905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63906. * @param engine The engine which the post process will be applied. (default: current engine)
  63907. * @param reusable If the post process can be reused on the same frame. (default: false)
  63908. * @param textureType Type of textures used when performing the post process. (default: 0)
  63909. * @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)
  63910. */
  63911. 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);
  63912. /**
  63913. * Updates the effect with the current post process compile time values and recompiles the shader.
  63914. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  63915. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  63916. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  63917. * @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
  63918. * @param onCompiled Called when the shader has been compiled.
  63919. * @param onError Called if there is an error when compiling a shader.
  63920. */
  63921. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  63922. }
  63923. }
  63924. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  63925. import { Nullable } from "babylonjs/types";
  63926. import { Camera } from "babylonjs/Cameras/camera";
  63927. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63928. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63929. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63930. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63931. import { Scene } from "babylonjs/scene";
  63932. /**
  63933. * Specifies the level of max blur that should be applied when using the depth of field effect
  63934. */
  63935. export enum DepthOfFieldEffectBlurLevel {
  63936. /**
  63937. * Subtle blur
  63938. */
  63939. Low = 0,
  63940. /**
  63941. * Medium blur
  63942. */
  63943. Medium = 1,
  63944. /**
  63945. * Large blur
  63946. */
  63947. High = 2
  63948. }
  63949. /**
  63950. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  63951. */
  63952. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  63953. private _circleOfConfusion;
  63954. /**
  63955. * @hidden Internal, blurs from high to low
  63956. */
  63957. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  63958. private _depthOfFieldBlurY;
  63959. private _dofMerge;
  63960. /**
  63961. * @hidden Internal post processes in depth of field effect
  63962. */
  63963. _effects: Array<PostProcess>;
  63964. /**
  63965. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  63966. */
  63967. focalLength: number;
  63968. /**
  63969. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  63970. */
  63971. fStop: number;
  63972. /**
  63973. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  63974. */
  63975. focusDistance: number;
  63976. /**
  63977. * 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.
  63978. */
  63979. lensSize: number;
  63980. /**
  63981. * Creates a new instance DepthOfFieldEffect
  63982. * @param scene The scene the effect belongs to.
  63983. * @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.
  63984. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  63985. * @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)
  63986. */
  63987. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  63988. /**
  63989. * Get the current class name of the current effet
  63990. * @returns "DepthOfFieldEffect"
  63991. */
  63992. getClassName(): string;
  63993. /**
  63994. * 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.
  63995. */
  63996. depthTexture: RenderTargetTexture;
  63997. /**
  63998. * Disposes each of the internal effects for a given camera.
  63999. * @param camera The camera to dispose the effect on.
  64000. */
  64001. disposeEffects(camera: Camera): void;
  64002. /**
  64003. * @hidden Internal
  64004. */
  64005. _updateEffects(): void;
  64006. /**
  64007. * Internal
  64008. * @returns if all the contained post processes are ready.
  64009. * @hidden
  64010. */
  64011. _isReady(): boolean;
  64012. }
  64013. }
  64014. declare module "babylonjs/Shaders/displayPass.fragment" {
  64015. /** @hidden */
  64016. export var displayPassPixelShader: {
  64017. name: string;
  64018. shader: string;
  64019. };
  64020. }
  64021. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  64022. import { Nullable } from "babylonjs/types";
  64023. import { Camera } from "babylonjs/Cameras/camera";
  64024. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64025. import { Engine } from "babylonjs/Engines/engine";
  64026. import "babylonjs/Shaders/displayPass.fragment";
  64027. /**
  64028. * DisplayPassPostProcess which produces an output the same as it's input
  64029. */
  64030. export class DisplayPassPostProcess extends PostProcess {
  64031. /**
  64032. * Creates the DisplayPassPostProcess
  64033. * @param name The name of the effect.
  64034. * @param options The required width/height ratio to downsize to before computing the render pass.
  64035. * @param camera The camera to apply the render pass to.
  64036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64037. * @param engine The engine which the post process will be applied. (default: current engine)
  64038. * @param reusable If the post process can be reused on the same frame. (default: false)
  64039. */
  64040. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64041. }
  64042. }
  64043. declare module "babylonjs/Shaders/filter.fragment" {
  64044. /** @hidden */
  64045. export var filterPixelShader: {
  64046. name: string;
  64047. shader: string;
  64048. };
  64049. }
  64050. declare module "babylonjs/PostProcesses/filterPostProcess" {
  64051. import { Nullable } from "babylonjs/types";
  64052. import { Matrix } from "babylonjs/Maths/math.vector";
  64053. import { Camera } from "babylonjs/Cameras/camera";
  64054. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64055. import { Engine } from "babylonjs/Engines/engine";
  64056. import "babylonjs/Shaders/filter.fragment";
  64057. /**
  64058. * Applies a kernel filter to the image
  64059. */
  64060. export class FilterPostProcess extends PostProcess {
  64061. /** The matrix to be applied to the image */
  64062. kernelMatrix: Matrix;
  64063. /**
  64064. *
  64065. * @param name The name of the effect.
  64066. * @param kernelMatrix The matrix to be applied to the image
  64067. * @param options The required width/height ratio to downsize to before computing the render pass.
  64068. * @param camera The camera to apply the render pass to.
  64069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64070. * @param engine The engine which the post process will be applied. (default: current engine)
  64071. * @param reusable If the post process can be reused on the same frame. (default: false)
  64072. */
  64073. constructor(name: string,
  64074. /** The matrix to be applied to the image */
  64075. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64076. }
  64077. }
  64078. declare module "babylonjs/Shaders/fxaa.fragment" {
  64079. /** @hidden */
  64080. export var fxaaPixelShader: {
  64081. name: string;
  64082. shader: string;
  64083. };
  64084. }
  64085. declare module "babylonjs/Shaders/fxaa.vertex" {
  64086. /** @hidden */
  64087. export var fxaaVertexShader: {
  64088. name: string;
  64089. shader: string;
  64090. };
  64091. }
  64092. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  64093. import { Nullable } from "babylonjs/types";
  64094. import { Camera } from "babylonjs/Cameras/camera";
  64095. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64096. import { Engine } from "babylonjs/Engines/engine";
  64097. import "babylonjs/Shaders/fxaa.fragment";
  64098. import "babylonjs/Shaders/fxaa.vertex";
  64099. /**
  64100. * Fxaa post process
  64101. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64102. */
  64103. export class FxaaPostProcess extends PostProcess {
  64104. /** @hidden */
  64105. texelWidth: number;
  64106. /** @hidden */
  64107. texelHeight: number;
  64108. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64109. private _getDefines;
  64110. }
  64111. }
  64112. declare module "babylonjs/Shaders/grain.fragment" {
  64113. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64114. /** @hidden */
  64115. export var grainPixelShader: {
  64116. name: string;
  64117. shader: string;
  64118. };
  64119. }
  64120. declare module "babylonjs/PostProcesses/grainPostProcess" {
  64121. import { Nullable } from "babylonjs/types";
  64122. import { Camera } from "babylonjs/Cameras/camera";
  64123. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64124. import { Engine } from "babylonjs/Engines/engine";
  64125. import "babylonjs/Shaders/grain.fragment";
  64126. /**
  64127. * The GrainPostProcess adds noise to the image at mid luminance levels
  64128. */
  64129. export class GrainPostProcess extends PostProcess {
  64130. /**
  64131. * The intensity of the grain added (default: 30)
  64132. */
  64133. intensity: number;
  64134. /**
  64135. * If the grain should be randomized on every frame
  64136. */
  64137. animated: boolean;
  64138. /**
  64139. * Creates a new instance of @see GrainPostProcess
  64140. * @param name The name of the effect.
  64141. * @param options The required width/height ratio to downsize to before computing the render pass.
  64142. * @param camera The camera to apply the render pass to.
  64143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64144. * @param engine The engine which the post process will be applied. (default: current engine)
  64145. * @param reusable If the post process can be reused on the same frame. (default: false)
  64146. * @param textureType Type of textures used when performing the post process. (default: 0)
  64147. * @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)
  64148. */
  64149. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64150. }
  64151. }
  64152. declare module "babylonjs/Shaders/highlights.fragment" {
  64153. /** @hidden */
  64154. export var highlightsPixelShader: {
  64155. name: string;
  64156. shader: string;
  64157. };
  64158. }
  64159. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  64160. import { Nullable } from "babylonjs/types";
  64161. import { Camera } from "babylonjs/Cameras/camera";
  64162. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64163. import { Engine } from "babylonjs/Engines/engine";
  64164. import "babylonjs/Shaders/highlights.fragment";
  64165. /**
  64166. * Extracts highlights from the image
  64167. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64168. */
  64169. export class HighlightsPostProcess extends PostProcess {
  64170. /**
  64171. * Extracts highlights from the image
  64172. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64173. * @param name The name of the effect.
  64174. * @param options The required width/height ratio to downsize to before computing the render pass.
  64175. * @param camera The camera to apply the render pass to.
  64176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64177. * @param engine The engine which the post process will be applied. (default: current engine)
  64178. * @param reusable If the post process can be reused on the same frame. (default: false)
  64179. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64180. */
  64181. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64182. }
  64183. }
  64184. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  64185. /** @hidden */
  64186. export var mrtFragmentDeclaration: {
  64187. name: string;
  64188. shader: string;
  64189. };
  64190. }
  64191. declare module "babylonjs/Shaders/geometry.fragment" {
  64192. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  64193. /** @hidden */
  64194. export var geometryPixelShader: {
  64195. name: string;
  64196. shader: string;
  64197. };
  64198. }
  64199. declare module "babylonjs/Shaders/geometry.vertex" {
  64200. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64201. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64202. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64203. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64204. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64205. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64206. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64207. /** @hidden */
  64208. export var geometryVertexShader: {
  64209. name: string;
  64210. shader: string;
  64211. };
  64212. }
  64213. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  64214. import { Matrix } from "babylonjs/Maths/math.vector";
  64215. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64216. import { Mesh } from "babylonjs/Meshes/mesh";
  64217. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  64218. import { Effect } from "babylonjs/Materials/effect";
  64219. import { Scene } from "babylonjs/scene";
  64220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64221. import "babylonjs/Shaders/geometry.fragment";
  64222. import "babylonjs/Shaders/geometry.vertex";
  64223. /** @hidden */
  64224. interface ISavedTransformationMatrix {
  64225. world: Matrix;
  64226. viewProjection: Matrix;
  64227. }
  64228. /**
  64229. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64230. */
  64231. export class GeometryBufferRenderer {
  64232. /**
  64233. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64234. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64235. */
  64236. static readonly POSITION_TEXTURE_TYPE: number;
  64237. /**
  64238. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64239. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64240. */
  64241. static readonly VELOCITY_TEXTURE_TYPE: number;
  64242. /**
  64243. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64244. * in order to compute objects velocities when enableVelocity is set to "true"
  64245. * @hidden
  64246. */
  64247. _previousTransformationMatrices: {
  64248. [index: number]: ISavedTransformationMatrix;
  64249. };
  64250. /**
  64251. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64252. * in order to compute objects velocities when enableVelocity is set to "true"
  64253. * @hidden
  64254. */
  64255. _previousBonesTransformationMatrices: {
  64256. [index: number]: Float32Array;
  64257. };
  64258. /**
  64259. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64260. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64261. */
  64262. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64263. private _scene;
  64264. private _multiRenderTarget;
  64265. private _ratio;
  64266. private _enablePosition;
  64267. private _enableVelocity;
  64268. private _positionIndex;
  64269. private _velocityIndex;
  64270. protected _effect: Effect;
  64271. protected _cachedDefines: string;
  64272. /**
  64273. * Set the render list (meshes to be rendered) used in the G buffer.
  64274. */
  64275. renderList: Mesh[];
  64276. /**
  64277. * Gets wether or not G buffer are supported by the running hardware.
  64278. * This requires draw buffer supports
  64279. */
  64280. readonly isSupported: boolean;
  64281. /**
  64282. * Returns the index of the given texture type in the G-Buffer textures array
  64283. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64284. * @returns the index of the given texture type in the G-Buffer textures array
  64285. */
  64286. getTextureIndex(textureType: number): number;
  64287. /**
  64288. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64289. */
  64290. /**
  64291. * Sets whether or not objects positions are enabled for the G buffer.
  64292. */
  64293. enablePosition: boolean;
  64294. /**
  64295. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64296. */
  64297. /**
  64298. * Sets wether or not objects velocities are enabled for the G buffer.
  64299. */
  64300. enableVelocity: boolean;
  64301. /**
  64302. * Gets the scene associated with the buffer.
  64303. */
  64304. readonly scene: Scene;
  64305. /**
  64306. * Gets the ratio used by the buffer during its creation.
  64307. * How big is the buffer related to the main canvas.
  64308. */
  64309. readonly ratio: number;
  64310. /** @hidden */
  64311. static _SceneComponentInitialization: (scene: Scene) => void;
  64312. /**
  64313. * Creates a new G Buffer for the scene
  64314. * @param scene The scene the buffer belongs to
  64315. * @param ratio How big is the buffer related to the main canvas.
  64316. */
  64317. constructor(scene: Scene, ratio?: number);
  64318. /**
  64319. * Checks wether everything is ready to render a submesh to the G buffer.
  64320. * @param subMesh the submesh to check readiness for
  64321. * @param useInstances is the mesh drawn using instance or not
  64322. * @returns true if ready otherwise false
  64323. */
  64324. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64325. /**
  64326. * Gets the current underlying G Buffer.
  64327. * @returns the buffer
  64328. */
  64329. getGBuffer(): MultiRenderTarget;
  64330. /**
  64331. * Gets the number of samples used to render the buffer (anti aliasing).
  64332. */
  64333. /**
  64334. * Sets the number of samples used to render the buffer (anti aliasing).
  64335. */
  64336. samples: number;
  64337. /**
  64338. * Disposes the renderer and frees up associated resources.
  64339. */
  64340. dispose(): void;
  64341. protected _createRenderTargets(): void;
  64342. private _copyBonesTransformationMatrices;
  64343. }
  64344. }
  64345. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  64346. import { Nullable } from "babylonjs/types";
  64347. import { Scene } from "babylonjs/scene";
  64348. import { ISceneComponent } from "babylonjs/sceneComponent";
  64349. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  64350. module "babylonjs/scene" {
  64351. interface Scene {
  64352. /** @hidden (Backing field) */
  64353. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64354. /**
  64355. * Gets or Sets the current geometry buffer associated to the scene.
  64356. */
  64357. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64358. /**
  64359. * Enables a GeometryBufferRender and associates it with the scene
  64360. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64361. * @returns the GeometryBufferRenderer
  64362. */
  64363. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64364. /**
  64365. * Disables the GeometryBufferRender associated with the scene
  64366. */
  64367. disableGeometryBufferRenderer(): void;
  64368. }
  64369. }
  64370. /**
  64371. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64372. * in several rendering techniques.
  64373. */
  64374. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64375. /**
  64376. * The component name helpful to identify the component in the list of scene components.
  64377. */
  64378. readonly name: string;
  64379. /**
  64380. * The scene the component belongs to.
  64381. */
  64382. scene: Scene;
  64383. /**
  64384. * Creates a new instance of the component for the given scene
  64385. * @param scene Defines the scene to register the component in
  64386. */
  64387. constructor(scene: Scene);
  64388. /**
  64389. * Registers the component in a given scene
  64390. */
  64391. register(): void;
  64392. /**
  64393. * Rebuilds the elements related to this component in case of
  64394. * context lost for instance.
  64395. */
  64396. rebuild(): void;
  64397. /**
  64398. * Disposes the component and the associated ressources
  64399. */
  64400. dispose(): void;
  64401. private _gatherRenderTargets;
  64402. }
  64403. }
  64404. declare module "babylonjs/Shaders/motionBlur.fragment" {
  64405. /** @hidden */
  64406. export var motionBlurPixelShader: {
  64407. name: string;
  64408. shader: string;
  64409. };
  64410. }
  64411. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  64412. import { Nullable } from "babylonjs/types";
  64413. import { Camera } from "babylonjs/Cameras/camera";
  64414. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64415. import { Scene } from "babylonjs/scene";
  64416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64417. import "babylonjs/Animations/animatable";
  64418. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64419. import "babylonjs/Shaders/motionBlur.fragment";
  64420. import { Engine } from "babylonjs/Engines/engine";
  64421. /**
  64422. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64423. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64424. * As an example, all you have to do is to create the post-process:
  64425. * var mb = new BABYLON.MotionBlurPostProcess(
  64426. * 'mb', // The name of the effect.
  64427. * scene, // The scene containing the objects to blur according to their velocity.
  64428. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64429. * camera // The camera to apply the render pass to.
  64430. * );
  64431. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64432. */
  64433. export class MotionBlurPostProcess extends PostProcess {
  64434. /**
  64435. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64436. */
  64437. motionStrength: number;
  64438. /**
  64439. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64440. */
  64441. /**
  64442. * Sets the number of iterations to be used for motion blur quality
  64443. */
  64444. motionBlurSamples: number;
  64445. private _motionBlurSamples;
  64446. private _geometryBufferRenderer;
  64447. /**
  64448. * Creates a new instance MotionBlurPostProcess
  64449. * @param name The name of the effect.
  64450. * @param scene The scene containing the objects to blur according to their velocity.
  64451. * @param options The required width/height ratio to downsize to before computing the render pass.
  64452. * @param camera The camera to apply the render pass to.
  64453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64454. * @param engine The engine which the post process will be applied. (default: current engine)
  64455. * @param reusable If the post process can be reused on the same frame. (default: false)
  64456. * @param textureType Type of textures used when performing the post process. (default: 0)
  64457. * @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)
  64458. */
  64459. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64460. /**
  64461. * Excludes the given skinned mesh from computing bones velocities.
  64462. * 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.
  64463. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64464. */
  64465. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64466. /**
  64467. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64468. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64469. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64470. */
  64471. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64472. /**
  64473. * Disposes the post process.
  64474. * @param camera The camera to dispose the post process on.
  64475. */
  64476. dispose(camera?: Camera): void;
  64477. }
  64478. }
  64479. declare module "babylonjs/Shaders/refraction.fragment" {
  64480. /** @hidden */
  64481. export var refractionPixelShader: {
  64482. name: string;
  64483. shader: string;
  64484. };
  64485. }
  64486. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  64487. import { Color3 } from "babylonjs/Maths/math.color";
  64488. import { Camera } from "babylonjs/Cameras/camera";
  64489. import { Texture } from "babylonjs/Materials/Textures/texture";
  64490. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64491. import { Engine } from "babylonjs/Engines/engine";
  64492. import "babylonjs/Shaders/refraction.fragment";
  64493. /**
  64494. * Post process which applies a refractin texture
  64495. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64496. */
  64497. export class RefractionPostProcess extends PostProcess {
  64498. /** the base color of the refraction (used to taint the rendering) */
  64499. color: Color3;
  64500. /** simulated refraction depth */
  64501. depth: number;
  64502. /** the coefficient of the base color (0 to remove base color tainting) */
  64503. colorLevel: number;
  64504. private _refTexture;
  64505. private _ownRefractionTexture;
  64506. /**
  64507. * Gets or sets the refraction texture
  64508. * Please note that you are responsible for disposing the texture if you set it manually
  64509. */
  64510. refractionTexture: Texture;
  64511. /**
  64512. * Initializes the RefractionPostProcess
  64513. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64514. * @param name The name of the effect.
  64515. * @param refractionTextureUrl Url of the refraction texture to use
  64516. * @param color the base color of the refraction (used to taint the rendering)
  64517. * @param depth simulated refraction depth
  64518. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64519. * @param camera The camera to apply the render pass to.
  64520. * @param options The required width/height ratio to downsize to before computing the render pass.
  64521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64522. * @param engine The engine which the post process will be applied. (default: current engine)
  64523. * @param reusable If the post process can be reused on the same frame. (default: false)
  64524. */
  64525. constructor(name: string, refractionTextureUrl: string,
  64526. /** the base color of the refraction (used to taint the rendering) */
  64527. color: Color3,
  64528. /** simulated refraction depth */
  64529. depth: number,
  64530. /** the coefficient of the base color (0 to remove base color tainting) */
  64531. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64532. /**
  64533. * Disposes of the post process
  64534. * @param camera Camera to dispose post process on
  64535. */
  64536. dispose(camera: Camera): void;
  64537. }
  64538. }
  64539. declare module "babylonjs/Shaders/sharpen.fragment" {
  64540. /** @hidden */
  64541. export var sharpenPixelShader: {
  64542. name: string;
  64543. shader: string;
  64544. };
  64545. }
  64546. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  64547. import { Nullable } from "babylonjs/types";
  64548. import { Camera } from "babylonjs/Cameras/camera";
  64549. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  64550. import "babylonjs/Shaders/sharpen.fragment";
  64551. import { Engine } from "babylonjs/Engines/engine";
  64552. /**
  64553. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64554. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64555. */
  64556. export class SharpenPostProcess extends PostProcess {
  64557. /**
  64558. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64559. */
  64560. colorAmount: number;
  64561. /**
  64562. * How much sharpness should be applied (default: 0.3)
  64563. */
  64564. edgeAmount: number;
  64565. /**
  64566. * Creates a new instance ConvolutionPostProcess
  64567. * @param name The name of the effect.
  64568. * @param options The required width/height ratio to downsize to before computing the render pass.
  64569. * @param camera The camera to apply the render pass to.
  64570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64571. * @param engine The engine which the post process will be applied. (default: current engine)
  64572. * @param reusable If the post process can be reused on the same frame. (default: false)
  64573. * @param textureType Type of textures used when performing the post process. (default: 0)
  64574. * @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)
  64575. */
  64576. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64577. }
  64578. }
  64579. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  64580. import { Nullable } from "babylonjs/types";
  64581. import { Camera } from "babylonjs/Cameras/camera";
  64582. import { Engine } from "babylonjs/Engines/engine";
  64583. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64584. import { IInspectable } from "babylonjs/Misc/iInspectable";
  64585. /**
  64586. * PostProcessRenderPipeline
  64587. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64588. */
  64589. export class PostProcessRenderPipeline {
  64590. private engine;
  64591. private _renderEffects;
  64592. private _renderEffectsForIsolatedPass;
  64593. /**
  64594. * List of inspectable custom properties (used by the Inspector)
  64595. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64596. */
  64597. inspectableCustomProperties: IInspectable[];
  64598. /**
  64599. * @hidden
  64600. */
  64601. protected _cameras: Camera[];
  64602. /** @hidden */
  64603. _name: string;
  64604. /**
  64605. * Gets pipeline name
  64606. */
  64607. readonly name: string;
  64608. /** Gets the list of attached cameras */
  64609. readonly cameras: Camera[];
  64610. /**
  64611. * Initializes a PostProcessRenderPipeline
  64612. * @param engine engine to add the pipeline to
  64613. * @param name name of the pipeline
  64614. */
  64615. constructor(engine: Engine, name: string);
  64616. /**
  64617. * Gets the class name
  64618. * @returns "PostProcessRenderPipeline"
  64619. */
  64620. getClassName(): string;
  64621. /**
  64622. * If all the render effects in the pipeline are supported
  64623. */
  64624. readonly isSupported: boolean;
  64625. /**
  64626. * Adds an effect to the pipeline
  64627. * @param renderEffect the effect to add
  64628. */
  64629. addEffect(renderEffect: PostProcessRenderEffect): void;
  64630. /** @hidden */
  64631. _rebuild(): void;
  64632. /** @hidden */
  64633. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64634. /** @hidden */
  64635. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64636. /** @hidden */
  64637. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64638. /** @hidden */
  64639. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64640. /** @hidden */
  64641. _attachCameras(cameras: Camera, unique: boolean): void;
  64642. /** @hidden */
  64643. _attachCameras(cameras: Camera[], unique: boolean): void;
  64644. /** @hidden */
  64645. _detachCameras(cameras: Camera): void;
  64646. /** @hidden */
  64647. _detachCameras(cameras: Nullable<Camera[]>): void;
  64648. /** @hidden */
  64649. _update(): void;
  64650. /** @hidden */
  64651. _reset(): void;
  64652. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64653. /**
  64654. * Disposes of the pipeline
  64655. */
  64656. dispose(): void;
  64657. }
  64658. }
  64659. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  64660. import { Camera } from "babylonjs/Cameras/camera";
  64661. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64662. /**
  64663. * PostProcessRenderPipelineManager class
  64664. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64665. */
  64666. export class PostProcessRenderPipelineManager {
  64667. private _renderPipelines;
  64668. /**
  64669. * Initializes a PostProcessRenderPipelineManager
  64670. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64671. */
  64672. constructor();
  64673. /**
  64674. * Gets the list of supported render pipelines
  64675. */
  64676. readonly supportedPipelines: PostProcessRenderPipeline[];
  64677. /**
  64678. * Adds a pipeline to the manager
  64679. * @param renderPipeline The pipeline to add
  64680. */
  64681. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  64682. /**
  64683. * Attaches a camera to the pipeline
  64684. * @param renderPipelineName The name of the pipeline to attach to
  64685. * @param cameras the camera to attach
  64686. * @param unique if the camera can be attached multiple times to the pipeline
  64687. */
  64688. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  64689. /**
  64690. * Detaches a camera from the pipeline
  64691. * @param renderPipelineName The name of the pipeline to detach from
  64692. * @param cameras the camera to detach
  64693. */
  64694. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  64695. /**
  64696. * Enables an effect by name on a pipeline
  64697. * @param renderPipelineName the name of the pipeline to enable the effect in
  64698. * @param renderEffectName the name of the effect to enable
  64699. * @param cameras the cameras that the effect should be enabled on
  64700. */
  64701. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64702. /**
  64703. * Disables an effect by name on a pipeline
  64704. * @param renderPipelineName the name of the pipeline to disable the effect in
  64705. * @param renderEffectName the name of the effect to disable
  64706. * @param cameras the cameras that the effect should be disabled on
  64707. */
  64708. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  64709. /**
  64710. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  64711. */
  64712. update(): void;
  64713. /** @hidden */
  64714. _rebuild(): void;
  64715. /**
  64716. * Disposes of the manager and pipelines
  64717. */
  64718. dispose(): void;
  64719. }
  64720. }
  64721. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  64722. import { ISceneComponent } from "babylonjs/sceneComponent";
  64723. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64724. import { Scene } from "babylonjs/scene";
  64725. module "babylonjs/scene" {
  64726. interface Scene {
  64727. /** @hidden (Backing field) */
  64728. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64729. /**
  64730. * Gets the postprocess render pipeline manager
  64731. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64732. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64733. */
  64734. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  64735. }
  64736. }
  64737. /**
  64738. * Defines the Render Pipeline scene component responsible to rendering pipelines
  64739. */
  64740. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  64741. /**
  64742. * The component name helpfull to identify the component in the list of scene components.
  64743. */
  64744. readonly name: string;
  64745. /**
  64746. * The scene the component belongs to.
  64747. */
  64748. scene: Scene;
  64749. /**
  64750. * Creates a new instance of the component for the given scene
  64751. * @param scene Defines the scene to register the component in
  64752. */
  64753. constructor(scene: Scene);
  64754. /**
  64755. * Registers the component in a given scene
  64756. */
  64757. register(): void;
  64758. /**
  64759. * Rebuilds the elements related to this component in case of
  64760. * context lost for instance.
  64761. */
  64762. rebuild(): void;
  64763. /**
  64764. * Disposes the component and the associated ressources
  64765. */
  64766. dispose(): void;
  64767. private _gatherRenderTargets;
  64768. }
  64769. }
  64770. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  64771. import { Nullable } from "babylonjs/types";
  64772. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64773. import { Camera } from "babylonjs/Cameras/camera";
  64774. import { IDisposable } from "babylonjs/scene";
  64775. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  64776. import { Scene } from "babylonjs/scene";
  64777. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  64778. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64779. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64780. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  64781. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64782. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64783. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  64784. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64785. import { Animation } from "babylonjs/Animations/animation";
  64786. /**
  64787. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  64788. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  64789. */
  64790. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64791. private _scene;
  64792. private _camerasToBeAttached;
  64793. /**
  64794. * ID of the sharpen post process,
  64795. */
  64796. private readonly SharpenPostProcessId;
  64797. /**
  64798. * @ignore
  64799. * ID of the image processing post process;
  64800. */
  64801. readonly ImageProcessingPostProcessId: string;
  64802. /**
  64803. * @ignore
  64804. * ID of the Fast Approximate Anti-Aliasing post process;
  64805. */
  64806. readonly FxaaPostProcessId: string;
  64807. /**
  64808. * ID of the chromatic aberration post process,
  64809. */
  64810. private readonly ChromaticAberrationPostProcessId;
  64811. /**
  64812. * ID of the grain post process
  64813. */
  64814. private readonly GrainPostProcessId;
  64815. /**
  64816. * Sharpen post process which will apply a sharpen convolution to enhance edges
  64817. */
  64818. sharpen: SharpenPostProcess;
  64819. private _sharpenEffect;
  64820. private bloom;
  64821. /**
  64822. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  64823. */
  64824. depthOfField: DepthOfFieldEffect;
  64825. /**
  64826. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64827. */
  64828. fxaa: FxaaPostProcess;
  64829. /**
  64830. * Image post processing pass used to perform operations such as tone mapping or color grading.
  64831. */
  64832. imageProcessing: ImageProcessingPostProcess;
  64833. /**
  64834. * Chromatic aberration post process which will shift rgb colors in the image
  64835. */
  64836. chromaticAberration: ChromaticAberrationPostProcess;
  64837. private _chromaticAberrationEffect;
  64838. /**
  64839. * Grain post process which add noise to the image
  64840. */
  64841. grain: GrainPostProcess;
  64842. private _grainEffect;
  64843. /**
  64844. * Glow post process which adds a glow to emissive areas of the image
  64845. */
  64846. private _glowLayer;
  64847. /**
  64848. * Animations which can be used to tweak settings over a period of time
  64849. */
  64850. animations: Animation[];
  64851. private _imageProcessingConfigurationObserver;
  64852. private _sharpenEnabled;
  64853. private _bloomEnabled;
  64854. private _depthOfFieldEnabled;
  64855. private _depthOfFieldBlurLevel;
  64856. private _fxaaEnabled;
  64857. private _imageProcessingEnabled;
  64858. private _defaultPipelineTextureType;
  64859. private _bloomScale;
  64860. private _chromaticAberrationEnabled;
  64861. private _grainEnabled;
  64862. private _buildAllowed;
  64863. /**
  64864. * Gets active scene
  64865. */
  64866. readonly scene: Scene;
  64867. /**
  64868. * Enable or disable the sharpen process from the pipeline
  64869. */
  64870. sharpenEnabled: boolean;
  64871. private _resizeObserver;
  64872. private _hardwareScaleLevel;
  64873. private _bloomKernel;
  64874. /**
  64875. * Specifies the size of the bloom blur kernel, relative to the final output size
  64876. */
  64877. bloomKernel: number;
  64878. /**
  64879. * Specifies the weight of the bloom in the final rendering
  64880. */
  64881. private _bloomWeight;
  64882. /**
  64883. * Specifies the luma threshold for the area that will be blurred by the bloom
  64884. */
  64885. private _bloomThreshold;
  64886. private _hdr;
  64887. /**
  64888. * The strength of the bloom.
  64889. */
  64890. bloomWeight: number;
  64891. /**
  64892. * The strength of the bloom.
  64893. */
  64894. bloomThreshold: number;
  64895. /**
  64896. * The scale of the bloom, lower value will provide better performance.
  64897. */
  64898. bloomScale: number;
  64899. /**
  64900. * Enable or disable the bloom from the pipeline
  64901. */
  64902. bloomEnabled: boolean;
  64903. private _rebuildBloom;
  64904. /**
  64905. * If the depth of field is enabled.
  64906. */
  64907. depthOfFieldEnabled: boolean;
  64908. /**
  64909. * Blur level of the depth of field effect. (Higher blur will effect performance)
  64910. */
  64911. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  64912. /**
  64913. * If the anti aliasing is enabled.
  64914. */
  64915. fxaaEnabled: boolean;
  64916. private _samples;
  64917. /**
  64918. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64919. */
  64920. samples: number;
  64921. /**
  64922. * If image processing is enabled.
  64923. */
  64924. imageProcessingEnabled: boolean;
  64925. /**
  64926. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  64927. */
  64928. glowLayerEnabled: boolean;
  64929. /**
  64930. * Gets the glow layer (or null if not defined)
  64931. */
  64932. readonly glowLayer: Nullable<GlowLayer>;
  64933. /**
  64934. * Enable or disable the chromaticAberration process from the pipeline
  64935. */
  64936. chromaticAberrationEnabled: boolean;
  64937. /**
  64938. * Enable or disable the grain process from the pipeline
  64939. */
  64940. grainEnabled: boolean;
  64941. /**
  64942. * @constructor
  64943. * @param name - The rendering pipeline name (default: "")
  64944. * @param hdr - If high dynamic range textures should be used (default: true)
  64945. * @param scene - The scene linked to this pipeline (default: the last created scene)
  64946. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  64947. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  64948. */
  64949. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  64950. /**
  64951. * Get the class name
  64952. * @returns "DefaultRenderingPipeline"
  64953. */
  64954. getClassName(): string;
  64955. /**
  64956. * Force the compilation of the entire pipeline.
  64957. */
  64958. prepare(): void;
  64959. private _hasCleared;
  64960. private _prevPostProcess;
  64961. private _prevPrevPostProcess;
  64962. private _setAutoClearAndTextureSharing;
  64963. private _depthOfFieldSceneObserver;
  64964. private _buildPipeline;
  64965. private _disposePostProcesses;
  64966. /**
  64967. * Adds a camera to the pipeline
  64968. * @param camera the camera to be added
  64969. */
  64970. addCamera(camera: Camera): void;
  64971. /**
  64972. * Removes a camera from the pipeline
  64973. * @param camera the camera to remove
  64974. */
  64975. removeCamera(camera: Camera): void;
  64976. /**
  64977. * Dispose of the pipeline and stop all post processes
  64978. */
  64979. dispose(): void;
  64980. /**
  64981. * Serialize the rendering pipeline (Used when exporting)
  64982. * @returns the serialized object
  64983. */
  64984. serialize(): any;
  64985. /**
  64986. * Parse the serialized pipeline
  64987. * @param source Source pipeline.
  64988. * @param scene The scene to load the pipeline to.
  64989. * @param rootUrl The URL of the serialized pipeline.
  64990. * @returns An instantiated pipeline from the serialized object.
  64991. */
  64992. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  64993. }
  64994. }
  64995. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  64996. /** @hidden */
  64997. export var lensHighlightsPixelShader: {
  64998. name: string;
  64999. shader: string;
  65000. };
  65001. }
  65002. declare module "babylonjs/Shaders/depthOfField.fragment" {
  65003. /** @hidden */
  65004. export var depthOfFieldPixelShader: {
  65005. name: string;
  65006. shader: string;
  65007. };
  65008. }
  65009. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  65010. import { Camera } from "babylonjs/Cameras/camera";
  65011. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65012. import { Scene } from "babylonjs/scene";
  65013. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65014. import "babylonjs/Shaders/chromaticAberration.fragment";
  65015. import "babylonjs/Shaders/lensHighlights.fragment";
  65016. import "babylonjs/Shaders/depthOfField.fragment";
  65017. /**
  65018. * BABYLON.JS Chromatic Aberration GLSL Shader
  65019. * Author: Olivier Guyot
  65020. * Separates very slightly R, G and B colors on the edges of the screen
  65021. * Inspired by Francois Tarlier & Martins Upitis
  65022. */
  65023. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65024. /**
  65025. * @ignore
  65026. * The chromatic aberration PostProcess id in the pipeline
  65027. */
  65028. LensChromaticAberrationEffect: string;
  65029. /**
  65030. * @ignore
  65031. * The highlights enhancing PostProcess id in the pipeline
  65032. */
  65033. HighlightsEnhancingEffect: string;
  65034. /**
  65035. * @ignore
  65036. * The depth-of-field PostProcess id in the pipeline
  65037. */
  65038. LensDepthOfFieldEffect: string;
  65039. private _scene;
  65040. private _depthTexture;
  65041. private _grainTexture;
  65042. private _chromaticAberrationPostProcess;
  65043. private _highlightsPostProcess;
  65044. private _depthOfFieldPostProcess;
  65045. private _edgeBlur;
  65046. private _grainAmount;
  65047. private _chromaticAberration;
  65048. private _distortion;
  65049. private _highlightsGain;
  65050. private _highlightsThreshold;
  65051. private _dofDistance;
  65052. private _dofAperture;
  65053. private _dofDarken;
  65054. private _dofPentagon;
  65055. private _blurNoise;
  65056. /**
  65057. * @constructor
  65058. *
  65059. * Effect parameters are as follow:
  65060. * {
  65061. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65062. * edge_blur: number; // from 0 to x (1 for realism)
  65063. * distortion: number; // from 0 to x (1 for realism)
  65064. * grain_amount: number; // from 0 to 1
  65065. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65066. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65067. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65068. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65069. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65070. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65071. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65072. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65073. * }
  65074. * Note: if an effect parameter is unset, effect is disabled
  65075. *
  65076. * @param name The rendering pipeline name
  65077. * @param parameters - An object containing all parameters (see above)
  65078. * @param scene The scene linked to this pipeline
  65079. * @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)
  65080. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65081. */
  65082. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65083. /**
  65084. * Get the class name
  65085. * @returns "LensRenderingPipeline"
  65086. */
  65087. getClassName(): string;
  65088. /**
  65089. * Gets associated scene
  65090. */
  65091. readonly scene: Scene;
  65092. /**
  65093. * Gets or sets the edge blur
  65094. */
  65095. edgeBlur: number;
  65096. /**
  65097. * Gets or sets the grain amount
  65098. */
  65099. grainAmount: number;
  65100. /**
  65101. * Gets or sets the chromatic aberration amount
  65102. */
  65103. chromaticAberration: number;
  65104. /**
  65105. * Gets or sets the depth of field aperture
  65106. */
  65107. dofAperture: number;
  65108. /**
  65109. * Gets or sets the edge distortion
  65110. */
  65111. edgeDistortion: number;
  65112. /**
  65113. * Gets or sets the depth of field distortion
  65114. */
  65115. dofDistortion: number;
  65116. /**
  65117. * Gets or sets the darken out of focus amount
  65118. */
  65119. darkenOutOfFocus: number;
  65120. /**
  65121. * Gets or sets a boolean indicating if blur noise is enabled
  65122. */
  65123. blurNoise: boolean;
  65124. /**
  65125. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65126. */
  65127. pentagonBokeh: boolean;
  65128. /**
  65129. * Gets or sets the highlight grain amount
  65130. */
  65131. highlightsGain: number;
  65132. /**
  65133. * Gets or sets the highlight threshold
  65134. */
  65135. highlightsThreshold: number;
  65136. /**
  65137. * Sets the amount of blur at the edges
  65138. * @param amount blur amount
  65139. */
  65140. setEdgeBlur(amount: number): void;
  65141. /**
  65142. * Sets edge blur to 0
  65143. */
  65144. disableEdgeBlur(): void;
  65145. /**
  65146. * Sets the amout of grain
  65147. * @param amount Amount of grain
  65148. */
  65149. setGrainAmount(amount: number): void;
  65150. /**
  65151. * Set grain amount to 0
  65152. */
  65153. disableGrain(): void;
  65154. /**
  65155. * Sets the chromatic aberration amount
  65156. * @param amount amount of chromatic aberration
  65157. */
  65158. setChromaticAberration(amount: number): void;
  65159. /**
  65160. * Sets chromatic aberration amount to 0
  65161. */
  65162. disableChromaticAberration(): void;
  65163. /**
  65164. * Sets the EdgeDistortion amount
  65165. * @param amount amount of EdgeDistortion
  65166. */
  65167. setEdgeDistortion(amount: number): void;
  65168. /**
  65169. * Sets edge distortion to 0
  65170. */
  65171. disableEdgeDistortion(): void;
  65172. /**
  65173. * Sets the FocusDistance amount
  65174. * @param amount amount of FocusDistance
  65175. */
  65176. setFocusDistance(amount: number): void;
  65177. /**
  65178. * Disables depth of field
  65179. */
  65180. disableDepthOfField(): void;
  65181. /**
  65182. * Sets the Aperture amount
  65183. * @param amount amount of Aperture
  65184. */
  65185. setAperture(amount: number): void;
  65186. /**
  65187. * Sets the DarkenOutOfFocus amount
  65188. * @param amount amount of DarkenOutOfFocus
  65189. */
  65190. setDarkenOutOfFocus(amount: number): void;
  65191. private _pentagonBokehIsEnabled;
  65192. /**
  65193. * Creates a pentagon bokeh effect
  65194. */
  65195. enablePentagonBokeh(): void;
  65196. /**
  65197. * Disables the pentagon bokeh effect
  65198. */
  65199. disablePentagonBokeh(): void;
  65200. /**
  65201. * Enables noise blur
  65202. */
  65203. enableNoiseBlur(): void;
  65204. /**
  65205. * Disables noise blur
  65206. */
  65207. disableNoiseBlur(): void;
  65208. /**
  65209. * Sets the HighlightsGain amount
  65210. * @param amount amount of HighlightsGain
  65211. */
  65212. setHighlightsGain(amount: number): void;
  65213. /**
  65214. * Sets the HighlightsThreshold amount
  65215. * @param amount amount of HighlightsThreshold
  65216. */
  65217. setHighlightsThreshold(amount: number): void;
  65218. /**
  65219. * Disables highlights
  65220. */
  65221. disableHighlights(): void;
  65222. /**
  65223. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65224. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65225. */
  65226. dispose(disableDepthRender?: boolean): void;
  65227. private _createChromaticAberrationPostProcess;
  65228. private _createHighlightsPostProcess;
  65229. private _createDepthOfFieldPostProcess;
  65230. private _createGrainTexture;
  65231. }
  65232. }
  65233. declare module "babylonjs/Shaders/ssao2.fragment" {
  65234. /** @hidden */
  65235. export var ssao2PixelShader: {
  65236. name: string;
  65237. shader: string;
  65238. };
  65239. }
  65240. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  65241. /** @hidden */
  65242. export var ssaoCombinePixelShader: {
  65243. name: string;
  65244. shader: string;
  65245. };
  65246. }
  65247. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  65248. import { Camera } from "babylonjs/Cameras/camera";
  65249. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65250. import { Scene } from "babylonjs/scene";
  65251. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65252. import "babylonjs/Shaders/ssao2.fragment";
  65253. import "babylonjs/Shaders/ssaoCombine.fragment";
  65254. /**
  65255. * Render pipeline to produce ssao effect
  65256. */
  65257. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65258. /**
  65259. * @ignore
  65260. * The PassPostProcess id in the pipeline that contains the original scene color
  65261. */
  65262. SSAOOriginalSceneColorEffect: string;
  65263. /**
  65264. * @ignore
  65265. * The SSAO PostProcess id in the pipeline
  65266. */
  65267. SSAORenderEffect: string;
  65268. /**
  65269. * @ignore
  65270. * The horizontal blur PostProcess id in the pipeline
  65271. */
  65272. SSAOBlurHRenderEffect: string;
  65273. /**
  65274. * @ignore
  65275. * The vertical blur PostProcess id in the pipeline
  65276. */
  65277. SSAOBlurVRenderEffect: string;
  65278. /**
  65279. * @ignore
  65280. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65281. */
  65282. SSAOCombineRenderEffect: string;
  65283. /**
  65284. * The output strength of the SSAO post-process. Default value is 1.0.
  65285. */
  65286. totalStrength: number;
  65287. /**
  65288. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65289. */
  65290. maxZ: number;
  65291. /**
  65292. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65293. */
  65294. minZAspect: number;
  65295. private _samples;
  65296. /**
  65297. * Number of samples used for the SSAO calculations. Default value is 8
  65298. */
  65299. samples: number;
  65300. private _textureSamples;
  65301. /**
  65302. * Number of samples to use for antialiasing
  65303. */
  65304. textureSamples: number;
  65305. /**
  65306. * Ratio object used for SSAO ratio and blur ratio
  65307. */
  65308. private _ratio;
  65309. /**
  65310. * Dynamically generated sphere sampler.
  65311. */
  65312. private _sampleSphere;
  65313. /**
  65314. * Blur filter offsets
  65315. */
  65316. private _samplerOffsets;
  65317. private _expensiveBlur;
  65318. /**
  65319. * If bilateral blur should be used
  65320. */
  65321. expensiveBlur: boolean;
  65322. /**
  65323. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65324. */
  65325. radius: number;
  65326. /**
  65327. * The base color of the SSAO post-process
  65328. * The final result is "base + ssao" between [0, 1]
  65329. */
  65330. base: number;
  65331. /**
  65332. * Support test.
  65333. */
  65334. static readonly IsSupported: boolean;
  65335. private _scene;
  65336. private _depthTexture;
  65337. private _normalTexture;
  65338. private _randomTexture;
  65339. private _originalColorPostProcess;
  65340. private _ssaoPostProcess;
  65341. private _blurHPostProcess;
  65342. private _blurVPostProcess;
  65343. private _ssaoCombinePostProcess;
  65344. /**
  65345. * Gets active scene
  65346. */
  65347. readonly scene: Scene;
  65348. /**
  65349. * @constructor
  65350. * @param name The rendering pipeline name
  65351. * @param scene The scene linked to this pipeline
  65352. * @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 }
  65353. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65354. */
  65355. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65356. /**
  65357. * Get the class name
  65358. * @returns "SSAO2RenderingPipeline"
  65359. */
  65360. getClassName(): string;
  65361. /**
  65362. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65363. */
  65364. dispose(disableGeometryBufferRenderer?: boolean): void;
  65365. private _createBlurPostProcess;
  65366. /** @hidden */
  65367. _rebuild(): void;
  65368. private _bits;
  65369. private _radicalInverse_VdC;
  65370. private _hammersley;
  65371. private _hemisphereSample_uniform;
  65372. private _generateHemisphere;
  65373. private _createSSAOPostProcess;
  65374. private _createSSAOCombinePostProcess;
  65375. private _createRandomTexture;
  65376. /**
  65377. * Serialize the rendering pipeline (Used when exporting)
  65378. * @returns the serialized object
  65379. */
  65380. serialize(): any;
  65381. /**
  65382. * Parse the serialized pipeline
  65383. * @param source Source pipeline.
  65384. * @param scene The scene to load the pipeline to.
  65385. * @param rootUrl The URL of the serialized pipeline.
  65386. * @returns An instantiated pipeline from the serialized object.
  65387. */
  65388. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65389. }
  65390. }
  65391. declare module "babylonjs/Shaders/ssao.fragment" {
  65392. /** @hidden */
  65393. export var ssaoPixelShader: {
  65394. name: string;
  65395. shader: string;
  65396. };
  65397. }
  65398. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  65399. import { Camera } from "babylonjs/Cameras/camera";
  65400. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65401. import { Scene } from "babylonjs/scene";
  65402. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65403. import "babylonjs/Shaders/ssao.fragment";
  65404. import "babylonjs/Shaders/ssaoCombine.fragment";
  65405. /**
  65406. * Render pipeline to produce ssao effect
  65407. */
  65408. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65409. /**
  65410. * @ignore
  65411. * The PassPostProcess id in the pipeline that contains the original scene color
  65412. */
  65413. SSAOOriginalSceneColorEffect: string;
  65414. /**
  65415. * @ignore
  65416. * The SSAO PostProcess id in the pipeline
  65417. */
  65418. SSAORenderEffect: string;
  65419. /**
  65420. * @ignore
  65421. * The horizontal blur PostProcess id in the pipeline
  65422. */
  65423. SSAOBlurHRenderEffect: string;
  65424. /**
  65425. * @ignore
  65426. * The vertical blur PostProcess id in the pipeline
  65427. */
  65428. SSAOBlurVRenderEffect: string;
  65429. /**
  65430. * @ignore
  65431. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65432. */
  65433. SSAOCombineRenderEffect: string;
  65434. /**
  65435. * The output strength of the SSAO post-process. Default value is 1.0.
  65436. */
  65437. totalStrength: number;
  65438. /**
  65439. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65440. */
  65441. radius: number;
  65442. /**
  65443. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65444. * Must not be equal to fallOff and superior to fallOff.
  65445. * Default value is 0.0075
  65446. */
  65447. area: number;
  65448. /**
  65449. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65450. * Must not be equal to area and inferior to area.
  65451. * Default value is 0.000001
  65452. */
  65453. fallOff: number;
  65454. /**
  65455. * The base color of the SSAO post-process
  65456. * The final result is "base + ssao" between [0, 1]
  65457. */
  65458. base: number;
  65459. private _scene;
  65460. private _depthTexture;
  65461. private _randomTexture;
  65462. private _originalColorPostProcess;
  65463. private _ssaoPostProcess;
  65464. private _blurHPostProcess;
  65465. private _blurVPostProcess;
  65466. private _ssaoCombinePostProcess;
  65467. private _firstUpdate;
  65468. /**
  65469. * Gets active scene
  65470. */
  65471. readonly scene: Scene;
  65472. /**
  65473. * @constructor
  65474. * @param name - The rendering pipeline name
  65475. * @param scene - The scene linked to this pipeline
  65476. * @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 }
  65477. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65478. */
  65479. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65480. /**
  65481. * Get the class name
  65482. * @returns "SSAORenderingPipeline"
  65483. */
  65484. getClassName(): string;
  65485. /**
  65486. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65487. */
  65488. dispose(disableDepthRender?: boolean): void;
  65489. private _createBlurPostProcess;
  65490. /** @hidden */
  65491. _rebuild(): void;
  65492. private _createSSAOPostProcess;
  65493. private _createSSAOCombinePostProcess;
  65494. private _createRandomTexture;
  65495. }
  65496. }
  65497. declare module "babylonjs/Shaders/standard.fragment" {
  65498. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  65499. /** @hidden */
  65500. export var standardPixelShader: {
  65501. name: string;
  65502. shader: string;
  65503. };
  65504. }
  65505. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  65506. import { Nullable } from "babylonjs/types";
  65507. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65508. import { Camera } from "babylonjs/Cameras/camera";
  65509. import { Texture } from "babylonjs/Materials/Textures/texture";
  65510. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65511. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65512. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  65513. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  65514. import { IDisposable } from "babylonjs/scene";
  65515. import { SpotLight } from "babylonjs/Lights/spotLight";
  65516. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  65517. import { Scene } from "babylonjs/scene";
  65518. import { Animation } from "babylonjs/Animations/animation";
  65519. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65520. import "babylonjs/Shaders/standard.fragment";
  65521. /**
  65522. * Standard rendering pipeline
  65523. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65524. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65525. */
  65526. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65527. /**
  65528. * Public members
  65529. */
  65530. /**
  65531. * Post-process which contains the original scene color before the pipeline applies all the effects
  65532. */
  65533. originalPostProcess: Nullable<PostProcess>;
  65534. /**
  65535. * Post-process used to down scale an image x4
  65536. */
  65537. downSampleX4PostProcess: Nullable<PostProcess>;
  65538. /**
  65539. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65540. */
  65541. brightPassPostProcess: Nullable<PostProcess>;
  65542. /**
  65543. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65544. */
  65545. blurHPostProcesses: PostProcess[];
  65546. /**
  65547. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65548. */
  65549. blurVPostProcesses: PostProcess[];
  65550. /**
  65551. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65552. */
  65553. textureAdderPostProcess: Nullable<PostProcess>;
  65554. /**
  65555. * Post-process used to create volumetric lighting effect
  65556. */
  65557. volumetricLightPostProcess: Nullable<PostProcess>;
  65558. /**
  65559. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65560. */
  65561. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65562. /**
  65563. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65564. */
  65565. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65566. /**
  65567. * Post-process used to merge the volumetric light effect and the real scene color
  65568. */
  65569. volumetricLightMergePostProces: Nullable<PostProcess>;
  65570. /**
  65571. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65572. */
  65573. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65574. /**
  65575. * Base post-process used to calculate the average luminance of the final image for HDR
  65576. */
  65577. luminancePostProcess: Nullable<PostProcess>;
  65578. /**
  65579. * Post-processes used to create down sample post-processes in order to get
  65580. * the average luminance of the final image for HDR
  65581. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65582. */
  65583. luminanceDownSamplePostProcesses: PostProcess[];
  65584. /**
  65585. * Post-process used to create a HDR effect (light adaptation)
  65586. */
  65587. hdrPostProcess: Nullable<PostProcess>;
  65588. /**
  65589. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65590. */
  65591. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65592. /**
  65593. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65594. */
  65595. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65596. /**
  65597. * Post-process used to merge the final HDR post-process and the real scene color
  65598. */
  65599. hdrFinalPostProcess: Nullable<PostProcess>;
  65600. /**
  65601. * Post-process used to create a lens flare effect
  65602. */
  65603. lensFlarePostProcess: Nullable<PostProcess>;
  65604. /**
  65605. * Post-process that merges the result of the lens flare post-process and the real scene color
  65606. */
  65607. lensFlareComposePostProcess: Nullable<PostProcess>;
  65608. /**
  65609. * Post-process used to create a motion blur effect
  65610. */
  65611. motionBlurPostProcess: Nullable<PostProcess>;
  65612. /**
  65613. * Post-process used to create a depth of field effect
  65614. */
  65615. depthOfFieldPostProcess: Nullable<PostProcess>;
  65616. /**
  65617. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65618. */
  65619. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65620. /**
  65621. * Represents the brightness threshold in order to configure the illuminated surfaces
  65622. */
  65623. brightThreshold: number;
  65624. /**
  65625. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65626. */
  65627. blurWidth: number;
  65628. /**
  65629. * Sets if the blur for highlighted surfaces must be only horizontal
  65630. */
  65631. horizontalBlur: boolean;
  65632. /**
  65633. * Gets the overall exposure used by the pipeline
  65634. */
  65635. /**
  65636. * Sets the overall exposure used by the pipeline
  65637. */
  65638. exposure: number;
  65639. /**
  65640. * Texture used typically to simulate "dirty" on camera lens
  65641. */
  65642. lensTexture: Nullable<Texture>;
  65643. /**
  65644. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65645. */
  65646. volumetricLightCoefficient: number;
  65647. /**
  65648. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65649. */
  65650. volumetricLightPower: number;
  65651. /**
  65652. * Used the set the blur intensity to smooth the volumetric lights
  65653. */
  65654. volumetricLightBlurScale: number;
  65655. /**
  65656. * Light (spot or directional) used to generate the volumetric lights rays
  65657. * The source light must have a shadow generate so the pipeline can get its
  65658. * depth map
  65659. */
  65660. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65661. /**
  65662. * For eye adaptation, represents the minimum luminance the eye can see
  65663. */
  65664. hdrMinimumLuminance: number;
  65665. /**
  65666. * For eye adaptation, represents the decrease luminance speed
  65667. */
  65668. hdrDecreaseRate: number;
  65669. /**
  65670. * For eye adaptation, represents the increase luminance speed
  65671. */
  65672. hdrIncreaseRate: number;
  65673. /**
  65674. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65675. */
  65676. /**
  65677. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  65678. */
  65679. hdrAutoExposure: boolean;
  65680. /**
  65681. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  65682. */
  65683. lensColorTexture: Nullable<Texture>;
  65684. /**
  65685. * The overall strengh for the lens flare effect
  65686. */
  65687. lensFlareStrength: number;
  65688. /**
  65689. * Dispersion coefficient for lens flare ghosts
  65690. */
  65691. lensFlareGhostDispersal: number;
  65692. /**
  65693. * Main lens flare halo width
  65694. */
  65695. lensFlareHaloWidth: number;
  65696. /**
  65697. * Based on the lens distortion effect, defines how much the lens flare result
  65698. * is distorted
  65699. */
  65700. lensFlareDistortionStrength: number;
  65701. /**
  65702. * Configures the blur intensity used for for lens flare (halo)
  65703. */
  65704. lensFlareBlurWidth: number;
  65705. /**
  65706. * Lens star texture must be used to simulate rays on the flares and is available
  65707. * in the documentation
  65708. */
  65709. lensStarTexture: Nullable<Texture>;
  65710. /**
  65711. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  65712. * flare effect by taking account of the dirt texture
  65713. */
  65714. lensFlareDirtTexture: Nullable<Texture>;
  65715. /**
  65716. * Represents the focal length for the depth of field effect
  65717. */
  65718. depthOfFieldDistance: number;
  65719. /**
  65720. * Represents the blur intensity for the blurred part of the depth of field effect
  65721. */
  65722. depthOfFieldBlurWidth: number;
  65723. /**
  65724. * Gets how much the image is blurred by the movement while using the motion blur post-process
  65725. */
  65726. /**
  65727. * Sets how much the image is blurred by the movement while using the motion blur post-process
  65728. */
  65729. motionStrength: number;
  65730. /**
  65731. * Gets wether or not the motion blur post-process is object based or screen based.
  65732. */
  65733. /**
  65734. * Sets wether or not the motion blur post-process should be object based or screen based
  65735. */
  65736. objectBasedMotionBlur: boolean;
  65737. /**
  65738. * List of animations for the pipeline (IAnimatable implementation)
  65739. */
  65740. animations: Animation[];
  65741. /**
  65742. * Private members
  65743. */
  65744. private _scene;
  65745. private _currentDepthOfFieldSource;
  65746. private _basePostProcess;
  65747. private _fixedExposure;
  65748. private _currentExposure;
  65749. private _hdrAutoExposure;
  65750. private _hdrCurrentLuminance;
  65751. private _motionStrength;
  65752. private _isObjectBasedMotionBlur;
  65753. private _floatTextureType;
  65754. private _camerasToBeAttached;
  65755. private _ratio;
  65756. private _bloomEnabled;
  65757. private _depthOfFieldEnabled;
  65758. private _vlsEnabled;
  65759. private _lensFlareEnabled;
  65760. private _hdrEnabled;
  65761. private _motionBlurEnabled;
  65762. private _fxaaEnabled;
  65763. private _motionBlurSamples;
  65764. private _volumetricLightStepsCount;
  65765. private _samples;
  65766. /**
  65767. * @ignore
  65768. * Specifies if the bloom pipeline is enabled
  65769. */
  65770. BloomEnabled: boolean;
  65771. /**
  65772. * @ignore
  65773. * Specifies if the depth of field pipeline is enabed
  65774. */
  65775. DepthOfFieldEnabled: boolean;
  65776. /**
  65777. * @ignore
  65778. * Specifies if the lens flare pipeline is enabed
  65779. */
  65780. LensFlareEnabled: boolean;
  65781. /**
  65782. * @ignore
  65783. * Specifies if the HDR pipeline is enabled
  65784. */
  65785. HDREnabled: boolean;
  65786. /**
  65787. * @ignore
  65788. * Specifies if the volumetric lights scattering effect is enabled
  65789. */
  65790. VLSEnabled: boolean;
  65791. /**
  65792. * @ignore
  65793. * Specifies if the motion blur effect is enabled
  65794. */
  65795. MotionBlurEnabled: boolean;
  65796. /**
  65797. * Specifies if anti-aliasing is enabled
  65798. */
  65799. fxaaEnabled: boolean;
  65800. /**
  65801. * Specifies the number of steps used to calculate the volumetric lights
  65802. * Typically in interval [50, 200]
  65803. */
  65804. volumetricLightStepsCount: number;
  65805. /**
  65806. * Specifies the number of samples used for the motion blur effect
  65807. * Typically in interval [16, 64]
  65808. */
  65809. motionBlurSamples: number;
  65810. /**
  65811. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65812. */
  65813. samples: number;
  65814. /**
  65815. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65816. * @constructor
  65817. * @param name The rendering pipeline name
  65818. * @param scene The scene linked to this pipeline
  65819. * @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)
  65820. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  65821. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65822. */
  65823. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  65824. private _buildPipeline;
  65825. private _createDownSampleX4PostProcess;
  65826. private _createBrightPassPostProcess;
  65827. private _createBlurPostProcesses;
  65828. private _createTextureAdderPostProcess;
  65829. private _createVolumetricLightPostProcess;
  65830. private _createLuminancePostProcesses;
  65831. private _createHdrPostProcess;
  65832. private _createLensFlarePostProcess;
  65833. private _createDepthOfFieldPostProcess;
  65834. private _createMotionBlurPostProcess;
  65835. private _getDepthTexture;
  65836. private _disposePostProcesses;
  65837. /**
  65838. * Dispose of the pipeline and stop all post processes
  65839. */
  65840. dispose(): void;
  65841. /**
  65842. * Serialize the rendering pipeline (Used when exporting)
  65843. * @returns the serialized object
  65844. */
  65845. serialize(): any;
  65846. /**
  65847. * Parse the serialized pipeline
  65848. * @param source Source pipeline.
  65849. * @param scene The scene to load the pipeline to.
  65850. * @param rootUrl The URL of the serialized pipeline.
  65851. * @returns An instantiated pipeline from the serialized object.
  65852. */
  65853. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  65854. /**
  65855. * Luminance steps
  65856. */
  65857. static LuminanceSteps: number;
  65858. }
  65859. }
  65860. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  65861. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  65862. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  65863. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  65864. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  65865. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  65866. }
  65867. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  65868. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  65869. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  65870. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  65871. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  65872. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  65873. }
  65874. declare module "babylonjs/Shaders/tonemap.fragment" {
  65875. /** @hidden */
  65876. export var tonemapPixelShader: {
  65877. name: string;
  65878. shader: string;
  65879. };
  65880. }
  65881. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  65882. import { Camera } from "babylonjs/Cameras/camera";
  65883. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65884. import "babylonjs/Shaders/tonemap.fragment";
  65885. import { Engine } from "babylonjs/Engines/engine";
  65886. /** Defines operator used for tonemapping */
  65887. export enum TonemappingOperator {
  65888. /** Hable */
  65889. Hable = 0,
  65890. /** Reinhard */
  65891. Reinhard = 1,
  65892. /** HejiDawson */
  65893. HejiDawson = 2,
  65894. /** Photographic */
  65895. Photographic = 3
  65896. }
  65897. /**
  65898. * Defines a post process to apply tone mapping
  65899. */
  65900. export class TonemapPostProcess extends PostProcess {
  65901. private _operator;
  65902. /** Defines the required exposure adjustement */
  65903. exposureAdjustment: number;
  65904. /**
  65905. * Creates a new TonemapPostProcess
  65906. * @param name defines the name of the postprocess
  65907. * @param _operator defines the operator to use
  65908. * @param exposureAdjustment defines the required exposure adjustement
  65909. * @param camera defines the camera to use (can be null)
  65910. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  65911. * @param engine defines the hosting engine (can be ignore if camera is set)
  65912. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65913. */
  65914. constructor(name: string, _operator: TonemappingOperator,
  65915. /** Defines the required exposure adjustement */
  65916. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  65917. }
  65918. }
  65919. declare module "babylonjs/Shaders/depth.vertex" {
  65920. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65921. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65922. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65923. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65924. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65925. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65926. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65927. /** @hidden */
  65928. export var depthVertexShader: {
  65929. name: string;
  65930. shader: string;
  65931. };
  65932. }
  65933. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  65934. /** @hidden */
  65935. export var volumetricLightScatteringPixelShader: {
  65936. name: string;
  65937. shader: string;
  65938. };
  65939. }
  65940. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  65941. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65942. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65943. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65944. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  65945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  65946. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  65947. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65948. /** @hidden */
  65949. export var volumetricLightScatteringPassVertexShader: {
  65950. name: string;
  65951. shader: string;
  65952. };
  65953. }
  65954. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  65955. /** @hidden */
  65956. export var volumetricLightScatteringPassPixelShader: {
  65957. name: string;
  65958. shader: string;
  65959. };
  65960. }
  65961. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  65962. import { Vector3 } from "babylonjs/Maths/math.vector";
  65963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65964. import { Mesh } from "babylonjs/Meshes/mesh";
  65965. import { Camera } from "babylonjs/Cameras/camera";
  65966. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65967. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  65968. import { Scene } from "babylonjs/scene";
  65969. import "babylonjs/Meshes/Builders/planeBuilder";
  65970. import "babylonjs/Shaders/depth.vertex";
  65971. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  65972. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  65973. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  65974. import { Engine } from "babylonjs/Engines/engine";
  65975. /**
  65976. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  65977. */
  65978. export class VolumetricLightScatteringPostProcess extends PostProcess {
  65979. private _volumetricLightScatteringPass;
  65980. private _volumetricLightScatteringRTT;
  65981. private _viewPort;
  65982. private _screenCoordinates;
  65983. private _cachedDefines;
  65984. /**
  65985. * If not undefined, the mesh position is computed from the attached node position
  65986. */
  65987. attachedNode: {
  65988. position: Vector3;
  65989. };
  65990. /**
  65991. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  65992. */
  65993. customMeshPosition: Vector3;
  65994. /**
  65995. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  65996. */
  65997. useCustomMeshPosition: boolean;
  65998. /**
  65999. * If the post-process should inverse the light scattering direction
  66000. */
  66001. invert: boolean;
  66002. /**
  66003. * The internal mesh used by the post-process
  66004. */
  66005. mesh: Mesh;
  66006. /**
  66007. * @hidden
  66008. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66009. */
  66010. useDiffuseColor: boolean;
  66011. /**
  66012. * Array containing the excluded meshes not rendered in the internal pass
  66013. */
  66014. excludedMeshes: AbstractMesh[];
  66015. /**
  66016. * Controls the overall intensity of the post-process
  66017. */
  66018. exposure: number;
  66019. /**
  66020. * Dissipates each sample's contribution in range [0, 1]
  66021. */
  66022. decay: number;
  66023. /**
  66024. * Controls the overall intensity of each sample
  66025. */
  66026. weight: number;
  66027. /**
  66028. * Controls the density of each sample
  66029. */
  66030. density: number;
  66031. /**
  66032. * @constructor
  66033. * @param name The post-process name
  66034. * @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)
  66035. * @param camera The camera that the post-process will be attached to
  66036. * @param mesh The mesh used to create the light scattering
  66037. * @param samples The post-process quality, default 100
  66038. * @param samplingModeThe post-process filtering mode
  66039. * @param engine The babylon engine
  66040. * @param reusable If the post-process is reusable
  66041. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66042. */
  66043. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66044. /**
  66045. * Returns the string "VolumetricLightScatteringPostProcess"
  66046. * @returns "VolumetricLightScatteringPostProcess"
  66047. */
  66048. getClassName(): string;
  66049. private _isReady;
  66050. /**
  66051. * Sets the new light position for light scattering effect
  66052. * @param position The new custom light position
  66053. */
  66054. setCustomMeshPosition(position: Vector3): void;
  66055. /**
  66056. * Returns the light position for light scattering effect
  66057. * @return Vector3 The custom light position
  66058. */
  66059. getCustomMeshPosition(): Vector3;
  66060. /**
  66061. * Disposes the internal assets and detaches the post-process from the camera
  66062. */
  66063. dispose(camera: Camera): void;
  66064. /**
  66065. * Returns the render target texture used by the post-process
  66066. * @return the render target texture used by the post-process
  66067. */
  66068. getPass(): RenderTargetTexture;
  66069. private _meshExcluded;
  66070. private _createPass;
  66071. private _updateMeshScreenCoordinates;
  66072. /**
  66073. * Creates a default mesh for the Volumeric Light Scattering post-process
  66074. * @param name The mesh name
  66075. * @param scene The scene where to create the mesh
  66076. * @return the default mesh
  66077. */
  66078. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66079. }
  66080. }
  66081. declare module "babylonjs/PostProcesses/index" {
  66082. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  66083. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  66084. export * from "babylonjs/PostProcesses/bloomEffect";
  66085. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  66086. export * from "babylonjs/PostProcesses/blurPostProcess";
  66087. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  66088. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  66089. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  66090. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  66091. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66092. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  66093. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  66094. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  66095. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66096. export * from "babylonjs/PostProcesses/filterPostProcess";
  66097. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  66098. export * from "babylonjs/PostProcesses/grainPostProcess";
  66099. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  66100. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  66101. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  66102. export * from "babylonjs/PostProcesses/passPostProcess";
  66103. export * from "babylonjs/PostProcesses/postProcess";
  66104. export * from "babylonjs/PostProcesses/postProcessManager";
  66105. export * from "babylonjs/PostProcesses/refractionPostProcess";
  66106. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  66107. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  66108. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  66109. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  66110. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  66111. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  66112. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  66113. }
  66114. declare module "babylonjs/Probes/index" {
  66115. export * from "babylonjs/Probes/reflectionProbe";
  66116. }
  66117. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  66118. import { Scene } from "babylonjs/scene";
  66119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66120. import { SmartArray } from "babylonjs/Misc/smartArray";
  66121. import { ISceneComponent } from "babylonjs/sceneComponent";
  66122. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  66123. import "babylonjs/Meshes/Builders/boxBuilder";
  66124. import "babylonjs/Shaders/color.fragment";
  66125. import "babylonjs/Shaders/color.vertex";
  66126. import { Color3 } from "babylonjs/Maths/math.color";
  66127. module "babylonjs/scene" {
  66128. interface Scene {
  66129. /** @hidden (Backing field) */
  66130. _boundingBoxRenderer: BoundingBoxRenderer;
  66131. /** @hidden (Backing field) */
  66132. _forceShowBoundingBoxes: boolean;
  66133. /**
  66134. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66135. */
  66136. forceShowBoundingBoxes: boolean;
  66137. /**
  66138. * Gets the bounding box renderer associated with the scene
  66139. * @returns a BoundingBoxRenderer
  66140. */
  66141. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66142. }
  66143. }
  66144. module "babylonjs/Meshes/abstractMesh" {
  66145. interface AbstractMesh {
  66146. /** @hidden (Backing field) */
  66147. _showBoundingBox: boolean;
  66148. /**
  66149. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66150. */
  66151. showBoundingBox: boolean;
  66152. }
  66153. }
  66154. /**
  66155. * Component responsible of rendering the bounding box of the meshes in a scene.
  66156. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66157. */
  66158. export class BoundingBoxRenderer implements ISceneComponent {
  66159. /**
  66160. * The component name helpfull to identify the component in the list of scene components.
  66161. */
  66162. readonly name: string;
  66163. /**
  66164. * The scene the component belongs to.
  66165. */
  66166. scene: Scene;
  66167. /**
  66168. * Color of the bounding box lines placed in front of an object
  66169. */
  66170. frontColor: Color3;
  66171. /**
  66172. * Color of the bounding box lines placed behind an object
  66173. */
  66174. backColor: Color3;
  66175. /**
  66176. * Defines if the renderer should show the back lines or not
  66177. */
  66178. showBackLines: boolean;
  66179. /**
  66180. * @hidden
  66181. */
  66182. renderList: SmartArray<BoundingBox>;
  66183. private _colorShader;
  66184. private _vertexBuffers;
  66185. private _indexBuffer;
  66186. private _fillIndexBuffer;
  66187. private _fillIndexData;
  66188. /**
  66189. * Instantiates a new bounding box renderer in a scene.
  66190. * @param scene the scene the renderer renders in
  66191. */
  66192. constructor(scene: Scene);
  66193. /**
  66194. * Registers the component in a given scene
  66195. */
  66196. register(): void;
  66197. private _evaluateSubMesh;
  66198. private _activeMesh;
  66199. private _prepareRessources;
  66200. private _createIndexBuffer;
  66201. /**
  66202. * Rebuilds the elements related to this component in case of
  66203. * context lost for instance.
  66204. */
  66205. rebuild(): void;
  66206. /**
  66207. * @hidden
  66208. */
  66209. reset(): void;
  66210. /**
  66211. * Render the bounding boxes of a specific rendering group
  66212. * @param renderingGroupId defines the rendering group to render
  66213. */
  66214. render(renderingGroupId: number): void;
  66215. /**
  66216. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66217. * @param mesh Define the mesh to render the occlusion bounding box for
  66218. */
  66219. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66220. /**
  66221. * Dispose and release the resources attached to this renderer.
  66222. */
  66223. dispose(): void;
  66224. }
  66225. }
  66226. declare module "babylonjs/Shaders/depth.fragment" {
  66227. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  66228. /** @hidden */
  66229. export var depthPixelShader: {
  66230. name: string;
  66231. shader: string;
  66232. };
  66233. }
  66234. declare module "babylonjs/Rendering/depthRenderer" {
  66235. import { Nullable } from "babylonjs/types";
  66236. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66237. import { Scene } from "babylonjs/scene";
  66238. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66239. import { Camera } from "babylonjs/Cameras/camera";
  66240. import "babylonjs/Shaders/depth.fragment";
  66241. import "babylonjs/Shaders/depth.vertex";
  66242. /**
  66243. * This represents a depth renderer in Babylon.
  66244. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  66245. */
  66246. export class DepthRenderer {
  66247. private _scene;
  66248. private _depthMap;
  66249. private _effect;
  66250. private readonly _storeNonLinearDepth;
  66251. private readonly _clearColor;
  66252. /** Get if the depth renderer is using packed depth or not */
  66253. readonly isPacked: boolean;
  66254. private _cachedDefines;
  66255. private _camera;
  66256. /**
  66257. * Specifiess that the depth renderer will only be used within
  66258. * the camera it is created for.
  66259. * This can help forcing its rendering during the camera processing.
  66260. */
  66261. useOnlyInActiveCamera: boolean;
  66262. /** @hidden */
  66263. static _SceneComponentInitialization: (scene: Scene) => void;
  66264. /**
  66265. * Instantiates a depth renderer
  66266. * @param scene The scene the renderer belongs to
  66267. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  66268. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  66269. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66270. */
  66271. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  66272. /**
  66273. * Creates the depth rendering effect and checks if the effect is ready.
  66274. * @param subMesh The submesh to be used to render the depth map of
  66275. * @param useInstances If multiple world instances should be used
  66276. * @returns if the depth renderer is ready to render the depth map
  66277. */
  66278. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66279. /**
  66280. * Gets the texture which the depth map will be written to.
  66281. * @returns The depth map texture
  66282. */
  66283. getDepthMap(): RenderTargetTexture;
  66284. /**
  66285. * Disposes of the depth renderer.
  66286. */
  66287. dispose(): void;
  66288. }
  66289. }
  66290. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  66291. import { Nullable } from "babylonjs/types";
  66292. import { Scene } from "babylonjs/scene";
  66293. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  66294. import { Camera } from "babylonjs/Cameras/camera";
  66295. import { ISceneComponent } from "babylonjs/sceneComponent";
  66296. module "babylonjs/scene" {
  66297. interface Scene {
  66298. /** @hidden (Backing field) */
  66299. _depthRenderer: {
  66300. [id: string]: DepthRenderer;
  66301. };
  66302. /**
  66303. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66304. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66305. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66306. * @returns the created depth renderer
  66307. */
  66308. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66309. /**
  66310. * Disables a depth renderer for a given camera
  66311. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66312. */
  66313. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66314. }
  66315. }
  66316. /**
  66317. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66318. * in several rendering techniques.
  66319. */
  66320. export class DepthRendererSceneComponent implements ISceneComponent {
  66321. /**
  66322. * The component name helpfull to identify the component in the list of scene components.
  66323. */
  66324. readonly name: string;
  66325. /**
  66326. * The scene the component belongs to.
  66327. */
  66328. scene: Scene;
  66329. /**
  66330. * Creates a new instance of the component for the given scene
  66331. * @param scene Defines the scene to register the component in
  66332. */
  66333. constructor(scene: Scene);
  66334. /**
  66335. * Registers the component in a given scene
  66336. */
  66337. register(): void;
  66338. /**
  66339. * Rebuilds the elements related to this component in case of
  66340. * context lost for instance.
  66341. */
  66342. rebuild(): void;
  66343. /**
  66344. * Disposes the component and the associated ressources
  66345. */
  66346. dispose(): void;
  66347. private _gatherRenderTargets;
  66348. private _gatherActiveCameraRenderTargets;
  66349. }
  66350. }
  66351. declare module "babylonjs/Shaders/outline.fragment" {
  66352. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66353. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  66354. /** @hidden */
  66355. export var outlinePixelShader: {
  66356. name: string;
  66357. shader: string;
  66358. };
  66359. }
  66360. declare module "babylonjs/Shaders/outline.vertex" {
  66361. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66362. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66363. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66364. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66365. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  66366. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66367. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66368. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66369. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  66370. /** @hidden */
  66371. export var outlineVertexShader: {
  66372. name: string;
  66373. shader: string;
  66374. };
  66375. }
  66376. declare module "babylonjs/Rendering/outlineRenderer" {
  66377. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66378. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  66379. import { Scene } from "babylonjs/scene";
  66380. import { ISceneComponent } from "babylonjs/sceneComponent";
  66381. import "babylonjs/Shaders/outline.fragment";
  66382. import "babylonjs/Shaders/outline.vertex";
  66383. module "babylonjs/scene" {
  66384. interface Scene {
  66385. /** @hidden */
  66386. _outlineRenderer: OutlineRenderer;
  66387. /**
  66388. * Gets the outline renderer associated with the scene
  66389. * @returns a OutlineRenderer
  66390. */
  66391. getOutlineRenderer(): OutlineRenderer;
  66392. }
  66393. }
  66394. module "babylonjs/Meshes/abstractMesh" {
  66395. interface AbstractMesh {
  66396. /** @hidden (Backing field) */
  66397. _renderOutline: boolean;
  66398. /**
  66399. * Gets or sets a boolean indicating if the outline must be rendered as well
  66400. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66401. */
  66402. renderOutline: boolean;
  66403. /** @hidden (Backing field) */
  66404. _renderOverlay: boolean;
  66405. /**
  66406. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66407. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66408. */
  66409. renderOverlay: boolean;
  66410. }
  66411. }
  66412. /**
  66413. * This class is responsible to draw bothe outline/overlay of meshes.
  66414. * It should not be used directly but through the available method on mesh.
  66415. */
  66416. export class OutlineRenderer implements ISceneComponent {
  66417. /**
  66418. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66419. */
  66420. private static _StencilReference;
  66421. /**
  66422. * The name of the component. Each component must have a unique name.
  66423. */
  66424. name: string;
  66425. /**
  66426. * The scene the component belongs to.
  66427. */
  66428. scene: Scene;
  66429. /**
  66430. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66431. */
  66432. zOffset: number;
  66433. private _engine;
  66434. private _effect;
  66435. private _cachedDefines;
  66436. private _savedDepthWrite;
  66437. /**
  66438. * Instantiates a new outline renderer. (There could be only one per scene).
  66439. * @param scene Defines the scene it belongs to
  66440. */
  66441. constructor(scene: Scene);
  66442. /**
  66443. * Register the component to one instance of a scene.
  66444. */
  66445. register(): void;
  66446. /**
  66447. * Rebuilds the elements related to this component in case of
  66448. * context lost for instance.
  66449. */
  66450. rebuild(): void;
  66451. /**
  66452. * Disposes the component and the associated ressources.
  66453. */
  66454. dispose(): void;
  66455. /**
  66456. * Renders the outline in the canvas.
  66457. * @param subMesh Defines the sumesh to render
  66458. * @param batch Defines the batch of meshes in case of instances
  66459. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66460. */
  66461. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66462. /**
  66463. * Returns whether or not the outline renderer is ready for a given submesh.
  66464. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66465. * @param subMesh Defines the submesh to check readyness for
  66466. * @param useInstances Defines wheter wee are trying to render instances or not
  66467. * @returns true if ready otherwise false
  66468. */
  66469. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66470. private _beforeRenderingMesh;
  66471. private _afterRenderingMesh;
  66472. }
  66473. }
  66474. declare module "babylonjs/Rendering/index" {
  66475. export * from "babylonjs/Rendering/boundingBoxRenderer";
  66476. export * from "babylonjs/Rendering/depthRenderer";
  66477. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  66478. export * from "babylonjs/Rendering/edgesRenderer";
  66479. export * from "babylonjs/Rendering/geometryBufferRenderer";
  66480. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  66481. export * from "babylonjs/Rendering/outlineRenderer";
  66482. export * from "babylonjs/Rendering/renderingGroup";
  66483. export * from "babylonjs/Rendering/renderingManager";
  66484. export * from "babylonjs/Rendering/utilityLayerRenderer";
  66485. }
  66486. declare module "babylonjs/Sprites/spritePackedManager" {
  66487. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  66488. import { Scene } from "babylonjs/scene";
  66489. /**
  66490. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66491. * @see http://doc.babylonjs.com/babylon101/sprites
  66492. */
  66493. export class SpritePackedManager extends SpriteManager {
  66494. /** defines the packed manager's name */
  66495. name: string;
  66496. /**
  66497. * Creates a new sprite manager from a packed sprite sheet
  66498. * @param name defines the manager's name
  66499. * @param imgUrl defines the sprite sheet url
  66500. * @param capacity defines the maximum allowed number of sprites
  66501. * @param scene defines the hosting scene
  66502. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66503. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66504. * @param samplingMode defines the smapling mode to use with spritesheet
  66505. * @param fromPacked set to true; do not alter
  66506. */
  66507. constructor(
  66508. /** defines the packed manager's name */
  66509. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66510. }
  66511. }
  66512. declare module "babylonjs/Sprites/index" {
  66513. export * from "babylonjs/Sprites/sprite";
  66514. export * from "babylonjs/Sprites/spriteManager";
  66515. export * from "babylonjs/Sprites/spritePackedManager";
  66516. export * from "babylonjs/Sprites/spriteSceneComponent";
  66517. }
  66518. declare module "babylonjs/States/index" {
  66519. export * from "babylonjs/States/alphaCullingState";
  66520. export * from "babylonjs/States/depthCullingState";
  66521. export * from "babylonjs/States/stencilState";
  66522. }
  66523. declare module "babylonjs/Misc/assetsManager" {
  66524. import { Scene } from "babylonjs/scene";
  66525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66526. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66527. import { Skeleton } from "babylonjs/Bones/skeleton";
  66528. import { Observable } from "babylonjs/Misc/observable";
  66529. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66530. import { Texture } from "babylonjs/Materials/Textures/texture";
  66531. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66532. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  66533. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66534. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  66535. /**
  66536. * Defines the list of states available for a task inside a AssetsManager
  66537. */
  66538. export enum AssetTaskState {
  66539. /**
  66540. * Initialization
  66541. */
  66542. INIT = 0,
  66543. /**
  66544. * Running
  66545. */
  66546. RUNNING = 1,
  66547. /**
  66548. * Done
  66549. */
  66550. DONE = 2,
  66551. /**
  66552. * Error
  66553. */
  66554. ERROR = 3
  66555. }
  66556. /**
  66557. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66558. */
  66559. export abstract class AbstractAssetTask {
  66560. /**
  66561. * Task name
  66562. */ name: string;
  66563. /**
  66564. * Callback called when the task is successful
  66565. */
  66566. onSuccess: (task: any) => void;
  66567. /**
  66568. * Callback called when the task is not successful
  66569. */
  66570. onError: (task: any, message?: string, exception?: any) => void;
  66571. /**
  66572. * Creates a new AssetsManager
  66573. * @param name defines the name of the task
  66574. */
  66575. constructor(
  66576. /**
  66577. * Task name
  66578. */ name: string);
  66579. private _isCompleted;
  66580. private _taskState;
  66581. private _errorObject;
  66582. /**
  66583. * Get if the task is completed
  66584. */
  66585. readonly isCompleted: boolean;
  66586. /**
  66587. * Gets the current state of the task
  66588. */
  66589. readonly taskState: AssetTaskState;
  66590. /**
  66591. * Gets the current error object (if task is in error)
  66592. */
  66593. readonly errorObject: {
  66594. message?: string;
  66595. exception?: any;
  66596. };
  66597. /**
  66598. * Internal only
  66599. * @hidden
  66600. */
  66601. _setErrorObject(message?: string, exception?: any): void;
  66602. /**
  66603. * Execute the current task
  66604. * @param scene defines the scene where you want your assets to be loaded
  66605. * @param onSuccess is a callback called when the task is successfully executed
  66606. * @param onError is a callback called if an error occurs
  66607. */
  66608. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66609. /**
  66610. * Execute the current task
  66611. * @param scene defines the scene where you want your assets to be loaded
  66612. * @param onSuccess is a callback called when the task is successfully executed
  66613. * @param onError is a callback called if an error occurs
  66614. */
  66615. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66616. /**
  66617. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  66618. * This can be used with failed tasks that have the reason for failure fixed.
  66619. */
  66620. reset(): void;
  66621. private onErrorCallback;
  66622. private onDoneCallback;
  66623. }
  66624. /**
  66625. * Define the interface used by progress events raised during assets loading
  66626. */
  66627. export interface IAssetsProgressEvent {
  66628. /**
  66629. * Defines the number of remaining tasks to process
  66630. */
  66631. remainingCount: number;
  66632. /**
  66633. * Defines the total number of tasks
  66634. */
  66635. totalCount: number;
  66636. /**
  66637. * Defines the task that was just processed
  66638. */
  66639. task: AbstractAssetTask;
  66640. }
  66641. /**
  66642. * Class used to share progress information about assets loading
  66643. */
  66644. export class AssetsProgressEvent implements IAssetsProgressEvent {
  66645. /**
  66646. * Defines the number of remaining tasks to process
  66647. */
  66648. remainingCount: number;
  66649. /**
  66650. * Defines the total number of tasks
  66651. */
  66652. totalCount: number;
  66653. /**
  66654. * Defines the task that was just processed
  66655. */
  66656. task: AbstractAssetTask;
  66657. /**
  66658. * Creates a AssetsProgressEvent
  66659. * @param remainingCount defines the number of remaining tasks to process
  66660. * @param totalCount defines the total number of tasks
  66661. * @param task defines the task that was just processed
  66662. */
  66663. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  66664. }
  66665. /**
  66666. * Define a task used by AssetsManager to load meshes
  66667. */
  66668. export class MeshAssetTask extends AbstractAssetTask {
  66669. /**
  66670. * Defines the name of the task
  66671. */
  66672. name: string;
  66673. /**
  66674. * Defines the list of mesh's names you want to load
  66675. */
  66676. meshesNames: any;
  66677. /**
  66678. * Defines the root url to use as a base to load your meshes and associated resources
  66679. */
  66680. rootUrl: string;
  66681. /**
  66682. * Defines the filename of the scene to load from
  66683. */
  66684. sceneFilename: string;
  66685. /**
  66686. * Gets the list of loaded meshes
  66687. */
  66688. loadedMeshes: Array<AbstractMesh>;
  66689. /**
  66690. * Gets the list of loaded particle systems
  66691. */
  66692. loadedParticleSystems: Array<IParticleSystem>;
  66693. /**
  66694. * Gets the list of loaded skeletons
  66695. */
  66696. loadedSkeletons: Array<Skeleton>;
  66697. /**
  66698. * Gets the list of loaded animation groups
  66699. */
  66700. loadedAnimationGroups: Array<AnimationGroup>;
  66701. /**
  66702. * Callback called when the task is successful
  66703. */
  66704. onSuccess: (task: MeshAssetTask) => void;
  66705. /**
  66706. * Callback called when the task is successful
  66707. */
  66708. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  66709. /**
  66710. * Creates a new MeshAssetTask
  66711. * @param name defines the name of the task
  66712. * @param meshesNames defines the list of mesh's names you want to load
  66713. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  66714. * @param sceneFilename defines the filename of the scene to load from
  66715. */
  66716. constructor(
  66717. /**
  66718. * Defines the name of the task
  66719. */
  66720. name: string,
  66721. /**
  66722. * Defines the list of mesh's names you want to load
  66723. */
  66724. meshesNames: any,
  66725. /**
  66726. * Defines the root url to use as a base to load your meshes and associated resources
  66727. */
  66728. rootUrl: string,
  66729. /**
  66730. * Defines the filename of the scene to load from
  66731. */
  66732. sceneFilename: string);
  66733. /**
  66734. * Execute the current task
  66735. * @param scene defines the scene where you want your assets to be loaded
  66736. * @param onSuccess is a callback called when the task is successfully executed
  66737. * @param onError is a callback called if an error occurs
  66738. */
  66739. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66740. }
  66741. /**
  66742. * Define a task used by AssetsManager to load text content
  66743. */
  66744. export class TextFileAssetTask extends AbstractAssetTask {
  66745. /**
  66746. * Defines the name of the task
  66747. */
  66748. name: string;
  66749. /**
  66750. * Defines the location of the file to load
  66751. */
  66752. url: string;
  66753. /**
  66754. * Gets the loaded text string
  66755. */
  66756. text: string;
  66757. /**
  66758. * Callback called when the task is successful
  66759. */
  66760. onSuccess: (task: TextFileAssetTask) => void;
  66761. /**
  66762. * Callback called when the task is successful
  66763. */
  66764. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  66765. /**
  66766. * Creates a new TextFileAssetTask object
  66767. * @param name defines the name of the task
  66768. * @param url defines the location of the file to load
  66769. */
  66770. constructor(
  66771. /**
  66772. * Defines the name of the task
  66773. */
  66774. name: string,
  66775. /**
  66776. * Defines the location of the file to load
  66777. */
  66778. url: string);
  66779. /**
  66780. * Execute the current task
  66781. * @param scene defines the scene where you want your assets to be loaded
  66782. * @param onSuccess is a callback called when the task is successfully executed
  66783. * @param onError is a callback called if an error occurs
  66784. */
  66785. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66786. }
  66787. /**
  66788. * Define a task used by AssetsManager to load binary data
  66789. */
  66790. export class BinaryFileAssetTask extends AbstractAssetTask {
  66791. /**
  66792. * Defines the name of the task
  66793. */
  66794. name: string;
  66795. /**
  66796. * Defines the location of the file to load
  66797. */
  66798. url: string;
  66799. /**
  66800. * Gets the lodaded data (as an array buffer)
  66801. */
  66802. data: ArrayBuffer;
  66803. /**
  66804. * Callback called when the task is successful
  66805. */
  66806. onSuccess: (task: BinaryFileAssetTask) => void;
  66807. /**
  66808. * Callback called when the task is successful
  66809. */
  66810. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  66811. /**
  66812. * Creates a new BinaryFileAssetTask object
  66813. * @param name defines the name of the new task
  66814. * @param url defines the location of the file to load
  66815. */
  66816. constructor(
  66817. /**
  66818. * Defines the name of the task
  66819. */
  66820. name: string,
  66821. /**
  66822. * Defines the location of the file to load
  66823. */
  66824. url: string);
  66825. /**
  66826. * Execute the current task
  66827. * @param scene defines the scene where you want your assets to be loaded
  66828. * @param onSuccess is a callback called when the task is successfully executed
  66829. * @param onError is a callback called if an error occurs
  66830. */
  66831. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66832. }
  66833. /**
  66834. * Define a task used by AssetsManager to load images
  66835. */
  66836. export class ImageAssetTask extends AbstractAssetTask {
  66837. /**
  66838. * Defines the name of the task
  66839. */
  66840. name: string;
  66841. /**
  66842. * Defines the location of the image to load
  66843. */
  66844. url: string;
  66845. /**
  66846. * Gets the loaded images
  66847. */
  66848. image: HTMLImageElement;
  66849. /**
  66850. * Callback called when the task is successful
  66851. */
  66852. onSuccess: (task: ImageAssetTask) => void;
  66853. /**
  66854. * Callback called when the task is successful
  66855. */
  66856. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  66857. /**
  66858. * Creates a new ImageAssetTask
  66859. * @param name defines the name of the task
  66860. * @param url defines the location of the image to load
  66861. */
  66862. constructor(
  66863. /**
  66864. * Defines the name of the task
  66865. */
  66866. name: string,
  66867. /**
  66868. * Defines the location of the image to load
  66869. */
  66870. url: string);
  66871. /**
  66872. * Execute the current task
  66873. * @param scene defines the scene where you want your assets to be loaded
  66874. * @param onSuccess is a callback called when the task is successfully executed
  66875. * @param onError is a callback called if an error occurs
  66876. */
  66877. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66878. }
  66879. /**
  66880. * Defines the interface used by texture loading tasks
  66881. */
  66882. export interface ITextureAssetTask<TEX extends BaseTexture> {
  66883. /**
  66884. * Gets the loaded texture
  66885. */
  66886. texture: TEX;
  66887. }
  66888. /**
  66889. * Define a task used by AssetsManager to load 2D textures
  66890. */
  66891. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  66892. /**
  66893. * Defines the name of the task
  66894. */
  66895. name: string;
  66896. /**
  66897. * Defines the location of the file to load
  66898. */
  66899. url: string;
  66900. /**
  66901. * Defines if mipmap should not be generated (default is false)
  66902. */
  66903. noMipmap?: boolean | undefined;
  66904. /**
  66905. * Defines if texture must be inverted on Y axis (default is false)
  66906. */
  66907. invertY?: boolean | undefined;
  66908. /**
  66909. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66910. */
  66911. samplingMode: number;
  66912. /**
  66913. * Gets the loaded texture
  66914. */
  66915. texture: Texture;
  66916. /**
  66917. * Callback called when the task is successful
  66918. */
  66919. onSuccess: (task: TextureAssetTask) => void;
  66920. /**
  66921. * Callback called when the task is successful
  66922. */
  66923. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  66924. /**
  66925. * Creates a new TextureAssetTask object
  66926. * @param name defines the name of the task
  66927. * @param url defines the location of the file to load
  66928. * @param noMipmap defines if mipmap should not be generated (default is false)
  66929. * @param invertY defines if texture must be inverted on Y axis (default is false)
  66930. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66931. */
  66932. constructor(
  66933. /**
  66934. * Defines the name of the task
  66935. */
  66936. name: string,
  66937. /**
  66938. * Defines the location of the file to load
  66939. */
  66940. url: string,
  66941. /**
  66942. * Defines if mipmap should not be generated (default is false)
  66943. */
  66944. noMipmap?: boolean | undefined,
  66945. /**
  66946. * Defines if texture must be inverted on Y axis (default is false)
  66947. */
  66948. invertY?: boolean | undefined,
  66949. /**
  66950. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  66951. */
  66952. samplingMode?: number);
  66953. /**
  66954. * Execute the current task
  66955. * @param scene defines the scene where you want your assets to be loaded
  66956. * @param onSuccess is a callback called when the task is successfully executed
  66957. * @param onError is a callback called if an error occurs
  66958. */
  66959. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  66960. }
  66961. /**
  66962. * Define a task used by AssetsManager to load cube textures
  66963. */
  66964. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  66965. /**
  66966. * Defines the name of the task
  66967. */
  66968. name: string;
  66969. /**
  66970. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  66971. */
  66972. url: string;
  66973. /**
  66974. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  66975. */
  66976. extensions?: string[] | undefined;
  66977. /**
  66978. * Defines if mipmaps should not be generated (default is false)
  66979. */
  66980. noMipmap?: boolean | undefined;
  66981. /**
  66982. * Defines the explicit list of files (undefined by default)
  66983. */
  66984. files?: string[] | undefined;
  66985. /**
  66986. * Gets the loaded texture
  66987. */
  66988. texture: CubeTexture;
  66989. /**
  66990. * Callback called when the task is successful
  66991. */
  66992. onSuccess: (task: CubeTextureAssetTask) => void;
  66993. /**
  66994. * Callback called when the task is successful
  66995. */
  66996. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  66997. /**
  66998. * Creates a new CubeTextureAssetTask
  66999. * @param name defines the name of the task
  67000. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67001. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67002. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67003. * @param files defines the explicit list of files (undefined by default)
  67004. */
  67005. constructor(
  67006. /**
  67007. * Defines the name of the task
  67008. */
  67009. name: string,
  67010. /**
  67011. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67012. */
  67013. url: string,
  67014. /**
  67015. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67016. */
  67017. extensions?: string[] | undefined,
  67018. /**
  67019. * Defines if mipmaps should not be generated (default is false)
  67020. */
  67021. noMipmap?: boolean | undefined,
  67022. /**
  67023. * Defines the explicit list of files (undefined by default)
  67024. */
  67025. files?: string[] | undefined);
  67026. /**
  67027. * Execute the current task
  67028. * @param scene defines the scene where you want your assets to be loaded
  67029. * @param onSuccess is a callback called when the task is successfully executed
  67030. * @param onError is a callback called if an error occurs
  67031. */
  67032. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67033. }
  67034. /**
  67035. * Define a task used by AssetsManager to load HDR cube textures
  67036. */
  67037. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67038. /**
  67039. * Defines the name of the task
  67040. */
  67041. name: string;
  67042. /**
  67043. * Defines the location of the file to load
  67044. */
  67045. url: string;
  67046. /**
  67047. * Defines the desired size (the more it increases the longer the generation will be)
  67048. */
  67049. size: number;
  67050. /**
  67051. * Defines if mipmaps should not be generated (default is false)
  67052. */
  67053. noMipmap: boolean;
  67054. /**
  67055. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67056. */
  67057. generateHarmonics: boolean;
  67058. /**
  67059. * 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)
  67060. */
  67061. gammaSpace: boolean;
  67062. /**
  67063. * Internal Use Only
  67064. */
  67065. reserved: boolean;
  67066. /**
  67067. * Gets the loaded texture
  67068. */
  67069. texture: HDRCubeTexture;
  67070. /**
  67071. * Callback called when the task is successful
  67072. */
  67073. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67074. /**
  67075. * Callback called when the task is successful
  67076. */
  67077. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67078. /**
  67079. * Creates a new HDRCubeTextureAssetTask object
  67080. * @param name defines the name of the task
  67081. * @param url defines the location of the file to load
  67082. * @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.
  67083. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67084. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67085. * @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)
  67086. * @param reserved Internal use only
  67087. */
  67088. constructor(
  67089. /**
  67090. * Defines the name of the task
  67091. */
  67092. name: string,
  67093. /**
  67094. * Defines the location of the file to load
  67095. */
  67096. url: string,
  67097. /**
  67098. * Defines the desired size (the more it increases the longer the generation will be)
  67099. */
  67100. size: number,
  67101. /**
  67102. * Defines if mipmaps should not be generated (default is false)
  67103. */
  67104. noMipmap?: boolean,
  67105. /**
  67106. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67107. */
  67108. generateHarmonics?: boolean,
  67109. /**
  67110. * 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)
  67111. */
  67112. gammaSpace?: boolean,
  67113. /**
  67114. * Internal Use Only
  67115. */
  67116. reserved?: boolean);
  67117. /**
  67118. * Execute the current task
  67119. * @param scene defines the scene where you want your assets to be loaded
  67120. * @param onSuccess is a callback called when the task is successfully executed
  67121. * @param onError is a callback called if an error occurs
  67122. */
  67123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67124. }
  67125. /**
  67126. * Define a task used by AssetsManager to load Equirectangular cube textures
  67127. */
  67128. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67129. /**
  67130. * Defines the name of the task
  67131. */
  67132. name: string;
  67133. /**
  67134. * Defines the location of the file to load
  67135. */
  67136. url: string;
  67137. /**
  67138. * Defines the desired size (the more it increases the longer the generation will be)
  67139. */
  67140. size: number;
  67141. /**
  67142. * Defines if mipmaps should not be generated (default is false)
  67143. */
  67144. noMipmap: boolean;
  67145. /**
  67146. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67147. * but the standard material would require them in Gamma space) (default is true)
  67148. */
  67149. gammaSpace: boolean;
  67150. /**
  67151. * Gets the loaded texture
  67152. */
  67153. texture: EquiRectangularCubeTexture;
  67154. /**
  67155. * Callback called when the task is successful
  67156. */
  67157. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67158. /**
  67159. * Callback called when the task is successful
  67160. */
  67161. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67162. /**
  67163. * Creates a new EquiRectangularCubeTextureAssetTask object
  67164. * @param name defines the name of the task
  67165. * @param url defines the location of the file to load
  67166. * @param size defines the desired size (the more it increases the longer the generation will be)
  67167. * If the size is omitted this implies you are using a preprocessed cubemap.
  67168. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67169. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67170. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67171. * (default is true)
  67172. */
  67173. constructor(
  67174. /**
  67175. * Defines the name of the task
  67176. */
  67177. name: string,
  67178. /**
  67179. * Defines the location of the file to load
  67180. */
  67181. url: string,
  67182. /**
  67183. * Defines the desired size (the more it increases the longer the generation will be)
  67184. */
  67185. size: number,
  67186. /**
  67187. * Defines if mipmaps should not be generated (default is false)
  67188. */
  67189. noMipmap?: boolean,
  67190. /**
  67191. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67192. * but the standard material would require them in Gamma space) (default is true)
  67193. */
  67194. gammaSpace?: boolean);
  67195. /**
  67196. * Execute the current task
  67197. * @param scene defines the scene where you want your assets to be loaded
  67198. * @param onSuccess is a callback called when the task is successfully executed
  67199. * @param onError is a callback called if an error occurs
  67200. */
  67201. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67202. }
  67203. /**
  67204. * This class can be used to easily import assets into a scene
  67205. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67206. */
  67207. export class AssetsManager {
  67208. private _scene;
  67209. private _isLoading;
  67210. protected _tasks: AbstractAssetTask[];
  67211. protected _waitingTasksCount: number;
  67212. protected _totalTasksCount: number;
  67213. /**
  67214. * Callback called when all tasks are processed
  67215. */
  67216. onFinish: (tasks: AbstractAssetTask[]) => void;
  67217. /**
  67218. * Callback called when a task is successful
  67219. */
  67220. onTaskSuccess: (task: AbstractAssetTask) => void;
  67221. /**
  67222. * Callback called when a task had an error
  67223. */
  67224. onTaskError: (task: AbstractAssetTask) => void;
  67225. /**
  67226. * Callback called when a task is done (whatever the result is)
  67227. */
  67228. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67229. /**
  67230. * Observable called when all tasks are processed
  67231. */
  67232. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67233. /**
  67234. * Observable called when a task had an error
  67235. */
  67236. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67237. /**
  67238. * Observable called when all tasks were executed
  67239. */
  67240. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67241. /**
  67242. * Observable called when a task is done (whatever the result is)
  67243. */
  67244. onProgressObservable: Observable<IAssetsProgressEvent>;
  67245. /**
  67246. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67247. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67248. */
  67249. useDefaultLoadingScreen: boolean;
  67250. /**
  67251. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67252. * when all assets have been downloaded.
  67253. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67254. */
  67255. autoHideLoadingUI: boolean;
  67256. /**
  67257. * Creates a new AssetsManager
  67258. * @param scene defines the scene to work on
  67259. */
  67260. constructor(scene: Scene);
  67261. /**
  67262. * Add a MeshAssetTask to the list of active tasks
  67263. * @param taskName defines the name of the new task
  67264. * @param meshesNames defines the name of meshes to load
  67265. * @param rootUrl defines the root url to use to locate files
  67266. * @param sceneFilename defines the filename of the scene file
  67267. * @returns a new MeshAssetTask object
  67268. */
  67269. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67270. /**
  67271. * Add a TextFileAssetTask to the list of active tasks
  67272. * @param taskName defines the name of the new task
  67273. * @param url defines the url of the file to load
  67274. * @returns a new TextFileAssetTask object
  67275. */
  67276. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67277. /**
  67278. * Add a BinaryFileAssetTask to the list of active tasks
  67279. * @param taskName defines the name of the new task
  67280. * @param url defines the url of the file to load
  67281. * @returns a new BinaryFileAssetTask object
  67282. */
  67283. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67284. /**
  67285. * Add a ImageAssetTask to the list of active tasks
  67286. * @param taskName defines the name of the new task
  67287. * @param url defines the url of the file to load
  67288. * @returns a new ImageAssetTask object
  67289. */
  67290. addImageTask(taskName: string, url: string): ImageAssetTask;
  67291. /**
  67292. * Add a TextureAssetTask to the list of active tasks
  67293. * @param taskName defines the name of the new task
  67294. * @param url defines the url of the file to load
  67295. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67296. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67297. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67298. * @returns a new TextureAssetTask object
  67299. */
  67300. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67301. /**
  67302. * Add a CubeTextureAssetTask to the list of active tasks
  67303. * @param taskName defines the name of the new task
  67304. * @param url defines the url of the file to load
  67305. * @param extensions defines the extension to use to load the cube map (can be null)
  67306. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67307. * @param files defines the list of files to load (can be null)
  67308. * @returns a new CubeTextureAssetTask object
  67309. */
  67310. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67311. /**
  67312. *
  67313. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67314. * @param taskName defines the name of the new task
  67315. * @param url defines the url of the file to load
  67316. * @param size defines the size you want for the cubemap (can be null)
  67317. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67318. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67319. * @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)
  67320. * @param reserved Internal use only
  67321. * @returns a new HDRCubeTextureAssetTask object
  67322. */
  67323. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67324. /**
  67325. *
  67326. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67327. * @param taskName defines the name of the new task
  67328. * @param url defines the url of the file to load
  67329. * @param size defines the size you want for the cubemap (can be null)
  67330. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67331. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67332. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67333. * @returns a new EquiRectangularCubeTextureAssetTask object
  67334. */
  67335. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67336. /**
  67337. * Remove a task from the assets manager.
  67338. * @param task the task to remove
  67339. */
  67340. removeTask(task: AbstractAssetTask): void;
  67341. private _decreaseWaitingTasksCount;
  67342. private _runTask;
  67343. /**
  67344. * Reset the AssetsManager and remove all tasks
  67345. * @return the current instance of the AssetsManager
  67346. */
  67347. reset(): AssetsManager;
  67348. /**
  67349. * Start the loading process
  67350. * @return the current instance of the AssetsManager
  67351. */
  67352. load(): AssetsManager;
  67353. /**
  67354. * Start the loading process as an async operation
  67355. * @return a promise returning the list of failed tasks
  67356. */
  67357. loadAsync(): Promise<void>;
  67358. }
  67359. }
  67360. declare module "babylonjs/Misc/deferred" {
  67361. /**
  67362. * Wrapper class for promise with external resolve and reject.
  67363. */
  67364. export class Deferred<T> {
  67365. /**
  67366. * The promise associated with this deferred object.
  67367. */
  67368. readonly promise: Promise<T>;
  67369. private _resolve;
  67370. private _reject;
  67371. /**
  67372. * The resolve method of the promise associated with this deferred object.
  67373. */
  67374. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  67375. /**
  67376. * The reject method of the promise associated with this deferred object.
  67377. */
  67378. readonly reject: (reason?: any) => void;
  67379. /**
  67380. * Constructor for this deferred object.
  67381. */
  67382. constructor();
  67383. }
  67384. }
  67385. declare module "babylonjs/Misc/meshExploder" {
  67386. import { Mesh } from "babylonjs/Meshes/mesh";
  67387. /**
  67388. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67389. */
  67390. export class MeshExploder {
  67391. private _centerMesh;
  67392. private _meshes;
  67393. private _meshesOrigins;
  67394. private _toCenterVectors;
  67395. private _scaledDirection;
  67396. private _newPosition;
  67397. private _centerPosition;
  67398. /**
  67399. * Explodes meshes from a center mesh.
  67400. * @param meshes The meshes to explode.
  67401. * @param centerMesh The mesh to be center of explosion.
  67402. */
  67403. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67404. private _setCenterMesh;
  67405. /**
  67406. * Get class name
  67407. * @returns "MeshExploder"
  67408. */
  67409. getClassName(): string;
  67410. /**
  67411. * "Exploded meshes"
  67412. * @returns Array of meshes with the centerMesh at index 0.
  67413. */
  67414. getMeshes(): Array<Mesh>;
  67415. /**
  67416. * Explodes meshes giving a specific direction
  67417. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67418. */
  67419. explode(direction?: number): void;
  67420. }
  67421. }
  67422. declare module "babylonjs/Misc/filesInput" {
  67423. import { Engine } from "babylonjs/Engines/engine";
  67424. import { Scene } from "babylonjs/scene";
  67425. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  67426. /**
  67427. * Class used to help managing file picking and drag'n'drop
  67428. */
  67429. export class FilesInput {
  67430. /**
  67431. * List of files ready to be loaded
  67432. */
  67433. static readonly FilesToLoad: {
  67434. [key: string]: File;
  67435. };
  67436. /**
  67437. * Callback called when a file is processed
  67438. */
  67439. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67440. private _engine;
  67441. private _currentScene;
  67442. private _sceneLoadedCallback;
  67443. private _progressCallback;
  67444. private _additionalRenderLoopLogicCallback;
  67445. private _textureLoadingCallback;
  67446. private _startingProcessingFilesCallback;
  67447. private _onReloadCallback;
  67448. private _errorCallback;
  67449. private _elementToMonitor;
  67450. private _sceneFileToLoad;
  67451. private _filesToLoad;
  67452. /**
  67453. * Creates a new FilesInput
  67454. * @param engine defines the rendering engine
  67455. * @param scene defines the hosting scene
  67456. * @param sceneLoadedCallback callback called when scene is loaded
  67457. * @param progressCallback callback called to track progress
  67458. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67459. * @param textureLoadingCallback callback called when a texture is loading
  67460. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67461. * @param onReloadCallback callback called when a reload is requested
  67462. * @param errorCallback callback call if an error occurs
  67463. */
  67464. 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);
  67465. private _dragEnterHandler;
  67466. private _dragOverHandler;
  67467. private _dropHandler;
  67468. /**
  67469. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67470. * @param elementToMonitor defines the DOM element to track
  67471. */
  67472. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67473. /**
  67474. * Release all associated resources
  67475. */
  67476. dispose(): void;
  67477. private renderFunction;
  67478. private drag;
  67479. private drop;
  67480. private _traverseFolder;
  67481. private _processFiles;
  67482. /**
  67483. * Load files from a drop event
  67484. * @param event defines the drop event to use as source
  67485. */
  67486. loadFiles(event: any): void;
  67487. private _processReload;
  67488. /**
  67489. * Reload the current scene from the loaded files
  67490. */
  67491. reload(): void;
  67492. }
  67493. }
  67494. declare module "babylonjs/Misc/HighDynamicRange/index" {
  67495. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  67496. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  67497. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  67498. }
  67499. declare module "babylonjs/Misc/sceneOptimizer" {
  67500. import { Scene, IDisposable } from "babylonjs/scene";
  67501. import { Observable } from "babylonjs/Misc/observable";
  67502. /**
  67503. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67504. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67505. */
  67506. export class SceneOptimization {
  67507. /**
  67508. * Defines the priority of this optimization (0 by default which means first in the list)
  67509. */
  67510. priority: number;
  67511. /**
  67512. * Gets a string describing the action executed by the current optimization
  67513. * @returns description string
  67514. */
  67515. getDescription(): string;
  67516. /**
  67517. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67518. * @param scene defines the current scene where to apply this optimization
  67519. * @param optimizer defines the current optimizer
  67520. * @returns true if everything that can be done was applied
  67521. */
  67522. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67523. /**
  67524. * Creates the SceneOptimization object
  67525. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67526. * @param desc defines the description associated with the optimization
  67527. */
  67528. constructor(
  67529. /**
  67530. * Defines the priority of this optimization (0 by default which means first in the list)
  67531. */
  67532. priority?: number);
  67533. }
  67534. /**
  67535. * Defines an optimization used to reduce the size of render target textures
  67536. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67537. */
  67538. export class TextureOptimization extends SceneOptimization {
  67539. /**
  67540. * Defines the priority of this optimization (0 by default which means first in the list)
  67541. */
  67542. priority: number;
  67543. /**
  67544. * 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
  67545. */
  67546. maximumSize: number;
  67547. /**
  67548. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67549. */
  67550. step: number;
  67551. /**
  67552. * Gets a string describing the action executed by the current optimization
  67553. * @returns description string
  67554. */
  67555. getDescription(): string;
  67556. /**
  67557. * Creates the TextureOptimization object
  67558. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67559. * @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
  67560. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67561. */
  67562. constructor(
  67563. /**
  67564. * Defines the priority of this optimization (0 by default which means first in the list)
  67565. */
  67566. priority?: number,
  67567. /**
  67568. * 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
  67569. */
  67570. maximumSize?: number,
  67571. /**
  67572. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67573. */
  67574. step?: number);
  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 increase or decrease the rendering resolution
  67585. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67586. */
  67587. export class HardwareScalingOptimization extends SceneOptimization {
  67588. /**
  67589. * Defines the priority of this optimization (0 by default which means first in the list)
  67590. */
  67591. priority: number;
  67592. /**
  67593. * Defines the maximum scale to use (2 by default)
  67594. */
  67595. maximumScale: number;
  67596. /**
  67597. * Defines the step to use between two passes (0.5 by default)
  67598. */
  67599. step: number;
  67600. private _currentScale;
  67601. private _directionOffset;
  67602. /**
  67603. * Gets a string describing the action executed by the current optimization
  67604. * @return description string
  67605. */
  67606. getDescription(): string;
  67607. /**
  67608. * Creates the HardwareScalingOptimization object
  67609. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67610. * @param maximumScale defines the maximum scale to use (2 by default)
  67611. * @param step defines the step to use between two passes (0.5 by default)
  67612. */
  67613. constructor(
  67614. /**
  67615. * Defines the priority of this optimization (0 by default which means first in the list)
  67616. */
  67617. priority?: number,
  67618. /**
  67619. * Defines the maximum scale to use (2 by default)
  67620. */
  67621. maximumScale?: number,
  67622. /**
  67623. * Defines the step to use between two passes (0.5 by default)
  67624. */
  67625. step?: number);
  67626. /**
  67627. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67628. * @param scene defines the current scene where to apply this optimization
  67629. * @param optimizer defines the current optimizer
  67630. * @returns true if everything that can be done was applied
  67631. */
  67632. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67633. }
  67634. /**
  67635. * Defines an optimization used to remove shadows
  67636. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67637. */
  67638. export class ShadowsOptimization extends SceneOptimization {
  67639. /**
  67640. * Gets a string describing the action executed by the current optimization
  67641. * @return description string
  67642. */
  67643. getDescription(): string;
  67644. /**
  67645. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67646. * @param scene defines the current scene where to apply this optimization
  67647. * @param optimizer defines the current optimizer
  67648. * @returns true if everything that can be done was applied
  67649. */
  67650. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67651. }
  67652. /**
  67653. * Defines an optimization used to turn post-processes off
  67654. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67655. */
  67656. export class PostProcessesOptimization extends SceneOptimization {
  67657. /**
  67658. * Gets a string describing the action executed by the current optimization
  67659. * @return description string
  67660. */
  67661. getDescription(): string;
  67662. /**
  67663. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67664. * @param scene defines the current scene where to apply this optimization
  67665. * @param optimizer defines the current optimizer
  67666. * @returns true if everything that can be done was applied
  67667. */
  67668. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67669. }
  67670. /**
  67671. * Defines an optimization used to turn lens flares off
  67672. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67673. */
  67674. export class LensFlaresOptimization extends SceneOptimization {
  67675. /**
  67676. * Gets a string describing the action executed by the current optimization
  67677. * @return description string
  67678. */
  67679. getDescription(): string;
  67680. /**
  67681. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67682. * @param scene defines the current scene where to apply this optimization
  67683. * @param optimizer defines the current optimizer
  67684. * @returns true if everything that can be done was applied
  67685. */
  67686. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67687. }
  67688. /**
  67689. * Defines an optimization based on user defined callback.
  67690. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67691. */
  67692. export class CustomOptimization extends SceneOptimization {
  67693. /**
  67694. * Callback called to apply the custom optimization.
  67695. */
  67696. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  67697. /**
  67698. * Callback called to get custom description
  67699. */
  67700. onGetDescription: () => string;
  67701. /**
  67702. * Gets a string describing the action executed by the current optimization
  67703. * @returns description string
  67704. */
  67705. getDescription(): string;
  67706. /**
  67707. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67708. * @param scene defines the current scene where to apply this optimization
  67709. * @param optimizer defines the current optimizer
  67710. * @returns true if everything that can be done was applied
  67711. */
  67712. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67713. }
  67714. /**
  67715. * Defines an optimization used to turn particles off
  67716. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67717. */
  67718. export class ParticlesOptimization extends SceneOptimization {
  67719. /**
  67720. * Gets a string describing the action executed by the current optimization
  67721. * @return description string
  67722. */
  67723. getDescription(): string;
  67724. /**
  67725. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67726. * @param scene defines the current scene where to apply this optimization
  67727. * @param optimizer defines the current optimizer
  67728. * @returns true if everything that can be done was applied
  67729. */
  67730. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67731. }
  67732. /**
  67733. * Defines an optimization used to turn render targets off
  67734. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67735. */
  67736. export class RenderTargetsOptimization extends SceneOptimization {
  67737. /**
  67738. * Gets a string describing the action executed by the current optimization
  67739. * @return description string
  67740. */
  67741. getDescription(): string;
  67742. /**
  67743. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67744. * @param scene defines the current scene where to apply this optimization
  67745. * @param optimizer defines the current optimizer
  67746. * @returns true if everything that can be done was applied
  67747. */
  67748. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67749. }
  67750. /**
  67751. * Defines an optimization used to merge meshes with compatible materials
  67752. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67753. */
  67754. export class MergeMeshesOptimization extends SceneOptimization {
  67755. private static _UpdateSelectionTree;
  67756. /**
  67757. * Gets or sets a boolean which defines if optimization octree has to be updated
  67758. */
  67759. /**
  67760. * Gets or sets a boolean which defines if optimization octree has to be updated
  67761. */
  67762. static UpdateSelectionTree: boolean;
  67763. /**
  67764. * Gets a string describing the action executed by the current optimization
  67765. * @return description string
  67766. */
  67767. getDescription(): string;
  67768. private _canBeMerged;
  67769. /**
  67770. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67771. * @param scene defines the current scene where to apply this optimization
  67772. * @param optimizer defines the current optimizer
  67773. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  67774. * @returns true if everything that can be done was applied
  67775. */
  67776. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  67777. }
  67778. /**
  67779. * Defines a list of options used by SceneOptimizer
  67780. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67781. */
  67782. export class SceneOptimizerOptions {
  67783. /**
  67784. * Defines the target frame rate to reach (60 by default)
  67785. */
  67786. targetFrameRate: number;
  67787. /**
  67788. * Defines the interval between two checkes (2000ms by default)
  67789. */
  67790. trackerDuration: number;
  67791. /**
  67792. * Gets the list of optimizations to apply
  67793. */
  67794. optimizations: SceneOptimization[];
  67795. /**
  67796. * Creates a new list of options used by SceneOptimizer
  67797. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  67798. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  67799. */
  67800. constructor(
  67801. /**
  67802. * Defines the target frame rate to reach (60 by default)
  67803. */
  67804. targetFrameRate?: number,
  67805. /**
  67806. * Defines the interval between two checkes (2000ms by default)
  67807. */
  67808. trackerDuration?: number);
  67809. /**
  67810. * Add a new optimization
  67811. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  67812. * @returns the current SceneOptimizerOptions
  67813. */
  67814. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  67815. /**
  67816. * Add a new custom optimization
  67817. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  67818. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  67819. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67820. * @returns the current SceneOptimizerOptions
  67821. */
  67822. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  67823. /**
  67824. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  67825. * @param targetFrameRate defines the target frame rate (60 by default)
  67826. * @returns a SceneOptimizerOptions object
  67827. */
  67828. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67829. /**
  67830. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  67831. * @param targetFrameRate defines the target frame rate (60 by default)
  67832. * @returns a SceneOptimizerOptions object
  67833. */
  67834. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67835. /**
  67836. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  67837. * @param targetFrameRate defines the target frame rate (60 by default)
  67838. * @returns a SceneOptimizerOptions object
  67839. */
  67840. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  67841. }
  67842. /**
  67843. * Class used to run optimizations in order to reach a target frame rate
  67844. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67845. */
  67846. export class SceneOptimizer implements IDisposable {
  67847. private _isRunning;
  67848. private _options;
  67849. private _scene;
  67850. private _currentPriorityLevel;
  67851. private _targetFrameRate;
  67852. private _trackerDuration;
  67853. private _currentFrameRate;
  67854. private _sceneDisposeObserver;
  67855. private _improvementMode;
  67856. /**
  67857. * Defines an observable called when the optimizer reaches the target frame rate
  67858. */
  67859. onSuccessObservable: Observable<SceneOptimizer>;
  67860. /**
  67861. * Defines an observable called when the optimizer enables an optimization
  67862. */
  67863. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  67864. /**
  67865. * Defines an observable called when the optimizer is not able to reach the target frame rate
  67866. */
  67867. onFailureObservable: Observable<SceneOptimizer>;
  67868. /**
  67869. * Gets a boolean indicating if the optimizer is in improvement mode
  67870. */
  67871. readonly isInImprovementMode: boolean;
  67872. /**
  67873. * Gets the current priority level (0 at start)
  67874. */
  67875. readonly currentPriorityLevel: number;
  67876. /**
  67877. * Gets the current frame rate checked by the SceneOptimizer
  67878. */
  67879. readonly currentFrameRate: number;
  67880. /**
  67881. * Gets or sets the current target frame rate (60 by default)
  67882. */
  67883. /**
  67884. * Gets or sets the current target frame rate (60 by default)
  67885. */
  67886. targetFrameRate: number;
  67887. /**
  67888. * Gets or sets the current interval between two checks (every 2000ms by default)
  67889. */
  67890. /**
  67891. * Gets or sets the current interval between two checks (every 2000ms by default)
  67892. */
  67893. trackerDuration: number;
  67894. /**
  67895. * Gets the list of active optimizations
  67896. */
  67897. readonly optimizations: SceneOptimization[];
  67898. /**
  67899. * Creates a new SceneOptimizer
  67900. * @param scene defines the scene to work on
  67901. * @param options defines the options to use with the SceneOptimizer
  67902. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  67903. * @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)
  67904. */
  67905. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  67906. /**
  67907. * Stops the current optimizer
  67908. */
  67909. stop(): void;
  67910. /**
  67911. * Reset the optimizer to initial step (current priority level = 0)
  67912. */
  67913. reset(): void;
  67914. /**
  67915. * Start the optimizer. By default it will try to reach a specific framerate
  67916. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  67917. */
  67918. start(): void;
  67919. private _checkCurrentState;
  67920. /**
  67921. * Release all resources
  67922. */
  67923. dispose(): void;
  67924. /**
  67925. * Helper function to create a SceneOptimizer with one single line of code
  67926. * @param scene defines the scene to work on
  67927. * @param options defines the options to use with the SceneOptimizer
  67928. * @param onSuccess defines a callback to call on success
  67929. * @param onFailure defines a callback to call on failure
  67930. * @returns the new SceneOptimizer object
  67931. */
  67932. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  67933. }
  67934. }
  67935. declare module "babylonjs/Misc/sceneSerializer" {
  67936. import { Scene } from "babylonjs/scene";
  67937. /**
  67938. * Class used to serialize a scene into a string
  67939. */
  67940. export class SceneSerializer {
  67941. /**
  67942. * Clear cache used by a previous serialization
  67943. */
  67944. static ClearCache(): void;
  67945. /**
  67946. * Serialize a scene into a JSON compatible object
  67947. * @param scene defines the scene to serialize
  67948. * @returns a JSON compatible object
  67949. */
  67950. static Serialize(scene: Scene): any;
  67951. /**
  67952. * Serialize a mesh into a JSON compatible object
  67953. * @param toSerialize defines the mesh to serialize
  67954. * @param withParents defines if parents must be serialized as well
  67955. * @param withChildren defines if children must be serialized as well
  67956. * @returns a JSON compatible object
  67957. */
  67958. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  67959. }
  67960. }
  67961. declare module "babylonjs/Misc/textureTools" {
  67962. import { Texture } from "babylonjs/Materials/Textures/texture";
  67963. /**
  67964. * Class used to host texture specific utilities
  67965. */
  67966. export class TextureTools {
  67967. /**
  67968. * Uses the GPU to create a copy texture rescaled at a given size
  67969. * @param texture Texture to copy from
  67970. * @param width defines the desired width
  67971. * @param height defines the desired height
  67972. * @param useBilinearMode defines if bilinear mode has to be used
  67973. * @return the generated texture
  67974. */
  67975. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  67976. }
  67977. }
  67978. declare module "babylonjs/Misc/videoRecorder" {
  67979. import { Nullable } from "babylonjs/types";
  67980. import { Engine } from "babylonjs/Engines/engine";
  67981. /**
  67982. * This represents the different options available for the video capture.
  67983. */
  67984. export interface VideoRecorderOptions {
  67985. /** Defines the mime type of the video. */
  67986. mimeType: string;
  67987. /** Defines the FPS the video should be recorded at. */
  67988. fps: number;
  67989. /** Defines the chunk size for the recording data. */
  67990. recordChunckSize: number;
  67991. /** The audio tracks to attach to the recording. */
  67992. audioTracks?: MediaStreamTrack[];
  67993. }
  67994. /**
  67995. * This can help with recording videos from BabylonJS.
  67996. * This is based on the available WebRTC functionalities of the browser.
  67997. *
  67998. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  67999. */
  68000. export class VideoRecorder {
  68001. private static readonly _defaultOptions;
  68002. /**
  68003. * Returns whether or not the VideoRecorder is available in your browser.
  68004. * @param engine Defines the Babylon Engine.
  68005. * @returns true if supported otherwise false.
  68006. */
  68007. static IsSupported(engine: Engine): boolean;
  68008. private readonly _options;
  68009. private _canvas;
  68010. private _mediaRecorder;
  68011. private _recordedChunks;
  68012. private _fileName;
  68013. private _resolve;
  68014. private _reject;
  68015. /**
  68016. * True when a recording is already in progress.
  68017. */
  68018. readonly isRecording: boolean;
  68019. /**
  68020. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68021. * @param engine Defines the BabylonJS Engine you wish to record.
  68022. * @param options Defines options that can be used to customize the capture.
  68023. */
  68024. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68025. /**
  68026. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68027. */
  68028. stopRecording(): void;
  68029. /**
  68030. * Starts recording the canvas for a max duration specified in parameters.
  68031. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68032. * If null no automatic download will start and you can rely on the promise to get the data back.
  68033. * @param maxDuration Defines the maximum recording time in seconds.
  68034. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68035. * @return A promise callback at the end of the recording with the video data in Blob.
  68036. */
  68037. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68038. /**
  68039. * Releases internal resources used during the recording.
  68040. */
  68041. dispose(): void;
  68042. private _handleDataAvailable;
  68043. private _handleError;
  68044. private _handleStop;
  68045. }
  68046. }
  68047. declare module "babylonjs/Misc/screenshotTools" {
  68048. import { Camera } from "babylonjs/Cameras/camera";
  68049. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  68050. import { Engine } from "babylonjs/Engines/engine";
  68051. /**
  68052. * Class containing a set of static utilities functions for screenshots
  68053. */
  68054. export class ScreenshotTools {
  68055. /**
  68056. * Captures a screenshot of the current rendering
  68057. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68058. * @param engine defines the rendering engine
  68059. * @param camera defines the source camera
  68060. * @param size This parameter can be set to a single number or to an object with the
  68061. * following (optional) properties: precision, width, height. If a single number is passed,
  68062. * it will be used for both width and height. If an object is passed, the screenshot size
  68063. * will be derived from the parameters. The precision property is a multiplier allowing
  68064. * rendering at a higher or lower resolution
  68065. * @param successCallback defines the callback receives a single parameter which contains the
  68066. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68067. * src parameter of an <img> to display it
  68068. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68069. * Check your browser for supported MIME types
  68070. */
  68071. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68072. /**
  68073. * Captures a screenshot of the current rendering
  68074. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68075. * @param engine defines the rendering engine
  68076. * @param camera defines the source camera
  68077. * @param size This parameter can be set to a single number or to an object with the
  68078. * following (optional) properties: precision, width, height. If a single number is passed,
  68079. * it will be used for both width and height. If an object is passed, the screenshot size
  68080. * will be derived from the parameters. The precision property is a multiplier allowing
  68081. * rendering at a higher or lower resolution
  68082. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68083. * Check your browser for supported MIME types
  68084. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68085. * to the src parameter of an <img> to display it
  68086. */
  68087. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68088. /**
  68089. * Generates an image screenshot from the specified camera.
  68090. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68091. * @param engine The engine to use for rendering
  68092. * @param camera The camera to use for rendering
  68093. * @param size This parameter can be set to a single number or to an object with the
  68094. * following (optional) properties: precision, width, height. If a single number is passed,
  68095. * it will be used for both width and height. If an object is passed, the screenshot size
  68096. * will be derived from the parameters. The precision property is a multiplier allowing
  68097. * rendering at a higher or lower resolution
  68098. * @param successCallback The callback receives a single parameter which contains the
  68099. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68100. * src parameter of an <img> to display it
  68101. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68102. * Check your browser for supported MIME types
  68103. * @param samples Texture samples (default: 1)
  68104. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68105. * @param fileName A name for for the downloaded file.
  68106. */
  68107. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68108. /**
  68109. * Generates an image screenshot from the specified camera.
  68110. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68111. * @param engine The engine to use for rendering
  68112. * @param camera The camera to use for rendering
  68113. * @param size This parameter can be set to a single number or to an object with the
  68114. * following (optional) properties: precision, width, height. If a single number is passed,
  68115. * it will be used for both width and height. If an object is passed, the screenshot size
  68116. * will be derived from the parameters. The precision property is a multiplier allowing
  68117. * rendering at a higher or lower resolution
  68118. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68119. * Check your browser for supported MIME types
  68120. * @param samples Texture samples (default: 1)
  68121. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68122. * @param fileName A name for for the downloaded file.
  68123. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68124. * to the src parameter of an <img> to display it
  68125. */
  68126. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68127. /**
  68128. * Gets height and width for screenshot size
  68129. * @private
  68130. */
  68131. private static _getScreenshotSize;
  68132. }
  68133. }
  68134. declare module "babylonjs/Misc/dataReader" {
  68135. /**
  68136. * Interface for a data buffer
  68137. */
  68138. export interface IDataBuffer {
  68139. /**
  68140. * Reads bytes from the data buffer.
  68141. * @param byteOffset The byte offset to read
  68142. * @param byteLength The byte length to read
  68143. * @returns A promise that resolves when the bytes are read
  68144. */
  68145. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68146. /**
  68147. * The byte length of the buffer.
  68148. */
  68149. readonly byteLength: number;
  68150. }
  68151. /**
  68152. * Utility class for reading from a data buffer
  68153. */
  68154. export class DataReader {
  68155. /**
  68156. * The data buffer associated with this data reader.
  68157. */
  68158. readonly buffer: IDataBuffer;
  68159. /**
  68160. * The current byte offset from the beginning of the data buffer.
  68161. */
  68162. byteOffset: number;
  68163. private _dataView;
  68164. private _dataByteOffset;
  68165. /**
  68166. * Constructor
  68167. * @param buffer The buffer to read
  68168. */
  68169. constructor(buffer: IDataBuffer);
  68170. /**
  68171. * Loads the given byte length.
  68172. * @param byteLength The byte length to load
  68173. * @returns A promise that resolves when the load is complete
  68174. */
  68175. loadAsync(byteLength: number): Promise<void>;
  68176. /**
  68177. * Read a unsigned 32-bit integer from the currently loaded data range.
  68178. * @returns The 32-bit integer read
  68179. */
  68180. readUint32(): number;
  68181. /**
  68182. * Read a byte array from the currently loaded data range.
  68183. * @param byteLength The byte length to read
  68184. * @returns The byte array read
  68185. */
  68186. readUint8Array(byteLength: number): Uint8Array;
  68187. /**
  68188. * Read a string from the currently loaded data range.
  68189. * @param byteLength The byte length to read
  68190. * @returns The string read
  68191. */
  68192. readString(byteLength: number): string;
  68193. /**
  68194. * Skips the given byte length the currently loaded data range.
  68195. * @param byteLength The byte length to skip
  68196. */
  68197. skipBytes(byteLength: number): void;
  68198. }
  68199. }
  68200. declare module "babylonjs/Misc/index" {
  68201. export * from "babylonjs/Misc/andOrNotEvaluator";
  68202. export * from "babylonjs/Misc/assetsManager";
  68203. export * from "babylonjs/Misc/dds";
  68204. export * from "babylonjs/Misc/decorators";
  68205. export * from "babylonjs/Misc/deferred";
  68206. export * from "babylonjs/Misc/environmentTextureTools";
  68207. export * from "babylonjs/Misc/meshExploder";
  68208. export * from "babylonjs/Misc/filesInput";
  68209. export * from "babylonjs/Misc/HighDynamicRange/index";
  68210. export * from "babylonjs/Misc/khronosTextureContainer";
  68211. export * from "babylonjs/Misc/observable";
  68212. export * from "babylonjs/Misc/performanceMonitor";
  68213. export * from "babylonjs/Misc/promise";
  68214. export * from "babylonjs/Misc/sceneOptimizer";
  68215. export * from "babylonjs/Misc/sceneSerializer";
  68216. export * from "babylonjs/Misc/smartArray";
  68217. export * from "babylonjs/Misc/stringDictionary";
  68218. export * from "babylonjs/Misc/tags";
  68219. export * from "babylonjs/Misc/textureTools";
  68220. export * from "babylonjs/Misc/tga";
  68221. export * from "babylonjs/Misc/tools";
  68222. export * from "babylonjs/Misc/videoRecorder";
  68223. export * from "babylonjs/Misc/virtualJoystick";
  68224. export * from "babylonjs/Misc/workerPool";
  68225. export * from "babylonjs/Misc/logger";
  68226. export * from "babylonjs/Misc/typeStore";
  68227. export * from "babylonjs/Misc/filesInputStore";
  68228. export * from "babylonjs/Misc/deepCopier";
  68229. export * from "babylonjs/Misc/pivotTools";
  68230. export * from "babylonjs/Misc/precisionDate";
  68231. export * from "babylonjs/Misc/screenshotTools";
  68232. export * from "babylonjs/Misc/typeStore";
  68233. export * from "babylonjs/Misc/webRequest";
  68234. export * from "babylonjs/Misc/iInspectable";
  68235. export * from "babylonjs/Misc/brdfTextureTools";
  68236. export * from "babylonjs/Misc/rgbdTextureTools";
  68237. export * from "babylonjs/Misc/gradients";
  68238. export * from "babylonjs/Misc/perfCounter";
  68239. export * from "babylonjs/Misc/fileRequest";
  68240. export * from "babylonjs/Misc/customAnimationFrameRequester";
  68241. export * from "babylonjs/Misc/retryStrategy";
  68242. export * from "babylonjs/Misc/interfaces/screenshotSize";
  68243. export * from "babylonjs/Misc/canvasGenerator";
  68244. export * from "babylonjs/Misc/fileTools";
  68245. export * from "babylonjs/Misc/stringTools";
  68246. export * from "babylonjs/Misc/dataReader";
  68247. }
  68248. declare module "babylonjs/index" {
  68249. export * from "babylonjs/abstractScene";
  68250. export * from "babylonjs/Actions/index";
  68251. export * from "babylonjs/Animations/index";
  68252. export * from "babylonjs/assetContainer";
  68253. export * from "babylonjs/Audio/index";
  68254. export * from "babylonjs/Behaviors/index";
  68255. export * from "babylonjs/Bones/index";
  68256. export * from "babylonjs/Cameras/index";
  68257. export * from "babylonjs/Collisions/index";
  68258. export * from "babylonjs/Culling/index";
  68259. export * from "babylonjs/Debug/index";
  68260. export * from "babylonjs/Engines/index";
  68261. export * from "babylonjs/Events/index";
  68262. export * from "babylonjs/Gamepads/index";
  68263. export * from "babylonjs/Gizmos/index";
  68264. export * from "babylonjs/Helpers/index";
  68265. export * from "babylonjs/Instrumentation/index";
  68266. export * from "babylonjs/Layers/index";
  68267. export * from "babylonjs/LensFlares/index";
  68268. export * from "babylonjs/Lights/index";
  68269. export * from "babylonjs/Loading/index";
  68270. export * from "babylonjs/Materials/index";
  68271. export * from "babylonjs/Maths/index";
  68272. export * from "babylonjs/Meshes/index";
  68273. export * from "babylonjs/Morph/index";
  68274. export * from "babylonjs/Navigation/index";
  68275. export * from "babylonjs/node";
  68276. export * from "babylonjs/Offline/index";
  68277. export * from "babylonjs/Particles/index";
  68278. export * from "babylonjs/Physics/index";
  68279. export * from "babylonjs/PostProcesses/index";
  68280. export * from "babylonjs/Probes/index";
  68281. export * from "babylonjs/Rendering/index";
  68282. export * from "babylonjs/scene";
  68283. export * from "babylonjs/sceneComponent";
  68284. export * from "babylonjs/Sprites/index";
  68285. export * from "babylonjs/States/index";
  68286. export * from "babylonjs/Misc/index";
  68287. export * from "babylonjs/types";
  68288. }
  68289. declare module "babylonjs/Animations/pathCursor" {
  68290. import { Vector3 } from "babylonjs/Maths/math.vector";
  68291. import { Path2 } from "babylonjs/Maths/math.path";
  68292. /**
  68293. * A cursor which tracks a point on a path
  68294. */
  68295. export class PathCursor {
  68296. private path;
  68297. /**
  68298. * Stores path cursor callbacks for when an onchange event is triggered
  68299. */
  68300. private _onchange;
  68301. /**
  68302. * The value of the path cursor
  68303. */
  68304. value: number;
  68305. /**
  68306. * The animation array of the path cursor
  68307. */
  68308. animations: Animation[];
  68309. /**
  68310. * Initializes the path cursor
  68311. * @param path The path to track
  68312. */
  68313. constructor(path: Path2);
  68314. /**
  68315. * Gets the cursor point on the path
  68316. * @returns A point on the path cursor at the cursor location
  68317. */
  68318. getPoint(): Vector3;
  68319. /**
  68320. * Moves the cursor ahead by the step amount
  68321. * @param step The amount to move the cursor forward
  68322. * @returns This path cursor
  68323. */
  68324. moveAhead(step?: number): PathCursor;
  68325. /**
  68326. * Moves the cursor behind by the step amount
  68327. * @param step The amount to move the cursor back
  68328. * @returns This path cursor
  68329. */
  68330. moveBack(step?: number): PathCursor;
  68331. /**
  68332. * Moves the cursor by the step amount
  68333. * If the step amount is greater than one, an exception is thrown
  68334. * @param step The amount to move the cursor
  68335. * @returns This path cursor
  68336. */
  68337. move(step: number): PathCursor;
  68338. /**
  68339. * Ensures that the value is limited between zero and one
  68340. * @returns This path cursor
  68341. */
  68342. private ensureLimits;
  68343. /**
  68344. * Runs onchange callbacks on change (used by the animation engine)
  68345. * @returns This path cursor
  68346. */
  68347. private raiseOnChange;
  68348. /**
  68349. * Executes a function on change
  68350. * @param f A path cursor onchange callback
  68351. * @returns This path cursor
  68352. */
  68353. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68354. }
  68355. }
  68356. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  68357. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  68358. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  68359. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  68360. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  68361. }
  68362. declare module "babylonjs/Engines/Processors/Expressions/index" {
  68363. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  68364. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  68365. }
  68366. declare module "babylonjs/Engines/Processors/index" {
  68367. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  68368. export * from "babylonjs/Engines/Processors/Expressions/index";
  68369. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  68370. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  68371. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  68372. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  68373. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  68374. export * from "babylonjs/Engines/Processors/shaderProcessor";
  68375. }
  68376. declare module "babylonjs/Legacy/legacy" {
  68377. import * as Babylon from "babylonjs/index";
  68378. export * from "babylonjs/index";
  68379. }
  68380. declare module "babylonjs/Shaders/blur.fragment" {
  68381. /** @hidden */
  68382. export var blurPixelShader: {
  68383. name: string;
  68384. shader: string;
  68385. };
  68386. }
  68387. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  68388. /** @hidden */
  68389. export var pointCloudVertexDeclaration: {
  68390. name: string;
  68391. shader: string;
  68392. };
  68393. }
  68394. declare module "babylonjs" {
  68395. export * from "babylonjs/Legacy/legacy";
  68396. }
  68397. declare module BABYLON {
  68398. /** Alias type for value that can be null */
  68399. export type Nullable<T> = T | null;
  68400. /**
  68401. * Alias type for number that are floats
  68402. * @ignorenaming
  68403. */
  68404. export type float = number;
  68405. /**
  68406. * Alias type for number that are doubles.
  68407. * @ignorenaming
  68408. */
  68409. export type double = number;
  68410. /**
  68411. * Alias type for number that are integer
  68412. * @ignorenaming
  68413. */
  68414. export type int = number;
  68415. /** Alias type for number array or Float32Array */
  68416. export type FloatArray = number[] | Float32Array;
  68417. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  68418. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  68419. /**
  68420. * Alias for types that can be used by a Buffer or VertexBuffer.
  68421. */
  68422. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  68423. /**
  68424. * Alias type for primitive types
  68425. * @ignorenaming
  68426. */
  68427. type Primitive = undefined | null | boolean | string | number | Function;
  68428. /**
  68429. * Type modifier to make all the properties of an object Readonly
  68430. */
  68431. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  68432. /**
  68433. * Type modifier to make all the properties of an object Readonly recursively
  68434. */
  68435. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  68436. /**
  68437. * Type modifier to make object properties readonly.
  68438. */
  68439. export type DeepImmutableObject<T> = {
  68440. readonly [K in keyof T]: DeepImmutable<T[K]>;
  68441. };
  68442. /** @hidden */
  68443. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  68444. }
  68445. }
  68446. declare module BABYLON {
  68447. /**
  68448. * A class serves as a medium between the observable and its observers
  68449. */
  68450. export class EventState {
  68451. /**
  68452. * Create a new EventState
  68453. * @param mask defines the mask associated with this state
  68454. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68455. * @param target defines the original target of the state
  68456. * @param currentTarget defines the current target of the state
  68457. */
  68458. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  68459. /**
  68460. * Initialize the current event state
  68461. * @param mask defines the mask associated with this state
  68462. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68463. * @param target defines the original target of the state
  68464. * @param currentTarget defines the current target of the state
  68465. * @returns the current event state
  68466. */
  68467. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  68468. /**
  68469. * An Observer can set this property to true to prevent subsequent observers of being notified
  68470. */
  68471. skipNextObservers: boolean;
  68472. /**
  68473. * Get the mask value that were used to trigger the event corresponding to this EventState object
  68474. */
  68475. mask: number;
  68476. /**
  68477. * The object that originally notified the event
  68478. */
  68479. target?: any;
  68480. /**
  68481. * The current object in the bubbling phase
  68482. */
  68483. currentTarget?: any;
  68484. /**
  68485. * This will be populated with the return value of the last function that was executed.
  68486. * If it is the first function in the callback chain it will be the event data.
  68487. */
  68488. lastReturnValue?: any;
  68489. }
  68490. /**
  68491. * Represent an Observer registered to a given Observable object.
  68492. */
  68493. export class Observer<T> {
  68494. /**
  68495. * Defines the callback to call when the observer is notified
  68496. */
  68497. callback: (eventData: T, eventState: EventState) => void;
  68498. /**
  68499. * Defines the mask of the observer (used to filter notifications)
  68500. */
  68501. mask: number;
  68502. /**
  68503. * Defines the current scope used to restore the JS context
  68504. */
  68505. scope: any;
  68506. /** @hidden */
  68507. _willBeUnregistered: boolean;
  68508. /**
  68509. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  68510. */
  68511. unregisterOnNextCall: boolean;
  68512. /**
  68513. * Creates a new observer
  68514. * @param callback defines the callback to call when the observer is notified
  68515. * @param mask defines the mask of the observer (used to filter notifications)
  68516. * @param scope defines the current scope used to restore the JS context
  68517. */
  68518. constructor(
  68519. /**
  68520. * Defines the callback to call when the observer is notified
  68521. */
  68522. callback: (eventData: T, eventState: EventState) => void,
  68523. /**
  68524. * Defines the mask of the observer (used to filter notifications)
  68525. */
  68526. mask: number,
  68527. /**
  68528. * Defines the current scope used to restore the JS context
  68529. */
  68530. scope?: any);
  68531. }
  68532. /**
  68533. * Represent a list of observers registered to multiple Observables object.
  68534. */
  68535. export class MultiObserver<T> {
  68536. private _observers;
  68537. private _observables;
  68538. /**
  68539. * Release associated resources
  68540. */
  68541. dispose(): void;
  68542. /**
  68543. * Raise a callback when one of the observable will notify
  68544. * @param observables defines a list of observables to watch
  68545. * @param callback defines the callback to call on notification
  68546. * @param mask defines the mask used to filter notifications
  68547. * @param scope defines the current scope used to restore the JS context
  68548. * @returns the new MultiObserver
  68549. */
  68550. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  68551. }
  68552. /**
  68553. * The Observable class is a simple implementation of the Observable pattern.
  68554. *
  68555. * 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.
  68556. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  68557. * 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).
  68558. * 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.
  68559. */
  68560. export class Observable<T> {
  68561. private _observers;
  68562. private _eventState;
  68563. private _onObserverAdded;
  68564. /**
  68565. * Gets the list of observers
  68566. */
  68567. readonly observers: Array<Observer<T>>;
  68568. /**
  68569. * Creates a new observable
  68570. * @param onObserverAdded defines a callback to call when a new observer is added
  68571. */
  68572. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  68573. /**
  68574. * Create a new Observer with the specified callback
  68575. * @param callback the callback that will be executed for that Observer
  68576. * @param mask the mask used to filter observers
  68577. * @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.
  68578. * @param scope optional scope for the callback to be called from
  68579. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  68580. * @returns the new observer created for the callback
  68581. */
  68582. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  68583. /**
  68584. * Create a new Observer with the specified callback and unregisters after the next notification
  68585. * @param callback the callback that will be executed for that Observer
  68586. * @returns the new observer created for the callback
  68587. */
  68588. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  68589. /**
  68590. * Remove an Observer from the Observable object
  68591. * @param observer the instance of the Observer to remove
  68592. * @returns false if it doesn't belong to this Observable
  68593. */
  68594. remove(observer: Nullable<Observer<T>>): boolean;
  68595. /**
  68596. * Remove a callback from the Observable object
  68597. * @param callback the callback to remove
  68598. * @param scope optional scope. If used only the callbacks with this scope will be removed
  68599. * @returns false if it doesn't belong to this Observable
  68600. */
  68601. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  68602. private _deferUnregister;
  68603. private _remove;
  68604. /**
  68605. * Moves the observable to the top of the observer list making it get called first when notified
  68606. * @param observer the observer to move
  68607. */
  68608. makeObserverTopPriority(observer: Observer<T>): void;
  68609. /**
  68610. * Moves the observable to the bottom of the observer list making it get called last when notified
  68611. * @param observer the observer to move
  68612. */
  68613. makeObserverBottomPriority(observer: Observer<T>): void;
  68614. /**
  68615. * Notify all Observers by calling their respective callback with the given data
  68616. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  68617. * @param eventData defines the data to send to all observers
  68618. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  68619. * @param target defines the original target of the state
  68620. * @param currentTarget defines the current target of the state
  68621. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  68622. */
  68623. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  68624. /**
  68625. * Calling this will execute each callback, expecting it to be a promise or return a value.
  68626. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  68627. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  68628. * and it is crucial that all callbacks will be executed.
  68629. * The order of the callbacks is kept, callbacks are not executed parallel.
  68630. *
  68631. * @param eventData The data to be sent to each callback
  68632. * @param mask is used to filter observers defaults to -1
  68633. * @param target defines the callback target (see EventState)
  68634. * @param currentTarget defines he current object in the bubbling phase
  68635. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  68636. */
  68637. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  68638. /**
  68639. * Notify a specific observer
  68640. * @param observer defines the observer to notify
  68641. * @param eventData defines the data to be sent to each callback
  68642. * @param mask is used to filter observers defaults to -1
  68643. */
  68644. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  68645. /**
  68646. * Gets a boolean indicating if the observable has at least one observer
  68647. * @returns true is the Observable has at least one Observer registered
  68648. */
  68649. hasObservers(): boolean;
  68650. /**
  68651. * Clear the list of observers
  68652. */
  68653. clear(): void;
  68654. /**
  68655. * Clone the current observable
  68656. * @returns a new observable
  68657. */
  68658. clone(): Observable<T>;
  68659. /**
  68660. * Does this observable handles observer registered with a given mask
  68661. * @param mask defines the mask to be tested
  68662. * @return whether or not one observer registered with the given mask is handeled
  68663. **/
  68664. hasSpecificMask(mask?: number): boolean;
  68665. }
  68666. }
  68667. declare module BABYLON {
  68668. /**
  68669. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  68670. * Babylon.js
  68671. */
  68672. export class DomManagement {
  68673. /**
  68674. * Checks if the window object exists
  68675. * @returns true if the window object exists
  68676. */
  68677. static IsWindowObjectExist(): boolean;
  68678. /**
  68679. * Checks if the navigator object exists
  68680. * @returns true if the navigator object exists
  68681. */
  68682. static IsNavigatorAvailable(): boolean;
  68683. /**
  68684. * Extracts text content from a DOM element hierarchy
  68685. * @param element defines the root element
  68686. * @returns a string
  68687. */
  68688. static GetDOMTextContent(element: HTMLElement): string;
  68689. }
  68690. }
  68691. declare module BABYLON {
  68692. /**
  68693. * Logger used througouht the application to allow configuration of
  68694. * the log level required for the messages.
  68695. */
  68696. export class Logger {
  68697. /**
  68698. * No log
  68699. */
  68700. static readonly NoneLogLevel: number;
  68701. /**
  68702. * Only message logs
  68703. */
  68704. static readonly MessageLogLevel: number;
  68705. /**
  68706. * Only warning logs
  68707. */
  68708. static readonly WarningLogLevel: number;
  68709. /**
  68710. * Only error logs
  68711. */
  68712. static readonly ErrorLogLevel: number;
  68713. /**
  68714. * All logs
  68715. */
  68716. static readonly AllLogLevel: number;
  68717. private static _LogCache;
  68718. /**
  68719. * Gets a value indicating the number of loading errors
  68720. * @ignorenaming
  68721. */
  68722. static errorsCount: number;
  68723. /**
  68724. * Callback called when a new log is added
  68725. */
  68726. static OnNewCacheEntry: (entry: string) => void;
  68727. private static _AddLogEntry;
  68728. private static _FormatMessage;
  68729. private static _LogDisabled;
  68730. private static _LogEnabled;
  68731. private static _WarnDisabled;
  68732. private static _WarnEnabled;
  68733. private static _ErrorDisabled;
  68734. private static _ErrorEnabled;
  68735. /**
  68736. * Log a message to the console
  68737. */
  68738. static Log: (message: string) => void;
  68739. /**
  68740. * Write a warning message to the console
  68741. */
  68742. static Warn: (message: string) => void;
  68743. /**
  68744. * Write an error message to the console
  68745. */
  68746. static Error: (message: string) => void;
  68747. /**
  68748. * Gets current log cache (list of logs)
  68749. */
  68750. static readonly LogCache: string;
  68751. /**
  68752. * Clears the log cache
  68753. */
  68754. static ClearLogCache(): void;
  68755. /**
  68756. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  68757. */
  68758. static LogLevels: number;
  68759. }
  68760. }
  68761. declare module BABYLON {
  68762. /** @hidden */
  68763. export class _TypeStore {
  68764. /** @hidden */
  68765. static RegisteredTypes: {
  68766. [key: string]: Object;
  68767. };
  68768. /** @hidden */
  68769. static GetClass(fqdn: string): any;
  68770. }
  68771. }
  68772. declare module BABYLON {
  68773. /**
  68774. * Helper to manipulate strings
  68775. */
  68776. export class StringTools {
  68777. /**
  68778. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68779. * @param str Source string
  68780. * @param suffix Suffix to search for in the source string
  68781. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68782. */
  68783. static EndsWith(str: string, suffix: string): boolean;
  68784. /**
  68785. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68786. * @param str Source string
  68787. * @param suffix Suffix to search for in the source string
  68788. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68789. */
  68790. static StartsWith(str: string, suffix: string): boolean;
  68791. /**
  68792. * Decodes a buffer into a string
  68793. * @param buffer The buffer to decode
  68794. * @returns The decoded string
  68795. */
  68796. static Decode(buffer: Uint8Array | Uint16Array): string;
  68797. /**
  68798. * Encode a buffer to a base64 string
  68799. * @param buffer defines the buffer to encode
  68800. * @returns the encoded string
  68801. */
  68802. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  68803. }
  68804. }
  68805. declare module BABYLON {
  68806. /**
  68807. * Class containing a set of static utilities functions for deep copy.
  68808. */
  68809. export class DeepCopier {
  68810. /**
  68811. * Tries to copy an object by duplicating every property
  68812. * @param source defines the source object
  68813. * @param destination defines the target object
  68814. * @param doNotCopyList defines a list of properties to avoid
  68815. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  68816. */
  68817. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  68818. }
  68819. }
  68820. declare module BABYLON {
  68821. /**
  68822. * Class containing a set of static utilities functions for precision date
  68823. */
  68824. export class PrecisionDate {
  68825. /**
  68826. * Gets either window.performance.now() if supported or Date.now() else
  68827. */
  68828. static readonly Now: number;
  68829. }
  68830. }
  68831. declare module BABYLON {
  68832. /** @hidden */
  68833. export class _DevTools {
  68834. static WarnImport(name: string): string;
  68835. }
  68836. }
  68837. declare module BABYLON {
  68838. /**
  68839. * Interface used to define the mechanism to get data from the network
  68840. */
  68841. export interface IWebRequest {
  68842. /**
  68843. * Returns client's response url
  68844. */
  68845. responseURL: string;
  68846. /**
  68847. * Returns client's status
  68848. */
  68849. status: number;
  68850. /**
  68851. * Returns client's status as a text
  68852. */
  68853. statusText: string;
  68854. }
  68855. }
  68856. declare module BABYLON {
  68857. /**
  68858. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  68859. */
  68860. export class WebRequest implements IWebRequest {
  68861. private _xhr;
  68862. /**
  68863. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  68864. * i.e. when loading files, where the server/service expects an Authorization header
  68865. */
  68866. static CustomRequestHeaders: {
  68867. [key: string]: string;
  68868. };
  68869. /**
  68870. * Add callback functions in this array to update all the requests before they get sent to the network
  68871. */
  68872. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  68873. private _injectCustomRequestHeaders;
  68874. /**
  68875. * Gets or sets a function to be called when loading progress changes
  68876. */
  68877. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  68878. /**
  68879. * Returns client's state
  68880. */
  68881. readonly readyState: number;
  68882. /**
  68883. * Returns client's status
  68884. */
  68885. readonly status: number;
  68886. /**
  68887. * Returns client's status as a text
  68888. */
  68889. readonly statusText: string;
  68890. /**
  68891. * Returns client's response
  68892. */
  68893. readonly response: any;
  68894. /**
  68895. * Returns client's response url
  68896. */
  68897. readonly responseURL: string;
  68898. /**
  68899. * Returns client's response as text
  68900. */
  68901. readonly responseText: string;
  68902. /**
  68903. * Gets or sets the expected response type
  68904. */
  68905. responseType: XMLHttpRequestResponseType;
  68906. /** @hidden */
  68907. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  68908. /** @hidden */
  68909. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  68910. /**
  68911. * Cancels any network activity
  68912. */
  68913. abort(): void;
  68914. /**
  68915. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  68916. * @param body defines an optional request body
  68917. */
  68918. send(body?: Document | BodyInit | null): void;
  68919. /**
  68920. * Sets the request method, request URL
  68921. * @param method defines the method to use (GET, POST, etc..)
  68922. * @param url defines the url to connect with
  68923. */
  68924. open(method: string, url: string): void;
  68925. /**
  68926. * Sets the value of a request header.
  68927. * @param name The name of the header whose value is to be set
  68928. * @param value The value to set as the body of the header
  68929. */
  68930. setRequestHeader(name: string, value: string): void;
  68931. /**
  68932. * Get the string containing the text of a particular header's value.
  68933. * @param name The name of the header
  68934. * @returns The string containing the text of the given header name
  68935. */
  68936. getResponseHeader(name: string): Nullable<string>;
  68937. }
  68938. }
  68939. declare module BABYLON {
  68940. /**
  68941. * File request interface
  68942. */
  68943. export interface IFileRequest {
  68944. /**
  68945. * Raised when the request is complete (success or error).
  68946. */
  68947. onCompleteObservable: Observable<IFileRequest>;
  68948. /**
  68949. * Aborts the request for a file.
  68950. */
  68951. abort: () => void;
  68952. }
  68953. }
  68954. declare module BABYLON {
  68955. /**
  68956. * Define options used to create a render target texture
  68957. */
  68958. export class RenderTargetCreationOptions {
  68959. /**
  68960. * Specifies is mipmaps must be generated
  68961. */
  68962. generateMipMaps?: boolean;
  68963. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68964. generateDepthBuffer?: boolean;
  68965. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68966. generateStencilBuffer?: boolean;
  68967. /** Defines texture type (int by default) */
  68968. type?: number;
  68969. /** Defines sampling mode (trilinear by default) */
  68970. samplingMode?: number;
  68971. /** Defines format (RGBA by default) */
  68972. format?: number;
  68973. }
  68974. }
  68975. declare module BABYLON {
  68976. /**
  68977. * @hidden
  68978. **/
  68979. export class _TimeToken {
  68980. _startTimeQuery: Nullable<WebGLQuery>;
  68981. _endTimeQuery: Nullable<WebGLQuery>;
  68982. _timeElapsedQuery: Nullable<WebGLQuery>;
  68983. _timeElapsedQueryEnded: boolean;
  68984. }
  68985. }
  68986. declare module BABYLON {
  68987. /** Defines the cross module used constants to avoid circular dependncies */
  68988. export class Constants {
  68989. /** Defines that alpha blending is disabled */
  68990. static readonly ALPHA_DISABLE: number;
  68991. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  68992. static readonly ALPHA_ADD: number;
  68993. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  68994. static readonly ALPHA_COMBINE: number;
  68995. /** Defines that alpha blending to DEST - SRC * DEST */
  68996. static readonly ALPHA_SUBTRACT: number;
  68997. /** Defines that alpha blending to SRC * DEST */
  68998. static readonly ALPHA_MULTIPLY: number;
  68999. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69000. static readonly ALPHA_MAXIMIZED: number;
  69001. /** Defines that alpha blending to SRC + DEST */
  69002. static readonly ALPHA_ONEONE: number;
  69003. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69004. static readonly ALPHA_PREMULTIPLIED: number;
  69005. /**
  69006. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69007. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69008. */
  69009. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69010. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69011. static readonly ALPHA_INTERPOLATE: number;
  69012. /**
  69013. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69014. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69015. */
  69016. static readonly ALPHA_SCREENMODE: number;
  69017. /**
  69018. * Defines that alpha blending to SRC + DST
  69019. * Alpha will be set to SRC ALPHA + DST ALPHA
  69020. */
  69021. static readonly ALPHA_ONEONE_ONEONE: number;
  69022. /**
  69023. * Defines that alpha blending to SRC * DST ALPHA + DST
  69024. * Alpha will be set to 0
  69025. */
  69026. static readonly ALPHA_ALPHATOCOLOR: number;
  69027. /**
  69028. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  69029. */
  69030. static readonly ALPHA_REVERSEONEMINUS: number;
  69031. /**
  69032. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  69033. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  69034. */
  69035. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  69036. /**
  69037. * Defines that alpha blending to SRC + DST
  69038. * Alpha will be set to SRC ALPHA
  69039. */
  69040. static readonly ALPHA_ONEONE_ONEZERO: number;
  69041. /** Defines that alpha blending equation a SUM */
  69042. static readonly ALPHA_EQUATION_ADD: number;
  69043. /** Defines that alpha blending equation a SUBSTRACTION */
  69044. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  69045. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  69046. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  69047. /** Defines that alpha blending equation a MAX operation */
  69048. static readonly ALPHA_EQUATION_MAX: number;
  69049. /** Defines that alpha blending equation a MIN operation */
  69050. static readonly ALPHA_EQUATION_MIN: number;
  69051. /**
  69052. * Defines that alpha blending equation a DARKEN operation:
  69053. * It takes the min of the src and sums the alpha channels.
  69054. */
  69055. static readonly ALPHA_EQUATION_DARKEN: number;
  69056. /** Defines that the ressource is not delayed*/
  69057. static readonly DELAYLOADSTATE_NONE: number;
  69058. /** Defines that the ressource was successfully delay loaded */
  69059. static readonly DELAYLOADSTATE_LOADED: number;
  69060. /** Defines that the ressource is currently delay loading */
  69061. static readonly DELAYLOADSTATE_LOADING: number;
  69062. /** Defines that the ressource is delayed and has not started loading */
  69063. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69064. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69065. static readonly NEVER: number;
  69066. /** 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 */
  69067. static readonly ALWAYS: number;
  69068. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69069. static readonly LESS: number;
  69070. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69071. static readonly EQUAL: number;
  69072. /** 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 */
  69073. static readonly LEQUAL: number;
  69074. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69075. static readonly GREATER: number;
  69076. /** 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 */
  69077. static readonly GEQUAL: number;
  69078. /** 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 */
  69079. static readonly NOTEQUAL: number;
  69080. /** Passed to stencilOperation to specify that stencil value must be kept */
  69081. static readonly KEEP: number;
  69082. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69083. static readonly REPLACE: number;
  69084. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69085. static readonly INCR: number;
  69086. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69087. static readonly DECR: number;
  69088. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69089. static readonly INVERT: number;
  69090. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69091. static readonly INCR_WRAP: number;
  69092. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69093. static readonly DECR_WRAP: number;
  69094. /** Texture is not repeating outside of 0..1 UVs */
  69095. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69096. /** Texture is repeating outside of 0..1 UVs */
  69097. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69098. /** Texture is repeating and mirrored */
  69099. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69100. /** ALPHA */
  69101. static readonly TEXTUREFORMAT_ALPHA: number;
  69102. /** LUMINANCE */
  69103. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69104. /** LUMINANCE_ALPHA */
  69105. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69106. /** RGB */
  69107. static readonly TEXTUREFORMAT_RGB: number;
  69108. /** RGBA */
  69109. static readonly TEXTUREFORMAT_RGBA: number;
  69110. /** RED */
  69111. static readonly TEXTUREFORMAT_RED: number;
  69112. /** RED (2nd reference) */
  69113. static readonly TEXTUREFORMAT_R: number;
  69114. /** RG */
  69115. static readonly TEXTUREFORMAT_RG: number;
  69116. /** RED_INTEGER */
  69117. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69118. /** RED_INTEGER (2nd reference) */
  69119. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69120. /** RG_INTEGER */
  69121. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69122. /** RGB_INTEGER */
  69123. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69124. /** RGBA_INTEGER */
  69125. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69126. /** UNSIGNED_BYTE */
  69127. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69128. /** UNSIGNED_BYTE (2nd reference) */
  69129. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69130. /** FLOAT */
  69131. static readonly TEXTURETYPE_FLOAT: number;
  69132. /** HALF_FLOAT */
  69133. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69134. /** BYTE */
  69135. static readonly TEXTURETYPE_BYTE: number;
  69136. /** SHORT */
  69137. static readonly TEXTURETYPE_SHORT: number;
  69138. /** UNSIGNED_SHORT */
  69139. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69140. /** INT */
  69141. static readonly TEXTURETYPE_INT: number;
  69142. /** UNSIGNED_INT */
  69143. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69144. /** UNSIGNED_SHORT_4_4_4_4 */
  69145. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69146. /** UNSIGNED_SHORT_5_5_5_1 */
  69147. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69148. /** UNSIGNED_SHORT_5_6_5 */
  69149. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69150. /** UNSIGNED_INT_2_10_10_10_REV */
  69151. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69152. /** UNSIGNED_INT_24_8 */
  69153. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69154. /** UNSIGNED_INT_10F_11F_11F_REV */
  69155. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69156. /** UNSIGNED_INT_5_9_9_9_REV */
  69157. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69158. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69159. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69160. /** nearest is mag = nearest and min = nearest and mip = nearest */
  69161. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69162. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69163. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69164. /** Trilinear is mag = linear and min = linear and mip = linear */
  69165. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69166. /** nearest is mag = nearest and min = nearest and mip = linear */
  69167. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69168. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69169. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69170. /** Trilinear is mag = linear and min = linear and mip = linear */
  69171. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69172. /** mag = nearest and min = nearest and mip = nearest */
  69173. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69174. /** mag = nearest and min = linear and mip = nearest */
  69175. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69176. /** mag = nearest and min = linear and mip = linear */
  69177. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69178. /** mag = nearest and min = linear and mip = none */
  69179. static readonly TEXTURE_NEAREST_LINEAR: number;
  69180. /** mag = nearest and min = nearest and mip = none */
  69181. static readonly TEXTURE_NEAREST_NEAREST: number;
  69182. /** mag = linear and min = nearest and mip = nearest */
  69183. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69184. /** mag = linear and min = nearest and mip = linear */
  69185. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69186. /** mag = linear and min = linear and mip = none */
  69187. static readonly TEXTURE_LINEAR_LINEAR: number;
  69188. /** mag = linear and min = nearest and mip = none */
  69189. static readonly TEXTURE_LINEAR_NEAREST: number;
  69190. /** Explicit coordinates mode */
  69191. static readonly TEXTURE_EXPLICIT_MODE: number;
  69192. /** Spherical coordinates mode */
  69193. static readonly TEXTURE_SPHERICAL_MODE: number;
  69194. /** Planar coordinates mode */
  69195. static readonly TEXTURE_PLANAR_MODE: number;
  69196. /** Cubic coordinates mode */
  69197. static readonly TEXTURE_CUBIC_MODE: number;
  69198. /** Projection coordinates mode */
  69199. static readonly TEXTURE_PROJECTION_MODE: number;
  69200. /** Skybox coordinates mode */
  69201. static readonly TEXTURE_SKYBOX_MODE: number;
  69202. /** Inverse Cubic coordinates mode */
  69203. static readonly TEXTURE_INVCUBIC_MODE: number;
  69204. /** Equirectangular coordinates mode */
  69205. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  69206. /** Equirectangular Fixed coordinates mode */
  69207. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  69208. /** Equirectangular Fixed Mirrored coordinates mode */
  69209. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  69210. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  69211. static readonly SCALEMODE_FLOOR: number;
  69212. /** Defines that texture rescaling will look for the nearest power of 2 size */
  69213. static readonly SCALEMODE_NEAREST: number;
  69214. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  69215. static readonly SCALEMODE_CEILING: number;
  69216. /**
  69217. * The dirty texture flag value
  69218. */
  69219. static readonly MATERIAL_TextureDirtyFlag: number;
  69220. /**
  69221. * The dirty light flag value
  69222. */
  69223. static readonly MATERIAL_LightDirtyFlag: number;
  69224. /**
  69225. * The dirty fresnel flag value
  69226. */
  69227. static readonly MATERIAL_FresnelDirtyFlag: number;
  69228. /**
  69229. * The dirty attribute flag value
  69230. */
  69231. static readonly MATERIAL_AttributesDirtyFlag: number;
  69232. /**
  69233. * The dirty misc flag value
  69234. */
  69235. static readonly MATERIAL_MiscDirtyFlag: number;
  69236. /**
  69237. * The all dirty flag value
  69238. */
  69239. static readonly MATERIAL_AllDirtyFlag: number;
  69240. /**
  69241. * Returns the triangle fill mode
  69242. */
  69243. static readonly MATERIAL_TriangleFillMode: number;
  69244. /**
  69245. * Returns the wireframe mode
  69246. */
  69247. static readonly MATERIAL_WireFrameFillMode: number;
  69248. /**
  69249. * Returns the point fill mode
  69250. */
  69251. static readonly MATERIAL_PointFillMode: number;
  69252. /**
  69253. * Returns the point list draw mode
  69254. */
  69255. static readonly MATERIAL_PointListDrawMode: number;
  69256. /**
  69257. * Returns the line list draw mode
  69258. */
  69259. static readonly MATERIAL_LineListDrawMode: number;
  69260. /**
  69261. * Returns the line loop draw mode
  69262. */
  69263. static readonly MATERIAL_LineLoopDrawMode: number;
  69264. /**
  69265. * Returns the line strip draw mode
  69266. */
  69267. static readonly MATERIAL_LineStripDrawMode: number;
  69268. /**
  69269. * Returns the triangle strip draw mode
  69270. */
  69271. static readonly MATERIAL_TriangleStripDrawMode: number;
  69272. /**
  69273. * Returns the triangle fan draw mode
  69274. */
  69275. static readonly MATERIAL_TriangleFanDrawMode: number;
  69276. /**
  69277. * Stores the clock-wise side orientation
  69278. */
  69279. static readonly MATERIAL_ClockWiseSideOrientation: number;
  69280. /**
  69281. * Stores the counter clock-wise side orientation
  69282. */
  69283. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  69284. /**
  69285. * Nothing
  69286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69287. */
  69288. static readonly ACTION_NothingTrigger: number;
  69289. /**
  69290. * On pick
  69291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69292. */
  69293. static readonly ACTION_OnPickTrigger: number;
  69294. /**
  69295. * On left pick
  69296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69297. */
  69298. static readonly ACTION_OnLeftPickTrigger: number;
  69299. /**
  69300. * On right pick
  69301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69302. */
  69303. static readonly ACTION_OnRightPickTrigger: number;
  69304. /**
  69305. * On center pick
  69306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69307. */
  69308. static readonly ACTION_OnCenterPickTrigger: number;
  69309. /**
  69310. * On pick down
  69311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69312. */
  69313. static readonly ACTION_OnPickDownTrigger: number;
  69314. /**
  69315. * On double pick
  69316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69317. */
  69318. static readonly ACTION_OnDoublePickTrigger: number;
  69319. /**
  69320. * On pick up
  69321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69322. */
  69323. static readonly ACTION_OnPickUpTrigger: number;
  69324. /**
  69325. * On pick out.
  69326. * This trigger will only be raised if you also declared a OnPickDown
  69327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69328. */
  69329. static readonly ACTION_OnPickOutTrigger: number;
  69330. /**
  69331. * On long press
  69332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69333. */
  69334. static readonly ACTION_OnLongPressTrigger: number;
  69335. /**
  69336. * On pointer over
  69337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69338. */
  69339. static readonly ACTION_OnPointerOverTrigger: number;
  69340. /**
  69341. * On pointer out
  69342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69343. */
  69344. static readonly ACTION_OnPointerOutTrigger: number;
  69345. /**
  69346. * On every frame
  69347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69348. */
  69349. static readonly ACTION_OnEveryFrameTrigger: number;
  69350. /**
  69351. * On intersection enter
  69352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69353. */
  69354. static readonly ACTION_OnIntersectionEnterTrigger: number;
  69355. /**
  69356. * On intersection exit
  69357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69358. */
  69359. static readonly ACTION_OnIntersectionExitTrigger: number;
  69360. /**
  69361. * On key down
  69362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69363. */
  69364. static readonly ACTION_OnKeyDownTrigger: number;
  69365. /**
  69366. * On key up
  69367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69368. */
  69369. static readonly ACTION_OnKeyUpTrigger: number;
  69370. /**
  69371. * Billboard mode will only apply to Y axis
  69372. */
  69373. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  69374. /**
  69375. * Billboard mode will apply to all axes
  69376. */
  69377. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  69378. /**
  69379. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69380. */
  69381. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  69382. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  69383. * Test order :
  69384. * Is the bounding sphere outside the frustum ?
  69385. * If not, are the bounding box vertices outside the frustum ?
  69386. * It not, then the cullable object is in the frustum.
  69387. */
  69388. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  69389. /** Culling strategy : Bounding Sphere Only.
  69390. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  69391. * It's also less accurate than the standard because some not visible objects can still be selected.
  69392. * Test : is the bounding sphere outside the frustum ?
  69393. * If not, then the cullable object is in the frustum.
  69394. */
  69395. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  69396. /** Culling strategy : Optimistic Inclusion.
  69397. * This in an inclusion test first, then the standard exclusion test.
  69398. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  69399. * 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.
  69400. * Anyway, it's as accurate as the standard strategy.
  69401. * Test :
  69402. * Is the cullable object bounding sphere center in the frustum ?
  69403. * If not, apply the default culling strategy.
  69404. */
  69405. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  69406. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  69407. * This in an inclusion test first, then the bounding sphere only exclusion test.
  69408. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  69409. * 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.
  69410. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  69411. * Test :
  69412. * Is the cullable object bounding sphere center in the frustum ?
  69413. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  69414. */
  69415. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  69416. /**
  69417. * No logging while loading
  69418. */
  69419. static readonly SCENELOADER_NO_LOGGING: number;
  69420. /**
  69421. * Minimal logging while loading
  69422. */
  69423. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  69424. /**
  69425. * Summary logging while loading
  69426. */
  69427. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  69428. /**
  69429. * Detailled logging while loading
  69430. */
  69431. static readonly SCENELOADER_DETAILED_LOGGING: number;
  69432. }
  69433. }
  69434. declare module BABYLON {
  69435. /**
  69436. * This represents the required contract to create a new type of texture loader.
  69437. */
  69438. export interface IInternalTextureLoader {
  69439. /**
  69440. * Defines wether the loader supports cascade loading the different faces.
  69441. */
  69442. supportCascades: boolean;
  69443. /**
  69444. * This returns if the loader support the current file information.
  69445. * @param extension defines the file extension of the file being loaded
  69446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69447. * @param fallback defines the fallback internal texture if any
  69448. * @param isBase64 defines whether the texture is encoded as a base64
  69449. * @param isBuffer defines whether the texture data are stored as a buffer
  69450. * @returns true if the loader can load the specified file
  69451. */
  69452. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  69453. /**
  69454. * Transform the url before loading if required.
  69455. * @param rootUrl the url of the texture
  69456. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69457. * @returns the transformed texture
  69458. */
  69459. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  69460. /**
  69461. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  69462. * @param rootUrl the url of the texture
  69463. * @param textureFormatInUse defines the current compressed format in use iun the engine
  69464. * @returns the fallback texture
  69465. */
  69466. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  69467. /**
  69468. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  69469. * @param data contains the texture data
  69470. * @param texture defines the BabylonJS internal texture
  69471. * @param createPolynomials will be true if polynomials have been requested
  69472. * @param onLoad defines the callback to trigger once the texture is ready
  69473. * @param onError defines the callback to trigger in case of error
  69474. */
  69475. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  69476. /**
  69477. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  69478. * @param data contains the texture data
  69479. * @param texture defines the BabylonJS internal texture
  69480. * @param callback defines the method to call once ready to upload
  69481. */
  69482. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  69483. }
  69484. }
  69485. declare module BABYLON {
  69486. /**
  69487. * Class used to store and describe the pipeline context associated with an effect
  69488. */
  69489. export interface IPipelineContext {
  69490. /**
  69491. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  69492. */
  69493. isAsync: boolean;
  69494. /**
  69495. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  69496. */
  69497. isReady: boolean;
  69498. /** @hidden */
  69499. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  69500. }
  69501. }
  69502. declare module BABYLON {
  69503. /**
  69504. * Class used to store gfx data (like WebGLBuffer)
  69505. */
  69506. export class DataBuffer {
  69507. /**
  69508. * Gets or sets the number of objects referencing this buffer
  69509. */
  69510. references: number;
  69511. /** Gets or sets the size of the underlying buffer */
  69512. capacity: number;
  69513. /**
  69514. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  69515. */
  69516. is32Bits: boolean;
  69517. /**
  69518. * Gets the underlying buffer
  69519. */
  69520. readonly underlyingResource: any;
  69521. }
  69522. }
  69523. declare module BABYLON {
  69524. /** @hidden */
  69525. export interface IShaderProcessor {
  69526. attributeProcessor?: (attribute: string) => string;
  69527. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  69528. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  69529. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  69530. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  69531. lineProcessor?: (line: string, isFragment: boolean) => string;
  69532. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69533. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  69534. }
  69535. }
  69536. declare module BABYLON {
  69537. /** @hidden */
  69538. export interface ProcessingOptions {
  69539. defines: string[];
  69540. indexParameters: any;
  69541. isFragment: boolean;
  69542. shouldUseHighPrecisionShader: boolean;
  69543. supportsUniformBuffers: boolean;
  69544. shadersRepository: string;
  69545. includesShadersStore: {
  69546. [key: string]: string;
  69547. };
  69548. processor?: IShaderProcessor;
  69549. version: string;
  69550. platformName: string;
  69551. lookForClosingBracketForUniformBuffer?: boolean;
  69552. }
  69553. }
  69554. declare module BABYLON {
  69555. /** @hidden */
  69556. export class ShaderCodeNode {
  69557. line: string;
  69558. children: ShaderCodeNode[];
  69559. additionalDefineKey?: string;
  69560. additionalDefineValue?: string;
  69561. isValid(preprocessors: {
  69562. [key: string]: string;
  69563. }): boolean;
  69564. process(preprocessors: {
  69565. [key: string]: string;
  69566. }, options: ProcessingOptions): string;
  69567. }
  69568. }
  69569. declare module BABYLON {
  69570. /** @hidden */
  69571. export class ShaderCodeCursor {
  69572. private _lines;
  69573. lineIndex: number;
  69574. readonly currentLine: string;
  69575. readonly canRead: boolean;
  69576. lines: string[];
  69577. }
  69578. }
  69579. declare module BABYLON {
  69580. /** @hidden */
  69581. export class ShaderCodeConditionNode extends ShaderCodeNode {
  69582. process(preprocessors: {
  69583. [key: string]: string;
  69584. }, options: ProcessingOptions): string;
  69585. }
  69586. }
  69587. declare module BABYLON {
  69588. /** @hidden */
  69589. export class ShaderDefineExpression {
  69590. isTrue(preprocessors: {
  69591. [key: string]: string;
  69592. }): boolean;
  69593. }
  69594. }
  69595. declare module BABYLON {
  69596. /** @hidden */
  69597. export class ShaderCodeTestNode extends ShaderCodeNode {
  69598. testExpression: ShaderDefineExpression;
  69599. isValid(preprocessors: {
  69600. [key: string]: string;
  69601. }): boolean;
  69602. }
  69603. }
  69604. declare module BABYLON {
  69605. /** @hidden */
  69606. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  69607. define: string;
  69608. not: boolean;
  69609. constructor(define: string, not?: boolean);
  69610. isTrue(preprocessors: {
  69611. [key: string]: string;
  69612. }): boolean;
  69613. }
  69614. }
  69615. declare module BABYLON {
  69616. /** @hidden */
  69617. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  69618. leftOperand: ShaderDefineExpression;
  69619. rightOperand: ShaderDefineExpression;
  69620. isTrue(preprocessors: {
  69621. [key: string]: string;
  69622. }): boolean;
  69623. }
  69624. }
  69625. declare module BABYLON {
  69626. /** @hidden */
  69627. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  69628. leftOperand: ShaderDefineExpression;
  69629. rightOperand: ShaderDefineExpression;
  69630. isTrue(preprocessors: {
  69631. [key: string]: string;
  69632. }): boolean;
  69633. }
  69634. }
  69635. declare module BABYLON {
  69636. /** @hidden */
  69637. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  69638. define: string;
  69639. operand: string;
  69640. testValue: string;
  69641. constructor(define: string, operand: string, testValue: string);
  69642. isTrue(preprocessors: {
  69643. [key: string]: string;
  69644. }): boolean;
  69645. }
  69646. }
  69647. declare module BABYLON {
  69648. /**
  69649. * Class used to enable access to offline support
  69650. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69651. */
  69652. export interface IOfflineProvider {
  69653. /**
  69654. * Gets a boolean indicating if scene must be saved in the database
  69655. */
  69656. enableSceneOffline: boolean;
  69657. /**
  69658. * Gets a boolean indicating if textures must be saved in the database
  69659. */
  69660. enableTexturesOffline: boolean;
  69661. /**
  69662. * Open the offline support and make it available
  69663. * @param successCallback defines the callback to call on success
  69664. * @param errorCallback defines the callback to call on error
  69665. */
  69666. open(successCallback: () => void, errorCallback: () => void): void;
  69667. /**
  69668. * Loads an image from the offline support
  69669. * @param url defines the url to load from
  69670. * @param image defines the target DOM image
  69671. */
  69672. loadImage(url: string, image: HTMLImageElement): void;
  69673. /**
  69674. * Loads a file from offline support
  69675. * @param url defines the URL to load from
  69676. * @param sceneLoaded defines a callback to call on success
  69677. * @param progressCallBack defines a callback to call when progress changed
  69678. * @param errorCallback defines a callback to call on error
  69679. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69680. */
  69681. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69682. }
  69683. }
  69684. declare module BABYLON {
  69685. /**
  69686. * Class used to help managing file picking and drag'n'drop
  69687. * File Storage
  69688. */
  69689. export class FilesInputStore {
  69690. /**
  69691. * List of files ready to be loaded
  69692. */
  69693. static FilesToLoad: {
  69694. [key: string]: File;
  69695. };
  69696. }
  69697. }
  69698. declare module BABYLON {
  69699. /**
  69700. * Class used to define a retry strategy when error happens while loading assets
  69701. */
  69702. export class RetryStrategy {
  69703. /**
  69704. * Function used to defines an exponential back off strategy
  69705. * @param maxRetries defines the maximum number of retries (3 by default)
  69706. * @param baseInterval defines the interval between retries
  69707. * @returns the strategy function to use
  69708. */
  69709. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  69710. }
  69711. }
  69712. declare module BABYLON {
  69713. /**
  69714. * @ignore
  69715. * Application error to support additional information when loading a file
  69716. */
  69717. export abstract class BaseError extends Error {
  69718. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  69719. }
  69720. }
  69721. declare module BABYLON {
  69722. /** @ignore */
  69723. export class LoadFileError extends BaseError {
  69724. request?: WebRequest;
  69725. file?: File;
  69726. /**
  69727. * Creates a new LoadFileError
  69728. * @param message defines the message of the error
  69729. * @param request defines the optional web request
  69730. * @param file defines the optional file
  69731. */
  69732. constructor(message: string, object?: WebRequest | File);
  69733. }
  69734. /** @ignore */
  69735. export class RequestFileError extends BaseError {
  69736. request: WebRequest;
  69737. /**
  69738. * Creates a new LoadFileError
  69739. * @param message defines the message of the error
  69740. * @param request defines the optional web request
  69741. */
  69742. constructor(message: string, request: WebRequest);
  69743. }
  69744. /** @ignore */
  69745. export class ReadFileError extends BaseError {
  69746. file: File;
  69747. /**
  69748. * Creates a new ReadFileError
  69749. * @param message defines the message of the error
  69750. * @param file defines the optional file
  69751. */
  69752. constructor(message: string, file: File);
  69753. }
  69754. /**
  69755. * @hidden
  69756. */
  69757. export class FileTools {
  69758. /**
  69759. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  69760. */
  69761. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  69762. /**
  69763. * Gets or sets the base URL to use to load assets
  69764. */
  69765. static BaseUrl: string;
  69766. /**
  69767. * Default behaviour for cors in the application.
  69768. * It can be a string if the expected behavior is identical in the entire app.
  69769. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  69770. */
  69771. static CorsBehavior: string | ((url: string | string[]) => string);
  69772. /**
  69773. * Gets or sets a function used to pre-process url before using them to load assets
  69774. */
  69775. static PreprocessUrl: (url: string) => string;
  69776. /**
  69777. * Removes unwanted characters from an url
  69778. * @param url defines the url to clean
  69779. * @returns the cleaned url
  69780. */
  69781. private static _CleanUrl;
  69782. /**
  69783. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  69784. * @param url define the url we are trying
  69785. * @param element define the dom element where to configure the cors policy
  69786. */
  69787. static SetCorsBehavior(url: string | string[], element: {
  69788. crossOrigin: string | null;
  69789. }): void;
  69790. /**
  69791. * Loads an image as an HTMLImageElement.
  69792. * @param input url string, ArrayBuffer, or Blob to load
  69793. * @param onLoad callback called when the image successfully loads
  69794. * @param onError callback called when the image fails to load
  69795. * @param offlineProvider offline provider for caching
  69796. * @param mimeType optional mime type
  69797. * @returns the HTMLImageElement of the loaded image
  69798. */
  69799. 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>;
  69800. /**
  69801. * Reads a file from a File object
  69802. * @param file defines the file to load
  69803. * @param onSuccess defines the callback to call when data is loaded
  69804. * @param onProgress defines the callback to call during loading process
  69805. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  69806. * @param onError defines the callback to call when an error occurs
  69807. * @returns a file request object
  69808. */
  69809. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  69810. /**
  69811. * Loads a file from a url
  69812. * @param url url to load
  69813. * @param onSuccess callback called when the file successfully loads
  69814. * @param onProgress callback called while file is loading (if the server supports this mode)
  69815. * @param offlineProvider defines the offline provider for caching
  69816. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69817. * @param onError callback called when the file fails to load
  69818. * @returns a file request object
  69819. */
  69820. 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;
  69821. /**
  69822. * Loads a file
  69823. * @param url url to load
  69824. * @param onSuccess callback called when the file successfully loads
  69825. * @param onProgress callback called while file is loading (if the server supports this mode)
  69826. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  69827. * @param onError callback called when the file fails to load
  69828. * @param onOpened callback called when the web request is opened
  69829. * @returns a file request object
  69830. */
  69831. 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;
  69832. /**
  69833. * Checks if the loaded document was accessed via `file:`-Protocol.
  69834. * @returns boolean
  69835. */
  69836. static IsFileURL(): boolean;
  69837. }
  69838. }
  69839. declare module BABYLON {
  69840. /** @hidden */
  69841. export class ShaderProcessor {
  69842. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  69843. private static _ProcessPrecision;
  69844. private static _ExtractOperation;
  69845. private static _BuildSubExpression;
  69846. private static _BuildExpression;
  69847. private static _MoveCursorWithinIf;
  69848. private static _MoveCursor;
  69849. private static _EvaluatePreProcessors;
  69850. private static _PreparePreProcessors;
  69851. private static _ProcessShaderConversion;
  69852. private static _ProcessIncludes;
  69853. }
  69854. }
  69855. declare module BABYLON {
  69856. /**
  69857. * @hidden
  69858. */
  69859. export interface IColor4Like {
  69860. r: float;
  69861. g: float;
  69862. b: float;
  69863. a: float;
  69864. }
  69865. /**
  69866. * @hidden
  69867. */
  69868. export interface IColor3Like {
  69869. r: float;
  69870. g: float;
  69871. b: float;
  69872. }
  69873. /**
  69874. * @hidden
  69875. */
  69876. export interface IVector4Like {
  69877. x: float;
  69878. y: float;
  69879. z: float;
  69880. w: float;
  69881. }
  69882. /**
  69883. * @hidden
  69884. */
  69885. export interface IVector3Like {
  69886. x: float;
  69887. y: float;
  69888. z: float;
  69889. }
  69890. /**
  69891. * @hidden
  69892. */
  69893. export interface IVector2Like {
  69894. x: float;
  69895. y: float;
  69896. }
  69897. /**
  69898. * @hidden
  69899. */
  69900. export interface IMatrixLike {
  69901. toArray(): DeepImmutable<Float32Array>;
  69902. updateFlag: int;
  69903. }
  69904. /**
  69905. * @hidden
  69906. */
  69907. export interface IViewportLike {
  69908. x: float;
  69909. y: float;
  69910. width: float;
  69911. height: float;
  69912. }
  69913. /**
  69914. * @hidden
  69915. */
  69916. export interface IPlaneLike {
  69917. normal: IVector3Like;
  69918. d: float;
  69919. normalize(): void;
  69920. }
  69921. }
  69922. declare module BABYLON {
  69923. /**
  69924. * Interface used to define common properties for effect fallbacks
  69925. */
  69926. export interface IEffectFallbacks {
  69927. /**
  69928. * Removes the defines that should be removed when falling back.
  69929. * @param currentDefines defines the current define statements for the shader.
  69930. * @param effect defines the current effect we try to compile
  69931. * @returns The resulting defines with defines of the current rank removed.
  69932. */
  69933. reduce(currentDefines: string, effect: Effect): string;
  69934. /**
  69935. * Removes the fallback from the bound mesh.
  69936. */
  69937. unBindMesh(): void;
  69938. /**
  69939. * Checks to see if more fallbacks are still availible.
  69940. */
  69941. hasMoreFallbacks: boolean;
  69942. }
  69943. }
  69944. declare module BABYLON {
  69945. /**
  69946. * Class used to evalaute queries containing `and` and `or` operators
  69947. */
  69948. export class AndOrNotEvaluator {
  69949. /**
  69950. * Evaluate a query
  69951. * @param query defines the query to evaluate
  69952. * @param evaluateCallback defines the callback used to filter result
  69953. * @returns true if the query matches
  69954. */
  69955. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69956. private static _HandleParenthesisContent;
  69957. private static _SimplifyNegation;
  69958. }
  69959. }
  69960. declare module BABYLON {
  69961. /**
  69962. * Class used to store custom tags
  69963. */
  69964. export class Tags {
  69965. /**
  69966. * Adds support for tags on the given object
  69967. * @param obj defines the object to use
  69968. */
  69969. static EnableFor(obj: any): void;
  69970. /**
  69971. * Removes tags support
  69972. * @param obj defines the object to use
  69973. */
  69974. static DisableFor(obj: any): void;
  69975. /**
  69976. * Gets a boolean indicating if the given object has tags
  69977. * @param obj defines the object to use
  69978. * @returns a boolean
  69979. */
  69980. static HasTags(obj: any): boolean;
  69981. /**
  69982. * Gets the tags available on a given object
  69983. * @param obj defines the object to use
  69984. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69985. * @returns the tags
  69986. */
  69987. static GetTags(obj: any, asString?: boolean): any;
  69988. /**
  69989. * Adds tags to an object
  69990. * @param obj defines the object to use
  69991. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69992. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69993. */
  69994. static AddTagsTo(obj: any, tagsString: string): void;
  69995. /**
  69996. * @hidden
  69997. */
  69998. static _AddTagTo(obj: any, tag: string): void;
  69999. /**
  70000. * Removes specific tags from a specific object
  70001. * @param obj defines the object to use
  70002. * @param tagsString defines the tags to remove
  70003. */
  70004. static RemoveTagsFrom(obj: any, tagsString: string): void;
  70005. /**
  70006. * @hidden
  70007. */
  70008. static _RemoveTagFrom(obj: any, tag: string): void;
  70009. /**
  70010. * Defines if tags hosted on an object match a given query
  70011. * @param obj defines the object to use
  70012. * @param tagsQuery defines the tag query
  70013. * @returns a boolean
  70014. */
  70015. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  70016. }
  70017. }
  70018. declare module BABYLON {
  70019. /**
  70020. * Scalar computation library
  70021. */
  70022. export class Scalar {
  70023. /**
  70024. * Two pi constants convenient for computation.
  70025. */
  70026. static TwoPi: number;
  70027. /**
  70028. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70029. * @param a number
  70030. * @param b number
  70031. * @param epsilon (default = 1.401298E-45)
  70032. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70033. */
  70034. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  70035. /**
  70036. * Returns a string : the upper case translation of the number i to hexadecimal.
  70037. * @param i number
  70038. * @returns the upper case translation of the number i to hexadecimal.
  70039. */
  70040. static ToHex(i: number): string;
  70041. /**
  70042. * Returns -1 if value is negative and +1 is value is positive.
  70043. * @param value the value
  70044. * @returns the value itself if it's equal to zero.
  70045. */
  70046. static Sign(value: number): number;
  70047. /**
  70048. * Returns the value itself if it's between min and max.
  70049. * Returns min if the value is lower than min.
  70050. * Returns max if the value is greater than max.
  70051. * @param value the value to clmap
  70052. * @param min the min value to clamp to (default: 0)
  70053. * @param max the max value to clamp to (default: 1)
  70054. * @returns the clamped value
  70055. */
  70056. static Clamp(value: number, min?: number, max?: number): number;
  70057. /**
  70058. * the log2 of value.
  70059. * @param value the value to compute log2 of
  70060. * @returns the log2 of value.
  70061. */
  70062. static Log2(value: number): number;
  70063. /**
  70064. * Loops the value, so that it is never larger than length and never smaller than 0.
  70065. *
  70066. * This is similar to the modulo operator but it works with floating point numbers.
  70067. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  70068. * With t = 5 and length = 2.5, the result would be 0.0.
  70069. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  70070. * @param value the value
  70071. * @param length the length
  70072. * @returns the looped value
  70073. */
  70074. static Repeat(value: number, length: number): number;
  70075. /**
  70076. * Normalize the value between 0.0 and 1.0 using min and max values
  70077. * @param value value to normalize
  70078. * @param min max to normalize between
  70079. * @param max min to normalize between
  70080. * @returns the normalized value
  70081. */
  70082. static Normalize(value: number, min: number, max: number): number;
  70083. /**
  70084. * Denormalize the value from 0.0 and 1.0 using min and max values
  70085. * @param normalized value to denormalize
  70086. * @param min max to denormalize between
  70087. * @param max min to denormalize between
  70088. * @returns the denormalized value
  70089. */
  70090. static Denormalize(normalized: number, min: number, max: number): number;
  70091. /**
  70092. * Calculates the shortest difference between two given angles given in degrees.
  70093. * @param current current angle in degrees
  70094. * @param target target angle in degrees
  70095. * @returns the delta
  70096. */
  70097. static DeltaAngle(current: number, target: number): number;
  70098. /**
  70099. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  70100. * @param tx value
  70101. * @param length length
  70102. * @returns The returned value will move back and forth between 0 and length
  70103. */
  70104. static PingPong(tx: number, length: number): number;
  70105. /**
  70106. * Interpolates between min and max with smoothing at the limits.
  70107. *
  70108. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70109. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70110. * @param from from
  70111. * @param to to
  70112. * @param tx value
  70113. * @returns the smooth stepped value
  70114. */
  70115. static SmoothStep(from: number, to: number, tx: number): number;
  70116. /**
  70117. * Moves a value current towards target.
  70118. *
  70119. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70120. * Negative values of maxDelta pushes the value away from target.
  70121. * @param current current value
  70122. * @param target target value
  70123. * @param maxDelta max distance to move
  70124. * @returns resulting value
  70125. */
  70126. static MoveTowards(current: number, target: number, maxDelta: number): number;
  70127. /**
  70128. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70129. *
  70130. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70131. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70132. * @param current current value
  70133. * @param target target value
  70134. * @param maxDelta max distance to move
  70135. * @returns resulting angle
  70136. */
  70137. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  70138. /**
  70139. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70140. * @param start start value
  70141. * @param end target value
  70142. * @param amount amount to lerp between
  70143. * @returns the lerped value
  70144. */
  70145. static Lerp(start: number, end: number, amount: number): number;
  70146. /**
  70147. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70148. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70149. * @param start start value
  70150. * @param end target value
  70151. * @param amount amount to lerp between
  70152. * @returns the lerped value
  70153. */
  70154. static LerpAngle(start: number, end: number, amount: number): number;
  70155. /**
  70156. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70157. * @param a start value
  70158. * @param b target value
  70159. * @param value value between a and b
  70160. * @returns the inverseLerp value
  70161. */
  70162. static InverseLerp(a: number, b: number, value: number): number;
  70163. /**
  70164. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70165. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70166. * @param value1 spline value
  70167. * @param tangent1 spline value
  70168. * @param value2 spline value
  70169. * @param tangent2 spline value
  70170. * @param amount input value
  70171. * @returns hermite result
  70172. */
  70173. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  70174. /**
  70175. * Returns a random float number between and min and max values
  70176. * @param min min value of random
  70177. * @param max max value of random
  70178. * @returns random value
  70179. */
  70180. static RandomRange(min: number, max: number): number;
  70181. /**
  70182. * This function returns percentage of a number in a given range.
  70183. *
  70184. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70185. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70186. * @param number to convert to percentage
  70187. * @param min min range
  70188. * @param max max range
  70189. * @returns the percentage
  70190. */
  70191. static RangeToPercent(number: number, min: number, max: number): number;
  70192. /**
  70193. * This function returns number that corresponds to the percentage in a given range.
  70194. *
  70195. * PercentToRange(0.34,0,100) will return 34.
  70196. * @param percent to convert to number
  70197. * @param min min range
  70198. * @param max max range
  70199. * @returns the number
  70200. */
  70201. static PercentToRange(percent: number, min: number, max: number): number;
  70202. /**
  70203. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  70204. * @param angle The angle to normalize in radian.
  70205. * @return The converted angle.
  70206. */
  70207. static NormalizeRadians(angle: number): number;
  70208. }
  70209. }
  70210. declare module BABYLON {
  70211. /**
  70212. * Constant used to convert a value to gamma space
  70213. * @ignorenaming
  70214. */
  70215. export const ToGammaSpace: number;
  70216. /**
  70217. * Constant used to convert a value to linear space
  70218. * @ignorenaming
  70219. */
  70220. export const ToLinearSpace = 2.2;
  70221. /**
  70222. * Constant used to define the minimal number value in Babylon.js
  70223. * @ignorenaming
  70224. */
  70225. let Epsilon: number;
  70226. }
  70227. declare module BABYLON {
  70228. /**
  70229. * Class used to represent a viewport on screen
  70230. */
  70231. export class Viewport {
  70232. /** viewport left coordinate */
  70233. x: number;
  70234. /** viewport top coordinate */
  70235. y: number;
  70236. /**viewport width */
  70237. width: number;
  70238. /** viewport height */
  70239. height: number;
  70240. /**
  70241. * Creates a Viewport object located at (x, y) and sized (width, height)
  70242. * @param x defines viewport left coordinate
  70243. * @param y defines viewport top coordinate
  70244. * @param width defines the viewport width
  70245. * @param height defines the viewport height
  70246. */
  70247. constructor(
  70248. /** viewport left coordinate */
  70249. x: number,
  70250. /** viewport top coordinate */
  70251. y: number,
  70252. /**viewport width */
  70253. width: number,
  70254. /** viewport height */
  70255. height: number);
  70256. /**
  70257. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  70258. * @param renderWidth defines the rendering width
  70259. * @param renderHeight defines the rendering height
  70260. * @returns a new Viewport
  70261. */
  70262. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  70263. /**
  70264. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  70265. * @param renderWidth defines the rendering width
  70266. * @param renderHeight defines the rendering height
  70267. * @param ref defines the target viewport
  70268. * @returns the current viewport
  70269. */
  70270. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  70271. /**
  70272. * Returns a new Viewport copied from the current one
  70273. * @returns a new Viewport
  70274. */
  70275. clone(): Viewport;
  70276. }
  70277. }
  70278. declare module BABYLON {
  70279. /**
  70280. * Class containing a set of static utilities functions for arrays.
  70281. */
  70282. export class ArrayTools {
  70283. /**
  70284. * Returns an array of the given size filled with element built from the given constructor and the paramters
  70285. * @param size the number of element to construct and put in the array
  70286. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  70287. * @returns a new array filled with new objects
  70288. */
  70289. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  70290. }
  70291. }
  70292. declare module BABYLON {
  70293. /**
  70294. * Class representing a vector containing 2 coordinates
  70295. */
  70296. export class Vector2 {
  70297. /** defines the first coordinate */
  70298. x: number;
  70299. /** defines the second coordinate */
  70300. y: number;
  70301. /**
  70302. * Creates a new Vector2 from the given x and y coordinates
  70303. * @param x defines the first coordinate
  70304. * @param y defines the second coordinate
  70305. */
  70306. constructor(
  70307. /** defines the first coordinate */
  70308. x?: number,
  70309. /** defines the second coordinate */
  70310. y?: number);
  70311. /**
  70312. * Gets a string with the Vector2 coordinates
  70313. * @returns a string with the Vector2 coordinates
  70314. */
  70315. toString(): string;
  70316. /**
  70317. * Gets class name
  70318. * @returns the string "Vector2"
  70319. */
  70320. getClassName(): string;
  70321. /**
  70322. * Gets current vector hash code
  70323. * @returns the Vector2 hash code as a number
  70324. */
  70325. getHashCode(): number;
  70326. /**
  70327. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  70328. * @param array defines the source array
  70329. * @param index defines the offset in source array
  70330. * @returns the current Vector2
  70331. */
  70332. toArray(array: FloatArray, index?: number): Vector2;
  70333. /**
  70334. * Copy the current vector to an array
  70335. * @returns a new array with 2 elements: the Vector2 coordinates.
  70336. */
  70337. asArray(): number[];
  70338. /**
  70339. * Sets the Vector2 coordinates with the given Vector2 coordinates
  70340. * @param source defines the source Vector2
  70341. * @returns the current updated Vector2
  70342. */
  70343. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  70344. /**
  70345. * Sets the Vector2 coordinates with the given floats
  70346. * @param x defines the first coordinate
  70347. * @param y defines the second coordinate
  70348. * @returns the current updated Vector2
  70349. */
  70350. copyFromFloats(x: number, y: number): Vector2;
  70351. /**
  70352. * Sets the Vector2 coordinates with the given floats
  70353. * @param x defines the first coordinate
  70354. * @param y defines the second coordinate
  70355. * @returns the current updated Vector2
  70356. */
  70357. set(x: number, y: number): Vector2;
  70358. /**
  70359. * Add another vector with the current one
  70360. * @param otherVector defines the other vector
  70361. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  70362. */
  70363. add(otherVector: DeepImmutable<Vector2>): Vector2;
  70364. /**
  70365. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  70366. * @param otherVector defines the other vector
  70367. * @param result defines the target vector
  70368. * @returns the unmodified current Vector2
  70369. */
  70370. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70371. /**
  70372. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  70373. * @param otherVector defines the other vector
  70374. * @returns the current updated Vector2
  70375. */
  70376. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70377. /**
  70378. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  70379. * @param otherVector defines the other vector
  70380. * @returns a new Vector2
  70381. */
  70382. addVector3(otherVector: Vector3): Vector2;
  70383. /**
  70384. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  70385. * @param otherVector defines the other vector
  70386. * @returns a new Vector2
  70387. */
  70388. subtract(otherVector: Vector2): Vector2;
  70389. /**
  70390. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  70391. * @param otherVector defines the other vector
  70392. * @param result defines the target vector
  70393. * @returns the unmodified current Vector2
  70394. */
  70395. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70396. /**
  70397. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  70398. * @param otherVector defines the other vector
  70399. * @returns the current updated Vector2
  70400. */
  70401. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70402. /**
  70403. * Multiplies in place the current Vector2 coordinates by the given ones
  70404. * @param otherVector defines the other vector
  70405. * @returns the current updated Vector2
  70406. */
  70407. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70408. /**
  70409. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  70410. * @param otherVector defines the other vector
  70411. * @returns a new Vector2
  70412. */
  70413. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  70414. /**
  70415. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  70416. * @param otherVector defines the other vector
  70417. * @param result defines the target vector
  70418. * @returns the unmodified current Vector2
  70419. */
  70420. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70421. /**
  70422. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  70423. * @param x defines the first coordinate
  70424. * @param y defines the second coordinate
  70425. * @returns a new Vector2
  70426. */
  70427. multiplyByFloats(x: number, y: number): Vector2;
  70428. /**
  70429. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  70430. * @param otherVector defines the other vector
  70431. * @returns a new Vector2
  70432. */
  70433. divide(otherVector: Vector2): Vector2;
  70434. /**
  70435. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  70436. * @param otherVector defines the other vector
  70437. * @param result defines the target vector
  70438. * @returns the unmodified current Vector2
  70439. */
  70440. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  70441. /**
  70442. * Divides the current Vector2 coordinates by the given ones
  70443. * @param otherVector defines the other vector
  70444. * @returns the current updated Vector2
  70445. */
  70446. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  70447. /**
  70448. * Gets a new Vector2 with current Vector2 negated coordinates
  70449. * @returns a new Vector2
  70450. */
  70451. negate(): Vector2;
  70452. /**
  70453. * Multiply the Vector2 coordinates by scale
  70454. * @param scale defines the scaling factor
  70455. * @returns the current updated Vector2
  70456. */
  70457. scaleInPlace(scale: number): Vector2;
  70458. /**
  70459. * Returns a new Vector2 scaled by "scale" from the current Vector2
  70460. * @param scale defines the scaling factor
  70461. * @returns a new Vector2
  70462. */
  70463. scale(scale: number): Vector2;
  70464. /**
  70465. * Scale the current Vector2 values by a factor to a given Vector2
  70466. * @param scale defines the scale factor
  70467. * @param result defines the Vector2 object where to store the result
  70468. * @returns the unmodified current Vector2
  70469. */
  70470. scaleToRef(scale: number, result: Vector2): Vector2;
  70471. /**
  70472. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  70473. * @param scale defines the scale factor
  70474. * @param result defines the Vector2 object where to store the result
  70475. * @returns the unmodified current Vector2
  70476. */
  70477. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  70478. /**
  70479. * Gets a boolean if two vectors are equals
  70480. * @param otherVector defines the other vector
  70481. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  70482. */
  70483. equals(otherVector: DeepImmutable<Vector2>): boolean;
  70484. /**
  70485. * Gets a boolean if two vectors are equals (using an epsilon value)
  70486. * @param otherVector defines the other vector
  70487. * @param epsilon defines the minimal distance to consider equality
  70488. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  70489. */
  70490. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  70491. /**
  70492. * Gets a new Vector2 from current Vector2 floored values
  70493. * @returns a new Vector2
  70494. */
  70495. floor(): Vector2;
  70496. /**
  70497. * Gets a new Vector2 from current Vector2 floored values
  70498. * @returns a new Vector2
  70499. */
  70500. fract(): Vector2;
  70501. /**
  70502. * Gets the length of the vector
  70503. * @returns the vector length (float)
  70504. */
  70505. length(): number;
  70506. /**
  70507. * Gets the vector squared length
  70508. * @returns the vector squared length (float)
  70509. */
  70510. lengthSquared(): number;
  70511. /**
  70512. * Normalize the vector
  70513. * @returns the current updated Vector2
  70514. */
  70515. normalize(): Vector2;
  70516. /**
  70517. * Gets a new Vector2 copied from the Vector2
  70518. * @returns a new Vector2
  70519. */
  70520. clone(): Vector2;
  70521. /**
  70522. * Gets a new Vector2(0, 0)
  70523. * @returns a new Vector2
  70524. */
  70525. static Zero(): Vector2;
  70526. /**
  70527. * Gets a new Vector2(1, 1)
  70528. * @returns a new Vector2
  70529. */
  70530. static One(): Vector2;
  70531. /**
  70532. * Gets a new Vector2 set from the given index element of the given array
  70533. * @param array defines the data source
  70534. * @param offset defines the offset in the data source
  70535. * @returns a new Vector2
  70536. */
  70537. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  70538. /**
  70539. * Sets "result" from the given index element of the given array
  70540. * @param array defines the data source
  70541. * @param offset defines the offset in the data source
  70542. * @param result defines the target vector
  70543. */
  70544. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  70545. /**
  70546. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  70547. * @param value1 defines 1st point of control
  70548. * @param value2 defines 2nd point of control
  70549. * @param value3 defines 3rd point of control
  70550. * @param value4 defines 4th point of control
  70551. * @param amount defines the interpolation factor
  70552. * @returns a new Vector2
  70553. */
  70554. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  70555. /**
  70556. * 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".
  70557. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  70558. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  70559. * @param value defines the value to clamp
  70560. * @param min defines the lower limit
  70561. * @param max defines the upper limit
  70562. * @returns a new Vector2
  70563. */
  70564. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  70565. /**
  70566. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  70567. * @param value1 defines the 1st control point
  70568. * @param tangent1 defines the outgoing tangent
  70569. * @param value2 defines the 2nd control point
  70570. * @param tangent2 defines the incoming tangent
  70571. * @param amount defines the interpolation factor
  70572. * @returns a new Vector2
  70573. */
  70574. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  70575. /**
  70576. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  70577. * @param start defines the start vector
  70578. * @param end defines the end vector
  70579. * @param amount defines the interpolation factor
  70580. * @returns a new Vector2
  70581. */
  70582. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  70583. /**
  70584. * Gets the dot product of the vector "left" and the vector "right"
  70585. * @param left defines first vector
  70586. * @param right defines second vector
  70587. * @returns the dot product (float)
  70588. */
  70589. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  70590. /**
  70591. * Returns a new Vector2 equal to the normalized given vector
  70592. * @param vector defines the vector to normalize
  70593. * @returns a new Vector2
  70594. */
  70595. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  70596. /**
  70597. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  70598. * @param left defines 1st vector
  70599. * @param right defines 2nd vector
  70600. * @returns a new Vector2
  70601. */
  70602. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70603. /**
  70604. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  70605. * @param left defines 1st vector
  70606. * @param right defines 2nd vector
  70607. * @returns a new Vector2
  70608. */
  70609. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  70610. /**
  70611. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  70612. * @param vector defines the vector to transform
  70613. * @param transformation defines the matrix to apply
  70614. * @returns a new Vector2
  70615. */
  70616. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  70617. /**
  70618. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  70619. * @param vector defines the vector to transform
  70620. * @param transformation defines the matrix to apply
  70621. * @param result defines the target vector
  70622. */
  70623. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  70624. /**
  70625. * Determines if a given vector is included in a triangle
  70626. * @param p defines the vector to test
  70627. * @param p0 defines 1st triangle point
  70628. * @param p1 defines 2nd triangle point
  70629. * @param p2 defines 3rd triangle point
  70630. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  70631. */
  70632. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  70633. /**
  70634. * Gets the distance between the vectors "value1" and "value2"
  70635. * @param value1 defines first vector
  70636. * @param value2 defines second vector
  70637. * @returns the distance between vectors
  70638. */
  70639. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70640. /**
  70641. * Returns the squared distance between the vectors "value1" and "value2"
  70642. * @param value1 defines first vector
  70643. * @param value2 defines second vector
  70644. * @returns the squared distance between vectors
  70645. */
  70646. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  70647. /**
  70648. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  70649. * @param value1 defines first vector
  70650. * @param value2 defines second vector
  70651. * @returns a new Vector2
  70652. */
  70653. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  70654. /**
  70655. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  70656. * @param p defines the middle point
  70657. * @param segA defines one point of the segment
  70658. * @param segB defines the other point of the segment
  70659. * @returns the shortest distance
  70660. */
  70661. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  70662. }
  70663. /**
  70664. * Classed used to store (x,y,z) vector representation
  70665. * A Vector3 is the main object used in 3D geometry
  70666. * It can represent etiher the coordinates of a point the space, either a direction
  70667. * Reminder: js uses a left handed forward facing system
  70668. */
  70669. export class Vector3 {
  70670. /**
  70671. * Defines the first coordinates (on X axis)
  70672. */
  70673. x: number;
  70674. /**
  70675. * Defines the second coordinates (on Y axis)
  70676. */
  70677. y: number;
  70678. /**
  70679. * Defines the third coordinates (on Z axis)
  70680. */
  70681. z: number;
  70682. private static _UpReadOnly;
  70683. private static _ZeroReadOnly;
  70684. /**
  70685. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  70686. * @param x defines the first coordinates (on X axis)
  70687. * @param y defines the second coordinates (on Y axis)
  70688. * @param z defines the third coordinates (on Z axis)
  70689. */
  70690. constructor(
  70691. /**
  70692. * Defines the first coordinates (on X axis)
  70693. */
  70694. x?: number,
  70695. /**
  70696. * Defines the second coordinates (on Y axis)
  70697. */
  70698. y?: number,
  70699. /**
  70700. * Defines the third coordinates (on Z axis)
  70701. */
  70702. z?: number);
  70703. /**
  70704. * Creates a string representation of the Vector3
  70705. * @returns a string with the Vector3 coordinates.
  70706. */
  70707. toString(): string;
  70708. /**
  70709. * Gets the class name
  70710. * @returns the string "Vector3"
  70711. */
  70712. getClassName(): string;
  70713. /**
  70714. * Creates the Vector3 hash code
  70715. * @returns a number which tends to be unique between Vector3 instances
  70716. */
  70717. getHashCode(): number;
  70718. /**
  70719. * Creates an array containing three elements : the coordinates of the Vector3
  70720. * @returns a new array of numbers
  70721. */
  70722. asArray(): number[];
  70723. /**
  70724. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  70725. * @param array defines the destination array
  70726. * @param index defines the offset in the destination array
  70727. * @returns the current Vector3
  70728. */
  70729. toArray(array: FloatArray, index?: number): Vector3;
  70730. /**
  70731. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  70732. * @returns a new Quaternion object, computed from the Vector3 coordinates
  70733. */
  70734. toQuaternion(): Quaternion;
  70735. /**
  70736. * Adds the given vector to the current Vector3
  70737. * @param otherVector defines the second operand
  70738. * @returns the current updated Vector3
  70739. */
  70740. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70741. /**
  70742. * Adds the given coordinates to the current Vector3
  70743. * @param x defines the x coordinate of the operand
  70744. * @param y defines the y coordinate of the operand
  70745. * @param z defines the z coordinate of the operand
  70746. * @returns the current updated Vector3
  70747. */
  70748. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70749. /**
  70750. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  70751. * @param otherVector defines the second operand
  70752. * @returns the resulting Vector3
  70753. */
  70754. add(otherVector: DeepImmutable<Vector3>): Vector3;
  70755. /**
  70756. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  70757. * @param otherVector defines the second operand
  70758. * @param result defines the Vector3 object where to store the result
  70759. * @returns the current Vector3
  70760. */
  70761. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70762. /**
  70763. * Subtract the given vector from the current Vector3
  70764. * @param otherVector defines the second operand
  70765. * @returns the current updated Vector3
  70766. */
  70767. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70768. /**
  70769. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  70770. * @param otherVector defines the second operand
  70771. * @returns the resulting Vector3
  70772. */
  70773. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  70774. /**
  70775. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  70776. * @param otherVector defines the second operand
  70777. * @param result defines the Vector3 object where to store the result
  70778. * @returns the current Vector3
  70779. */
  70780. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70781. /**
  70782. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  70783. * @param x defines the x coordinate of the operand
  70784. * @param y defines the y coordinate of the operand
  70785. * @param z defines the z coordinate of the operand
  70786. * @returns the resulting Vector3
  70787. */
  70788. subtractFromFloats(x: number, y: number, z: number): Vector3;
  70789. /**
  70790. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  70791. * @param x defines the x coordinate of the operand
  70792. * @param y defines the y coordinate of the operand
  70793. * @param z defines the z coordinate of the operand
  70794. * @param result defines the Vector3 object where to store the result
  70795. * @returns the current Vector3
  70796. */
  70797. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  70798. /**
  70799. * Gets a new Vector3 set with the current Vector3 negated coordinates
  70800. * @returns a new Vector3
  70801. */
  70802. negate(): Vector3;
  70803. /**
  70804. * Multiplies the Vector3 coordinates by the float "scale"
  70805. * @param scale defines the multiplier factor
  70806. * @returns the current updated Vector3
  70807. */
  70808. scaleInPlace(scale: number): Vector3;
  70809. /**
  70810. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  70811. * @param scale defines the multiplier factor
  70812. * @returns a new Vector3
  70813. */
  70814. scale(scale: number): Vector3;
  70815. /**
  70816. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  70817. * @param scale defines the multiplier factor
  70818. * @param result defines the Vector3 object where to store the result
  70819. * @returns the current Vector3
  70820. */
  70821. scaleToRef(scale: number, result: Vector3): Vector3;
  70822. /**
  70823. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  70824. * @param scale defines the scale factor
  70825. * @param result defines the Vector3 object where to store the result
  70826. * @returns the unmodified current Vector3
  70827. */
  70828. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  70829. /**
  70830. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  70831. * @param otherVector defines the second operand
  70832. * @returns true if both vectors are equals
  70833. */
  70834. equals(otherVector: DeepImmutable<Vector3>): boolean;
  70835. /**
  70836. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  70837. * @param otherVector defines the second operand
  70838. * @param epsilon defines the minimal distance to define values as equals
  70839. * @returns true if both vectors are distant less than epsilon
  70840. */
  70841. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  70842. /**
  70843. * Returns true if the current Vector3 coordinates equals the given floats
  70844. * @param x defines the x coordinate of the operand
  70845. * @param y defines the y coordinate of the operand
  70846. * @param z defines the z coordinate of the operand
  70847. * @returns true if both vectors are equals
  70848. */
  70849. equalsToFloats(x: number, y: number, z: number): boolean;
  70850. /**
  70851. * Multiplies the current Vector3 coordinates by the given ones
  70852. * @param otherVector defines the second operand
  70853. * @returns the current updated Vector3
  70854. */
  70855. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  70856. /**
  70857. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  70858. * @param otherVector defines the second operand
  70859. * @returns the new Vector3
  70860. */
  70861. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  70862. /**
  70863. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  70864. * @param otherVector defines the second operand
  70865. * @param result defines the Vector3 object where to store the result
  70866. * @returns the current Vector3
  70867. */
  70868. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70869. /**
  70870. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  70871. * @param x defines the x coordinate of the operand
  70872. * @param y defines the y coordinate of the operand
  70873. * @param z defines the z coordinate of the operand
  70874. * @returns the new Vector3
  70875. */
  70876. multiplyByFloats(x: number, y: number, z: number): Vector3;
  70877. /**
  70878. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  70879. * @param otherVector defines the second operand
  70880. * @returns the new Vector3
  70881. */
  70882. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  70883. /**
  70884. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  70885. * @param otherVector defines the second operand
  70886. * @param result defines the Vector3 object where to store the result
  70887. * @returns the current Vector3
  70888. */
  70889. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  70890. /**
  70891. * Divides the current Vector3 coordinates by the given ones.
  70892. * @param otherVector defines the second operand
  70893. * @returns the current updated Vector3
  70894. */
  70895. divideInPlace(otherVector: Vector3): Vector3;
  70896. /**
  70897. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70898. * @param other defines the second operand
  70899. * @returns the current updated Vector3
  70900. */
  70901. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70902. /**
  70903. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70904. * @param other defines the second operand
  70905. * @returns the current updated Vector3
  70906. */
  70907. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  70908. /**
  70909. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70910. * @param x defines the x coordinate of the operand
  70911. * @param y defines the y coordinate of the operand
  70912. * @param z defines the z coordinate of the operand
  70913. * @returns the current updated Vector3
  70914. */
  70915. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70916. /**
  70917. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70918. * @param x defines the x coordinate of the operand
  70919. * @param y defines the y coordinate of the operand
  70920. * @param z defines the z coordinate of the operand
  70921. * @returns the current updated Vector3
  70922. */
  70923. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  70924. /**
  70925. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70926. * Check if is non uniform within a certain amount of decimal places to account for this
  70927. * @param epsilon the amount the values can differ
  70928. * @returns if the the vector is non uniform to a certain number of decimal places
  70929. */
  70930. isNonUniformWithinEpsilon(epsilon: number): boolean;
  70931. /**
  70932. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70933. */
  70934. readonly isNonUniform: boolean;
  70935. /**
  70936. * Gets a new Vector3 from current Vector3 floored values
  70937. * @returns a new Vector3
  70938. */
  70939. floor(): Vector3;
  70940. /**
  70941. * Gets a new Vector3 from current Vector3 floored values
  70942. * @returns a new Vector3
  70943. */
  70944. fract(): Vector3;
  70945. /**
  70946. * Gets the length of the Vector3
  70947. * @returns the length of the Vector3
  70948. */
  70949. length(): number;
  70950. /**
  70951. * Gets the squared length of the Vector3
  70952. * @returns squared length of the Vector3
  70953. */
  70954. lengthSquared(): number;
  70955. /**
  70956. * Normalize the current Vector3.
  70957. * Please note that this is an in place operation.
  70958. * @returns the current updated Vector3
  70959. */
  70960. normalize(): Vector3;
  70961. /**
  70962. * Reorders the x y z properties of the vector in place
  70963. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70964. * @returns the current updated vector
  70965. */
  70966. reorderInPlace(order: string): this;
  70967. /**
  70968. * Rotates the vector around 0,0,0 by a quaternion
  70969. * @param quaternion the rotation quaternion
  70970. * @param result vector to store the result
  70971. * @returns the resulting vector
  70972. */
  70973. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  70974. /**
  70975. * Rotates a vector around a given point
  70976. * @param quaternion the rotation quaternion
  70977. * @param point the point to rotate around
  70978. * @param result vector to store the result
  70979. * @returns the resulting vector
  70980. */
  70981. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  70982. /**
  70983. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  70984. * The cross product is then orthogonal to both current and "other"
  70985. * @param other defines the right operand
  70986. * @returns the cross product
  70987. */
  70988. cross(other: Vector3): Vector3;
  70989. /**
  70990. * Normalize the current Vector3 with the given input length.
  70991. * Please note that this is an in place operation.
  70992. * @param len the length of the vector
  70993. * @returns the current updated Vector3
  70994. */
  70995. normalizeFromLength(len: number): Vector3;
  70996. /**
  70997. * Normalize the current Vector3 to a new vector
  70998. * @returns the new Vector3
  70999. */
  71000. normalizeToNew(): Vector3;
  71001. /**
  71002. * Normalize the current Vector3 to the reference
  71003. * @param reference define the Vector3 to update
  71004. * @returns the updated Vector3
  71005. */
  71006. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  71007. /**
  71008. * Creates a new Vector3 copied from the current Vector3
  71009. * @returns the new Vector3
  71010. */
  71011. clone(): Vector3;
  71012. /**
  71013. * Copies the given vector coordinates to the current Vector3 ones
  71014. * @param source defines the source Vector3
  71015. * @returns the current updated Vector3
  71016. */
  71017. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  71018. /**
  71019. * Copies the given floats to the current Vector3 coordinates
  71020. * @param x defines the x coordinate of the operand
  71021. * @param y defines the y coordinate of the operand
  71022. * @param z defines the z coordinate of the operand
  71023. * @returns the current updated Vector3
  71024. */
  71025. copyFromFloats(x: number, y: number, z: number): Vector3;
  71026. /**
  71027. * Copies the given floats to the current Vector3 coordinates
  71028. * @param x defines the x coordinate of the operand
  71029. * @param y defines the y coordinate of the operand
  71030. * @param z defines the z coordinate of the operand
  71031. * @returns the current updated Vector3
  71032. */
  71033. set(x: number, y: number, z: number): Vector3;
  71034. /**
  71035. * Copies the given float to the current Vector3 coordinates
  71036. * @param v defines the x, y and z coordinates of the operand
  71037. * @returns the current updated Vector3
  71038. */
  71039. setAll(v: number): Vector3;
  71040. /**
  71041. * Get the clip factor between two vectors
  71042. * @param vector0 defines the first operand
  71043. * @param vector1 defines the second operand
  71044. * @param axis defines the axis to use
  71045. * @param size defines the size along the axis
  71046. * @returns the clip factor
  71047. */
  71048. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  71049. /**
  71050. * Get angle between two vectors
  71051. * @param vector0 angle between vector0 and vector1
  71052. * @param vector1 angle between vector0 and vector1
  71053. * @param normal direction of the normal
  71054. * @return the angle between vector0 and vector1
  71055. */
  71056. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  71057. /**
  71058. * Returns a new Vector3 set from the index "offset" of the given array
  71059. * @param array defines the source array
  71060. * @param offset defines the offset in the source array
  71061. * @returns the new Vector3
  71062. */
  71063. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  71064. /**
  71065. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  71066. * This function is deprecated. Use FromArray instead
  71067. * @param array defines the source array
  71068. * @param offset defines the offset in the source array
  71069. * @returns the new Vector3
  71070. */
  71071. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  71072. /**
  71073. * Sets the given vector "result" with the element values from the index "offset" of the given array
  71074. * @param array defines the source array
  71075. * @param offset defines the offset in the source array
  71076. * @param result defines the Vector3 where to store the result
  71077. */
  71078. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  71079. /**
  71080. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  71081. * This function is deprecated. Use FromArrayToRef instead.
  71082. * @param array defines the source array
  71083. * @param offset defines the offset in the source array
  71084. * @param result defines the Vector3 where to store the result
  71085. */
  71086. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  71087. /**
  71088. * Sets the given vector "result" with the given floats.
  71089. * @param x defines the x coordinate of the source
  71090. * @param y defines the y coordinate of the source
  71091. * @param z defines the z coordinate of the source
  71092. * @param result defines the Vector3 where to store the result
  71093. */
  71094. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  71095. /**
  71096. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  71097. * @returns a new empty Vector3
  71098. */
  71099. static Zero(): Vector3;
  71100. /**
  71101. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  71102. * @returns a new unit Vector3
  71103. */
  71104. static One(): Vector3;
  71105. /**
  71106. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  71107. * @returns a new up Vector3
  71108. */
  71109. static Up(): Vector3;
  71110. /**
  71111. * Gets a up Vector3 that must not be updated
  71112. */
  71113. static readonly UpReadOnly: DeepImmutable<Vector3>;
  71114. /**
  71115. * Gets a zero Vector3 that must not be updated
  71116. */
  71117. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  71118. /**
  71119. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  71120. * @returns a new down Vector3
  71121. */
  71122. static Down(): Vector3;
  71123. /**
  71124. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  71125. * @returns a new forward Vector3
  71126. */
  71127. static Forward(): Vector3;
  71128. /**
  71129. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  71130. * @returns a new forward Vector3
  71131. */
  71132. static Backward(): Vector3;
  71133. /**
  71134. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  71135. * @returns a new right Vector3
  71136. */
  71137. static Right(): Vector3;
  71138. /**
  71139. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  71140. * @returns a new left Vector3
  71141. */
  71142. static Left(): Vector3;
  71143. /**
  71144. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  71145. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71146. * @param vector defines the Vector3 to transform
  71147. * @param transformation defines the transformation matrix
  71148. * @returns the transformed Vector3
  71149. */
  71150. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71151. /**
  71152. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  71153. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  71154. * @param vector defines the Vector3 to transform
  71155. * @param transformation defines the transformation matrix
  71156. * @param result defines the Vector3 where to store the result
  71157. */
  71158. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71159. /**
  71160. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  71161. * This method computes tranformed coordinates only, not transformed direction vectors
  71162. * @param x define the x coordinate of the source vector
  71163. * @param y define the y coordinate of the source vector
  71164. * @param z define the z coordinate of the source vector
  71165. * @param transformation defines the transformation matrix
  71166. * @param result defines the Vector3 where to store the result
  71167. */
  71168. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71169. /**
  71170. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  71171. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71172. * @param vector defines the Vector3 to transform
  71173. * @param transformation defines the transformation matrix
  71174. * @returns the new Vector3
  71175. */
  71176. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  71177. /**
  71178. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  71179. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71180. * @param vector defines the Vector3 to transform
  71181. * @param transformation defines the transformation matrix
  71182. * @param result defines the Vector3 where to store the result
  71183. */
  71184. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71185. /**
  71186. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  71187. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  71188. * @param x define the x coordinate of the source vector
  71189. * @param y define the y coordinate of the source vector
  71190. * @param z define the z coordinate of the source vector
  71191. * @param transformation defines the transformation matrix
  71192. * @param result defines the Vector3 where to store the result
  71193. */
  71194. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  71195. /**
  71196. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  71197. * @param value1 defines the first control point
  71198. * @param value2 defines the second control point
  71199. * @param value3 defines the third control point
  71200. * @param value4 defines the fourth control point
  71201. * @param amount defines the amount on the spline to use
  71202. * @returns the new Vector3
  71203. */
  71204. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  71205. /**
  71206. * 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"
  71207. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71208. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71209. * @param value defines the current value
  71210. * @param min defines the lower range value
  71211. * @param max defines the upper range value
  71212. * @returns the new Vector3
  71213. */
  71214. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  71215. /**
  71216. * 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"
  71217. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  71218. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  71219. * @param value defines the current value
  71220. * @param min defines the lower range value
  71221. * @param max defines the upper range value
  71222. * @param result defines the Vector3 where to store the result
  71223. */
  71224. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  71225. /**
  71226. * Checks if a given vector is inside a specific range
  71227. * @param v defines the vector to test
  71228. * @param min defines the minimum range
  71229. * @param max defines the maximum range
  71230. */
  71231. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  71232. /**
  71233. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  71234. * @param value1 defines the first control point
  71235. * @param tangent1 defines the first tangent vector
  71236. * @param value2 defines the second control point
  71237. * @param tangent2 defines the second tangent vector
  71238. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  71239. * @returns the new Vector3
  71240. */
  71241. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  71242. /**
  71243. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  71244. * @param start defines the start value
  71245. * @param end defines the end value
  71246. * @param amount max defines amount between both (between 0 and 1)
  71247. * @returns the new Vector3
  71248. */
  71249. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  71250. /**
  71251. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  71252. * @param start defines the start value
  71253. * @param end defines the end value
  71254. * @param amount max defines amount between both (between 0 and 1)
  71255. * @param result defines the Vector3 where to store the result
  71256. */
  71257. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  71258. /**
  71259. * Returns the dot product (float) between the vectors "left" and "right"
  71260. * @param left defines the left operand
  71261. * @param right defines the right operand
  71262. * @returns the dot product
  71263. */
  71264. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  71265. /**
  71266. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  71267. * The cross product is then orthogonal to both "left" and "right"
  71268. * @param left defines the left operand
  71269. * @param right defines the right operand
  71270. * @returns the cross product
  71271. */
  71272. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71273. /**
  71274. * Sets the given vector "result" with the cross product of "left" and "right"
  71275. * The cross product is then orthogonal to both "left" and "right"
  71276. * @param left defines the left operand
  71277. * @param right defines the right operand
  71278. * @param result defines the Vector3 where to store the result
  71279. */
  71280. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  71281. /**
  71282. * Returns a new Vector3 as the normalization of the given vector
  71283. * @param vector defines the Vector3 to normalize
  71284. * @returns the new Vector3
  71285. */
  71286. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  71287. /**
  71288. * Sets the given vector "result" with the normalization of the given first vector
  71289. * @param vector defines the Vector3 to normalize
  71290. * @param result defines the Vector3 where to store the result
  71291. */
  71292. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  71293. /**
  71294. * Project a Vector3 onto screen space
  71295. * @param vector defines the Vector3 to project
  71296. * @param world defines the world matrix to use
  71297. * @param transform defines the transform (view x projection) matrix to use
  71298. * @param viewport defines the screen viewport to use
  71299. * @returns the new Vector3
  71300. */
  71301. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  71302. /** @hidden */
  71303. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  71304. /**
  71305. * Unproject from screen space to object space
  71306. * @param source defines the screen space Vector3 to use
  71307. * @param viewportWidth defines the current width of the viewport
  71308. * @param viewportHeight defines the current height of the viewport
  71309. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71310. * @param transform defines the transform (view x projection) matrix to use
  71311. * @returns the new Vector3
  71312. */
  71313. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  71314. /**
  71315. * Unproject from screen space to object space
  71316. * @param source defines the screen space Vector3 to use
  71317. * @param viewportWidth defines the current width of the viewport
  71318. * @param viewportHeight defines the current height of the viewport
  71319. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71320. * @param view defines the view matrix to use
  71321. * @param projection defines the projection matrix to use
  71322. * @returns the new Vector3
  71323. */
  71324. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  71325. /**
  71326. * Unproject from screen space to object space
  71327. * @param source defines the screen space Vector3 to use
  71328. * @param viewportWidth defines the current width of the viewport
  71329. * @param viewportHeight defines the current height of the viewport
  71330. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71331. * @param view defines the view matrix to use
  71332. * @param projection defines the projection matrix to use
  71333. * @param result defines the Vector3 where to store the result
  71334. */
  71335. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71336. /**
  71337. * Unproject from screen space to object space
  71338. * @param sourceX defines the screen space x coordinate to use
  71339. * @param sourceY defines the screen space y coordinate to use
  71340. * @param sourceZ defines the screen space z coordinate to use
  71341. * @param viewportWidth defines the current width of the viewport
  71342. * @param viewportHeight defines the current height of the viewport
  71343. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  71344. * @param view defines the view matrix to use
  71345. * @param projection defines the projection matrix to use
  71346. * @param result defines the Vector3 where to store the result
  71347. */
  71348. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  71349. /**
  71350. * Gets the minimal coordinate values between two Vector3
  71351. * @param left defines the first operand
  71352. * @param right defines the second operand
  71353. * @returns the new Vector3
  71354. */
  71355. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71356. /**
  71357. * Gets the maximal coordinate values between two Vector3
  71358. * @param left defines the first operand
  71359. * @param right defines the second operand
  71360. * @returns the new Vector3
  71361. */
  71362. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  71363. /**
  71364. * Returns the distance between the vectors "value1" and "value2"
  71365. * @param value1 defines the first operand
  71366. * @param value2 defines the second operand
  71367. * @returns the distance
  71368. */
  71369. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71370. /**
  71371. * Returns the squared distance between the vectors "value1" and "value2"
  71372. * @param value1 defines the first operand
  71373. * @param value2 defines the second operand
  71374. * @returns the squared distance
  71375. */
  71376. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  71377. /**
  71378. * Returns a new Vector3 located at the center between "value1" and "value2"
  71379. * @param value1 defines the first operand
  71380. * @param value2 defines the second operand
  71381. * @returns the new Vector3
  71382. */
  71383. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  71384. /**
  71385. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  71386. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  71387. * to something in order to rotate it from its local system to the given target system
  71388. * Note: axis1, axis2 and axis3 are normalized during this operation
  71389. * @param axis1 defines the first axis
  71390. * @param axis2 defines the second axis
  71391. * @param axis3 defines the third axis
  71392. * @returns a new Vector3
  71393. */
  71394. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  71395. /**
  71396. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  71397. * @param axis1 defines the first axis
  71398. * @param axis2 defines the second axis
  71399. * @param axis3 defines the third axis
  71400. * @param ref defines the Vector3 where to store the result
  71401. */
  71402. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  71403. }
  71404. /**
  71405. * Vector4 class created for EulerAngle class conversion to Quaternion
  71406. */
  71407. export class Vector4 {
  71408. /** x value of the vector */
  71409. x: number;
  71410. /** y value of the vector */
  71411. y: number;
  71412. /** z value of the vector */
  71413. z: number;
  71414. /** w value of the vector */
  71415. w: number;
  71416. /**
  71417. * Creates a Vector4 object from the given floats.
  71418. * @param x x value of the vector
  71419. * @param y y value of the vector
  71420. * @param z z value of the vector
  71421. * @param w w value of the vector
  71422. */
  71423. constructor(
  71424. /** x value of the vector */
  71425. x: number,
  71426. /** y value of the vector */
  71427. y: number,
  71428. /** z value of the vector */
  71429. z: number,
  71430. /** w value of the vector */
  71431. w: number);
  71432. /**
  71433. * Returns the string with the Vector4 coordinates.
  71434. * @returns a string containing all the vector values
  71435. */
  71436. toString(): string;
  71437. /**
  71438. * Returns the string "Vector4".
  71439. * @returns "Vector4"
  71440. */
  71441. getClassName(): string;
  71442. /**
  71443. * Returns the Vector4 hash code.
  71444. * @returns a unique hash code
  71445. */
  71446. getHashCode(): number;
  71447. /**
  71448. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  71449. * @returns the resulting array
  71450. */
  71451. asArray(): number[];
  71452. /**
  71453. * Populates the given array from the given index with the Vector4 coordinates.
  71454. * @param array array to populate
  71455. * @param index index of the array to start at (default: 0)
  71456. * @returns the Vector4.
  71457. */
  71458. toArray(array: FloatArray, index?: number): Vector4;
  71459. /**
  71460. * Adds the given vector to the current Vector4.
  71461. * @param otherVector the vector to add
  71462. * @returns the updated Vector4.
  71463. */
  71464. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71465. /**
  71466. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  71467. * @param otherVector the vector to add
  71468. * @returns the resulting vector
  71469. */
  71470. add(otherVector: DeepImmutable<Vector4>): Vector4;
  71471. /**
  71472. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  71473. * @param otherVector the vector to add
  71474. * @param result the vector to store the result
  71475. * @returns the current Vector4.
  71476. */
  71477. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71478. /**
  71479. * Subtract in place the given vector from the current Vector4.
  71480. * @param otherVector the vector to subtract
  71481. * @returns the updated Vector4.
  71482. */
  71483. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71484. /**
  71485. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  71486. * @param otherVector the vector to add
  71487. * @returns the new vector with the result
  71488. */
  71489. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  71490. /**
  71491. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  71492. * @param otherVector the vector to subtract
  71493. * @param result the vector to store the result
  71494. * @returns the current Vector4.
  71495. */
  71496. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71497. /**
  71498. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71499. */
  71500. /**
  71501. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71502. * @param x value to subtract
  71503. * @param y value to subtract
  71504. * @param z value to subtract
  71505. * @param w value to subtract
  71506. * @returns new vector containing the result
  71507. */
  71508. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71509. /**
  71510. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  71511. * @param x value to subtract
  71512. * @param y value to subtract
  71513. * @param z value to subtract
  71514. * @param w value to subtract
  71515. * @param result the vector to store the result in
  71516. * @returns the current Vector4.
  71517. */
  71518. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  71519. /**
  71520. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  71521. * @returns a new vector with the negated values
  71522. */
  71523. negate(): Vector4;
  71524. /**
  71525. * Multiplies the current Vector4 coordinates by scale (float).
  71526. * @param scale the number to scale with
  71527. * @returns the updated Vector4.
  71528. */
  71529. scaleInPlace(scale: number): Vector4;
  71530. /**
  71531. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71532. * @param scale the number to scale with
  71533. * @returns a new vector with the result
  71534. */
  71535. scale(scale: number): Vector4;
  71536. /**
  71537. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71538. * @param scale the number to scale with
  71539. * @param result a vector to store the result in
  71540. * @returns the current Vector4.
  71541. */
  71542. scaleToRef(scale: number, result: Vector4): Vector4;
  71543. /**
  71544. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71545. * @param scale defines the scale factor
  71546. * @param result defines the Vector4 object where to store the result
  71547. * @returns the unmodified current Vector4
  71548. */
  71549. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  71550. /**
  71551. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71552. * @param otherVector the vector to compare against
  71553. * @returns true if they are equal
  71554. */
  71555. equals(otherVector: DeepImmutable<Vector4>): boolean;
  71556. /**
  71557. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71558. * @param otherVector vector to compare against
  71559. * @param epsilon (Default: very small number)
  71560. * @returns true if they are equal
  71561. */
  71562. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  71563. /**
  71564. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71565. * @param x x value to compare against
  71566. * @param y y value to compare against
  71567. * @param z z value to compare against
  71568. * @param w w value to compare against
  71569. * @returns true if equal
  71570. */
  71571. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  71572. /**
  71573. * Multiplies in place the current Vector4 by the given one.
  71574. * @param otherVector vector to multiple with
  71575. * @returns the updated Vector4.
  71576. */
  71577. multiplyInPlace(otherVector: Vector4): Vector4;
  71578. /**
  71579. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71580. * @param otherVector vector to multiple with
  71581. * @returns resulting new vector
  71582. */
  71583. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  71584. /**
  71585. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71586. * @param otherVector vector to multiple with
  71587. * @param result vector to store the result
  71588. * @returns the current Vector4.
  71589. */
  71590. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71591. /**
  71592. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71593. * @param x x value multiply with
  71594. * @param y y value multiply with
  71595. * @param z z value multiply with
  71596. * @param w w value multiply with
  71597. * @returns resulting new vector
  71598. */
  71599. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  71600. /**
  71601. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71602. * @param otherVector vector to devide with
  71603. * @returns resulting new vector
  71604. */
  71605. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  71606. /**
  71607. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71608. * @param otherVector vector to devide with
  71609. * @param result vector to store the result
  71610. * @returns the current Vector4.
  71611. */
  71612. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  71613. /**
  71614. * Divides the current Vector3 coordinates by the given ones.
  71615. * @param otherVector vector to devide with
  71616. * @returns the updated Vector3.
  71617. */
  71618. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  71619. /**
  71620. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71621. * @param other defines the second operand
  71622. * @returns the current updated Vector4
  71623. */
  71624. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71625. /**
  71626. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71627. * @param other defines the second operand
  71628. * @returns the current updated Vector4
  71629. */
  71630. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  71631. /**
  71632. * Gets a new Vector4 from current Vector4 floored values
  71633. * @returns a new Vector4
  71634. */
  71635. floor(): Vector4;
  71636. /**
  71637. * Gets a new Vector4 from current Vector3 floored values
  71638. * @returns a new Vector4
  71639. */
  71640. fract(): Vector4;
  71641. /**
  71642. * Returns the Vector4 length (float).
  71643. * @returns the length
  71644. */
  71645. length(): number;
  71646. /**
  71647. * Returns the Vector4 squared length (float).
  71648. * @returns the length squared
  71649. */
  71650. lengthSquared(): number;
  71651. /**
  71652. * Normalizes in place the Vector4.
  71653. * @returns the updated Vector4.
  71654. */
  71655. normalize(): Vector4;
  71656. /**
  71657. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71658. * @returns this converted to a new vector3
  71659. */
  71660. toVector3(): Vector3;
  71661. /**
  71662. * Returns a new Vector4 copied from the current one.
  71663. * @returns the new cloned vector
  71664. */
  71665. clone(): Vector4;
  71666. /**
  71667. * Updates the current Vector4 with the given one coordinates.
  71668. * @param source the source vector to copy from
  71669. * @returns the updated Vector4.
  71670. */
  71671. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  71672. /**
  71673. * Updates the current Vector4 coordinates with the given floats.
  71674. * @param x float to copy from
  71675. * @param y float to copy from
  71676. * @param z float to copy from
  71677. * @param w float to copy from
  71678. * @returns the updated Vector4.
  71679. */
  71680. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  71681. /**
  71682. * Updates the current Vector4 coordinates with the given floats.
  71683. * @param x float to set from
  71684. * @param y float to set from
  71685. * @param z float to set from
  71686. * @param w float to set from
  71687. * @returns the updated Vector4.
  71688. */
  71689. set(x: number, y: number, z: number, w: number): Vector4;
  71690. /**
  71691. * Copies the given float to the current Vector3 coordinates
  71692. * @param v defines the x, y, z and w coordinates of the operand
  71693. * @returns the current updated Vector3
  71694. */
  71695. setAll(v: number): Vector4;
  71696. /**
  71697. * Returns a new Vector4 set from the starting index of the given array.
  71698. * @param array the array to pull values from
  71699. * @param offset the offset into the array to start at
  71700. * @returns the new vector
  71701. */
  71702. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  71703. /**
  71704. * Updates the given vector "result" from the starting index of the given array.
  71705. * @param array the array to pull values from
  71706. * @param offset the offset into the array to start at
  71707. * @param result the vector to store the result in
  71708. */
  71709. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  71710. /**
  71711. * Updates the given vector "result" from the starting index of the given Float32Array.
  71712. * @param array the array to pull values from
  71713. * @param offset the offset into the array to start at
  71714. * @param result the vector to store the result in
  71715. */
  71716. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  71717. /**
  71718. * Updates the given vector "result" coordinates from the given floats.
  71719. * @param x float to set from
  71720. * @param y float to set from
  71721. * @param z float to set from
  71722. * @param w float to set from
  71723. * @param result the vector to the floats in
  71724. */
  71725. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  71726. /**
  71727. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71728. * @returns the new vector
  71729. */
  71730. static Zero(): Vector4;
  71731. /**
  71732. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71733. * @returns the new vector
  71734. */
  71735. static One(): Vector4;
  71736. /**
  71737. * Returns a new normalized Vector4 from the given one.
  71738. * @param vector the vector to normalize
  71739. * @returns the vector
  71740. */
  71741. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  71742. /**
  71743. * Updates the given vector "result" from the normalization of the given one.
  71744. * @param vector the vector to normalize
  71745. * @param result the vector to store the result in
  71746. */
  71747. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  71748. /**
  71749. * Returns a vector with the minimum values from the left and right vectors
  71750. * @param left left vector to minimize
  71751. * @param right right vector to minimize
  71752. * @returns a new vector with the minimum of the left and right vector values
  71753. */
  71754. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71755. /**
  71756. * Returns a vector with the maximum values from the left and right vectors
  71757. * @param left left vector to maximize
  71758. * @param right right vector to maximize
  71759. * @returns a new vector with the maximum of the left and right vector values
  71760. */
  71761. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  71762. /**
  71763. * Returns the distance (float) between the vectors "value1" and "value2".
  71764. * @param value1 value to calulate the distance between
  71765. * @param value2 value to calulate the distance between
  71766. * @return the distance between the two vectors
  71767. */
  71768. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71769. /**
  71770. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71771. * @param value1 value to calulate the distance between
  71772. * @param value2 value to calulate the distance between
  71773. * @return the distance between the two vectors squared
  71774. */
  71775. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  71776. /**
  71777. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71778. * @param value1 value to calulate the center between
  71779. * @param value2 value to calulate the center between
  71780. * @return the center between the two vectors
  71781. */
  71782. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  71783. /**
  71784. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71785. * This methods computes transformed normalized direction vectors only.
  71786. * @param vector the vector to transform
  71787. * @param transformation the transformation matrix to apply
  71788. * @returns the new vector
  71789. */
  71790. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  71791. /**
  71792. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71793. * This methods computes transformed normalized direction vectors only.
  71794. * @param vector the vector to transform
  71795. * @param transformation the transformation matrix to apply
  71796. * @param result the vector to store the result in
  71797. */
  71798. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71799. /**
  71800. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71801. * This methods computes transformed normalized direction vectors only.
  71802. * @param x value to transform
  71803. * @param y value to transform
  71804. * @param z value to transform
  71805. * @param w value to transform
  71806. * @param transformation the transformation matrix to apply
  71807. * @param result the vector to store the results in
  71808. */
  71809. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  71810. /**
  71811. * Creates a new Vector4 from a Vector3
  71812. * @param source defines the source data
  71813. * @param w defines the 4th component (default is 0)
  71814. * @returns a new Vector4
  71815. */
  71816. static FromVector3(source: Vector3, w?: number): Vector4;
  71817. }
  71818. /**
  71819. * Class used to store quaternion data
  71820. * @see https://en.wikipedia.org/wiki/Quaternion
  71821. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71822. */
  71823. export class Quaternion {
  71824. /** defines the first component (0 by default) */
  71825. x: number;
  71826. /** defines the second component (0 by default) */
  71827. y: number;
  71828. /** defines the third component (0 by default) */
  71829. z: number;
  71830. /** defines the fourth component (1.0 by default) */
  71831. w: number;
  71832. /**
  71833. * Creates a new Quaternion from the given floats
  71834. * @param x defines the first component (0 by default)
  71835. * @param y defines the second component (0 by default)
  71836. * @param z defines the third component (0 by default)
  71837. * @param w defines the fourth component (1.0 by default)
  71838. */
  71839. constructor(
  71840. /** defines the first component (0 by default) */
  71841. x?: number,
  71842. /** defines the second component (0 by default) */
  71843. y?: number,
  71844. /** defines the third component (0 by default) */
  71845. z?: number,
  71846. /** defines the fourth component (1.0 by default) */
  71847. w?: number);
  71848. /**
  71849. * Gets a string representation for the current quaternion
  71850. * @returns a string with the Quaternion coordinates
  71851. */
  71852. toString(): string;
  71853. /**
  71854. * Gets the class name of the quaternion
  71855. * @returns the string "Quaternion"
  71856. */
  71857. getClassName(): string;
  71858. /**
  71859. * Gets a hash code for this quaternion
  71860. * @returns the quaternion hash code
  71861. */
  71862. getHashCode(): number;
  71863. /**
  71864. * Copy the quaternion to an array
  71865. * @returns a new array populated with 4 elements from the quaternion coordinates
  71866. */
  71867. asArray(): number[];
  71868. /**
  71869. * Check if two quaternions are equals
  71870. * @param otherQuaternion defines the second operand
  71871. * @return true if the current quaternion and the given one coordinates are strictly equals
  71872. */
  71873. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  71874. /**
  71875. * Clone the current quaternion
  71876. * @returns a new quaternion copied from the current one
  71877. */
  71878. clone(): Quaternion;
  71879. /**
  71880. * Copy a quaternion to the current one
  71881. * @param other defines the other quaternion
  71882. * @returns the updated current quaternion
  71883. */
  71884. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  71885. /**
  71886. * Updates the current quaternion with the given float coordinates
  71887. * @param x defines the x coordinate
  71888. * @param y defines the y coordinate
  71889. * @param z defines the z coordinate
  71890. * @param w defines the w coordinate
  71891. * @returns the updated current quaternion
  71892. */
  71893. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  71894. /**
  71895. * Updates the current quaternion from the given float coordinates
  71896. * @param x defines the x coordinate
  71897. * @param y defines the y coordinate
  71898. * @param z defines the z coordinate
  71899. * @param w defines the w coordinate
  71900. * @returns the updated current quaternion
  71901. */
  71902. set(x: number, y: number, z: number, w: number): Quaternion;
  71903. /**
  71904. * Adds two quaternions
  71905. * @param other defines the second operand
  71906. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71907. */
  71908. add(other: DeepImmutable<Quaternion>): Quaternion;
  71909. /**
  71910. * Add a quaternion to the current one
  71911. * @param other defines the quaternion to add
  71912. * @returns the current quaternion
  71913. */
  71914. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  71915. /**
  71916. * Subtract two quaternions
  71917. * @param other defines the second operand
  71918. * @returns a new quaternion as the subtraction result of the given one from the current one
  71919. */
  71920. subtract(other: Quaternion): Quaternion;
  71921. /**
  71922. * Multiplies the current quaternion by a scale factor
  71923. * @param value defines the scale factor
  71924. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71925. */
  71926. scale(value: number): Quaternion;
  71927. /**
  71928. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71929. * @param scale defines the scale factor
  71930. * @param result defines the Quaternion object where to store the result
  71931. * @returns the unmodified current quaternion
  71932. */
  71933. scaleToRef(scale: number, result: Quaternion): Quaternion;
  71934. /**
  71935. * Multiplies in place the current quaternion by a scale factor
  71936. * @param value defines the scale factor
  71937. * @returns the current modified quaternion
  71938. */
  71939. scaleInPlace(value: number): Quaternion;
  71940. /**
  71941. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71942. * @param scale defines the scale factor
  71943. * @param result defines the Quaternion object where to store the result
  71944. * @returns the unmodified current quaternion
  71945. */
  71946. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  71947. /**
  71948. * Multiplies two quaternions
  71949. * @param q1 defines the second operand
  71950. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71951. */
  71952. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  71953. /**
  71954. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71955. * @param q1 defines the second operand
  71956. * @param result defines the target quaternion
  71957. * @returns the current quaternion
  71958. */
  71959. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  71960. /**
  71961. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71962. * @param q1 defines the second operand
  71963. * @returns the currentupdated quaternion
  71964. */
  71965. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  71966. /**
  71967. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71968. * @param ref defines the target quaternion
  71969. * @returns the current quaternion
  71970. */
  71971. conjugateToRef(ref: Quaternion): Quaternion;
  71972. /**
  71973. * Conjugates in place (1-q) the current quaternion
  71974. * @returns the current updated quaternion
  71975. */
  71976. conjugateInPlace(): Quaternion;
  71977. /**
  71978. * Conjugates in place (1-q) the current quaternion
  71979. * @returns a new quaternion
  71980. */
  71981. conjugate(): Quaternion;
  71982. /**
  71983. * Gets length of current quaternion
  71984. * @returns the quaternion length (float)
  71985. */
  71986. length(): number;
  71987. /**
  71988. * Normalize in place the current quaternion
  71989. * @returns the current updated quaternion
  71990. */
  71991. normalize(): Quaternion;
  71992. /**
  71993. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71994. * @param order is a reserved parameter and is ignore for now
  71995. * @returns a new Vector3 containing the Euler angles
  71996. */
  71997. toEulerAngles(order?: string): Vector3;
  71998. /**
  71999. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  72000. * @param result defines the vector which will be filled with the Euler angles
  72001. * @param order is a reserved parameter and is ignore for now
  72002. * @returns the current unchanged quaternion
  72003. */
  72004. toEulerAnglesToRef(result: Vector3): Quaternion;
  72005. /**
  72006. * Updates the given rotation matrix with the current quaternion values
  72007. * @param result defines the target matrix
  72008. * @returns the current unchanged quaternion
  72009. */
  72010. toRotationMatrix(result: Matrix): Quaternion;
  72011. /**
  72012. * Updates the current quaternion from the given rotation matrix values
  72013. * @param matrix defines the source matrix
  72014. * @returns the current updated quaternion
  72015. */
  72016. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72017. /**
  72018. * Creates a new quaternion from a rotation matrix
  72019. * @param matrix defines the source matrix
  72020. * @returns a new quaternion created from the given rotation matrix values
  72021. */
  72022. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  72023. /**
  72024. * Updates the given quaternion with the given rotation matrix values
  72025. * @param matrix defines the source matrix
  72026. * @param result defines the target quaternion
  72027. */
  72028. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  72029. /**
  72030. * Returns the dot product (float) between the quaternions "left" and "right"
  72031. * @param left defines the left operand
  72032. * @param right defines the right operand
  72033. * @returns the dot product
  72034. */
  72035. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  72036. /**
  72037. * Checks if the two quaternions are close to each other
  72038. * @param quat0 defines the first quaternion to check
  72039. * @param quat1 defines the second quaternion to check
  72040. * @returns true if the two quaternions are close to each other
  72041. */
  72042. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  72043. /**
  72044. * Creates an empty quaternion
  72045. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  72046. */
  72047. static Zero(): Quaternion;
  72048. /**
  72049. * Inverse a given quaternion
  72050. * @param q defines the source quaternion
  72051. * @returns a new quaternion as the inverted current quaternion
  72052. */
  72053. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  72054. /**
  72055. * Inverse a given quaternion
  72056. * @param q defines the source quaternion
  72057. * @param result the quaternion the result will be stored in
  72058. * @returns the result quaternion
  72059. */
  72060. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  72061. /**
  72062. * Creates an identity quaternion
  72063. * @returns the identity quaternion
  72064. */
  72065. static Identity(): Quaternion;
  72066. /**
  72067. * Gets a boolean indicating if the given quaternion is identity
  72068. * @param quaternion defines the quaternion to check
  72069. * @returns true if the quaternion is identity
  72070. */
  72071. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  72072. /**
  72073. * Creates a quaternion from a rotation around an axis
  72074. * @param axis defines the axis to use
  72075. * @param angle defines the angle to use
  72076. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  72077. */
  72078. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  72079. /**
  72080. * Creates a rotation around an axis and stores it into the given quaternion
  72081. * @param axis defines the axis to use
  72082. * @param angle defines the angle to use
  72083. * @param result defines the target quaternion
  72084. * @returns the target quaternion
  72085. */
  72086. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  72087. /**
  72088. * Creates a new quaternion from data stored into an array
  72089. * @param array defines the data source
  72090. * @param offset defines the offset in the source array where the data starts
  72091. * @returns a new quaternion
  72092. */
  72093. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  72094. /**
  72095. * Create a quaternion from Euler rotation angles
  72096. * @param x Pitch
  72097. * @param y Yaw
  72098. * @param z Roll
  72099. * @returns the new Quaternion
  72100. */
  72101. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  72102. /**
  72103. * Updates a quaternion from Euler rotation angles
  72104. * @param x Pitch
  72105. * @param y Yaw
  72106. * @param z Roll
  72107. * @param result the quaternion to store the result
  72108. * @returns the updated quaternion
  72109. */
  72110. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  72111. /**
  72112. * Create a quaternion from Euler rotation vector
  72113. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72114. * @returns the new Quaternion
  72115. */
  72116. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  72117. /**
  72118. * Updates a quaternion from Euler rotation vector
  72119. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72120. * @param result the quaternion to store the result
  72121. * @returns the updated quaternion
  72122. */
  72123. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  72124. /**
  72125. * Creates a new quaternion from the given Euler float angles (y, x, z)
  72126. * @param yaw defines the rotation around Y axis
  72127. * @param pitch defines the rotation around X axis
  72128. * @param roll defines the rotation around Z axis
  72129. * @returns the new quaternion
  72130. */
  72131. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  72132. /**
  72133. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  72134. * @param yaw defines the rotation around Y axis
  72135. * @param pitch defines the rotation around X axis
  72136. * @param roll defines the rotation around Z axis
  72137. * @param result defines the target quaternion
  72138. */
  72139. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  72140. /**
  72141. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  72142. * @param alpha defines the rotation around first axis
  72143. * @param beta defines the rotation around second axis
  72144. * @param gamma defines the rotation around third axis
  72145. * @returns the new quaternion
  72146. */
  72147. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  72148. /**
  72149. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  72150. * @param alpha defines the rotation around first axis
  72151. * @param beta defines the rotation around second axis
  72152. * @param gamma defines the rotation around third axis
  72153. * @param result defines the target quaternion
  72154. */
  72155. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  72156. /**
  72157. * 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)
  72158. * @param axis1 defines the first axis
  72159. * @param axis2 defines the second axis
  72160. * @param axis3 defines the third axis
  72161. * @returns the new quaternion
  72162. */
  72163. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  72164. /**
  72165. * 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
  72166. * @param axis1 defines the first axis
  72167. * @param axis2 defines the second axis
  72168. * @param axis3 defines the third axis
  72169. * @param ref defines the target quaternion
  72170. */
  72171. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  72172. /**
  72173. * Interpolates between two quaternions
  72174. * @param left defines first quaternion
  72175. * @param right defines second quaternion
  72176. * @param amount defines the gradient to use
  72177. * @returns the new interpolated quaternion
  72178. */
  72179. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72180. /**
  72181. * Interpolates between two quaternions and stores it into a target quaternion
  72182. * @param left defines first quaternion
  72183. * @param right defines second quaternion
  72184. * @param amount defines the gradient to use
  72185. * @param result defines the target quaternion
  72186. */
  72187. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  72188. /**
  72189. * Interpolate between two quaternions using Hermite interpolation
  72190. * @param value1 defines first quaternion
  72191. * @param tangent1 defines the incoming tangent
  72192. * @param value2 defines second quaternion
  72193. * @param tangent2 defines the outgoing tangent
  72194. * @param amount defines the target quaternion
  72195. * @returns the new interpolated quaternion
  72196. */
  72197. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  72198. }
  72199. /**
  72200. * Class used to store matrix data (4x4)
  72201. */
  72202. export class Matrix {
  72203. private static _updateFlagSeed;
  72204. private static _identityReadOnly;
  72205. private _isIdentity;
  72206. private _isIdentityDirty;
  72207. private _isIdentity3x2;
  72208. private _isIdentity3x2Dirty;
  72209. /**
  72210. * Gets the update flag of the matrix which is an unique number for the matrix.
  72211. * It will be incremented every time the matrix data change.
  72212. * You can use it to speed the comparison between two versions of the same matrix.
  72213. */
  72214. updateFlag: number;
  72215. private readonly _m;
  72216. /**
  72217. * Gets the internal data of the matrix
  72218. */
  72219. readonly m: DeepImmutable<Float32Array>;
  72220. /** @hidden */
  72221. _markAsUpdated(): void;
  72222. /** @hidden */
  72223. private _updateIdentityStatus;
  72224. /**
  72225. * Creates an empty matrix (filled with zeros)
  72226. */
  72227. constructor();
  72228. /**
  72229. * Check if the current matrix is identity
  72230. * @returns true is the matrix is the identity matrix
  72231. */
  72232. isIdentity(): boolean;
  72233. /**
  72234. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  72235. * @returns true is the matrix is the identity matrix
  72236. */
  72237. isIdentityAs3x2(): boolean;
  72238. /**
  72239. * Gets the determinant of the matrix
  72240. * @returns the matrix determinant
  72241. */
  72242. determinant(): number;
  72243. /**
  72244. * Returns the matrix as a Float32Array
  72245. * @returns the matrix underlying array
  72246. */
  72247. toArray(): DeepImmutable<Float32Array>;
  72248. /**
  72249. * Returns the matrix as a Float32Array
  72250. * @returns the matrix underlying array.
  72251. */
  72252. asArray(): DeepImmutable<Float32Array>;
  72253. /**
  72254. * Inverts the current matrix in place
  72255. * @returns the current inverted matrix
  72256. */
  72257. invert(): Matrix;
  72258. /**
  72259. * Sets all the matrix elements to zero
  72260. * @returns the current matrix
  72261. */
  72262. reset(): Matrix;
  72263. /**
  72264. * Adds the current matrix with a second one
  72265. * @param other defines the matrix to add
  72266. * @returns a new matrix as the addition of the current matrix and the given one
  72267. */
  72268. add(other: DeepImmutable<Matrix>): Matrix;
  72269. /**
  72270. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72271. * @param other defines the matrix to add
  72272. * @param result defines the target matrix
  72273. * @returns the current matrix
  72274. */
  72275. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72276. /**
  72277. * Adds in place the given matrix to the current matrix
  72278. * @param other defines the second operand
  72279. * @returns the current updated matrix
  72280. */
  72281. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  72282. /**
  72283. * Sets the given matrix to the current inverted Matrix
  72284. * @param other defines the target matrix
  72285. * @returns the unmodified current matrix
  72286. */
  72287. invertToRef(other: Matrix): Matrix;
  72288. /**
  72289. * add a value at the specified position in the current Matrix
  72290. * @param index the index of the value within the matrix. between 0 and 15.
  72291. * @param value the value to be added
  72292. * @returns the current updated matrix
  72293. */
  72294. addAtIndex(index: number, value: number): Matrix;
  72295. /**
  72296. * mutiply the specified position in the current Matrix by a value
  72297. * @param index the index of the value within the matrix. between 0 and 15.
  72298. * @param value the value to be added
  72299. * @returns the current updated matrix
  72300. */
  72301. multiplyAtIndex(index: number, value: number): Matrix;
  72302. /**
  72303. * Inserts the translation vector (using 3 floats) in the current matrix
  72304. * @param x defines the 1st component of the translation
  72305. * @param y defines the 2nd component of the translation
  72306. * @param z defines the 3rd component of the translation
  72307. * @returns the current updated matrix
  72308. */
  72309. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72310. /**
  72311. * Adds the translation vector (using 3 floats) in the current matrix
  72312. * @param x defines the 1st component of the translation
  72313. * @param y defines the 2nd component of the translation
  72314. * @param z defines the 3rd component of the translation
  72315. * @returns the current updated matrix
  72316. */
  72317. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  72318. /**
  72319. * Inserts the translation vector in the current matrix
  72320. * @param vector3 defines the translation to insert
  72321. * @returns the current updated matrix
  72322. */
  72323. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  72324. /**
  72325. * Gets the translation value of the current matrix
  72326. * @returns a new Vector3 as the extracted translation from the matrix
  72327. */
  72328. getTranslation(): Vector3;
  72329. /**
  72330. * Fill a Vector3 with the extracted translation from the matrix
  72331. * @param result defines the Vector3 where to store the translation
  72332. * @returns the current matrix
  72333. */
  72334. getTranslationToRef(result: Vector3): Matrix;
  72335. /**
  72336. * Remove rotation and scaling part from the matrix
  72337. * @returns the updated matrix
  72338. */
  72339. removeRotationAndScaling(): Matrix;
  72340. /**
  72341. * Multiply two matrices
  72342. * @param other defines the second operand
  72343. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72344. */
  72345. multiply(other: DeepImmutable<Matrix>): Matrix;
  72346. /**
  72347. * Copy the current matrix from the given one
  72348. * @param other defines the source matrix
  72349. * @returns the current updated matrix
  72350. */
  72351. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  72352. /**
  72353. * Populates the given array from the starting index with the current matrix values
  72354. * @param array defines the target array
  72355. * @param offset defines the offset in the target array where to start storing values
  72356. * @returns the current matrix
  72357. */
  72358. copyToArray(array: Float32Array, offset?: number): Matrix;
  72359. /**
  72360. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72361. * @param other defines the second operand
  72362. * @param result defines the matrix where to store the multiplication
  72363. * @returns the current matrix
  72364. */
  72365. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  72366. /**
  72367. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72368. * @param other defines the second operand
  72369. * @param result defines the array where to store the multiplication
  72370. * @param offset defines the offset in the target array where to start storing values
  72371. * @returns the current matrix
  72372. */
  72373. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  72374. /**
  72375. * Check equality between this matrix and a second one
  72376. * @param value defines the second matrix to compare
  72377. * @returns true is the current matrix and the given one values are strictly equal
  72378. */
  72379. equals(value: DeepImmutable<Matrix>): boolean;
  72380. /**
  72381. * Clone the current matrix
  72382. * @returns a new matrix from the current matrix
  72383. */
  72384. clone(): Matrix;
  72385. /**
  72386. * Returns the name of the current matrix class
  72387. * @returns the string "Matrix"
  72388. */
  72389. getClassName(): string;
  72390. /**
  72391. * Gets the hash code of the current matrix
  72392. * @returns the hash code
  72393. */
  72394. getHashCode(): number;
  72395. /**
  72396. * Decomposes the current Matrix into a translation, rotation and scaling components
  72397. * @param scale defines the scale vector3 given as a reference to update
  72398. * @param rotation defines the rotation quaternion given as a reference to update
  72399. * @param translation defines the translation vector3 given as a reference to update
  72400. * @returns true if operation was successful
  72401. */
  72402. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  72403. /**
  72404. * Gets specific row of the matrix
  72405. * @param index defines the number of the row to get
  72406. * @returns the index-th row of the current matrix as a new Vector4
  72407. */
  72408. getRow(index: number): Nullable<Vector4>;
  72409. /**
  72410. * Sets the index-th row of the current matrix to the vector4 values
  72411. * @param index defines the number of the row to set
  72412. * @param row defines the target vector4
  72413. * @returns the updated current matrix
  72414. */
  72415. setRow(index: number, row: Vector4): Matrix;
  72416. /**
  72417. * Compute the transpose of the matrix
  72418. * @returns the new transposed matrix
  72419. */
  72420. transpose(): Matrix;
  72421. /**
  72422. * Compute the transpose of the matrix and store it in a given matrix
  72423. * @param result defines the target matrix
  72424. * @returns the current matrix
  72425. */
  72426. transposeToRef(result: Matrix): Matrix;
  72427. /**
  72428. * Sets the index-th row of the current matrix with the given 4 x float values
  72429. * @param index defines the row index
  72430. * @param x defines the x component to set
  72431. * @param y defines the y component to set
  72432. * @param z defines the z component to set
  72433. * @param w defines the w component to set
  72434. * @returns the updated current matrix
  72435. */
  72436. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  72437. /**
  72438. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72439. * @param scale defines the scale factor
  72440. * @returns a new matrix
  72441. */
  72442. scale(scale: number): Matrix;
  72443. /**
  72444. * Scale the current matrix values by a factor to a given result matrix
  72445. * @param scale defines the scale factor
  72446. * @param result defines the matrix to store the result
  72447. * @returns the current matrix
  72448. */
  72449. scaleToRef(scale: number, result: Matrix): Matrix;
  72450. /**
  72451. * Scale the current matrix values by a factor and add the result to a given matrix
  72452. * @param scale defines the scale factor
  72453. * @param result defines the Matrix to store the result
  72454. * @returns the current matrix
  72455. */
  72456. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  72457. /**
  72458. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72459. * @param ref matrix to store the result
  72460. */
  72461. toNormalMatrix(ref: Matrix): void;
  72462. /**
  72463. * Gets only rotation part of the current matrix
  72464. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72465. */
  72466. getRotationMatrix(): Matrix;
  72467. /**
  72468. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72469. * @param result defines the target matrix to store data to
  72470. * @returns the current matrix
  72471. */
  72472. getRotationMatrixToRef(result: Matrix): Matrix;
  72473. /**
  72474. * Toggles model matrix from being right handed to left handed in place and vice versa
  72475. */
  72476. toggleModelMatrixHandInPlace(): void;
  72477. /**
  72478. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72479. */
  72480. toggleProjectionMatrixHandInPlace(): void;
  72481. /**
  72482. * Creates a matrix from an array
  72483. * @param array defines the source array
  72484. * @param offset defines an offset in the source array
  72485. * @returns a new Matrix set from the starting index of the given array
  72486. */
  72487. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  72488. /**
  72489. * Copy the content of an array into a given matrix
  72490. * @param array defines the source array
  72491. * @param offset defines an offset in the source array
  72492. * @param result defines the target matrix
  72493. */
  72494. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  72495. /**
  72496. * Stores an array into a matrix after having multiplied each component by a given factor
  72497. * @param array defines the source array
  72498. * @param offset defines the offset in the source array
  72499. * @param scale defines the scaling factor
  72500. * @param result defines the target matrix
  72501. */
  72502. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  72503. /**
  72504. * Gets an identity matrix that must not be updated
  72505. */
  72506. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  72507. /**
  72508. * Stores a list of values (16) inside a given matrix
  72509. * @param initialM11 defines 1st value of 1st row
  72510. * @param initialM12 defines 2nd value of 1st row
  72511. * @param initialM13 defines 3rd value of 1st row
  72512. * @param initialM14 defines 4th value of 1st row
  72513. * @param initialM21 defines 1st value of 2nd row
  72514. * @param initialM22 defines 2nd value of 2nd row
  72515. * @param initialM23 defines 3rd value of 2nd row
  72516. * @param initialM24 defines 4th value of 2nd row
  72517. * @param initialM31 defines 1st value of 3rd row
  72518. * @param initialM32 defines 2nd value of 3rd row
  72519. * @param initialM33 defines 3rd value of 3rd row
  72520. * @param initialM34 defines 4th value of 3rd row
  72521. * @param initialM41 defines 1st value of 4th row
  72522. * @param initialM42 defines 2nd value of 4th row
  72523. * @param initialM43 defines 3rd value of 4th row
  72524. * @param initialM44 defines 4th value of 4th row
  72525. * @param result defines the target matrix
  72526. */
  72527. 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;
  72528. /**
  72529. * Creates new matrix from a list of values (16)
  72530. * @param initialM11 defines 1st value of 1st row
  72531. * @param initialM12 defines 2nd value of 1st row
  72532. * @param initialM13 defines 3rd value of 1st row
  72533. * @param initialM14 defines 4th value of 1st row
  72534. * @param initialM21 defines 1st value of 2nd row
  72535. * @param initialM22 defines 2nd value of 2nd row
  72536. * @param initialM23 defines 3rd value of 2nd row
  72537. * @param initialM24 defines 4th value of 2nd row
  72538. * @param initialM31 defines 1st value of 3rd row
  72539. * @param initialM32 defines 2nd value of 3rd row
  72540. * @param initialM33 defines 3rd value of 3rd row
  72541. * @param initialM34 defines 4th value of 3rd row
  72542. * @param initialM41 defines 1st value of 4th row
  72543. * @param initialM42 defines 2nd value of 4th row
  72544. * @param initialM43 defines 3rd value of 4th row
  72545. * @param initialM44 defines 4th value of 4th row
  72546. * @returns the new matrix
  72547. */
  72548. 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;
  72549. /**
  72550. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72551. * @param scale defines the scale vector3
  72552. * @param rotation defines the rotation quaternion
  72553. * @param translation defines the translation vector3
  72554. * @returns a new matrix
  72555. */
  72556. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  72557. /**
  72558. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  72559. * @param scale defines the scale vector3
  72560. * @param rotation defines the rotation quaternion
  72561. * @param translation defines the translation vector3
  72562. * @param result defines the target matrix
  72563. */
  72564. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  72565. /**
  72566. * Creates a new identity matrix
  72567. * @returns a new identity matrix
  72568. */
  72569. static Identity(): Matrix;
  72570. /**
  72571. * Creates a new identity matrix and stores the result in a given matrix
  72572. * @param result defines the target matrix
  72573. */
  72574. static IdentityToRef(result: Matrix): void;
  72575. /**
  72576. * Creates a new zero matrix
  72577. * @returns a new zero matrix
  72578. */
  72579. static Zero(): Matrix;
  72580. /**
  72581. * Creates a new rotation matrix for "angle" radians around the X axis
  72582. * @param angle defines the angle (in radians) to use
  72583. * @return the new matrix
  72584. */
  72585. static RotationX(angle: number): Matrix;
  72586. /**
  72587. * Creates a new matrix as the invert of a given matrix
  72588. * @param source defines the source matrix
  72589. * @returns the new matrix
  72590. */
  72591. static Invert(source: DeepImmutable<Matrix>): Matrix;
  72592. /**
  72593. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  72594. * @param angle defines the angle (in radians) to use
  72595. * @param result defines the target matrix
  72596. */
  72597. static RotationXToRef(angle: number, result: Matrix): void;
  72598. /**
  72599. * Creates a new rotation matrix for "angle" radians around the Y axis
  72600. * @param angle defines the angle (in radians) to use
  72601. * @return the new matrix
  72602. */
  72603. static RotationY(angle: number): Matrix;
  72604. /**
  72605. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  72606. * @param angle defines the angle (in radians) to use
  72607. * @param result defines the target matrix
  72608. */
  72609. static RotationYToRef(angle: number, result: Matrix): void;
  72610. /**
  72611. * Creates a new rotation matrix for "angle" radians around the Z axis
  72612. * @param angle defines the angle (in radians) to use
  72613. * @return the new matrix
  72614. */
  72615. static RotationZ(angle: number): Matrix;
  72616. /**
  72617. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  72618. * @param angle defines the angle (in radians) to use
  72619. * @param result defines the target matrix
  72620. */
  72621. static RotationZToRef(angle: number, result: Matrix): void;
  72622. /**
  72623. * Creates a new rotation matrix for "angle" radians around the given axis
  72624. * @param axis defines the axis to use
  72625. * @param angle defines the angle (in radians) to use
  72626. * @return the new matrix
  72627. */
  72628. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  72629. /**
  72630. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  72631. * @param axis defines the axis to use
  72632. * @param angle defines the angle (in radians) to use
  72633. * @param result defines the target matrix
  72634. */
  72635. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  72636. /**
  72637. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  72638. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  72639. * @param from defines the vector to align
  72640. * @param to defines the vector to align to
  72641. * @param result defines the target matrix
  72642. */
  72643. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  72644. /**
  72645. * Creates a rotation matrix
  72646. * @param yaw defines the yaw angle in radians (Y axis)
  72647. * @param pitch defines the pitch angle in radians (X axis)
  72648. * @param roll defines the roll angle in radians (X axis)
  72649. * @returns the new rotation matrix
  72650. */
  72651. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  72652. /**
  72653. * Creates a rotation matrix and stores it in a given matrix
  72654. * @param yaw defines the yaw angle in radians (Y axis)
  72655. * @param pitch defines the pitch angle in radians (X axis)
  72656. * @param roll defines the roll angle in radians (X axis)
  72657. * @param result defines the target matrix
  72658. */
  72659. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  72660. /**
  72661. * Creates a scaling matrix
  72662. * @param x defines the scale factor on X axis
  72663. * @param y defines the scale factor on Y axis
  72664. * @param z defines the scale factor on Z axis
  72665. * @returns the new matrix
  72666. */
  72667. static Scaling(x: number, y: number, z: number): Matrix;
  72668. /**
  72669. * Creates a scaling matrix and stores it in a given matrix
  72670. * @param x defines the scale factor on X axis
  72671. * @param y defines the scale factor on Y axis
  72672. * @param z defines the scale factor on Z axis
  72673. * @param result defines the target matrix
  72674. */
  72675. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  72676. /**
  72677. * Creates a translation matrix
  72678. * @param x defines the translation on X axis
  72679. * @param y defines the translation on Y axis
  72680. * @param z defines the translationon Z axis
  72681. * @returns the new matrix
  72682. */
  72683. static Translation(x: number, y: number, z: number): Matrix;
  72684. /**
  72685. * Creates a translation matrix and stores it in a given matrix
  72686. * @param x defines the translation on X axis
  72687. * @param y defines the translation on Y axis
  72688. * @param z defines the translationon Z axis
  72689. * @param result defines the target matrix
  72690. */
  72691. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  72692. /**
  72693. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72694. * @param startValue defines the start value
  72695. * @param endValue defines the end value
  72696. * @param gradient defines the gradient factor
  72697. * @returns the new matrix
  72698. */
  72699. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72700. /**
  72701. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  72702. * @param startValue defines the start value
  72703. * @param endValue defines the end value
  72704. * @param gradient defines the gradient factor
  72705. * @param result defines the Matrix object where to store data
  72706. */
  72707. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72708. /**
  72709. * Builds a new matrix whose values are computed by:
  72710. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72711. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72712. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72713. * @param startValue defines the first matrix
  72714. * @param endValue defines the second matrix
  72715. * @param gradient defines the gradient between the two matrices
  72716. * @returns the new matrix
  72717. */
  72718. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  72719. /**
  72720. * Update a matrix to values which are computed by:
  72721. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  72722. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  72723. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  72724. * @param startValue defines the first matrix
  72725. * @param endValue defines the second matrix
  72726. * @param gradient defines the gradient between the two matrices
  72727. * @param result defines the target matrix
  72728. */
  72729. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  72730. /**
  72731. * 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"
  72732. * This function works in left handed mode
  72733. * @param eye defines the final position of the entity
  72734. * @param target defines where the entity should look at
  72735. * @param up defines the up vector for the entity
  72736. * @returns the new matrix
  72737. */
  72738. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72739. /**
  72740. * 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".
  72741. * This function works in left handed mode
  72742. * @param eye defines the final position of the entity
  72743. * @param target defines where the entity should look at
  72744. * @param up defines the up vector for the entity
  72745. * @param result defines the target matrix
  72746. */
  72747. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72748. /**
  72749. * 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"
  72750. * This function works in right handed mode
  72751. * @param eye defines the final position of the entity
  72752. * @param target defines where the entity should look at
  72753. * @param up defines the up vector for the entity
  72754. * @returns the new matrix
  72755. */
  72756. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  72757. /**
  72758. * 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".
  72759. * This function works in right handed mode
  72760. * @param eye defines the final position of the entity
  72761. * @param target defines where the entity should look at
  72762. * @param up defines the up vector for the entity
  72763. * @param result defines the target matrix
  72764. */
  72765. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  72766. /**
  72767. * Create a left-handed orthographic projection matrix
  72768. * @param width defines the viewport width
  72769. * @param height defines the viewport height
  72770. * @param znear defines the near clip plane
  72771. * @param zfar defines the far clip plane
  72772. * @returns a new matrix as a left-handed orthographic projection matrix
  72773. */
  72774. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72775. /**
  72776. * Store a left-handed orthographic projection to a given matrix
  72777. * @param width defines the viewport width
  72778. * @param height defines the viewport height
  72779. * @param znear defines the near clip plane
  72780. * @param zfar defines the far clip plane
  72781. * @param result defines the target matrix
  72782. */
  72783. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  72784. /**
  72785. * Create a left-handed orthographic projection matrix
  72786. * @param left defines the viewport left coordinate
  72787. * @param right defines the viewport right coordinate
  72788. * @param bottom defines the viewport bottom coordinate
  72789. * @param top defines the viewport top coordinate
  72790. * @param znear defines the near clip plane
  72791. * @param zfar defines the far clip plane
  72792. * @returns a new matrix as a left-handed orthographic projection matrix
  72793. */
  72794. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72795. /**
  72796. * Stores a left-handed orthographic projection into a given matrix
  72797. * @param left defines the viewport left coordinate
  72798. * @param right defines the viewport right coordinate
  72799. * @param bottom defines the viewport bottom coordinate
  72800. * @param top defines the viewport top coordinate
  72801. * @param znear defines the near clip plane
  72802. * @param zfar defines the far clip plane
  72803. * @param result defines the target matrix
  72804. */
  72805. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72806. /**
  72807. * Creates a right-handed orthographic projection matrix
  72808. * @param left defines the viewport left coordinate
  72809. * @param right defines the viewport right coordinate
  72810. * @param bottom defines the viewport bottom coordinate
  72811. * @param top defines the viewport top coordinate
  72812. * @param znear defines the near clip plane
  72813. * @param zfar defines the far clip plane
  72814. * @returns a new matrix as a right-handed orthographic projection matrix
  72815. */
  72816. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  72817. /**
  72818. * Stores a right-handed orthographic projection into a given matrix
  72819. * @param left defines the viewport left coordinate
  72820. * @param right defines the viewport right coordinate
  72821. * @param bottom defines the viewport bottom coordinate
  72822. * @param top defines the viewport top coordinate
  72823. * @param znear defines the near clip plane
  72824. * @param zfar defines the far clip plane
  72825. * @param result defines the target matrix
  72826. */
  72827. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  72828. /**
  72829. * Creates a left-handed perspective projection matrix
  72830. * @param width defines the viewport width
  72831. * @param height defines the viewport height
  72832. * @param znear defines the near clip plane
  72833. * @param zfar defines the far clip plane
  72834. * @returns a new matrix as a left-handed perspective projection matrix
  72835. */
  72836. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  72837. /**
  72838. * Creates a left-handed perspective projection matrix
  72839. * @param fov defines the horizontal field of view
  72840. * @param aspect defines the aspect ratio
  72841. * @param znear defines the near clip plane
  72842. * @param zfar defines the far clip plane
  72843. * @returns a new matrix as a left-handed perspective projection matrix
  72844. */
  72845. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72846. /**
  72847. * Stores a left-handed perspective projection into a given matrix
  72848. * @param fov defines the horizontal field of view
  72849. * @param aspect defines the aspect ratio
  72850. * @param znear defines the near clip plane
  72851. * @param zfar defines the far clip plane
  72852. * @param result defines the target matrix
  72853. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72854. */
  72855. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72856. /**
  72857. * Stores a left-handed perspective projection into a given matrix with depth reversed
  72858. * @param fov defines the horizontal field of view
  72859. * @param aspect defines the aspect ratio
  72860. * @param znear defines the near clip plane
  72861. * @param zfar not used as infinity is used as far clip
  72862. * @param result defines the target matrix
  72863. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72864. */
  72865. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72866. /**
  72867. * Creates a right-handed perspective projection matrix
  72868. * @param fov defines the horizontal field of view
  72869. * @param aspect defines the aspect ratio
  72870. * @param znear defines the near clip plane
  72871. * @param zfar defines the far clip plane
  72872. * @returns a new matrix as a right-handed perspective projection matrix
  72873. */
  72874. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  72875. /**
  72876. * Stores a right-handed perspective projection into a given matrix
  72877. * @param fov defines the horizontal field of view
  72878. * @param aspect defines the aspect ratio
  72879. * @param znear defines the near clip plane
  72880. * @param zfar defines the far clip plane
  72881. * @param result defines the target matrix
  72882. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72883. */
  72884. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72885. /**
  72886. * Stores a right-handed perspective projection into a given matrix
  72887. * @param fov defines the horizontal field of view
  72888. * @param aspect defines the aspect ratio
  72889. * @param znear defines the near clip plane
  72890. * @param zfar not used as infinity is used as far clip
  72891. * @param result defines the target matrix
  72892. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  72893. */
  72894. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  72895. /**
  72896. * Stores a perspective projection for WebVR info a given matrix
  72897. * @param fov defines the field of view
  72898. * @param znear defines the near clip plane
  72899. * @param zfar defines the far clip plane
  72900. * @param result defines the target matrix
  72901. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  72902. */
  72903. static PerspectiveFovWebVRToRef(fov: {
  72904. upDegrees: number;
  72905. downDegrees: number;
  72906. leftDegrees: number;
  72907. rightDegrees: number;
  72908. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  72909. /**
  72910. * Computes a complete transformation matrix
  72911. * @param viewport defines the viewport to use
  72912. * @param world defines the world matrix
  72913. * @param view defines the view matrix
  72914. * @param projection defines the projection matrix
  72915. * @param zmin defines the near clip plane
  72916. * @param zmax defines the far clip plane
  72917. * @returns the transformation matrix
  72918. */
  72919. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  72920. /**
  72921. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  72922. * @param matrix defines the matrix to use
  72923. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  72924. */
  72925. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  72926. /**
  72927. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  72928. * @param matrix defines the matrix to use
  72929. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  72930. */
  72931. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  72932. /**
  72933. * Compute the transpose of a given matrix
  72934. * @param matrix defines the matrix to transpose
  72935. * @returns the new matrix
  72936. */
  72937. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  72938. /**
  72939. * Compute the transpose of a matrix and store it in a target matrix
  72940. * @param matrix defines the matrix to transpose
  72941. * @param result defines the target matrix
  72942. */
  72943. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  72944. /**
  72945. * Computes a reflection matrix from a plane
  72946. * @param plane defines the reflection plane
  72947. * @returns a new matrix
  72948. */
  72949. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  72950. /**
  72951. * Computes a reflection matrix from a plane
  72952. * @param plane defines the reflection plane
  72953. * @param result defines the target matrix
  72954. */
  72955. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  72956. /**
  72957. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  72958. * @param xaxis defines the value of the 1st axis
  72959. * @param yaxis defines the value of the 2nd axis
  72960. * @param zaxis defines the value of the 3rd axis
  72961. * @param result defines the target matrix
  72962. */
  72963. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  72964. /**
  72965. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  72966. * @param quat defines the quaternion to use
  72967. * @param result defines the target matrix
  72968. */
  72969. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  72970. }
  72971. /**
  72972. * @hidden
  72973. */
  72974. export class TmpVectors {
  72975. static Vector2: Vector2[];
  72976. static Vector3: Vector3[];
  72977. static Vector4: Vector4[];
  72978. static Quaternion: Quaternion[];
  72979. static Matrix: Matrix[];
  72980. }
  72981. }
  72982. declare module BABYLON {
  72983. /**
  72984. * Defines potential orientation for back face culling
  72985. */
  72986. export enum Orientation {
  72987. /**
  72988. * Clockwise
  72989. */
  72990. CW = 0,
  72991. /** Counter clockwise */
  72992. CCW = 1
  72993. }
  72994. /** Class used to represent a Bezier curve */
  72995. export class BezierCurve {
  72996. /**
  72997. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72998. * @param t defines the time
  72999. * @param x1 defines the left coordinate on X axis
  73000. * @param y1 defines the left coordinate on Y axis
  73001. * @param x2 defines the right coordinate on X axis
  73002. * @param y2 defines the right coordinate on Y axis
  73003. * @returns the interpolated value
  73004. */
  73005. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  73006. }
  73007. /**
  73008. * Defines angle representation
  73009. */
  73010. export class Angle {
  73011. private _radians;
  73012. /**
  73013. * Creates an Angle object of "radians" radians (float).
  73014. * @param radians the angle in radians
  73015. */
  73016. constructor(radians: number);
  73017. /**
  73018. * Get value in degrees
  73019. * @returns the Angle value in degrees (float)
  73020. */
  73021. degrees(): number;
  73022. /**
  73023. * Get value in radians
  73024. * @returns the Angle value in radians (float)
  73025. */
  73026. radians(): number;
  73027. /**
  73028. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  73029. * @param a defines first vector
  73030. * @param b defines second vector
  73031. * @returns a new Angle
  73032. */
  73033. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  73034. /**
  73035. * Gets a new Angle object from the given float in radians
  73036. * @param radians defines the angle value in radians
  73037. * @returns a new Angle
  73038. */
  73039. static FromRadians(radians: number): Angle;
  73040. /**
  73041. * Gets a new Angle object from the given float in degrees
  73042. * @param degrees defines the angle value in degrees
  73043. * @returns a new Angle
  73044. */
  73045. static FromDegrees(degrees: number): Angle;
  73046. }
  73047. /**
  73048. * This represents an arc in a 2d space.
  73049. */
  73050. export class Arc2 {
  73051. /** Defines the start point of the arc */
  73052. startPoint: Vector2;
  73053. /** Defines the mid point of the arc */
  73054. midPoint: Vector2;
  73055. /** Defines the end point of the arc */
  73056. endPoint: Vector2;
  73057. /**
  73058. * Defines the center point of the arc.
  73059. */
  73060. centerPoint: Vector2;
  73061. /**
  73062. * Defines the radius of the arc.
  73063. */
  73064. radius: number;
  73065. /**
  73066. * Defines the angle of the arc (from mid point to end point).
  73067. */
  73068. angle: Angle;
  73069. /**
  73070. * Defines the start angle of the arc (from start point to middle point).
  73071. */
  73072. startAngle: Angle;
  73073. /**
  73074. * Defines the orientation of the arc (clock wise/counter clock wise).
  73075. */
  73076. orientation: Orientation;
  73077. /**
  73078. * Creates an Arc object from the three given points : start, middle and end.
  73079. * @param startPoint Defines the start point of the arc
  73080. * @param midPoint Defines the midlle point of the arc
  73081. * @param endPoint Defines the end point of the arc
  73082. */
  73083. constructor(
  73084. /** Defines the start point of the arc */
  73085. startPoint: Vector2,
  73086. /** Defines the mid point of the arc */
  73087. midPoint: Vector2,
  73088. /** Defines the end point of the arc */
  73089. endPoint: Vector2);
  73090. }
  73091. /**
  73092. * Represents a 2D path made up of multiple 2D points
  73093. */
  73094. export class Path2 {
  73095. private _points;
  73096. private _length;
  73097. /**
  73098. * If the path start and end point are the same
  73099. */
  73100. closed: boolean;
  73101. /**
  73102. * Creates a Path2 object from the starting 2D coordinates x and y.
  73103. * @param x the starting points x value
  73104. * @param y the starting points y value
  73105. */
  73106. constructor(x: number, y: number);
  73107. /**
  73108. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  73109. * @param x the added points x value
  73110. * @param y the added points y value
  73111. * @returns the updated Path2.
  73112. */
  73113. addLineTo(x: number, y: number): Path2;
  73114. /**
  73115. * 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.
  73116. * @param midX middle point x value
  73117. * @param midY middle point y value
  73118. * @param endX end point x value
  73119. * @param endY end point y value
  73120. * @param numberOfSegments (default: 36)
  73121. * @returns the updated Path2.
  73122. */
  73123. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  73124. /**
  73125. * Closes the Path2.
  73126. * @returns the Path2.
  73127. */
  73128. close(): Path2;
  73129. /**
  73130. * Gets the sum of the distance between each sequential point in the path
  73131. * @returns the Path2 total length (float).
  73132. */
  73133. length(): number;
  73134. /**
  73135. * Gets the points which construct the path
  73136. * @returns the Path2 internal array of points.
  73137. */
  73138. getPoints(): Vector2[];
  73139. /**
  73140. * Retreives the point at the distance aways from the starting point
  73141. * @param normalizedLengthPosition the length along the path to retreive the point from
  73142. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  73143. */
  73144. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  73145. /**
  73146. * Creates a new path starting from an x and y position
  73147. * @param x starting x value
  73148. * @param y starting y value
  73149. * @returns a new Path2 starting at the coordinates (x, y).
  73150. */
  73151. static StartingAt(x: number, y: number): Path2;
  73152. }
  73153. /**
  73154. * Represents a 3D path made up of multiple 3D points
  73155. */
  73156. export class Path3D {
  73157. /**
  73158. * an array of Vector3, the curve axis of the Path3D
  73159. */
  73160. path: Vector3[];
  73161. private _curve;
  73162. private _distances;
  73163. private _tangents;
  73164. private _normals;
  73165. private _binormals;
  73166. private _raw;
  73167. private _alignTangentsWithPath;
  73168. private readonly _pointAtData;
  73169. /**
  73170. * new Path3D(path, normal, raw)
  73171. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  73172. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  73173. * @param path an array of Vector3, the curve axis of the Path3D
  73174. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  73175. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  73176. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  73177. */
  73178. constructor(
  73179. /**
  73180. * an array of Vector3, the curve axis of the Path3D
  73181. */
  73182. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  73183. /**
  73184. * Returns the Path3D array of successive Vector3 designing its curve.
  73185. * @returns the Path3D array of successive Vector3 designing its curve.
  73186. */
  73187. getCurve(): Vector3[];
  73188. /**
  73189. * Returns the Path3D array of successive Vector3 designing its curve.
  73190. * @returns the Path3D array of successive Vector3 designing its curve.
  73191. */
  73192. getPoints(): Vector3[];
  73193. /**
  73194. * @returns the computed length (float) of the path.
  73195. */
  73196. length(): number;
  73197. /**
  73198. * Returns an array populated with tangent vectors on each Path3D curve point.
  73199. * @returns an array populated with tangent vectors on each Path3D curve point.
  73200. */
  73201. getTangents(): Vector3[];
  73202. /**
  73203. * Returns an array populated with normal vectors on each Path3D curve point.
  73204. * @returns an array populated with normal vectors on each Path3D curve point.
  73205. */
  73206. getNormals(): Vector3[];
  73207. /**
  73208. * Returns an array populated with binormal vectors on each Path3D curve point.
  73209. * @returns an array populated with binormal vectors on each Path3D curve point.
  73210. */
  73211. getBinormals(): Vector3[];
  73212. /**
  73213. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  73214. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  73215. */
  73216. getDistances(): number[];
  73217. /**
  73218. * Returns an interpolated point along this path
  73219. * @param position the position of the point along this path, from 0.0 to 1.0
  73220. * @returns a new Vector3 as the point
  73221. */
  73222. getPointAt(position: number): Vector3;
  73223. /**
  73224. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73225. * @param position the position of the point along this path, from 0.0 to 1.0
  73226. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  73227. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  73228. */
  73229. getTangentAt(position: number, interpolated?: boolean): Vector3;
  73230. /**
  73231. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  73232. * @param position the position of the point along this path, from 0.0 to 1.0
  73233. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  73234. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  73235. */
  73236. getNormalAt(position: number, interpolated?: boolean): Vector3;
  73237. /**
  73238. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  73239. * @param position the position of the point along this path, from 0.0 to 1.0
  73240. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  73241. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  73242. */
  73243. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  73244. /**
  73245. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  73246. * @param position the position of the point along this path, from 0.0 to 1.0
  73247. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  73248. */
  73249. getDistanceAt(position: number): number;
  73250. /**
  73251. * Returns the array index of the previous point of an interpolated point along this path
  73252. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73253. * @returns the array index
  73254. */
  73255. getPreviousPointIndexAt(position: number): number;
  73256. /**
  73257. * 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)
  73258. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  73259. * @returns the sub position
  73260. */
  73261. getSubPositionAt(position: number): number;
  73262. /**
  73263. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  73264. * @param target the vector of which to get the closest position to
  73265. * @returns the position of the closest virtual point on this path to the target vector
  73266. */
  73267. getClosestPositionTo(target: Vector3): number;
  73268. /**
  73269. * Returns a sub path (slice) of this path
  73270. * @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
  73271. * @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
  73272. * @returns a sub path (slice) of this path
  73273. */
  73274. slice(start?: number, end?: number): Path3D;
  73275. /**
  73276. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  73277. * @param path path which all values are copied into the curves points
  73278. * @param firstNormal which should be projected onto the curve
  73279. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  73280. * @returns the same object updated.
  73281. */
  73282. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  73283. private _compute;
  73284. private _getFirstNonNullVector;
  73285. private _getLastNonNullVector;
  73286. private _normalVector;
  73287. /**
  73288. * Updates the point at data for an interpolated point along this curve
  73289. * @param position the position of the point along this curve, from 0.0 to 1.0
  73290. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  73291. * @returns the (updated) point at data
  73292. */
  73293. private _updatePointAtData;
  73294. /**
  73295. * Updates the point at data from the specified parameters
  73296. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  73297. * @param point the interpolated point
  73298. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  73299. */
  73300. private _setPointAtData;
  73301. /**
  73302. * Updates the point at interpolation matrix for the tangents, normals and binormals
  73303. */
  73304. private _updateInterpolationMatrix;
  73305. }
  73306. /**
  73307. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73308. * A Curve3 is designed from a series of successive Vector3.
  73309. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  73310. */
  73311. export class Curve3 {
  73312. private _points;
  73313. private _length;
  73314. /**
  73315. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  73316. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  73317. * @param v1 (Vector3) the control point
  73318. * @param v2 (Vector3) the end point of the Quadratic Bezier
  73319. * @param nbPoints (integer) the wanted number of points in the curve
  73320. * @returns the created Curve3
  73321. */
  73322. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73323. /**
  73324. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  73325. * @param v0 (Vector3) the origin point of the Cubic Bezier
  73326. * @param v1 (Vector3) the first control point
  73327. * @param v2 (Vector3) the second control point
  73328. * @param v3 (Vector3) the end point of the Cubic Bezier
  73329. * @param nbPoints (integer) the wanted number of points in the curve
  73330. * @returns the created Curve3
  73331. */
  73332. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73333. /**
  73334. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  73335. * @param p1 (Vector3) the origin point of the Hermite Spline
  73336. * @param t1 (Vector3) the tangent vector at the origin point
  73337. * @param p2 (Vector3) the end point of the Hermite Spline
  73338. * @param t2 (Vector3) the tangent vector at the end point
  73339. * @param nbPoints (integer) the wanted number of points in the curve
  73340. * @returns the created Curve3
  73341. */
  73342. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  73343. /**
  73344. * Returns a Curve3 object along a CatmullRom Spline curve :
  73345. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  73346. * @param nbPoints (integer) the wanted number of points between each curve control points
  73347. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  73348. * @returns the created Curve3
  73349. */
  73350. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  73351. /**
  73352. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  73353. * A Curve3 is designed from a series of successive Vector3.
  73354. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  73355. * @param points points which make up the curve
  73356. */
  73357. constructor(points: Vector3[]);
  73358. /**
  73359. * @returns the Curve3 stored array of successive Vector3
  73360. */
  73361. getPoints(): Vector3[];
  73362. /**
  73363. * @returns the computed length (float) of the curve.
  73364. */
  73365. length(): number;
  73366. /**
  73367. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  73368. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  73369. * curveA and curveB keep unchanged.
  73370. * @param curve the curve to continue from this curve
  73371. * @returns the newly constructed curve
  73372. */
  73373. continue(curve: DeepImmutable<Curve3>): Curve3;
  73374. private _computeLength;
  73375. }
  73376. }
  73377. declare module BABYLON {
  73378. /**
  73379. * This represents the main contract an easing function should follow.
  73380. * Easing functions are used throughout the animation system.
  73381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73382. */
  73383. export interface IEasingFunction {
  73384. /**
  73385. * Given an input gradient between 0 and 1, this returns the corrseponding value
  73386. * of the easing function.
  73387. * The link below provides some of the most common examples of easing functions.
  73388. * @see https://easings.net/
  73389. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73390. * @returns the corresponding value on the curve defined by the easing function
  73391. */
  73392. ease(gradient: number): number;
  73393. }
  73394. /**
  73395. * Base class used for every default easing function.
  73396. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73397. */
  73398. export class EasingFunction implements IEasingFunction {
  73399. /**
  73400. * Interpolation follows the mathematical formula associated with the easing function.
  73401. */
  73402. static readonly EASINGMODE_EASEIN: number;
  73403. /**
  73404. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  73405. */
  73406. static readonly EASINGMODE_EASEOUT: number;
  73407. /**
  73408. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  73409. */
  73410. static readonly EASINGMODE_EASEINOUT: number;
  73411. private _easingMode;
  73412. /**
  73413. * Sets the easing mode of the current function.
  73414. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  73415. */
  73416. setEasingMode(easingMode: number): void;
  73417. /**
  73418. * Gets the current easing mode.
  73419. * @returns the easing mode
  73420. */
  73421. getEasingMode(): number;
  73422. /**
  73423. * @hidden
  73424. */
  73425. easeInCore(gradient: number): number;
  73426. /**
  73427. * Given an input gradient between 0 and 1, this returns the corresponding value
  73428. * of the easing function.
  73429. * @param gradient Defines the value between 0 and 1 we want the easing value for
  73430. * @returns the corresponding value on the curve defined by the easing function
  73431. */
  73432. ease(gradient: number): number;
  73433. }
  73434. /**
  73435. * Easing function with a circle shape (see link below).
  73436. * @see https://easings.net/#easeInCirc
  73437. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73438. */
  73439. export class CircleEase extends EasingFunction implements IEasingFunction {
  73440. /** @hidden */
  73441. easeInCore(gradient: number): number;
  73442. }
  73443. /**
  73444. * Easing function with a ease back shape (see link below).
  73445. * @see https://easings.net/#easeInBack
  73446. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73447. */
  73448. export class BackEase extends EasingFunction implements IEasingFunction {
  73449. /** Defines the amplitude of the function */
  73450. amplitude: number;
  73451. /**
  73452. * Instantiates a back ease easing
  73453. * @see https://easings.net/#easeInBack
  73454. * @param amplitude Defines the amplitude of the function
  73455. */
  73456. constructor(
  73457. /** Defines the amplitude of the function */
  73458. amplitude?: number);
  73459. /** @hidden */
  73460. easeInCore(gradient: number): number;
  73461. }
  73462. /**
  73463. * Easing function with a bouncing shape (see link below).
  73464. * @see https://easings.net/#easeInBounce
  73465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73466. */
  73467. export class BounceEase extends EasingFunction implements IEasingFunction {
  73468. /** Defines the number of bounces */
  73469. bounces: number;
  73470. /** Defines the amplitude of the bounce */
  73471. bounciness: number;
  73472. /**
  73473. * Instantiates a bounce easing
  73474. * @see https://easings.net/#easeInBounce
  73475. * @param bounces Defines the number of bounces
  73476. * @param bounciness Defines the amplitude of the bounce
  73477. */
  73478. constructor(
  73479. /** Defines the number of bounces */
  73480. bounces?: number,
  73481. /** Defines the amplitude of the bounce */
  73482. bounciness?: number);
  73483. /** @hidden */
  73484. easeInCore(gradient: number): number;
  73485. }
  73486. /**
  73487. * Easing function with a power of 3 shape (see link below).
  73488. * @see https://easings.net/#easeInCubic
  73489. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73490. */
  73491. export class CubicEase extends EasingFunction implements IEasingFunction {
  73492. /** @hidden */
  73493. easeInCore(gradient: number): number;
  73494. }
  73495. /**
  73496. * Easing function with an elastic shape (see link below).
  73497. * @see https://easings.net/#easeInElastic
  73498. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73499. */
  73500. export class ElasticEase extends EasingFunction implements IEasingFunction {
  73501. /** Defines the number of oscillations*/
  73502. oscillations: number;
  73503. /** Defines the amplitude of the oscillations*/
  73504. springiness: number;
  73505. /**
  73506. * Instantiates an elastic easing function
  73507. * @see https://easings.net/#easeInElastic
  73508. * @param oscillations Defines the number of oscillations
  73509. * @param springiness Defines the amplitude of the oscillations
  73510. */
  73511. constructor(
  73512. /** Defines the number of oscillations*/
  73513. oscillations?: number,
  73514. /** Defines the amplitude of the oscillations*/
  73515. springiness?: number);
  73516. /** @hidden */
  73517. easeInCore(gradient: number): number;
  73518. }
  73519. /**
  73520. * Easing function with an exponential shape (see link below).
  73521. * @see https://easings.net/#easeInExpo
  73522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73523. */
  73524. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  73525. /** Defines the exponent of the function */
  73526. exponent: number;
  73527. /**
  73528. * Instantiates an exponential easing function
  73529. * @see https://easings.net/#easeInExpo
  73530. * @param exponent Defines the exponent of the function
  73531. */
  73532. constructor(
  73533. /** Defines the exponent of the function */
  73534. exponent?: number);
  73535. /** @hidden */
  73536. easeInCore(gradient: number): number;
  73537. }
  73538. /**
  73539. * Easing function with a power shape (see link below).
  73540. * @see https://easings.net/#easeInQuad
  73541. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73542. */
  73543. export class PowerEase extends EasingFunction implements IEasingFunction {
  73544. /** Defines the power of the function */
  73545. power: number;
  73546. /**
  73547. * Instantiates an power base easing function
  73548. * @see https://easings.net/#easeInQuad
  73549. * @param power Defines the power of the function
  73550. */
  73551. constructor(
  73552. /** Defines the power of the function */
  73553. power?: number);
  73554. /** @hidden */
  73555. easeInCore(gradient: number): number;
  73556. }
  73557. /**
  73558. * Easing function with a power of 2 shape (see link below).
  73559. * @see https://easings.net/#easeInQuad
  73560. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73561. */
  73562. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  73563. /** @hidden */
  73564. easeInCore(gradient: number): number;
  73565. }
  73566. /**
  73567. * Easing function with a power of 4 shape (see link below).
  73568. * @see https://easings.net/#easeInQuart
  73569. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73570. */
  73571. export class QuarticEase extends EasingFunction implements IEasingFunction {
  73572. /** @hidden */
  73573. easeInCore(gradient: number): number;
  73574. }
  73575. /**
  73576. * Easing function with a power of 5 shape (see link below).
  73577. * @see https://easings.net/#easeInQuint
  73578. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73579. */
  73580. export class QuinticEase extends EasingFunction implements IEasingFunction {
  73581. /** @hidden */
  73582. easeInCore(gradient: number): number;
  73583. }
  73584. /**
  73585. * Easing function with a sin shape (see link below).
  73586. * @see https://easings.net/#easeInSine
  73587. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73588. */
  73589. export class SineEase extends EasingFunction implements IEasingFunction {
  73590. /** @hidden */
  73591. easeInCore(gradient: number): number;
  73592. }
  73593. /**
  73594. * Easing function with a bezier shape (see link below).
  73595. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73596. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  73597. */
  73598. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  73599. /** Defines the x component of the start tangent in the bezier curve */
  73600. x1: number;
  73601. /** Defines the y component of the start tangent in the bezier curve */
  73602. y1: number;
  73603. /** Defines the x component of the end tangent in the bezier curve */
  73604. x2: number;
  73605. /** Defines the y component of the end tangent in the bezier curve */
  73606. y2: number;
  73607. /**
  73608. * Instantiates a bezier function
  73609. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  73610. * @param x1 Defines the x component of the start tangent in the bezier curve
  73611. * @param y1 Defines the y component of the start tangent in the bezier curve
  73612. * @param x2 Defines the x component of the end tangent in the bezier curve
  73613. * @param y2 Defines the y component of the end tangent in the bezier curve
  73614. */
  73615. constructor(
  73616. /** Defines the x component of the start tangent in the bezier curve */
  73617. x1?: number,
  73618. /** Defines the y component of the start tangent in the bezier curve */
  73619. y1?: number,
  73620. /** Defines the x component of the end tangent in the bezier curve */
  73621. x2?: number,
  73622. /** Defines the y component of the end tangent in the bezier curve */
  73623. y2?: number);
  73624. /** @hidden */
  73625. easeInCore(gradient: number): number;
  73626. }
  73627. }
  73628. declare module BABYLON {
  73629. /**
  73630. * Class used to hold a RBG color
  73631. */
  73632. export class Color3 {
  73633. /**
  73634. * Defines the red component (between 0 and 1, default is 0)
  73635. */
  73636. r: number;
  73637. /**
  73638. * Defines the green component (between 0 and 1, default is 0)
  73639. */
  73640. g: number;
  73641. /**
  73642. * Defines the blue component (between 0 and 1, default is 0)
  73643. */
  73644. b: number;
  73645. /**
  73646. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  73647. * @param r defines the red component (between 0 and 1, default is 0)
  73648. * @param g defines the green component (between 0 and 1, default is 0)
  73649. * @param b defines the blue component (between 0 and 1, default is 0)
  73650. */
  73651. constructor(
  73652. /**
  73653. * Defines the red component (between 0 and 1, default is 0)
  73654. */
  73655. r?: number,
  73656. /**
  73657. * Defines the green component (between 0 and 1, default is 0)
  73658. */
  73659. g?: number,
  73660. /**
  73661. * Defines the blue component (between 0 and 1, default is 0)
  73662. */
  73663. b?: number);
  73664. /**
  73665. * Creates a string with the Color3 current values
  73666. * @returns the string representation of the Color3 object
  73667. */
  73668. toString(): string;
  73669. /**
  73670. * Returns the string "Color3"
  73671. * @returns "Color3"
  73672. */
  73673. getClassName(): string;
  73674. /**
  73675. * Compute the Color3 hash code
  73676. * @returns an unique number that can be used to hash Color3 objects
  73677. */
  73678. getHashCode(): number;
  73679. /**
  73680. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  73681. * @param array defines the array where to store the r,g,b components
  73682. * @param index defines an optional index in the target array to define where to start storing values
  73683. * @returns the current Color3 object
  73684. */
  73685. toArray(array: FloatArray, index?: number): Color3;
  73686. /**
  73687. * Returns a new Color4 object from the current Color3 and the given alpha
  73688. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  73689. * @returns a new Color4 object
  73690. */
  73691. toColor4(alpha?: number): Color4;
  73692. /**
  73693. * Returns a new array populated with 3 numeric elements : red, green and blue values
  73694. * @returns the new array
  73695. */
  73696. asArray(): number[];
  73697. /**
  73698. * Returns the luminance value
  73699. * @returns a float value
  73700. */
  73701. toLuminance(): number;
  73702. /**
  73703. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  73704. * @param otherColor defines the second operand
  73705. * @returns the new Color3 object
  73706. */
  73707. multiply(otherColor: DeepImmutable<Color3>): Color3;
  73708. /**
  73709. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  73710. * @param otherColor defines the second operand
  73711. * @param result defines the Color3 object where to store the result
  73712. * @returns the current Color3
  73713. */
  73714. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73715. /**
  73716. * Determines equality between Color3 objects
  73717. * @param otherColor defines the second operand
  73718. * @returns true if the rgb values are equal to the given ones
  73719. */
  73720. equals(otherColor: DeepImmutable<Color3>): boolean;
  73721. /**
  73722. * Determines equality between the current Color3 object and a set of r,b,g values
  73723. * @param r defines the red component to check
  73724. * @param g defines the green component to check
  73725. * @param b defines the blue component to check
  73726. * @returns true if the rgb values are equal to the given ones
  73727. */
  73728. equalsFloats(r: number, g: number, b: number): boolean;
  73729. /**
  73730. * Multiplies in place each rgb value by scale
  73731. * @param scale defines the scaling factor
  73732. * @returns the updated Color3
  73733. */
  73734. scale(scale: number): Color3;
  73735. /**
  73736. * Multiplies the rgb values by scale and stores the result into "result"
  73737. * @param scale defines the scaling factor
  73738. * @param result defines the Color3 object where to store the result
  73739. * @returns the unmodified current Color3
  73740. */
  73741. scaleToRef(scale: number, result: Color3): Color3;
  73742. /**
  73743. * Scale the current Color3 values by a factor and add the result to a given Color3
  73744. * @param scale defines the scale factor
  73745. * @param result defines color to store the result into
  73746. * @returns the unmodified current Color3
  73747. */
  73748. scaleAndAddToRef(scale: number, result: Color3): Color3;
  73749. /**
  73750. * Clamps the rgb values by the min and max values and stores the result into "result"
  73751. * @param min defines minimum clamping value (default is 0)
  73752. * @param max defines maximum clamping value (default is 1)
  73753. * @param result defines color to store the result into
  73754. * @returns the original Color3
  73755. */
  73756. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  73757. /**
  73758. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  73759. * @param otherColor defines the second operand
  73760. * @returns the new Color3
  73761. */
  73762. add(otherColor: DeepImmutable<Color3>): Color3;
  73763. /**
  73764. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  73765. * @param otherColor defines the second operand
  73766. * @param result defines Color3 object to store the result into
  73767. * @returns the unmodified current Color3
  73768. */
  73769. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73770. /**
  73771. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  73772. * @param otherColor defines the second operand
  73773. * @returns the new Color3
  73774. */
  73775. subtract(otherColor: DeepImmutable<Color3>): Color3;
  73776. /**
  73777. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  73778. * @param otherColor defines the second operand
  73779. * @param result defines Color3 object to store the result into
  73780. * @returns the unmodified current Color3
  73781. */
  73782. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  73783. /**
  73784. * Copy the current object
  73785. * @returns a new Color3 copied the current one
  73786. */
  73787. clone(): Color3;
  73788. /**
  73789. * Copies the rgb values from the source in the current Color3
  73790. * @param source defines the source Color3 object
  73791. * @returns the updated Color3 object
  73792. */
  73793. copyFrom(source: DeepImmutable<Color3>): Color3;
  73794. /**
  73795. * Updates the Color3 rgb values from the given floats
  73796. * @param r defines the red component to read from
  73797. * @param g defines the green component to read from
  73798. * @param b defines the blue component to read from
  73799. * @returns the current Color3 object
  73800. */
  73801. copyFromFloats(r: number, g: number, b: number): Color3;
  73802. /**
  73803. * Updates the Color3 rgb values from the given floats
  73804. * @param r defines the red component to read from
  73805. * @param g defines the green component to read from
  73806. * @param b defines the blue component to read from
  73807. * @returns the current Color3 object
  73808. */
  73809. set(r: number, g: number, b: number): Color3;
  73810. /**
  73811. * Compute the Color3 hexadecimal code as a string
  73812. * @returns a string containing the hexadecimal representation of the Color3 object
  73813. */
  73814. toHexString(): string;
  73815. /**
  73816. * Computes a new Color3 converted from the current one to linear space
  73817. * @returns a new Color3 object
  73818. */
  73819. toLinearSpace(): Color3;
  73820. /**
  73821. * Converts current color in rgb space to HSV values
  73822. * @returns a new color3 representing the HSV values
  73823. */
  73824. toHSV(): Color3;
  73825. /**
  73826. * Converts current color in rgb space to HSV values
  73827. * @param result defines the Color3 where to store the HSV values
  73828. */
  73829. toHSVToRef(result: Color3): void;
  73830. /**
  73831. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  73832. * @param convertedColor defines the Color3 object where to store the linear space version
  73833. * @returns the unmodified Color3
  73834. */
  73835. toLinearSpaceToRef(convertedColor: Color3): Color3;
  73836. /**
  73837. * Computes a new Color3 converted from the current one to gamma space
  73838. * @returns a new Color3 object
  73839. */
  73840. toGammaSpace(): Color3;
  73841. /**
  73842. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  73843. * @param convertedColor defines the Color3 object where to store the gamma space version
  73844. * @returns the unmodified Color3
  73845. */
  73846. toGammaSpaceToRef(convertedColor: Color3): Color3;
  73847. private static _BlackReadOnly;
  73848. /**
  73849. * Convert Hue, saturation and value to a Color3 (RGB)
  73850. * @param hue defines the hue
  73851. * @param saturation defines the saturation
  73852. * @param value defines the value
  73853. * @param result defines the Color3 where to store the RGB values
  73854. */
  73855. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  73856. /**
  73857. * Creates a new Color3 from the string containing valid hexadecimal values
  73858. * @param hex defines a string containing valid hexadecimal values
  73859. * @returns a new Color3 object
  73860. */
  73861. static FromHexString(hex: string): Color3;
  73862. /**
  73863. * Creates a new Color3 from the starting index of the given array
  73864. * @param array defines the source array
  73865. * @param offset defines an offset in the source array
  73866. * @returns a new Color3 object
  73867. */
  73868. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  73869. /**
  73870. * Creates a new Color3 from integer values (< 256)
  73871. * @param r defines the red component to read from (value between 0 and 255)
  73872. * @param g defines the green component to read from (value between 0 and 255)
  73873. * @param b defines the blue component to read from (value between 0 and 255)
  73874. * @returns a new Color3 object
  73875. */
  73876. static FromInts(r: number, g: number, b: number): Color3;
  73877. /**
  73878. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73879. * @param start defines the start Color3 value
  73880. * @param end defines the end Color3 value
  73881. * @param amount defines the gradient value between start and end
  73882. * @returns a new Color3 object
  73883. */
  73884. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  73885. /**
  73886. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  73887. * @param left defines the start value
  73888. * @param right defines the end value
  73889. * @param amount defines the gradient factor
  73890. * @param result defines the Color3 object where to store the result
  73891. */
  73892. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  73893. /**
  73894. * Returns a Color3 value containing a red color
  73895. * @returns a new Color3 object
  73896. */
  73897. static Red(): Color3;
  73898. /**
  73899. * Returns a Color3 value containing a green color
  73900. * @returns a new Color3 object
  73901. */
  73902. static Green(): Color3;
  73903. /**
  73904. * Returns a Color3 value containing a blue color
  73905. * @returns a new Color3 object
  73906. */
  73907. static Blue(): Color3;
  73908. /**
  73909. * Returns a Color3 value containing a black color
  73910. * @returns a new Color3 object
  73911. */
  73912. static Black(): Color3;
  73913. /**
  73914. * Gets a Color3 value containing a black color that must not be updated
  73915. */
  73916. static readonly BlackReadOnly: DeepImmutable<Color3>;
  73917. /**
  73918. * Returns a Color3 value containing a white color
  73919. * @returns a new Color3 object
  73920. */
  73921. static White(): Color3;
  73922. /**
  73923. * Returns a Color3 value containing a purple color
  73924. * @returns a new Color3 object
  73925. */
  73926. static Purple(): Color3;
  73927. /**
  73928. * Returns a Color3 value containing a magenta color
  73929. * @returns a new Color3 object
  73930. */
  73931. static Magenta(): Color3;
  73932. /**
  73933. * Returns a Color3 value containing a yellow color
  73934. * @returns a new Color3 object
  73935. */
  73936. static Yellow(): Color3;
  73937. /**
  73938. * Returns a Color3 value containing a gray color
  73939. * @returns a new Color3 object
  73940. */
  73941. static Gray(): Color3;
  73942. /**
  73943. * Returns a Color3 value containing a teal color
  73944. * @returns a new Color3 object
  73945. */
  73946. static Teal(): Color3;
  73947. /**
  73948. * Returns a Color3 value containing a random color
  73949. * @returns a new Color3 object
  73950. */
  73951. static Random(): Color3;
  73952. }
  73953. /**
  73954. * Class used to hold a RBGA color
  73955. */
  73956. export class Color4 {
  73957. /**
  73958. * Defines the red component (between 0 and 1, default is 0)
  73959. */
  73960. r: number;
  73961. /**
  73962. * Defines the green component (between 0 and 1, default is 0)
  73963. */
  73964. g: number;
  73965. /**
  73966. * Defines the blue component (between 0 and 1, default is 0)
  73967. */
  73968. b: number;
  73969. /**
  73970. * Defines the alpha component (between 0 and 1, default is 1)
  73971. */
  73972. a: number;
  73973. /**
  73974. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  73975. * @param r defines the red component (between 0 and 1, default is 0)
  73976. * @param g defines the green component (between 0 and 1, default is 0)
  73977. * @param b defines the blue component (between 0 and 1, default is 0)
  73978. * @param a defines the alpha component (between 0 and 1, default is 1)
  73979. */
  73980. constructor(
  73981. /**
  73982. * Defines the red component (between 0 and 1, default is 0)
  73983. */
  73984. r?: number,
  73985. /**
  73986. * Defines the green component (between 0 and 1, default is 0)
  73987. */
  73988. g?: number,
  73989. /**
  73990. * Defines the blue component (between 0 and 1, default is 0)
  73991. */
  73992. b?: number,
  73993. /**
  73994. * Defines the alpha component (between 0 and 1, default is 1)
  73995. */
  73996. a?: number);
  73997. /**
  73998. * Adds in place the given Color4 values to the current Color4 object
  73999. * @param right defines the second operand
  74000. * @returns the current updated Color4 object
  74001. */
  74002. addInPlace(right: DeepImmutable<Color4>): Color4;
  74003. /**
  74004. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  74005. * @returns the new array
  74006. */
  74007. asArray(): number[];
  74008. /**
  74009. * Stores from the starting index in the given array the Color4 successive values
  74010. * @param array defines the array where to store the r,g,b components
  74011. * @param index defines an optional index in the target array to define where to start storing values
  74012. * @returns the current Color4 object
  74013. */
  74014. toArray(array: number[], index?: number): Color4;
  74015. /**
  74016. * Determines equality between Color4 objects
  74017. * @param otherColor defines the second operand
  74018. * @returns true if the rgba values are equal to the given ones
  74019. */
  74020. equals(otherColor: DeepImmutable<Color4>): boolean;
  74021. /**
  74022. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  74023. * @param right defines the second operand
  74024. * @returns a new Color4 object
  74025. */
  74026. add(right: DeepImmutable<Color4>): Color4;
  74027. /**
  74028. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  74029. * @param right defines the second operand
  74030. * @returns a new Color4 object
  74031. */
  74032. subtract(right: DeepImmutable<Color4>): Color4;
  74033. /**
  74034. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  74035. * @param right defines the second operand
  74036. * @param result defines the Color4 object where to store the result
  74037. * @returns the current Color4 object
  74038. */
  74039. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  74040. /**
  74041. * Creates a new Color4 with the current Color4 values multiplied by scale
  74042. * @param scale defines the scaling factor to apply
  74043. * @returns a new Color4 object
  74044. */
  74045. scale(scale: number): Color4;
  74046. /**
  74047. * Multiplies the current Color4 values by scale and stores the result in "result"
  74048. * @param scale defines the scaling factor to apply
  74049. * @param result defines the Color4 object where to store the result
  74050. * @returns the current unmodified Color4
  74051. */
  74052. scaleToRef(scale: number, result: Color4): Color4;
  74053. /**
  74054. * Scale the current Color4 values by a factor and add the result to a given Color4
  74055. * @param scale defines the scale factor
  74056. * @param result defines the Color4 object where to store the result
  74057. * @returns the unmodified current Color4
  74058. */
  74059. scaleAndAddToRef(scale: number, result: Color4): Color4;
  74060. /**
  74061. * Clamps the rgb values by the min and max values and stores the result into "result"
  74062. * @param min defines minimum clamping value (default is 0)
  74063. * @param max defines maximum clamping value (default is 1)
  74064. * @param result defines color to store the result into.
  74065. * @returns the cuurent Color4
  74066. */
  74067. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  74068. /**
  74069. * Multipy an Color4 value by another and return a new Color4 object
  74070. * @param color defines the Color4 value to multiply by
  74071. * @returns a new Color4 object
  74072. */
  74073. multiply(color: Color4): Color4;
  74074. /**
  74075. * Multipy a Color4 value by another and push the result in a reference value
  74076. * @param color defines the Color4 value to multiply by
  74077. * @param result defines the Color4 to fill the result in
  74078. * @returns the result Color4
  74079. */
  74080. multiplyToRef(color: Color4, result: Color4): Color4;
  74081. /**
  74082. * Creates a string with the Color4 current values
  74083. * @returns the string representation of the Color4 object
  74084. */
  74085. toString(): string;
  74086. /**
  74087. * Returns the string "Color4"
  74088. * @returns "Color4"
  74089. */
  74090. getClassName(): string;
  74091. /**
  74092. * Compute the Color4 hash code
  74093. * @returns an unique number that can be used to hash Color4 objects
  74094. */
  74095. getHashCode(): number;
  74096. /**
  74097. * Creates a new Color4 copied from the current one
  74098. * @returns a new Color4 object
  74099. */
  74100. clone(): Color4;
  74101. /**
  74102. * Copies the given Color4 values into the current one
  74103. * @param source defines the source Color4 object
  74104. * @returns the current updated Color4 object
  74105. */
  74106. copyFrom(source: Color4): Color4;
  74107. /**
  74108. * Copies the given float values into the current one
  74109. * @param r defines the red component to read from
  74110. * @param g defines the green component to read from
  74111. * @param b defines the blue component to read from
  74112. * @param a defines the alpha component to read from
  74113. * @returns the current updated Color4 object
  74114. */
  74115. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  74116. /**
  74117. * Copies the given float values into the current one
  74118. * @param r defines the red component to read from
  74119. * @param g defines the green component to read from
  74120. * @param b defines the blue component to read from
  74121. * @param a defines the alpha component to read from
  74122. * @returns the current updated Color4 object
  74123. */
  74124. set(r: number, g: number, b: number, a: number): Color4;
  74125. /**
  74126. * Compute the Color4 hexadecimal code as a string
  74127. * @returns a string containing the hexadecimal representation of the Color4 object
  74128. */
  74129. toHexString(): string;
  74130. /**
  74131. * Computes a new Color4 converted from the current one to linear space
  74132. * @returns a new Color4 object
  74133. */
  74134. toLinearSpace(): Color4;
  74135. /**
  74136. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  74137. * @param convertedColor defines the Color4 object where to store the linear space version
  74138. * @returns the unmodified Color4
  74139. */
  74140. toLinearSpaceToRef(convertedColor: Color4): Color4;
  74141. /**
  74142. * Computes a new Color4 converted from the current one to gamma space
  74143. * @returns a new Color4 object
  74144. */
  74145. toGammaSpace(): Color4;
  74146. /**
  74147. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  74148. * @param convertedColor defines the Color4 object where to store the gamma space version
  74149. * @returns the unmodified Color4
  74150. */
  74151. toGammaSpaceToRef(convertedColor: Color4): Color4;
  74152. /**
  74153. * Creates a new Color4 from the string containing valid hexadecimal values
  74154. * @param hex defines a string containing valid hexadecimal values
  74155. * @returns a new Color4 object
  74156. */
  74157. static FromHexString(hex: string): Color4;
  74158. /**
  74159. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74160. * @param left defines the start value
  74161. * @param right defines the end value
  74162. * @param amount defines the gradient factor
  74163. * @returns a new Color4 object
  74164. */
  74165. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  74166. /**
  74167. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  74168. * @param left defines the start value
  74169. * @param right defines the end value
  74170. * @param amount defines the gradient factor
  74171. * @param result defines the Color4 object where to store data
  74172. */
  74173. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  74174. /**
  74175. * Creates a new Color4 from a Color3 and an alpha value
  74176. * @param color3 defines the source Color3 to read from
  74177. * @param alpha defines the alpha component (1.0 by default)
  74178. * @returns a new Color4 object
  74179. */
  74180. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  74181. /**
  74182. * Creates a new Color4 from the starting index element of the given array
  74183. * @param array defines the source array to read from
  74184. * @param offset defines the offset in the source array
  74185. * @returns a new Color4 object
  74186. */
  74187. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  74188. /**
  74189. * Creates a new Color3 from integer values (< 256)
  74190. * @param r defines the red component to read from (value between 0 and 255)
  74191. * @param g defines the green component to read from (value between 0 and 255)
  74192. * @param b defines the blue component to read from (value between 0 and 255)
  74193. * @param a defines the alpha component to read from (value between 0 and 255)
  74194. * @returns a new Color3 object
  74195. */
  74196. static FromInts(r: number, g: number, b: number, a: number): Color4;
  74197. /**
  74198. * Check the content of a given array and convert it to an array containing RGBA data
  74199. * If the original array was already containing count * 4 values then it is returned directly
  74200. * @param colors defines the array to check
  74201. * @param count defines the number of RGBA data to expect
  74202. * @returns an array containing count * 4 values (RGBA)
  74203. */
  74204. static CheckColors4(colors: number[], count: number): number[];
  74205. }
  74206. /**
  74207. * @hidden
  74208. */
  74209. export class TmpColors {
  74210. static Color3: Color3[];
  74211. static Color4: Color4[];
  74212. }
  74213. }
  74214. declare module BABYLON {
  74215. /**
  74216. * Defines an interface which represents an animation key frame
  74217. */
  74218. export interface IAnimationKey {
  74219. /**
  74220. * Frame of the key frame
  74221. */
  74222. frame: number;
  74223. /**
  74224. * Value at the specifies key frame
  74225. */
  74226. value: any;
  74227. /**
  74228. * The input tangent for the cubic hermite spline
  74229. */
  74230. inTangent?: any;
  74231. /**
  74232. * The output tangent for the cubic hermite spline
  74233. */
  74234. outTangent?: any;
  74235. /**
  74236. * The animation interpolation type
  74237. */
  74238. interpolation?: AnimationKeyInterpolation;
  74239. }
  74240. /**
  74241. * Enum for the animation key frame interpolation type
  74242. */
  74243. export enum AnimationKeyInterpolation {
  74244. /**
  74245. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  74246. */
  74247. STEP = 1
  74248. }
  74249. }
  74250. declare module BABYLON {
  74251. /**
  74252. * Represents the range of an animation
  74253. */
  74254. export class AnimationRange {
  74255. /**The name of the animation range**/
  74256. name: string;
  74257. /**The starting frame of the animation */
  74258. from: number;
  74259. /**The ending frame of the animation*/
  74260. to: number;
  74261. /**
  74262. * Initializes the range of an animation
  74263. * @param name The name of the animation range
  74264. * @param from The starting frame of the animation
  74265. * @param to The ending frame of the animation
  74266. */
  74267. constructor(
  74268. /**The name of the animation range**/
  74269. name: string,
  74270. /**The starting frame of the animation */
  74271. from: number,
  74272. /**The ending frame of the animation*/
  74273. to: number);
  74274. /**
  74275. * Makes a copy of the animation range
  74276. * @returns A copy of the animation range
  74277. */
  74278. clone(): AnimationRange;
  74279. }
  74280. }
  74281. declare module BABYLON {
  74282. /**
  74283. * Composed of a frame, and an action function
  74284. */
  74285. export class AnimationEvent {
  74286. /** The frame for which the event is triggered **/
  74287. frame: number;
  74288. /** The event to perform when triggered **/
  74289. action: (currentFrame: number) => void;
  74290. /** Specifies if the event should be triggered only once**/
  74291. onlyOnce?: boolean | undefined;
  74292. /**
  74293. * Specifies if the animation event is done
  74294. */
  74295. isDone: boolean;
  74296. /**
  74297. * Initializes the animation event
  74298. * @param frame The frame for which the event is triggered
  74299. * @param action The event to perform when triggered
  74300. * @param onlyOnce Specifies if the event should be triggered only once
  74301. */
  74302. constructor(
  74303. /** The frame for which the event is triggered **/
  74304. frame: number,
  74305. /** The event to perform when triggered **/
  74306. action: (currentFrame: number) => void,
  74307. /** Specifies if the event should be triggered only once**/
  74308. onlyOnce?: boolean | undefined);
  74309. /** @hidden */
  74310. _clone(): AnimationEvent;
  74311. }
  74312. }
  74313. declare module BABYLON {
  74314. /**
  74315. * Interface used to define a behavior
  74316. */
  74317. export interface Behavior<T> {
  74318. /** gets or sets behavior's name */
  74319. name: string;
  74320. /**
  74321. * Function called when the behavior needs to be initialized (after attaching it to a target)
  74322. */
  74323. init(): void;
  74324. /**
  74325. * Called when the behavior is attached to a target
  74326. * @param target defines the target where the behavior is attached to
  74327. */
  74328. attach(target: T): void;
  74329. /**
  74330. * Called when the behavior is detached from its target
  74331. */
  74332. detach(): void;
  74333. }
  74334. /**
  74335. * Interface implemented by classes supporting behaviors
  74336. */
  74337. export interface IBehaviorAware<T> {
  74338. /**
  74339. * Attach a behavior
  74340. * @param behavior defines the behavior to attach
  74341. * @returns the current host
  74342. */
  74343. addBehavior(behavior: Behavior<T>): T;
  74344. /**
  74345. * Remove a behavior from the current object
  74346. * @param behavior defines the behavior to detach
  74347. * @returns the current host
  74348. */
  74349. removeBehavior(behavior: Behavior<T>): T;
  74350. /**
  74351. * Gets a behavior using its name to search
  74352. * @param name defines the name to search
  74353. * @returns the behavior or null if not found
  74354. */
  74355. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  74356. }
  74357. }
  74358. declare module BABYLON {
  74359. /**
  74360. * Defines an array and its length.
  74361. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  74362. */
  74363. export interface ISmartArrayLike<T> {
  74364. /**
  74365. * The data of the array.
  74366. */
  74367. data: Array<T>;
  74368. /**
  74369. * The active length of the array.
  74370. */
  74371. length: number;
  74372. }
  74373. /**
  74374. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74375. */
  74376. export class SmartArray<T> implements ISmartArrayLike<T> {
  74377. /**
  74378. * The full set of data from the array.
  74379. */
  74380. data: Array<T>;
  74381. /**
  74382. * The active length of the array.
  74383. */
  74384. length: number;
  74385. protected _id: number;
  74386. /**
  74387. * Instantiates a Smart Array.
  74388. * @param capacity defines the default capacity of the array.
  74389. */
  74390. constructor(capacity: number);
  74391. /**
  74392. * Pushes a value at the end of the active data.
  74393. * @param value defines the object to push in the array.
  74394. */
  74395. push(value: T): void;
  74396. /**
  74397. * Iterates over the active data and apply the lambda to them.
  74398. * @param func defines the action to apply on each value.
  74399. */
  74400. forEach(func: (content: T) => void): void;
  74401. /**
  74402. * Sorts the full sets of data.
  74403. * @param compareFn defines the comparison function to apply.
  74404. */
  74405. sort(compareFn: (a: T, b: T) => number): void;
  74406. /**
  74407. * Resets the active data to an empty array.
  74408. */
  74409. reset(): void;
  74410. /**
  74411. * Releases all the data from the array as well as the array.
  74412. */
  74413. dispose(): void;
  74414. /**
  74415. * Concats the active data with a given array.
  74416. * @param array defines the data to concatenate with.
  74417. */
  74418. concat(array: any): void;
  74419. /**
  74420. * Returns the position of a value in the active data.
  74421. * @param value defines the value to find the index for
  74422. * @returns the index if found in the active data otherwise -1
  74423. */
  74424. indexOf(value: T): number;
  74425. /**
  74426. * Returns whether an element is part of the active data.
  74427. * @param value defines the value to look for
  74428. * @returns true if found in the active data otherwise false
  74429. */
  74430. contains(value: T): boolean;
  74431. private static _GlobalId;
  74432. }
  74433. /**
  74434. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  74435. * The data in this array can only be present once
  74436. */
  74437. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  74438. private _duplicateId;
  74439. /**
  74440. * Pushes a value at the end of the active data.
  74441. * THIS DOES NOT PREVENT DUPPLICATE DATA
  74442. * @param value defines the object to push in the array.
  74443. */
  74444. push(value: T): void;
  74445. /**
  74446. * Pushes a value at the end of the active data.
  74447. * If the data is already present, it won t be added again
  74448. * @param value defines the object to push in the array.
  74449. * @returns true if added false if it was already present
  74450. */
  74451. pushNoDuplicate(value: T): boolean;
  74452. /**
  74453. * Resets the active data to an empty array.
  74454. */
  74455. reset(): void;
  74456. /**
  74457. * Concats the active data with a given array.
  74458. * This ensures no dupplicate will be present in the result.
  74459. * @param array defines the data to concatenate with.
  74460. */
  74461. concatWithNoDuplicate(array: any): void;
  74462. }
  74463. }
  74464. declare module BABYLON {
  74465. /**
  74466. * @ignore
  74467. * This is a list of all the different input types that are available in the application.
  74468. * Fo instance: ArcRotateCameraGamepadInput...
  74469. */
  74470. export var CameraInputTypes: {};
  74471. /**
  74472. * This is the contract to implement in order to create a new input class.
  74473. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  74474. */
  74475. export interface ICameraInput<TCamera extends Camera> {
  74476. /**
  74477. * Defines the camera the input is attached to.
  74478. */
  74479. camera: Nullable<TCamera>;
  74480. /**
  74481. * Gets the class name of the current intput.
  74482. * @returns the class name
  74483. */
  74484. getClassName(): string;
  74485. /**
  74486. * Get the friendly name associated with the input class.
  74487. * @returns the input friendly name
  74488. */
  74489. getSimpleName(): string;
  74490. /**
  74491. * Attach the input controls to a specific dom element to get the input from.
  74492. * @param element Defines the element the controls should be listened from
  74493. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74494. */
  74495. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74496. /**
  74497. * Detach the current controls from the specified dom element.
  74498. * @param element Defines the element to stop listening the inputs from
  74499. */
  74500. detachControl(element: Nullable<HTMLElement>): void;
  74501. /**
  74502. * Update the current camera state depending on the inputs that have been used this frame.
  74503. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74504. */
  74505. checkInputs?: () => void;
  74506. }
  74507. /**
  74508. * Represents a map of input types to input instance or input index to input instance.
  74509. */
  74510. export interface CameraInputsMap<TCamera extends Camera> {
  74511. /**
  74512. * Accessor to the input by input type.
  74513. */
  74514. [name: string]: ICameraInput<TCamera>;
  74515. /**
  74516. * Accessor to the input by input index.
  74517. */
  74518. [idx: number]: ICameraInput<TCamera>;
  74519. }
  74520. /**
  74521. * This represents the input manager used within a camera.
  74522. * It helps dealing with all the different kind of input attached to a camera.
  74523. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74524. */
  74525. export class CameraInputsManager<TCamera extends Camera> {
  74526. /**
  74527. * Defines the list of inputs attahed to the camera.
  74528. */
  74529. attached: CameraInputsMap<TCamera>;
  74530. /**
  74531. * Defines the dom element the camera is collecting inputs from.
  74532. * This is null if the controls have not been attached.
  74533. */
  74534. attachedElement: Nullable<HTMLElement>;
  74535. /**
  74536. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74537. */
  74538. noPreventDefault: boolean;
  74539. /**
  74540. * Defined the camera the input manager belongs to.
  74541. */
  74542. camera: TCamera;
  74543. /**
  74544. * Update the current camera state depending on the inputs that have been used this frame.
  74545. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74546. */
  74547. checkInputs: () => void;
  74548. /**
  74549. * Instantiate a new Camera Input Manager.
  74550. * @param camera Defines the camera the input manager blongs to
  74551. */
  74552. constructor(camera: TCamera);
  74553. /**
  74554. * Add an input method to a camera
  74555. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74556. * @param input camera input method
  74557. */
  74558. add(input: ICameraInput<TCamera>): void;
  74559. /**
  74560. * Remove a specific input method from a camera
  74561. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  74562. * @param inputToRemove camera input method
  74563. */
  74564. remove(inputToRemove: ICameraInput<TCamera>): void;
  74565. /**
  74566. * Remove a specific input type from a camera
  74567. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  74568. * @param inputType the type of the input to remove
  74569. */
  74570. removeByType(inputType: string): void;
  74571. private _addCheckInputs;
  74572. /**
  74573. * Attach the input controls to the currently attached dom element to listen the events from.
  74574. * @param input Defines the input to attach
  74575. */
  74576. attachInput(input: ICameraInput<TCamera>): void;
  74577. /**
  74578. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  74579. * @param element Defines the dom element to collect the events from
  74580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74581. */
  74582. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  74583. /**
  74584. * Detach the current manager inputs controls from a specific dom element.
  74585. * @param element Defines the dom element to collect the events from
  74586. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  74587. */
  74588. detachElement(element: HTMLElement, disconnect?: boolean): void;
  74589. /**
  74590. * Rebuild the dynamic inputCheck function from the current list of
  74591. * defined inputs in the manager.
  74592. */
  74593. rebuildInputCheck(): void;
  74594. /**
  74595. * Remove all attached input methods from a camera
  74596. */
  74597. clear(): void;
  74598. /**
  74599. * Serialize the current input manager attached to a camera.
  74600. * This ensures than once parsed,
  74601. * the input associated to the camera will be identical to the current ones
  74602. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  74603. */
  74604. serialize(serializedCamera: any): void;
  74605. /**
  74606. * Parses an input manager serialized JSON to restore the previous list of inputs
  74607. * and states associated to a camera.
  74608. * @param parsedCamera Defines the JSON to parse
  74609. */
  74610. parse(parsedCamera: any): void;
  74611. }
  74612. }
  74613. declare module BABYLON {
  74614. /**
  74615. * Class used to store data that will be store in GPU memory
  74616. */
  74617. export class Buffer {
  74618. private _engine;
  74619. private _buffer;
  74620. /** @hidden */
  74621. _data: Nullable<DataArray>;
  74622. private _updatable;
  74623. private _instanced;
  74624. private _divisor;
  74625. /**
  74626. * Gets the byte stride.
  74627. */
  74628. readonly byteStride: number;
  74629. /**
  74630. * Constructor
  74631. * @param engine the engine
  74632. * @param data the data to use for this buffer
  74633. * @param updatable whether the data is updatable
  74634. * @param stride the stride (optional)
  74635. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74636. * @param instanced whether the buffer is instanced (optional)
  74637. * @param useBytes set to true if the stride in in bytes (optional)
  74638. * @param divisor sets an optional divisor for instances (1 by default)
  74639. */
  74640. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  74641. /**
  74642. * Create a new VertexBuffer based on the current buffer
  74643. * @param kind defines the vertex buffer kind (position, normal, etc.)
  74644. * @param offset defines offset in the buffer (0 by default)
  74645. * @param size defines the size in floats of attributes (position is 3 for instance)
  74646. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  74647. * @param instanced defines if the vertex buffer contains indexed data
  74648. * @param useBytes defines if the offset and stride are in bytes *
  74649. * @param divisor sets an optional divisor for instances (1 by default)
  74650. * @returns the new vertex buffer
  74651. */
  74652. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  74653. /**
  74654. * Gets a boolean indicating if the Buffer is updatable?
  74655. * @returns true if the buffer is updatable
  74656. */
  74657. isUpdatable(): boolean;
  74658. /**
  74659. * Gets current buffer's data
  74660. * @returns a DataArray or null
  74661. */
  74662. getData(): Nullable<DataArray>;
  74663. /**
  74664. * Gets underlying native buffer
  74665. * @returns underlying native buffer
  74666. */
  74667. getBuffer(): Nullable<DataBuffer>;
  74668. /**
  74669. * Gets the stride in float32 units (i.e. byte stride / 4).
  74670. * May not be an integer if the byte stride is not divisible by 4.
  74671. * DEPRECATED. Use byteStride instead.
  74672. * @returns the stride in float32 units
  74673. */
  74674. getStrideSize(): number;
  74675. /**
  74676. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74677. * @param data defines the data to store
  74678. */
  74679. create(data?: Nullable<DataArray>): void;
  74680. /** @hidden */
  74681. _rebuild(): void;
  74682. /**
  74683. * Update current buffer data
  74684. * @param data defines the data to store
  74685. */
  74686. update(data: DataArray): void;
  74687. /**
  74688. * Updates the data directly.
  74689. * @param data the new data
  74690. * @param offset the new offset
  74691. * @param vertexCount the vertex count (optional)
  74692. * @param useBytes set to true if the offset is in bytes
  74693. */
  74694. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  74695. /**
  74696. * Release all resources
  74697. */
  74698. dispose(): void;
  74699. }
  74700. /**
  74701. * Specialized buffer used to store vertex data
  74702. */
  74703. export class VertexBuffer {
  74704. /** @hidden */
  74705. _buffer: Buffer;
  74706. private _kind;
  74707. private _size;
  74708. private _ownsBuffer;
  74709. private _instanced;
  74710. private _instanceDivisor;
  74711. /**
  74712. * The byte type.
  74713. */
  74714. static readonly BYTE: number;
  74715. /**
  74716. * The unsigned byte type.
  74717. */
  74718. static readonly UNSIGNED_BYTE: number;
  74719. /**
  74720. * The short type.
  74721. */
  74722. static readonly SHORT: number;
  74723. /**
  74724. * The unsigned short type.
  74725. */
  74726. static readonly UNSIGNED_SHORT: number;
  74727. /**
  74728. * The integer type.
  74729. */
  74730. static readonly INT: number;
  74731. /**
  74732. * The unsigned integer type.
  74733. */
  74734. static readonly UNSIGNED_INT: number;
  74735. /**
  74736. * The float type.
  74737. */
  74738. static readonly FLOAT: number;
  74739. /**
  74740. * Gets or sets the instance divisor when in instanced mode
  74741. */
  74742. instanceDivisor: number;
  74743. /**
  74744. * Gets the byte stride.
  74745. */
  74746. readonly byteStride: number;
  74747. /**
  74748. * Gets the byte offset.
  74749. */
  74750. readonly byteOffset: number;
  74751. /**
  74752. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  74753. */
  74754. readonly normalized: boolean;
  74755. /**
  74756. * Gets the data type of each component in the array.
  74757. */
  74758. readonly type: number;
  74759. /**
  74760. * Constructor
  74761. * @param engine the engine
  74762. * @param data the data to use for this vertex buffer
  74763. * @param kind the vertex buffer kind
  74764. * @param updatable whether the data is updatable
  74765. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  74766. * @param stride the stride (optional)
  74767. * @param instanced whether the buffer is instanced (optional)
  74768. * @param offset the offset of the data (optional)
  74769. * @param size the number of components (optional)
  74770. * @param type the type of the component (optional)
  74771. * @param normalized whether the data contains normalized data (optional)
  74772. * @param useBytes set to true if stride and offset are in bytes (optional)
  74773. * @param divisor defines the instance divisor to use (1 by default)
  74774. */
  74775. 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);
  74776. /** @hidden */
  74777. _rebuild(): void;
  74778. /**
  74779. * Returns the kind of the VertexBuffer (string)
  74780. * @returns a string
  74781. */
  74782. getKind(): string;
  74783. /**
  74784. * Gets a boolean indicating if the VertexBuffer is updatable?
  74785. * @returns true if the buffer is updatable
  74786. */
  74787. isUpdatable(): boolean;
  74788. /**
  74789. * Gets current buffer's data
  74790. * @returns a DataArray or null
  74791. */
  74792. getData(): Nullable<DataArray>;
  74793. /**
  74794. * Gets underlying native buffer
  74795. * @returns underlying native buffer
  74796. */
  74797. getBuffer(): Nullable<DataBuffer>;
  74798. /**
  74799. * Gets the stride in float32 units (i.e. byte stride / 4).
  74800. * May not be an integer if the byte stride is not divisible by 4.
  74801. * DEPRECATED. Use byteStride instead.
  74802. * @returns the stride in float32 units
  74803. */
  74804. getStrideSize(): number;
  74805. /**
  74806. * Returns the offset as a multiple of the type byte length.
  74807. * DEPRECATED. Use byteOffset instead.
  74808. * @returns the offset in bytes
  74809. */
  74810. getOffset(): number;
  74811. /**
  74812. * Returns the number of components per vertex attribute (integer)
  74813. * @returns the size in float
  74814. */
  74815. getSize(): number;
  74816. /**
  74817. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  74818. * @returns true if this buffer is instanced
  74819. */
  74820. getIsInstanced(): boolean;
  74821. /**
  74822. * Returns the instancing divisor, zero for non-instanced (integer).
  74823. * @returns a number
  74824. */
  74825. getInstanceDivisor(): number;
  74826. /**
  74827. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  74828. * @param data defines the data to store
  74829. */
  74830. create(data?: DataArray): void;
  74831. /**
  74832. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  74833. * This function will create a new buffer if the current one is not updatable
  74834. * @param data defines the data to store
  74835. */
  74836. update(data: DataArray): void;
  74837. /**
  74838. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  74839. * Returns the directly updated WebGLBuffer.
  74840. * @param data the new data
  74841. * @param offset the new offset
  74842. * @param useBytes set to true if the offset is in bytes
  74843. */
  74844. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  74845. /**
  74846. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  74847. */
  74848. dispose(): void;
  74849. /**
  74850. * Enumerates each value of this vertex buffer as numbers.
  74851. * @param count the number of values to enumerate
  74852. * @param callback the callback function called for each value
  74853. */
  74854. forEach(count: number, callback: (value: number, index: number) => void): void;
  74855. /**
  74856. * Positions
  74857. */
  74858. static readonly PositionKind: string;
  74859. /**
  74860. * Normals
  74861. */
  74862. static readonly NormalKind: string;
  74863. /**
  74864. * Tangents
  74865. */
  74866. static readonly TangentKind: string;
  74867. /**
  74868. * Texture coordinates
  74869. */
  74870. static readonly UVKind: string;
  74871. /**
  74872. * Texture coordinates 2
  74873. */
  74874. static readonly UV2Kind: string;
  74875. /**
  74876. * Texture coordinates 3
  74877. */
  74878. static readonly UV3Kind: string;
  74879. /**
  74880. * Texture coordinates 4
  74881. */
  74882. static readonly UV4Kind: string;
  74883. /**
  74884. * Texture coordinates 5
  74885. */
  74886. static readonly UV5Kind: string;
  74887. /**
  74888. * Texture coordinates 6
  74889. */
  74890. static readonly UV6Kind: string;
  74891. /**
  74892. * Colors
  74893. */
  74894. static readonly ColorKind: string;
  74895. /**
  74896. * Matrix indices (for bones)
  74897. */
  74898. static readonly MatricesIndicesKind: string;
  74899. /**
  74900. * Matrix weights (for bones)
  74901. */
  74902. static readonly MatricesWeightsKind: string;
  74903. /**
  74904. * Additional matrix indices (for bones)
  74905. */
  74906. static readonly MatricesIndicesExtraKind: string;
  74907. /**
  74908. * Additional matrix weights (for bones)
  74909. */
  74910. static readonly MatricesWeightsExtraKind: string;
  74911. /**
  74912. * Deduces the stride given a kind.
  74913. * @param kind The kind string to deduce
  74914. * @returns The deduced stride
  74915. */
  74916. static DeduceStride(kind: string): number;
  74917. /**
  74918. * Gets the byte length of the given type.
  74919. * @param type the type
  74920. * @returns the number of bytes
  74921. */
  74922. static GetTypeByteLength(type: number): number;
  74923. /**
  74924. * Enumerates each value of the given parameters as numbers.
  74925. * @param data the data to enumerate
  74926. * @param byteOffset the byte offset of the data
  74927. * @param byteStride the byte stride of the data
  74928. * @param componentCount the number of components per element
  74929. * @param componentType the type of the component
  74930. * @param count the number of values to enumerate
  74931. * @param normalized whether the data is normalized
  74932. * @param callback the callback function called for each value
  74933. */
  74934. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  74935. private static _GetFloatValue;
  74936. }
  74937. }
  74938. declare module BABYLON {
  74939. /**
  74940. * @hidden
  74941. */
  74942. export class IntersectionInfo {
  74943. bu: Nullable<number>;
  74944. bv: Nullable<number>;
  74945. distance: number;
  74946. faceId: number;
  74947. subMeshId: number;
  74948. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  74949. }
  74950. }
  74951. declare module BABYLON {
  74952. /**
  74953. * Represens a plane by the equation ax + by + cz + d = 0
  74954. */
  74955. export class Plane {
  74956. private static _TmpMatrix;
  74957. /**
  74958. * Normal of the plane (a,b,c)
  74959. */
  74960. normal: Vector3;
  74961. /**
  74962. * d component of the plane
  74963. */
  74964. d: number;
  74965. /**
  74966. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  74967. * @param a a component of the plane
  74968. * @param b b component of the plane
  74969. * @param c c component of the plane
  74970. * @param d d component of the plane
  74971. */
  74972. constructor(a: number, b: number, c: number, d: number);
  74973. /**
  74974. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  74975. */
  74976. asArray(): number[];
  74977. /**
  74978. * @returns a new plane copied from the current Plane.
  74979. */
  74980. clone(): Plane;
  74981. /**
  74982. * @returns the string "Plane".
  74983. */
  74984. getClassName(): string;
  74985. /**
  74986. * @returns the Plane hash code.
  74987. */
  74988. getHashCode(): number;
  74989. /**
  74990. * Normalize the current Plane in place.
  74991. * @returns the updated Plane.
  74992. */
  74993. normalize(): Plane;
  74994. /**
  74995. * Applies a transformation the plane and returns the result
  74996. * @param transformation the transformation matrix to be applied to the plane
  74997. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  74998. */
  74999. transform(transformation: DeepImmutable<Matrix>): Plane;
  75000. /**
  75001. * Calcualtte the dot product between the point and the plane normal
  75002. * @param point point to calculate the dot product with
  75003. * @returns the dot product (float) of the point coordinates and the plane normal.
  75004. */
  75005. dotCoordinate(point: DeepImmutable<Vector3>): number;
  75006. /**
  75007. * Updates the current Plane from the plane defined by the three given points.
  75008. * @param point1 one of the points used to contruct the plane
  75009. * @param point2 one of the points used to contruct the plane
  75010. * @param point3 one of the points used to contruct the plane
  75011. * @returns the updated Plane.
  75012. */
  75013. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75014. /**
  75015. * Checks if the plane is facing a given direction
  75016. * @param direction the direction to check if the plane is facing
  75017. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  75018. * @returns True is the vector "direction" is the same side than the plane normal.
  75019. */
  75020. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  75021. /**
  75022. * Calculates the distance to a point
  75023. * @param point point to calculate distance to
  75024. * @returns the signed distance (float) from the given point to the Plane.
  75025. */
  75026. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  75027. /**
  75028. * Creates a plane from an array
  75029. * @param array the array to create a plane from
  75030. * @returns a new Plane from the given array.
  75031. */
  75032. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  75033. /**
  75034. * Creates a plane from three points
  75035. * @param point1 point used to create the plane
  75036. * @param point2 point used to create the plane
  75037. * @param point3 point used to create the plane
  75038. * @returns a new Plane defined by the three given points.
  75039. */
  75040. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  75041. /**
  75042. * Creates a plane from an origin point and a normal
  75043. * @param origin origin of the plane to be constructed
  75044. * @param normal normal of the plane to be constructed
  75045. * @returns a new Plane the normal vector to this plane at the given origin point.
  75046. * Note : the vector "normal" is updated because normalized.
  75047. */
  75048. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  75049. /**
  75050. * Calculates the distance from a plane and a point
  75051. * @param origin origin of the plane to be constructed
  75052. * @param normal normal of the plane to be constructed
  75053. * @param point point to calculate distance to
  75054. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  75055. */
  75056. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  75057. }
  75058. }
  75059. declare module BABYLON {
  75060. /**
  75061. * Class used to store bounding sphere information
  75062. */
  75063. export class BoundingSphere {
  75064. /**
  75065. * Gets the center of the bounding sphere in local space
  75066. */
  75067. readonly center: Vector3;
  75068. /**
  75069. * Radius of the bounding sphere in local space
  75070. */
  75071. radius: number;
  75072. /**
  75073. * Gets the center of the bounding sphere in world space
  75074. */
  75075. readonly centerWorld: Vector3;
  75076. /**
  75077. * Radius of the bounding sphere in world space
  75078. */
  75079. radiusWorld: number;
  75080. /**
  75081. * Gets the minimum vector in local space
  75082. */
  75083. readonly minimum: Vector3;
  75084. /**
  75085. * Gets the maximum vector in local space
  75086. */
  75087. readonly maximum: Vector3;
  75088. private _worldMatrix;
  75089. private static readonly TmpVector3;
  75090. /**
  75091. * Creates a new bounding sphere
  75092. * @param min defines the minimum vector (in local space)
  75093. * @param max defines the maximum vector (in local space)
  75094. * @param worldMatrix defines the new world matrix
  75095. */
  75096. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75097. /**
  75098. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  75099. * @param min defines the new minimum vector (in local space)
  75100. * @param max defines the new maximum vector (in local space)
  75101. * @param worldMatrix defines the new world matrix
  75102. */
  75103. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75104. /**
  75105. * Scale the current bounding sphere by applying a scale factor
  75106. * @param factor defines the scale factor to apply
  75107. * @returns the current bounding box
  75108. */
  75109. scale(factor: number): BoundingSphere;
  75110. /**
  75111. * Gets the world matrix of the bounding box
  75112. * @returns a matrix
  75113. */
  75114. getWorldMatrix(): DeepImmutable<Matrix>;
  75115. /** @hidden */
  75116. _update(worldMatrix: DeepImmutable<Matrix>): void;
  75117. /**
  75118. * Tests if the bounding sphere is intersecting the frustum planes
  75119. * @param frustumPlanes defines the frustum planes to test
  75120. * @returns true if there is an intersection
  75121. */
  75122. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75123. /**
  75124. * Tests if the bounding sphere center is in between the frustum planes.
  75125. * Used for optimistic fast inclusion.
  75126. * @param frustumPlanes defines the frustum planes to test
  75127. * @returns true if the sphere center is in between the frustum planes
  75128. */
  75129. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75130. /**
  75131. * Tests if a point is inside the bounding sphere
  75132. * @param point defines the point to test
  75133. * @returns true if the point is inside the bounding sphere
  75134. */
  75135. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75136. /**
  75137. * Checks if two sphere intersct
  75138. * @param sphere0 sphere 0
  75139. * @param sphere1 sphere 1
  75140. * @returns true if the speres intersect
  75141. */
  75142. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  75143. }
  75144. }
  75145. declare module BABYLON {
  75146. /**
  75147. * Class used to store bounding box information
  75148. */
  75149. export class BoundingBox implements ICullable {
  75150. /**
  75151. * Gets the 8 vectors representing the bounding box in local space
  75152. */
  75153. readonly vectors: Vector3[];
  75154. /**
  75155. * Gets the center of the bounding box in local space
  75156. */
  75157. readonly center: Vector3;
  75158. /**
  75159. * Gets the center of the bounding box in world space
  75160. */
  75161. readonly centerWorld: Vector3;
  75162. /**
  75163. * Gets the extend size in local space
  75164. */
  75165. readonly extendSize: Vector3;
  75166. /**
  75167. * Gets the extend size in world space
  75168. */
  75169. readonly extendSizeWorld: Vector3;
  75170. /**
  75171. * Gets the OBB (object bounding box) directions
  75172. */
  75173. readonly directions: Vector3[];
  75174. /**
  75175. * Gets the 8 vectors representing the bounding box in world space
  75176. */
  75177. readonly vectorsWorld: Vector3[];
  75178. /**
  75179. * Gets the minimum vector in world space
  75180. */
  75181. readonly minimumWorld: Vector3;
  75182. /**
  75183. * Gets the maximum vector in world space
  75184. */
  75185. readonly maximumWorld: Vector3;
  75186. /**
  75187. * Gets the minimum vector in local space
  75188. */
  75189. readonly minimum: Vector3;
  75190. /**
  75191. * Gets the maximum vector in local space
  75192. */
  75193. readonly maximum: Vector3;
  75194. private _worldMatrix;
  75195. private static readonly TmpVector3;
  75196. /**
  75197. * @hidden
  75198. */
  75199. _tag: number;
  75200. /**
  75201. * Creates a new bounding box
  75202. * @param min defines the minimum vector (in local space)
  75203. * @param max defines the maximum vector (in local space)
  75204. * @param worldMatrix defines the new world matrix
  75205. */
  75206. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75207. /**
  75208. * Recreates the entire bounding box from scratch as if we call the constructor in place
  75209. * @param min defines the new minimum vector (in local space)
  75210. * @param max defines the new maximum vector (in local space)
  75211. * @param worldMatrix defines the new world matrix
  75212. */
  75213. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75214. /**
  75215. * Scale the current bounding box by applying a scale factor
  75216. * @param factor defines the scale factor to apply
  75217. * @returns the current bounding box
  75218. */
  75219. scale(factor: number): BoundingBox;
  75220. /**
  75221. * Gets the world matrix of the bounding box
  75222. * @returns a matrix
  75223. */
  75224. getWorldMatrix(): DeepImmutable<Matrix>;
  75225. /** @hidden */
  75226. _update(world: DeepImmutable<Matrix>): void;
  75227. /**
  75228. * Tests if the bounding box is intersecting the frustum planes
  75229. * @param frustumPlanes defines the frustum planes to test
  75230. * @returns true if there is an intersection
  75231. */
  75232. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75233. /**
  75234. * Tests if the bounding box is entirely inside the frustum planes
  75235. * @param frustumPlanes defines the frustum planes to test
  75236. * @returns true if there is an inclusion
  75237. */
  75238. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75239. /**
  75240. * Tests if a point is inside the bounding box
  75241. * @param point defines the point to test
  75242. * @returns true if the point is inside the bounding box
  75243. */
  75244. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75245. /**
  75246. * Tests if the bounding box intersects with a bounding sphere
  75247. * @param sphere defines the sphere to test
  75248. * @returns true if there is an intersection
  75249. */
  75250. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  75251. /**
  75252. * Tests if the bounding box intersects with a box defined by a min and max vectors
  75253. * @param min defines the min vector to use
  75254. * @param max defines the max vector to use
  75255. * @returns true if there is an intersection
  75256. */
  75257. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  75258. /**
  75259. * Tests if two bounding boxes are intersections
  75260. * @param box0 defines the first box to test
  75261. * @param box1 defines the second box to test
  75262. * @returns true if there is an intersection
  75263. */
  75264. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  75265. /**
  75266. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  75267. * @param minPoint defines the minimum vector of the bounding box
  75268. * @param maxPoint defines the maximum vector of the bounding box
  75269. * @param sphereCenter defines the sphere center
  75270. * @param sphereRadius defines the sphere radius
  75271. * @returns true if there is an intersection
  75272. */
  75273. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  75274. /**
  75275. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  75276. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75277. * @param frustumPlanes defines the frustum planes to test
  75278. * @return true if there is an inclusion
  75279. */
  75280. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75281. /**
  75282. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  75283. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  75284. * @param frustumPlanes defines the frustum planes to test
  75285. * @return true if there is an intersection
  75286. */
  75287. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75288. }
  75289. }
  75290. declare module BABYLON {
  75291. /** @hidden */
  75292. export class Collider {
  75293. /** Define if a collision was found */
  75294. collisionFound: boolean;
  75295. /**
  75296. * Define last intersection point in local space
  75297. */
  75298. intersectionPoint: Vector3;
  75299. /**
  75300. * Define last collided mesh
  75301. */
  75302. collidedMesh: Nullable<AbstractMesh>;
  75303. private _collisionPoint;
  75304. private _planeIntersectionPoint;
  75305. private _tempVector;
  75306. private _tempVector2;
  75307. private _tempVector3;
  75308. private _tempVector4;
  75309. private _edge;
  75310. private _baseToVertex;
  75311. private _destinationPoint;
  75312. private _slidePlaneNormal;
  75313. private _displacementVector;
  75314. /** @hidden */
  75315. _radius: Vector3;
  75316. /** @hidden */
  75317. _retry: number;
  75318. private _velocity;
  75319. private _basePoint;
  75320. private _epsilon;
  75321. /** @hidden */
  75322. _velocityWorldLength: number;
  75323. /** @hidden */
  75324. _basePointWorld: Vector3;
  75325. private _velocityWorld;
  75326. private _normalizedVelocity;
  75327. /** @hidden */
  75328. _initialVelocity: Vector3;
  75329. /** @hidden */
  75330. _initialPosition: Vector3;
  75331. private _nearestDistance;
  75332. private _collisionMask;
  75333. collisionMask: number;
  75334. /**
  75335. * Gets the plane normal used to compute the sliding response (in local space)
  75336. */
  75337. readonly slidePlaneNormal: Vector3;
  75338. /** @hidden */
  75339. _initialize(source: Vector3, dir: Vector3, e: number): void;
  75340. /** @hidden */
  75341. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  75342. /** @hidden */
  75343. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  75344. /** @hidden */
  75345. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75346. /** @hidden */
  75347. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  75348. /** @hidden */
  75349. _getResponse(pos: Vector3, vel: Vector3): void;
  75350. }
  75351. }
  75352. declare module BABYLON {
  75353. /**
  75354. * Interface for cullable objects
  75355. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  75356. */
  75357. export interface ICullable {
  75358. /**
  75359. * Checks if the object or part of the object is in the frustum
  75360. * @param frustumPlanes Camera near/planes
  75361. * @returns true if the object is in frustum otherwise false
  75362. */
  75363. isInFrustum(frustumPlanes: Plane[]): boolean;
  75364. /**
  75365. * Checks if a cullable object (mesh...) is in the camera frustum
  75366. * Unlike isInFrustum this cheks the full bounding box
  75367. * @param frustumPlanes Camera near/planes
  75368. * @returns true if the object is in frustum otherwise false
  75369. */
  75370. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  75371. }
  75372. /**
  75373. * Info for a bounding data of a mesh
  75374. */
  75375. export class BoundingInfo implements ICullable {
  75376. /**
  75377. * Bounding box for the mesh
  75378. */
  75379. readonly boundingBox: BoundingBox;
  75380. /**
  75381. * Bounding sphere for the mesh
  75382. */
  75383. readonly boundingSphere: BoundingSphere;
  75384. private _isLocked;
  75385. private static readonly TmpVector3;
  75386. /**
  75387. * Constructs bounding info
  75388. * @param minimum min vector of the bounding box/sphere
  75389. * @param maximum max vector of the bounding box/sphere
  75390. * @param worldMatrix defines the new world matrix
  75391. */
  75392. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  75393. /**
  75394. * Recreates the entire bounding info from scratch as if we call the constructor in place
  75395. * @param min defines the new minimum vector (in local space)
  75396. * @param max defines the new maximum vector (in local space)
  75397. * @param worldMatrix defines the new world matrix
  75398. */
  75399. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  75400. /**
  75401. * min vector of the bounding box/sphere
  75402. */
  75403. readonly minimum: Vector3;
  75404. /**
  75405. * max vector of the bounding box/sphere
  75406. */
  75407. readonly maximum: Vector3;
  75408. /**
  75409. * If the info is locked and won't be updated to avoid perf overhead
  75410. */
  75411. isLocked: boolean;
  75412. /**
  75413. * Updates the bounding sphere and box
  75414. * @param world world matrix to be used to update
  75415. */
  75416. update(world: DeepImmutable<Matrix>): void;
  75417. /**
  75418. * Recreate the bounding info to be centered around a specific point given a specific extend.
  75419. * @param center New center of the bounding info
  75420. * @param extend New extend of the bounding info
  75421. * @returns the current bounding info
  75422. */
  75423. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  75424. /**
  75425. * Scale the current bounding info by applying a scale factor
  75426. * @param factor defines the scale factor to apply
  75427. * @returns the current bounding info
  75428. */
  75429. scale(factor: number): BoundingInfo;
  75430. /**
  75431. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  75432. * @param frustumPlanes defines the frustum to test
  75433. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  75434. * @returns true if the bounding info is in the frustum planes
  75435. */
  75436. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  75437. /**
  75438. * Gets the world distance between the min and max points of the bounding box
  75439. */
  75440. readonly diagonalLength: number;
  75441. /**
  75442. * Checks if a cullable object (mesh...) is in the camera frustum
  75443. * Unlike isInFrustum this cheks the full bounding box
  75444. * @param frustumPlanes Camera near/planes
  75445. * @returns true if the object is in frustum otherwise false
  75446. */
  75447. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  75448. /** @hidden */
  75449. _checkCollision(collider: Collider): boolean;
  75450. /**
  75451. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  75452. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75453. * @param point the point to check intersection with
  75454. * @returns if the point intersects
  75455. */
  75456. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  75457. /**
  75458. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  75459. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  75460. * @param boundingInfo the bounding info to check intersection with
  75461. * @param precise if the intersection should be done using OBB
  75462. * @returns if the bounding info intersects
  75463. */
  75464. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  75465. }
  75466. }
  75467. declare module BABYLON {
  75468. /**
  75469. * Extracts minimum and maximum values from a list of indexed positions
  75470. * @param positions defines the positions to use
  75471. * @param indices defines the indices to the positions
  75472. * @param indexStart defines the start index
  75473. * @param indexCount defines the end index
  75474. * @param bias defines bias value to add to the result
  75475. * @return minimum and maximum values
  75476. */
  75477. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  75478. minimum: Vector3;
  75479. maximum: Vector3;
  75480. };
  75481. /**
  75482. * Extracts minimum and maximum values from a list of positions
  75483. * @param positions defines the positions to use
  75484. * @param start defines the start index in the positions array
  75485. * @param count defines the number of positions to handle
  75486. * @param bias defines bias value to add to the result
  75487. * @param stride defines the stride size to use (distance between two positions in the positions array)
  75488. * @return minimum and maximum values
  75489. */
  75490. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  75491. minimum: Vector3;
  75492. maximum: Vector3;
  75493. };
  75494. }
  75495. declare module BABYLON {
  75496. /** @hidden */
  75497. export class WebGLDataBuffer extends DataBuffer {
  75498. private _buffer;
  75499. constructor(resource: WebGLBuffer);
  75500. readonly underlyingResource: any;
  75501. }
  75502. }
  75503. declare module BABYLON {
  75504. /** @hidden */
  75505. export class WebGLPipelineContext implements IPipelineContext {
  75506. engine: ThinEngine;
  75507. program: Nullable<WebGLProgram>;
  75508. context?: WebGLRenderingContext;
  75509. vertexShader?: WebGLShader;
  75510. fragmentShader?: WebGLShader;
  75511. isParallelCompiled: boolean;
  75512. onCompiled?: () => void;
  75513. transformFeedback?: WebGLTransformFeedback | null;
  75514. readonly isAsync: boolean;
  75515. readonly isReady: boolean;
  75516. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  75517. }
  75518. }
  75519. declare module BABYLON {
  75520. interface ThinEngine {
  75521. /**
  75522. * Create an uniform buffer
  75523. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75524. * @param elements defines the content of the uniform buffer
  75525. * @returns the webGL uniform buffer
  75526. */
  75527. createUniformBuffer(elements: FloatArray): DataBuffer;
  75528. /**
  75529. * Create a dynamic uniform buffer
  75530. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75531. * @param elements defines the content of the uniform buffer
  75532. * @returns the webGL uniform buffer
  75533. */
  75534. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  75535. /**
  75536. * Update an existing uniform buffer
  75537. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  75538. * @param uniformBuffer defines the target uniform buffer
  75539. * @param elements defines the content to update
  75540. * @param offset defines the offset in the uniform buffer where update should start
  75541. * @param count defines the size of the data to update
  75542. */
  75543. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  75544. /**
  75545. * Bind an uniform buffer to the current webGL context
  75546. * @param buffer defines the buffer to bind
  75547. */
  75548. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  75549. /**
  75550. * Bind a buffer to the current webGL context at a given location
  75551. * @param buffer defines the buffer to bind
  75552. * @param location defines the index where to bind the buffer
  75553. */
  75554. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  75555. /**
  75556. * Bind a specific block at a given index in a specific shader program
  75557. * @param pipelineContext defines the pipeline context to use
  75558. * @param blockName defines the block name
  75559. * @param index defines the index where to bind the block
  75560. */
  75561. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  75562. }
  75563. }
  75564. declare module BABYLON {
  75565. /**
  75566. * Uniform buffer objects.
  75567. *
  75568. * Handles blocks of uniform on the GPU.
  75569. *
  75570. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75571. *
  75572. * For more information, please refer to :
  75573. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75574. */
  75575. export class UniformBuffer {
  75576. private _engine;
  75577. private _buffer;
  75578. private _data;
  75579. private _bufferData;
  75580. private _dynamic?;
  75581. private _uniformLocations;
  75582. private _uniformSizes;
  75583. private _uniformLocationPointer;
  75584. private _needSync;
  75585. private _noUBO;
  75586. private _currentEffect;
  75587. /** @hidden */
  75588. _alreadyBound: boolean;
  75589. private static _MAX_UNIFORM_SIZE;
  75590. private static _tempBuffer;
  75591. /**
  75592. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  75593. * This is dynamic to allow compat with webgl 1 and 2.
  75594. * You will need to pass the name of the uniform as well as the value.
  75595. */
  75596. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  75597. /**
  75598. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  75599. * This is dynamic to allow compat with webgl 1 and 2.
  75600. * You will need to pass the name of the uniform as well as the value.
  75601. */
  75602. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  75603. /**
  75604. * Lambda to Update a single float in a uniform buffer.
  75605. * This is dynamic to allow compat with webgl 1 and 2.
  75606. * You will need to pass the name of the uniform as well as the value.
  75607. */
  75608. updateFloat: (name: string, x: number) => void;
  75609. /**
  75610. * Lambda to Update a vec2 of float in a uniform buffer.
  75611. * This is dynamic to allow compat with webgl 1 and 2.
  75612. * You will need to pass the name of the uniform as well as the value.
  75613. */
  75614. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  75615. /**
  75616. * Lambda to Update a vec3 of float in a uniform buffer.
  75617. * This is dynamic to allow compat with webgl 1 and 2.
  75618. * You will need to pass the name of the uniform as well as the value.
  75619. */
  75620. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  75621. /**
  75622. * Lambda to Update a vec4 of float in a uniform buffer.
  75623. * This is dynamic to allow compat with webgl 1 and 2.
  75624. * You will need to pass the name of the uniform as well as the value.
  75625. */
  75626. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  75627. /**
  75628. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  75629. * This is dynamic to allow compat with webgl 1 and 2.
  75630. * You will need to pass the name of the uniform as well as the value.
  75631. */
  75632. updateMatrix: (name: string, mat: Matrix) => void;
  75633. /**
  75634. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  75635. * This is dynamic to allow compat with webgl 1 and 2.
  75636. * You will need to pass the name of the uniform as well as the value.
  75637. */
  75638. updateVector3: (name: string, vector: Vector3) => void;
  75639. /**
  75640. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  75641. * This is dynamic to allow compat with webgl 1 and 2.
  75642. * You will need to pass the name of the uniform as well as the value.
  75643. */
  75644. updateVector4: (name: string, vector: Vector4) => void;
  75645. /**
  75646. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  75647. * This is dynamic to allow compat with webgl 1 and 2.
  75648. * You will need to pass the name of the uniform as well as the value.
  75649. */
  75650. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  75651. /**
  75652. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  75653. * This is dynamic to allow compat with webgl 1 and 2.
  75654. * You will need to pass the name of the uniform as well as the value.
  75655. */
  75656. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  75657. /**
  75658. * Instantiates a new Uniform buffer objects.
  75659. *
  75660. * Handles blocks of uniform on the GPU.
  75661. *
  75662. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  75663. *
  75664. * For more information, please refer to :
  75665. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  75666. * @param engine Define the engine the buffer is associated with
  75667. * @param data Define the data contained in the buffer
  75668. * @param dynamic Define if the buffer is updatable
  75669. */
  75670. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  75671. /**
  75672. * Indicates if the buffer is using the WebGL2 UBO implementation,
  75673. * or just falling back on setUniformXXX calls.
  75674. */
  75675. readonly useUbo: boolean;
  75676. /**
  75677. * Indicates if the WebGL underlying uniform buffer is in sync
  75678. * with the javascript cache data.
  75679. */
  75680. readonly isSync: boolean;
  75681. /**
  75682. * Indicates if the WebGL underlying uniform buffer is dynamic.
  75683. * Also, a dynamic UniformBuffer will disable cache verification and always
  75684. * update the underlying WebGL uniform buffer to the GPU.
  75685. * @returns if Dynamic, otherwise false
  75686. */
  75687. isDynamic(): boolean;
  75688. /**
  75689. * The data cache on JS side.
  75690. * @returns the underlying data as a float array
  75691. */
  75692. getData(): Float32Array;
  75693. /**
  75694. * The underlying WebGL Uniform buffer.
  75695. * @returns the webgl buffer
  75696. */
  75697. getBuffer(): Nullable<DataBuffer>;
  75698. /**
  75699. * std140 layout specifies how to align data within an UBO structure.
  75700. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  75701. * for specs.
  75702. */
  75703. private _fillAlignment;
  75704. /**
  75705. * Adds an uniform in the buffer.
  75706. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  75707. * for the layout to be correct !
  75708. * @param name Name of the uniform, as used in the uniform block in the shader.
  75709. * @param size Data size, or data directly.
  75710. */
  75711. addUniform(name: string, size: number | number[]): void;
  75712. /**
  75713. * Adds a Matrix 4x4 to the uniform buffer.
  75714. * @param name Name of the uniform, as used in the uniform block in the shader.
  75715. * @param mat A 4x4 matrix.
  75716. */
  75717. addMatrix(name: string, mat: Matrix): void;
  75718. /**
  75719. * Adds a vec2 to the uniform buffer.
  75720. * @param name Name of the uniform, as used in the uniform block in the shader.
  75721. * @param x Define the x component value of the vec2
  75722. * @param y Define the y component value of the vec2
  75723. */
  75724. addFloat2(name: string, x: number, y: number): void;
  75725. /**
  75726. * Adds a vec3 to the uniform buffer.
  75727. * @param name Name of the uniform, as used in the uniform block in the shader.
  75728. * @param x Define the x component value of the vec3
  75729. * @param y Define the y component value of the vec3
  75730. * @param z Define the z component value of the vec3
  75731. */
  75732. addFloat3(name: string, x: number, y: number, z: number): void;
  75733. /**
  75734. * Adds a vec3 to the uniform buffer.
  75735. * @param name Name of the uniform, as used in the uniform block in the shader.
  75736. * @param color Define the vec3 from a Color
  75737. */
  75738. addColor3(name: string, color: Color3): void;
  75739. /**
  75740. * Adds a vec4 to the uniform buffer.
  75741. * @param name Name of the uniform, as used in the uniform block in the shader.
  75742. * @param color Define the rgb components from a Color
  75743. * @param alpha Define the a component of the vec4
  75744. */
  75745. addColor4(name: string, color: Color3, alpha: number): void;
  75746. /**
  75747. * Adds a vec3 to the uniform buffer.
  75748. * @param name Name of the uniform, as used in the uniform block in the shader.
  75749. * @param vector Define the vec3 components from a Vector
  75750. */
  75751. addVector3(name: string, vector: Vector3): void;
  75752. /**
  75753. * Adds a Matrix 3x3 to the uniform buffer.
  75754. * @param name Name of the uniform, as used in the uniform block in the shader.
  75755. */
  75756. addMatrix3x3(name: string): void;
  75757. /**
  75758. * Adds a Matrix 2x2 to the uniform buffer.
  75759. * @param name Name of the uniform, as used in the uniform block in the shader.
  75760. */
  75761. addMatrix2x2(name: string): void;
  75762. /**
  75763. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  75764. */
  75765. create(): void;
  75766. /** @hidden */
  75767. _rebuild(): void;
  75768. /**
  75769. * Updates the WebGL Uniform Buffer on the GPU.
  75770. * If the `dynamic` flag is set to true, no cache comparison is done.
  75771. * Otherwise, the buffer will be updated only if the cache differs.
  75772. */
  75773. update(): void;
  75774. /**
  75775. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  75776. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75777. * @param data Define the flattened data
  75778. * @param size Define the size of the data.
  75779. */
  75780. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  75781. private _valueCache;
  75782. private _cacheMatrix;
  75783. private _updateMatrix3x3ForUniform;
  75784. private _updateMatrix3x3ForEffect;
  75785. private _updateMatrix2x2ForEffect;
  75786. private _updateMatrix2x2ForUniform;
  75787. private _updateFloatForEffect;
  75788. private _updateFloatForUniform;
  75789. private _updateFloat2ForEffect;
  75790. private _updateFloat2ForUniform;
  75791. private _updateFloat3ForEffect;
  75792. private _updateFloat3ForUniform;
  75793. private _updateFloat4ForEffect;
  75794. private _updateFloat4ForUniform;
  75795. private _updateMatrixForEffect;
  75796. private _updateMatrixForUniform;
  75797. private _updateVector3ForEffect;
  75798. private _updateVector3ForUniform;
  75799. private _updateVector4ForEffect;
  75800. private _updateVector4ForUniform;
  75801. private _updateColor3ForEffect;
  75802. private _updateColor3ForUniform;
  75803. private _updateColor4ForEffect;
  75804. private _updateColor4ForUniform;
  75805. /**
  75806. * Sets a sampler uniform on the effect.
  75807. * @param name Define the name of the sampler.
  75808. * @param texture Define the texture to set in the sampler
  75809. */
  75810. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  75811. /**
  75812. * Directly updates the value of the uniform in the cache AND on the GPU.
  75813. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  75814. * @param data Define the flattened data
  75815. */
  75816. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  75817. /**
  75818. * Binds this uniform buffer to an effect.
  75819. * @param effect Define the effect to bind the buffer to
  75820. * @param name Name of the uniform block in the shader.
  75821. */
  75822. bindToEffect(effect: Effect, name: string): void;
  75823. /**
  75824. * Disposes the uniform buffer.
  75825. */
  75826. dispose(): void;
  75827. }
  75828. }
  75829. declare module BABYLON {
  75830. /**
  75831. * Enum that determines the text-wrapping mode to use.
  75832. */
  75833. export enum InspectableType {
  75834. /**
  75835. * Checkbox for booleans
  75836. */
  75837. Checkbox = 0,
  75838. /**
  75839. * Sliders for numbers
  75840. */
  75841. Slider = 1,
  75842. /**
  75843. * Vector3
  75844. */
  75845. Vector3 = 2,
  75846. /**
  75847. * Quaternions
  75848. */
  75849. Quaternion = 3,
  75850. /**
  75851. * Color3
  75852. */
  75853. Color3 = 4,
  75854. /**
  75855. * String
  75856. */
  75857. String = 5
  75858. }
  75859. /**
  75860. * Interface used to define custom inspectable properties.
  75861. * This interface is used by the inspector to display custom property grids
  75862. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75863. */
  75864. export interface IInspectable {
  75865. /**
  75866. * Gets the label to display
  75867. */
  75868. label: string;
  75869. /**
  75870. * Gets the name of the property to edit
  75871. */
  75872. propertyName: string;
  75873. /**
  75874. * Gets the type of the editor to use
  75875. */
  75876. type: InspectableType;
  75877. /**
  75878. * Gets the minimum value of the property when using in "slider" mode
  75879. */
  75880. min?: number;
  75881. /**
  75882. * Gets the maximum value of the property when using in "slider" mode
  75883. */
  75884. max?: number;
  75885. /**
  75886. * Gets the setp to use when using in "slider" mode
  75887. */
  75888. step?: number;
  75889. }
  75890. }
  75891. declare module BABYLON {
  75892. /**
  75893. * Class used to provide helper for timing
  75894. */
  75895. export class TimingTools {
  75896. /**
  75897. * Polyfill for setImmediate
  75898. * @param action defines the action to execute after the current execution block
  75899. */
  75900. static SetImmediate(action: () => void): void;
  75901. }
  75902. }
  75903. declare module BABYLON {
  75904. /**
  75905. * Class used to enable instatition of objects by class name
  75906. */
  75907. export class InstantiationTools {
  75908. /**
  75909. * Use this object to register external classes like custom textures or material
  75910. * to allow the laoders to instantiate them
  75911. */
  75912. static RegisteredExternalClasses: {
  75913. [key: string]: Object;
  75914. };
  75915. /**
  75916. * Tries to instantiate a new object from a given class name
  75917. * @param className defines the class name to instantiate
  75918. * @returns the new object or null if the system was not able to do the instantiation
  75919. */
  75920. static Instantiate(className: string): any;
  75921. }
  75922. }
  75923. declare module BABYLON {
  75924. /**
  75925. * Define options used to create a depth texture
  75926. */
  75927. export class DepthTextureCreationOptions {
  75928. /** Specifies whether or not a stencil should be allocated in the texture */
  75929. generateStencil?: boolean;
  75930. /** Specifies whether or not bilinear filtering is enable on the texture */
  75931. bilinearFiltering?: boolean;
  75932. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  75933. comparisonFunction?: number;
  75934. /** Specifies if the created texture is a cube texture */
  75935. isCube?: boolean;
  75936. }
  75937. }
  75938. declare module BABYLON {
  75939. interface ThinEngine {
  75940. /**
  75941. * Creates a depth stencil cube texture.
  75942. * This is only available in WebGL 2.
  75943. * @param size The size of face edge in the cube texture.
  75944. * @param options The options defining the cube texture.
  75945. * @returns The cube texture
  75946. */
  75947. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  75948. /**
  75949. * Creates a cube texture
  75950. * @param rootUrl defines the url where the files to load is located
  75951. * @param scene defines the current scene
  75952. * @param files defines the list of files to load (1 per face)
  75953. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75954. * @param onLoad defines an optional callback raised when the texture is loaded
  75955. * @param onError defines an optional callback raised if there is an issue to load the texture
  75956. * @param format defines the format of the data
  75957. * @param forcedExtension defines the extension to use to pick the right loader
  75958. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75959. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75960. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75961. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  75962. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  75963. * @returns the cube texture as an InternalTexture
  75964. */
  75965. 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;
  75966. /**
  75967. * Creates a cube texture
  75968. * @param rootUrl defines the url where the files to load is located
  75969. * @param scene defines the current scene
  75970. * @param files defines the list of files to load (1 per face)
  75971. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75972. * @param onLoad defines an optional callback raised when the texture is loaded
  75973. * @param onError defines an optional callback raised if there is an issue to load the texture
  75974. * @param format defines the format of the data
  75975. * @param forcedExtension defines the extension to use to pick the right loader
  75976. * @returns the cube texture as an InternalTexture
  75977. */
  75978. 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;
  75979. /**
  75980. * Creates a cube texture
  75981. * @param rootUrl defines the url where the files to load is located
  75982. * @param scene defines the current scene
  75983. * @param files defines the list of files to load (1 per face)
  75984. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  75985. * @param onLoad defines an optional callback raised when the texture is loaded
  75986. * @param onError defines an optional callback raised if there is an issue to load the texture
  75987. * @param format defines the format of the data
  75988. * @param forcedExtension defines the extension to use to pick the right loader
  75989. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  75990. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  75991. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  75992. * @returns the cube texture as an InternalTexture
  75993. */
  75994. 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;
  75995. /** @hidden */
  75996. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  75997. /** @hidden */
  75998. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  75999. /** @hidden */
  76000. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76001. /** @hidden */
  76002. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  76003. /**
  76004. * @hidden
  76005. */
  76006. _setCubeMapTextureParams(loadMipmap: boolean): void;
  76007. }
  76008. }
  76009. declare module BABYLON {
  76010. /**
  76011. * Class for creating a cube texture
  76012. */
  76013. export class CubeTexture extends BaseTexture {
  76014. private _delayedOnLoad;
  76015. /**
  76016. * The url of the texture
  76017. */
  76018. url: string;
  76019. /**
  76020. * Gets or sets the center of the bounding box associated with the cube texture.
  76021. * It must define where the camera used to render the texture was set
  76022. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76023. */
  76024. boundingBoxPosition: Vector3;
  76025. private _boundingBoxSize;
  76026. /**
  76027. * Gets or sets the size of the bounding box associated with the cube texture
  76028. * When defined, the cubemap will switch to local mode
  76029. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  76030. * @example https://www.babylonjs-playground.com/#RNASML
  76031. */
  76032. /**
  76033. * Returns the bounding box size
  76034. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  76035. */
  76036. boundingBoxSize: Vector3;
  76037. protected _rotationY: number;
  76038. /**
  76039. * Sets texture matrix rotation angle around Y axis in radians.
  76040. */
  76041. /**
  76042. * Gets texture matrix rotation angle around Y axis radians.
  76043. */
  76044. rotationY: number;
  76045. /**
  76046. * Are mip maps generated for this texture or not.
  76047. */
  76048. readonly noMipmap: boolean;
  76049. private _noMipmap;
  76050. private _files;
  76051. protected _forcedExtension: Nullable<string>;
  76052. private _extensions;
  76053. private _textureMatrix;
  76054. private _format;
  76055. private _createPolynomials;
  76056. /** @hidden */
  76057. _prefiltered: boolean;
  76058. /**
  76059. * Creates a cube texture from an array of image urls
  76060. * @param files defines an array of image urls
  76061. * @param scene defines the hosting scene
  76062. * @param noMipmap specifies if mip maps are not used
  76063. * @returns a cube texture
  76064. */
  76065. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  76066. /**
  76067. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  76068. * @param url defines the url of the prefiltered texture
  76069. * @param scene defines the scene the texture is attached to
  76070. * @param forcedExtension defines the extension of the file if different from the url
  76071. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76072. * @return the prefiltered texture
  76073. */
  76074. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  76075. /**
  76076. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  76077. * as prefiltered data.
  76078. * @param rootUrl defines the url of the texture or the root name of the six images
  76079. * @param scene defines the scene the texture is attached to
  76080. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  76081. * @param noMipmap defines if mipmaps should be created or not
  76082. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  76083. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  76084. * @param onError defines a callback triggered in case of error during load
  76085. * @param format defines the internal format to use for the texture once loaded
  76086. * @param prefiltered defines whether or not the texture is created from prefiltered data
  76087. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  76088. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  76089. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  76090. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  76091. * @return the cube texture
  76092. */
  76093. 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);
  76094. /**
  76095. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  76096. */
  76097. readonly isPrefiltered: boolean;
  76098. /**
  76099. * Get the current class name of the texture useful for serialization or dynamic coding.
  76100. * @returns "CubeTexture"
  76101. */
  76102. getClassName(): string;
  76103. /**
  76104. * Update the url (and optional buffer) of this texture if url was null during construction.
  76105. * @param url the url of the texture
  76106. * @param forcedExtension defines the extension to use
  76107. * @param onLoad callback called when the texture is loaded (defaults to null)
  76108. */
  76109. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  76110. /**
  76111. * Delays loading of the cube texture
  76112. * @param forcedExtension defines the extension to use
  76113. */
  76114. delayLoad(forcedExtension?: string): void;
  76115. /**
  76116. * Returns the reflection texture matrix
  76117. * @returns the reflection texture matrix
  76118. */
  76119. getReflectionTextureMatrix(): Matrix;
  76120. /**
  76121. * Sets the reflection texture matrix
  76122. * @param value Reflection texture matrix
  76123. */
  76124. setReflectionTextureMatrix(value: Matrix): void;
  76125. /**
  76126. * Parses text to create a cube texture
  76127. * @param parsedTexture define the serialized text to read from
  76128. * @param scene defines the hosting scene
  76129. * @param rootUrl defines the root url of the cube texture
  76130. * @returns a cube texture
  76131. */
  76132. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  76133. /**
  76134. * Makes a clone, or deep copy, of the cube texture
  76135. * @returns a new cube texture
  76136. */
  76137. clone(): CubeTexture;
  76138. }
  76139. }
  76140. declare module BABYLON {
  76141. /**
  76142. * Manages the defines for the Material
  76143. */
  76144. export class MaterialDefines {
  76145. /** @hidden */
  76146. protected _keys: string[];
  76147. private _isDirty;
  76148. /** @hidden */
  76149. _renderId: number;
  76150. /** @hidden */
  76151. _areLightsDirty: boolean;
  76152. /** @hidden */
  76153. _areLightsDisposed: boolean;
  76154. /** @hidden */
  76155. _areAttributesDirty: boolean;
  76156. /** @hidden */
  76157. _areTexturesDirty: boolean;
  76158. /** @hidden */
  76159. _areFresnelDirty: boolean;
  76160. /** @hidden */
  76161. _areMiscDirty: boolean;
  76162. /** @hidden */
  76163. _areImageProcessingDirty: boolean;
  76164. /** @hidden */
  76165. _normals: boolean;
  76166. /** @hidden */
  76167. _uvs: boolean;
  76168. /** @hidden */
  76169. _needNormals: boolean;
  76170. /** @hidden */
  76171. _needUVs: boolean;
  76172. [id: string]: any;
  76173. /**
  76174. * Specifies if the material needs to be re-calculated
  76175. */
  76176. readonly isDirty: boolean;
  76177. /**
  76178. * Marks the material to indicate that it has been re-calculated
  76179. */
  76180. markAsProcessed(): void;
  76181. /**
  76182. * Marks the material to indicate that it needs to be re-calculated
  76183. */
  76184. markAsUnprocessed(): void;
  76185. /**
  76186. * Marks the material to indicate all of its defines need to be re-calculated
  76187. */
  76188. markAllAsDirty(): void;
  76189. /**
  76190. * Marks the material to indicate that image processing needs to be re-calculated
  76191. */
  76192. markAsImageProcessingDirty(): void;
  76193. /**
  76194. * Marks the material to indicate the lights need to be re-calculated
  76195. * @param disposed Defines whether the light is dirty due to dispose or not
  76196. */
  76197. markAsLightDirty(disposed?: boolean): void;
  76198. /**
  76199. * Marks the attribute state as changed
  76200. */
  76201. markAsAttributesDirty(): void;
  76202. /**
  76203. * Marks the texture state as changed
  76204. */
  76205. markAsTexturesDirty(): void;
  76206. /**
  76207. * Marks the fresnel state as changed
  76208. */
  76209. markAsFresnelDirty(): void;
  76210. /**
  76211. * Marks the misc state as changed
  76212. */
  76213. markAsMiscDirty(): void;
  76214. /**
  76215. * Rebuilds the material defines
  76216. */
  76217. rebuild(): void;
  76218. /**
  76219. * Specifies if two material defines are equal
  76220. * @param other - A material define instance to compare to
  76221. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  76222. */
  76223. isEqual(other: MaterialDefines): boolean;
  76224. /**
  76225. * Clones this instance's defines to another instance
  76226. * @param other - material defines to clone values to
  76227. */
  76228. cloneTo(other: MaterialDefines): void;
  76229. /**
  76230. * Resets the material define values
  76231. */
  76232. reset(): void;
  76233. /**
  76234. * Converts the material define values to a string
  76235. * @returns - String of material define information
  76236. */
  76237. toString(): string;
  76238. }
  76239. }
  76240. declare module BABYLON {
  76241. /**
  76242. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  76243. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  76244. * 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;
  76245. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  76246. */
  76247. export class ColorCurves {
  76248. private _dirty;
  76249. private _tempColor;
  76250. private _globalCurve;
  76251. private _highlightsCurve;
  76252. private _midtonesCurve;
  76253. private _shadowsCurve;
  76254. private _positiveCurve;
  76255. private _negativeCurve;
  76256. private _globalHue;
  76257. private _globalDensity;
  76258. private _globalSaturation;
  76259. private _globalExposure;
  76260. /**
  76261. * Gets the global Hue value.
  76262. * 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).
  76263. */
  76264. /**
  76265. * Sets the global Hue value.
  76266. * 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).
  76267. */
  76268. globalHue: number;
  76269. /**
  76270. * Gets the global Density value.
  76271. * 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.
  76272. * Values less than zero provide a filter of opposite hue.
  76273. */
  76274. /**
  76275. * Sets the global Density value.
  76276. * 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.
  76277. * Values less than zero provide a filter of opposite hue.
  76278. */
  76279. globalDensity: number;
  76280. /**
  76281. * Gets the global Saturation value.
  76282. * 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.
  76283. */
  76284. /**
  76285. * Sets the global Saturation value.
  76286. * 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.
  76287. */
  76288. globalSaturation: number;
  76289. /**
  76290. * Gets the global Exposure value.
  76291. * 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.
  76292. */
  76293. /**
  76294. * Sets the global Exposure value.
  76295. * 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.
  76296. */
  76297. globalExposure: number;
  76298. private _highlightsHue;
  76299. private _highlightsDensity;
  76300. private _highlightsSaturation;
  76301. private _highlightsExposure;
  76302. /**
  76303. * Gets the highlights Hue value.
  76304. * 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).
  76305. */
  76306. /**
  76307. * Sets the highlights Hue value.
  76308. * 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).
  76309. */
  76310. highlightsHue: number;
  76311. /**
  76312. * Gets the highlights Density value.
  76313. * 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.
  76314. * Values less than zero provide a filter of opposite hue.
  76315. */
  76316. /**
  76317. * Sets the highlights Density value.
  76318. * 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.
  76319. * Values less than zero provide a filter of opposite hue.
  76320. */
  76321. highlightsDensity: number;
  76322. /**
  76323. * Gets the highlights Saturation value.
  76324. * 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.
  76325. */
  76326. /**
  76327. * Sets the highlights Saturation value.
  76328. * 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.
  76329. */
  76330. highlightsSaturation: number;
  76331. /**
  76332. * Gets the highlights Exposure value.
  76333. * 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.
  76334. */
  76335. /**
  76336. * Sets the highlights Exposure value.
  76337. * 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.
  76338. */
  76339. highlightsExposure: number;
  76340. private _midtonesHue;
  76341. private _midtonesDensity;
  76342. private _midtonesSaturation;
  76343. private _midtonesExposure;
  76344. /**
  76345. * Gets the midtones Hue value.
  76346. * 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).
  76347. */
  76348. /**
  76349. * Sets the midtones Hue value.
  76350. * 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).
  76351. */
  76352. midtonesHue: number;
  76353. /**
  76354. * Gets the midtones Density value.
  76355. * 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.
  76356. * Values less than zero provide a filter of opposite hue.
  76357. */
  76358. /**
  76359. * Sets the midtones Density value.
  76360. * 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.
  76361. * Values less than zero provide a filter of opposite hue.
  76362. */
  76363. midtonesDensity: number;
  76364. /**
  76365. * Gets the midtones Saturation value.
  76366. * 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.
  76367. */
  76368. /**
  76369. * Sets the midtones Saturation value.
  76370. * 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.
  76371. */
  76372. midtonesSaturation: number;
  76373. /**
  76374. * Gets the midtones Exposure value.
  76375. * 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.
  76376. */
  76377. /**
  76378. * Sets the midtones Exposure value.
  76379. * 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.
  76380. */
  76381. midtonesExposure: number;
  76382. private _shadowsHue;
  76383. private _shadowsDensity;
  76384. private _shadowsSaturation;
  76385. private _shadowsExposure;
  76386. /**
  76387. * Gets the shadows Hue value.
  76388. * 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).
  76389. */
  76390. /**
  76391. * Sets the shadows Hue value.
  76392. * 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).
  76393. */
  76394. shadowsHue: number;
  76395. /**
  76396. * Gets the shadows Density value.
  76397. * 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.
  76398. * Values less than zero provide a filter of opposite hue.
  76399. */
  76400. /**
  76401. * Sets the shadows Density value.
  76402. * 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.
  76403. * Values less than zero provide a filter of opposite hue.
  76404. */
  76405. shadowsDensity: number;
  76406. /**
  76407. * Gets the shadows Saturation value.
  76408. * 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.
  76409. */
  76410. /**
  76411. * Sets the shadows Saturation value.
  76412. * 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.
  76413. */
  76414. shadowsSaturation: number;
  76415. /**
  76416. * Gets the shadows Exposure value.
  76417. * 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.
  76418. */
  76419. /**
  76420. * Sets the shadows Exposure value.
  76421. * 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.
  76422. */
  76423. shadowsExposure: number;
  76424. /**
  76425. * Returns the class name
  76426. * @returns The class name
  76427. */
  76428. getClassName(): string;
  76429. /**
  76430. * Binds the color curves to the shader.
  76431. * @param colorCurves The color curve to bind
  76432. * @param effect The effect to bind to
  76433. * @param positiveUniform The positive uniform shader parameter
  76434. * @param neutralUniform The neutral uniform shader parameter
  76435. * @param negativeUniform The negative uniform shader parameter
  76436. */
  76437. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  76438. /**
  76439. * Prepare the list of uniforms associated with the ColorCurves effects.
  76440. * @param uniformsList The list of uniforms used in the effect
  76441. */
  76442. static PrepareUniforms(uniformsList: string[]): void;
  76443. /**
  76444. * Returns color grading data based on a hue, density, saturation and exposure value.
  76445. * @param filterHue The hue of the color filter.
  76446. * @param filterDensity The density of the color filter.
  76447. * @param saturation The saturation.
  76448. * @param exposure The exposure.
  76449. * @param result The result data container.
  76450. */
  76451. private getColorGradingDataToRef;
  76452. /**
  76453. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  76454. * @param value The input slider value in range [-100,100].
  76455. * @returns Adjusted value.
  76456. */
  76457. private static applyColorGradingSliderNonlinear;
  76458. /**
  76459. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  76460. * @param hue The hue (H) input.
  76461. * @param saturation The saturation (S) input.
  76462. * @param brightness The brightness (B) input.
  76463. * @result An RGBA color represented as Vector4.
  76464. */
  76465. private static fromHSBToRef;
  76466. /**
  76467. * Returns a value clamped between min and max
  76468. * @param value The value to clamp
  76469. * @param min The minimum of value
  76470. * @param max The maximum of value
  76471. * @returns The clamped value.
  76472. */
  76473. private static clamp;
  76474. /**
  76475. * Clones the current color curve instance.
  76476. * @return The cloned curves
  76477. */
  76478. clone(): ColorCurves;
  76479. /**
  76480. * Serializes the current color curve instance to a json representation.
  76481. * @return a JSON representation
  76482. */
  76483. serialize(): any;
  76484. /**
  76485. * Parses the color curve from a json representation.
  76486. * @param source the JSON source to parse
  76487. * @return The parsed curves
  76488. */
  76489. static Parse(source: any): ColorCurves;
  76490. }
  76491. }
  76492. declare module BABYLON {
  76493. /**
  76494. * Interface to follow in your material defines to integrate easily the
  76495. * Image proccessing functions.
  76496. * @hidden
  76497. */
  76498. export interface IImageProcessingConfigurationDefines {
  76499. IMAGEPROCESSING: boolean;
  76500. VIGNETTE: boolean;
  76501. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76502. VIGNETTEBLENDMODEOPAQUE: boolean;
  76503. TONEMAPPING: boolean;
  76504. TONEMAPPING_ACES: boolean;
  76505. CONTRAST: boolean;
  76506. EXPOSURE: boolean;
  76507. COLORCURVES: boolean;
  76508. COLORGRADING: boolean;
  76509. COLORGRADING3D: boolean;
  76510. SAMPLER3DGREENDEPTH: boolean;
  76511. SAMPLER3DBGRMAP: boolean;
  76512. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76513. }
  76514. /**
  76515. * @hidden
  76516. */
  76517. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  76518. IMAGEPROCESSING: boolean;
  76519. VIGNETTE: boolean;
  76520. VIGNETTEBLENDMODEMULTIPLY: boolean;
  76521. VIGNETTEBLENDMODEOPAQUE: boolean;
  76522. TONEMAPPING: boolean;
  76523. TONEMAPPING_ACES: boolean;
  76524. CONTRAST: boolean;
  76525. COLORCURVES: boolean;
  76526. COLORGRADING: boolean;
  76527. COLORGRADING3D: boolean;
  76528. SAMPLER3DGREENDEPTH: boolean;
  76529. SAMPLER3DBGRMAP: boolean;
  76530. IMAGEPROCESSINGPOSTPROCESS: boolean;
  76531. EXPOSURE: boolean;
  76532. constructor();
  76533. }
  76534. /**
  76535. * This groups together the common properties used for image processing either in direct forward pass
  76536. * or through post processing effect depending on the use of the image processing pipeline in your scene
  76537. * or not.
  76538. */
  76539. export class ImageProcessingConfiguration {
  76540. /**
  76541. * Default tone mapping applied in BabylonJS.
  76542. */
  76543. static readonly TONEMAPPING_STANDARD: number;
  76544. /**
  76545. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  76546. * to other engines rendering to increase portability.
  76547. */
  76548. static readonly TONEMAPPING_ACES: number;
  76549. /**
  76550. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  76551. */
  76552. colorCurves: Nullable<ColorCurves>;
  76553. private _colorCurvesEnabled;
  76554. /**
  76555. * Gets wether the color curves effect is enabled.
  76556. */
  76557. /**
  76558. * Sets wether the color curves effect is enabled.
  76559. */
  76560. colorCurvesEnabled: boolean;
  76561. private _colorGradingTexture;
  76562. /**
  76563. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76564. */
  76565. /**
  76566. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  76567. */
  76568. colorGradingTexture: Nullable<BaseTexture>;
  76569. private _colorGradingEnabled;
  76570. /**
  76571. * Gets wether the color grading effect is enabled.
  76572. */
  76573. /**
  76574. * Sets wether the color grading effect is enabled.
  76575. */
  76576. colorGradingEnabled: boolean;
  76577. private _colorGradingWithGreenDepth;
  76578. /**
  76579. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  76580. */
  76581. /**
  76582. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  76583. */
  76584. colorGradingWithGreenDepth: boolean;
  76585. private _colorGradingBGR;
  76586. /**
  76587. * Gets wether the color grading texture contains BGR values.
  76588. */
  76589. /**
  76590. * Sets wether the color grading texture contains BGR values.
  76591. */
  76592. colorGradingBGR: boolean;
  76593. /** @hidden */
  76594. _exposure: number;
  76595. /**
  76596. * Gets the Exposure used in the effect.
  76597. */
  76598. /**
  76599. * Sets the Exposure used in the effect.
  76600. */
  76601. exposure: number;
  76602. private _toneMappingEnabled;
  76603. /**
  76604. * Gets wether the tone mapping effect is enabled.
  76605. */
  76606. /**
  76607. * Sets wether the tone mapping effect is enabled.
  76608. */
  76609. toneMappingEnabled: boolean;
  76610. private _toneMappingType;
  76611. /**
  76612. * Gets the type of tone mapping effect.
  76613. */
  76614. /**
  76615. * Sets the type of tone mapping effect used in BabylonJS.
  76616. */
  76617. toneMappingType: number;
  76618. protected _contrast: number;
  76619. /**
  76620. * Gets the contrast used in the effect.
  76621. */
  76622. /**
  76623. * Sets the contrast used in the effect.
  76624. */
  76625. contrast: number;
  76626. /**
  76627. * Vignette stretch size.
  76628. */
  76629. vignetteStretch: number;
  76630. /**
  76631. * Vignette centre X Offset.
  76632. */
  76633. vignetteCentreX: number;
  76634. /**
  76635. * Vignette centre Y Offset.
  76636. */
  76637. vignetteCentreY: number;
  76638. /**
  76639. * Vignette weight or intensity of the vignette effect.
  76640. */
  76641. vignetteWeight: number;
  76642. /**
  76643. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  76644. * if vignetteEnabled is set to true.
  76645. */
  76646. vignetteColor: Color4;
  76647. /**
  76648. * Camera field of view used by the Vignette effect.
  76649. */
  76650. vignetteCameraFov: number;
  76651. private _vignetteBlendMode;
  76652. /**
  76653. * Gets the vignette blend mode allowing different kind of effect.
  76654. */
  76655. /**
  76656. * Sets the vignette blend mode allowing different kind of effect.
  76657. */
  76658. vignetteBlendMode: number;
  76659. private _vignetteEnabled;
  76660. /**
  76661. * Gets wether the vignette effect is enabled.
  76662. */
  76663. /**
  76664. * Sets wether the vignette effect is enabled.
  76665. */
  76666. vignetteEnabled: boolean;
  76667. private _applyByPostProcess;
  76668. /**
  76669. * Gets wether the image processing is applied through a post process or not.
  76670. */
  76671. /**
  76672. * Sets wether the image processing is applied through a post process or not.
  76673. */
  76674. applyByPostProcess: boolean;
  76675. private _isEnabled;
  76676. /**
  76677. * Gets wether the image processing is enabled or not.
  76678. */
  76679. /**
  76680. * Sets wether the image processing is enabled or not.
  76681. */
  76682. isEnabled: boolean;
  76683. /**
  76684. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  76685. */
  76686. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  76687. /**
  76688. * Method called each time the image processing information changes requires to recompile the effect.
  76689. */
  76690. protected _updateParameters(): void;
  76691. /**
  76692. * Gets the current class name.
  76693. * @return "ImageProcessingConfiguration"
  76694. */
  76695. getClassName(): string;
  76696. /**
  76697. * Prepare the list of uniforms associated with the Image Processing effects.
  76698. * @param uniforms The list of uniforms used in the effect
  76699. * @param defines the list of defines currently in use
  76700. */
  76701. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  76702. /**
  76703. * Prepare the list of samplers associated with the Image Processing effects.
  76704. * @param samplersList The list of uniforms used in the effect
  76705. * @param defines the list of defines currently in use
  76706. */
  76707. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  76708. /**
  76709. * Prepare the list of defines associated to the shader.
  76710. * @param defines the list of defines to complete
  76711. * @param forPostProcess Define if we are currently in post process mode or not
  76712. */
  76713. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  76714. /**
  76715. * Returns true if all the image processing information are ready.
  76716. * @returns True if ready, otherwise, false
  76717. */
  76718. isReady(): boolean;
  76719. /**
  76720. * Binds the image processing to the shader.
  76721. * @param effect The effect to bind to
  76722. * @param overrideAspectRatio Override the aspect ratio of the effect
  76723. */
  76724. bind(effect: Effect, overrideAspectRatio?: number): void;
  76725. /**
  76726. * Clones the current image processing instance.
  76727. * @return The cloned image processing
  76728. */
  76729. clone(): ImageProcessingConfiguration;
  76730. /**
  76731. * Serializes the current image processing instance to a json representation.
  76732. * @return a JSON representation
  76733. */
  76734. serialize(): any;
  76735. /**
  76736. * Parses the image processing from a json representation.
  76737. * @param source the JSON source to parse
  76738. * @return The parsed image processing
  76739. */
  76740. static Parse(source: any): ImageProcessingConfiguration;
  76741. private static _VIGNETTEMODE_MULTIPLY;
  76742. private static _VIGNETTEMODE_OPAQUE;
  76743. /**
  76744. * Used to apply the vignette as a mix with the pixel color.
  76745. */
  76746. static readonly VIGNETTEMODE_MULTIPLY: number;
  76747. /**
  76748. * Used to apply the vignette as a replacement of the pixel color.
  76749. */
  76750. static readonly VIGNETTEMODE_OPAQUE: number;
  76751. }
  76752. }
  76753. declare module BABYLON {
  76754. /** @hidden */
  76755. export var postprocessVertexShader: {
  76756. name: string;
  76757. shader: string;
  76758. };
  76759. }
  76760. declare module BABYLON {
  76761. interface ThinEngine {
  76762. /**
  76763. * Creates a new render target texture
  76764. * @param size defines the size of the texture
  76765. * @param options defines the options used to create the texture
  76766. * @returns a new render target texture stored in an InternalTexture
  76767. */
  76768. createRenderTargetTexture(size: number | {
  76769. width: number;
  76770. height: number;
  76771. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  76772. /**
  76773. * Creates a depth stencil texture.
  76774. * This is only available in WebGL 2 or with the depth texture extension available.
  76775. * @param size The size of face edge in the texture.
  76776. * @param options The options defining the texture.
  76777. * @returns The texture
  76778. */
  76779. createDepthStencilTexture(size: number | {
  76780. width: number;
  76781. height: number;
  76782. }, options: DepthTextureCreationOptions): InternalTexture;
  76783. /** @hidden */
  76784. _createDepthStencilTexture(size: number | {
  76785. width: number;
  76786. height: number;
  76787. }, options: DepthTextureCreationOptions): InternalTexture;
  76788. }
  76789. }
  76790. declare module BABYLON {
  76791. /** Defines supported spaces */
  76792. export enum Space {
  76793. /** Local (object) space */
  76794. LOCAL = 0,
  76795. /** World space */
  76796. WORLD = 1,
  76797. /** Bone space */
  76798. BONE = 2
  76799. }
  76800. /** Defines the 3 main axes */
  76801. export class Axis {
  76802. /** X axis */
  76803. static X: Vector3;
  76804. /** Y axis */
  76805. static Y: Vector3;
  76806. /** Z axis */
  76807. static Z: Vector3;
  76808. }
  76809. }
  76810. declare module BABYLON {
  76811. /**
  76812. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  76813. * This is the base of the follow, arc rotate cameras and Free camera
  76814. * @see http://doc.babylonjs.com/features/cameras
  76815. */
  76816. export class TargetCamera extends Camera {
  76817. private static _RigCamTransformMatrix;
  76818. private static _TargetTransformMatrix;
  76819. private static _TargetFocalPoint;
  76820. /**
  76821. * Define the current direction the camera is moving to
  76822. */
  76823. cameraDirection: Vector3;
  76824. /**
  76825. * Define the current rotation the camera is rotating to
  76826. */
  76827. cameraRotation: Vector2;
  76828. /**
  76829. * When set, the up vector of the camera will be updated by the rotation of the camera
  76830. */
  76831. updateUpVectorFromRotation: boolean;
  76832. private _tmpQuaternion;
  76833. /**
  76834. * Define the current rotation of the camera
  76835. */
  76836. rotation: Vector3;
  76837. /**
  76838. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  76839. */
  76840. rotationQuaternion: Quaternion;
  76841. /**
  76842. * Define the current speed of the camera
  76843. */
  76844. speed: number;
  76845. /**
  76846. * Add constraint to the camera to prevent it to move freely in all directions and
  76847. * around all axis.
  76848. */
  76849. noRotationConstraint: boolean;
  76850. /**
  76851. * Define the current target of the camera as an object or a position.
  76852. */
  76853. lockedTarget: any;
  76854. /** @hidden */
  76855. _currentTarget: Vector3;
  76856. /** @hidden */
  76857. _initialFocalDistance: number;
  76858. /** @hidden */
  76859. _viewMatrix: Matrix;
  76860. /** @hidden */
  76861. _camMatrix: Matrix;
  76862. /** @hidden */
  76863. _cameraTransformMatrix: Matrix;
  76864. /** @hidden */
  76865. _cameraRotationMatrix: Matrix;
  76866. /** @hidden */
  76867. _referencePoint: Vector3;
  76868. /** @hidden */
  76869. _transformedReferencePoint: Vector3;
  76870. protected _globalCurrentTarget: Vector3;
  76871. protected _globalCurrentUpVector: Vector3;
  76872. /** @hidden */
  76873. _reset: () => void;
  76874. private _defaultUp;
  76875. /**
  76876. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  76877. * This is the base of the follow, arc rotate cameras and Free camera
  76878. * @see http://doc.babylonjs.com/features/cameras
  76879. * @param name Defines the name of the camera in the scene
  76880. * @param position Defines the start position of the camera in the scene
  76881. * @param scene Defines the scene the camera belongs to
  76882. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  76883. */
  76884. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  76885. /**
  76886. * Gets the position in front of the camera at a given distance.
  76887. * @param distance The distance from the camera we want the position to be
  76888. * @returns the position
  76889. */
  76890. getFrontPosition(distance: number): Vector3;
  76891. /** @hidden */
  76892. _getLockedTargetPosition(): Nullable<Vector3>;
  76893. private _storedPosition;
  76894. private _storedRotation;
  76895. private _storedRotationQuaternion;
  76896. /**
  76897. * Store current camera state of the camera (fov, position, rotation, etc..)
  76898. * @returns the camera
  76899. */
  76900. storeState(): Camera;
  76901. /**
  76902. * Restored camera state. You must call storeState() first
  76903. * @returns whether it was successful or not
  76904. * @hidden
  76905. */
  76906. _restoreStateValues(): boolean;
  76907. /** @hidden */
  76908. _initCache(): void;
  76909. /** @hidden */
  76910. _updateCache(ignoreParentClass?: boolean): void;
  76911. /** @hidden */
  76912. _isSynchronizedViewMatrix(): boolean;
  76913. /** @hidden */
  76914. _computeLocalCameraSpeed(): number;
  76915. /**
  76916. * Defines the target the camera should look at.
  76917. * @param target Defines the new target as a Vector or a mesh
  76918. */
  76919. setTarget(target: Vector3): void;
  76920. /**
  76921. * Return the current target position of the camera. This value is expressed in local space.
  76922. * @returns the target position
  76923. */
  76924. getTarget(): Vector3;
  76925. /** @hidden */
  76926. _decideIfNeedsToMove(): boolean;
  76927. /** @hidden */
  76928. _updatePosition(): void;
  76929. /** @hidden */
  76930. _checkInputs(): void;
  76931. protected _updateCameraRotationMatrix(): void;
  76932. /**
  76933. * 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)
  76934. * @returns the current camera
  76935. */
  76936. private _rotateUpVectorWithCameraRotationMatrix;
  76937. private _cachedRotationZ;
  76938. private _cachedQuaternionRotationZ;
  76939. /** @hidden */
  76940. _getViewMatrix(): Matrix;
  76941. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  76942. /**
  76943. * @hidden
  76944. */
  76945. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  76946. /**
  76947. * @hidden
  76948. */
  76949. _updateRigCameras(): void;
  76950. private _getRigCamPositionAndTarget;
  76951. /**
  76952. * Gets the current object class name.
  76953. * @return the class name
  76954. */
  76955. getClassName(): string;
  76956. }
  76957. }
  76958. declare module BABYLON {
  76959. /**
  76960. * Gather the list of keyboard event types as constants.
  76961. */
  76962. export class KeyboardEventTypes {
  76963. /**
  76964. * The keydown event is fired when a key becomes active (pressed).
  76965. */
  76966. static readonly KEYDOWN: number;
  76967. /**
  76968. * The keyup event is fired when a key has been released.
  76969. */
  76970. static readonly KEYUP: number;
  76971. }
  76972. /**
  76973. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76974. */
  76975. export class KeyboardInfo {
  76976. /**
  76977. * Defines the type of event (KeyboardEventTypes)
  76978. */
  76979. type: number;
  76980. /**
  76981. * Defines the related dom event
  76982. */
  76983. event: KeyboardEvent;
  76984. /**
  76985. * Instantiates a new keyboard info.
  76986. * This class is used to store keyboard related info for the onKeyboardObservable event.
  76987. * @param type Defines the type of event (KeyboardEventTypes)
  76988. * @param event Defines the related dom event
  76989. */
  76990. constructor(
  76991. /**
  76992. * Defines the type of event (KeyboardEventTypes)
  76993. */
  76994. type: number,
  76995. /**
  76996. * Defines the related dom event
  76997. */
  76998. event: KeyboardEvent);
  76999. }
  77000. /**
  77001. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77002. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  77003. */
  77004. export class KeyboardInfoPre extends KeyboardInfo {
  77005. /**
  77006. * Defines the type of event (KeyboardEventTypes)
  77007. */
  77008. type: number;
  77009. /**
  77010. * Defines the related dom event
  77011. */
  77012. event: KeyboardEvent;
  77013. /**
  77014. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  77015. */
  77016. skipOnPointerObservable: boolean;
  77017. /**
  77018. * Instantiates a new keyboard pre info.
  77019. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  77020. * @param type Defines the type of event (KeyboardEventTypes)
  77021. * @param event Defines the related dom event
  77022. */
  77023. constructor(
  77024. /**
  77025. * Defines the type of event (KeyboardEventTypes)
  77026. */
  77027. type: number,
  77028. /**
  77029. * Defines the related dom event
  77030. */
  77031. event: KeyboardEvent);
  77032. }
  77033. }
  77034. declare module BABYLON {
  77035. /**
  77036. * Manage the keyboard inputs to control the movement of a free camera.
  77037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77038. */
  77039. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  77040. /**
  77041. * Defines the camera the input is attached to.
  77042. */
  77043. camera: FreeCamera;
  77044. /**
  77045. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77046. */
  77047. keysUp: number[];
  77048. /**
  77049. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77050. */
  77051. keysDown: number[];
  77052. /**
  77053. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77054. */
  77055. keysLeft: number[];
  77056. /**
  77057. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77058. */
  77059. keysRight: number[];
  77060. private _keys;
  77061. private _onCanvasBlurObserver;
  77062. private _onKeyboardObserver;
  77063. private _engine;
  77064. private _scene;
  77065. /**
  77066. * Attach the input controls to a specific dom element to get the input from.
  77067. * @param element Defines the element the controls should be listened from
  77068. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77069. */
  77070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77071. /**
  77072. * Detach the current controls from the specified dom element.
  77073. * @param element Defines the element to stop listening the inputs from
  77074. */
  77075. detachControl(element: Nullable<HTMLElement>): void;
  77076. /**
  77077. * Update the current camera state depending on the inputs that have been used this frame.
  77078. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77079. */
  77080. checkInputs(): void;
  77081. /**
  77082. * Gets the class name of the current intput.
  77083. * @returns the class name
  77084. */
  77085. getClassName(): string;
  77086. /** @hidden */
  77087. _onLostFocus(): void;
  77088. /**
  77089. * Get the friendly name associated with the input class.
  77090. * @returns the input friendly name
  77091. */
  77092. getSimpleName(): string;
  77093. }
  77094. }
  77095. declare module BABYLON {
  77096. /**
  77097. * Interface describing all the common properties and methods a shadow light needs to implement.
  77098. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  77099. * as well as binding the different shadow properties to the effects.
  77100. */
  77101. export interface IShadowLight extends Light {
  77102. /**
  77103. * The light id in the scene (used in scene.findLighById for instance)
  77104. */
  77105. id: string;
  77106. /**
  77107. * The position the shdow will be casted from.
  77108. */
  77109. position: Vector3;
  77110. /**
  77111. * In 2d mode (needCube being false), the direction used to cast the shadow.
  77112. */
  77113. direction: Vector3;
  77114. /**
  77115. * The transformed position. Position of the light in world space taking parenting in account.
  77116. */
  77117. transformedPosition: Vector3;
  77118. /**
  77119. * The transformed direction. Direction of the light in world space taking parenting in account.
  77120. */
  77121. transformedDirection: Vector3;
  77122. /**
  77123. * The friendly name of the light in the scene.
  77124. */
  77125. name: string;
  77126. /**
  77127. * Defines the shadow projection clipping minimum z value.
  77128. */
  77129. shadowMinZ: number;
  77130. /**
  77131. * Defines the shadow projection clipping maximum z value.
  77132. */
  77133. shadowMaxZ: number;
  77134. /**
  77135. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77136. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77137. */
  77138. computeTransformedInformation(): boolean;
  77139. /**
  77140. * Gets the scene the light belongs to.
  77141. * @returns The scene
  77142. */
  77143. getScene(): Scene;
  77144. /**
  77145. * Callback defining a custom Projection Matrix Builder.
  77146. * This can be used to override the default projection matrix computation.
  77147. */
  77148. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77149. /**
  77150. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77151. * @param matrix The materix to updated with the projection information
  77152. * @param viewMatrix The transform matrix of the light
  77153. * @param renderList The list of mesh to render in the map
  77154. * @returns The current light
  77155. */
  77156. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77157. /**
  77158. * Gets the current depth scale used in ESM.
  77159. * @returns The scale
  77160. */
  77161. getDepthScale(): number;
  77162. /**
  77163. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77164. * @returns true if a cube texture needs to be use
  77165. */
  77166. needCube(): boolean;
  77167. /**
  77168. * Detects if the projection matrix requires to be recomputed this frame.
  77169. * @returns true if it requires to be recomputed otherwise, false.
  77170. */
  77171. needProjectionMatrixCompute(): boolean;
  77172. /**
  77173. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77174. */
  77175. forceProjectionMatrixCompute(): void;
  77176. /**
  77177. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77178. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77179. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77180. */
  77181. getShadowDirection(faceIndex?: number): Vector3;
  77182. /**
  77183. * Gets the minZ used for shadow according to both the scene and the light.
  77184. * @param activeCamera The camera we are returning the min for
  77185. * @returns the depth min z
  77186. */
  77187. getDepthMinZ(activeCamera: Camera): number;
  77188. /**
  77189. * Gets the maxZ used for shadow according to both the scene and the light.
  77190. * @param activeCamera The camera we are returning the max for
  77191. * @returns the depth max z
  77192. */
  77193. getDepthMaxZ(activeCamera: Camera): number;
  77194. }
  77195. /**
  77196. * Base implementation IShadowLight
  77197. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  77198. */
  77199. export abstract class ShadowLight extends Light implements IShadowLight {
  77200. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  77201. protected _position: Vector3;
  77202. protected _setPosition(value: Vector3): void;
  77203. /**
  77204. * Sets the position the shadow will be casted from. Also use as the light position for both
  77205. * point and spot lights.
  77206. */
  77207. /**
  77208. * Sets the position the shadow will be casted from. Also use as the light position for both
  77209. * point and spot lights.
  77210. */
  77211. position: Vector3;
  77212. protected _direction: Vector3;
  77213. protected _setDirection(value: Vector3): void;
  77214. /**
  77215. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  77216. * Also use as the light direction on spot and directional lights.
  77217. */
  77218. /**
  77219. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  77220. * Also use as the light direction on spot and directional lights.
  77221. */
  77222. direction: Vector3;
  77223. private _shadowMinZ;
  77224. /**
  77225. * Gets the shadow projection clipping minimum z value.
  77226. */
  77227. /**
  77228. * Sets the shadow projection clipping minimum z value.
  77229. */
  77230. shadowMinZ: number;
  77231. private _shadowMaxZ;
  77232. /**
  77233. * Sets the shadow projection clipping maximum z value.
  77234. */
  77235. /**
  77236. * Gets the shadow projection clipping maximum z value.
  77237. */
  77238. shadowMaxZ: number;
  77239. /**
  77240. * Callback defining a custom Projection Matrix Builder.
  77241. * This can be used to override the default projection matrix computation.
  77242. */
  77243. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  77244. /**
  77245. * The transformed position. Position of the light in world space taking parenting in account.
  77246. */
  77247. transformedPosition: Vector3;
  77248. /**
  77249. * The transformed direction. Direction of the light in world space taking parenting in account.
  77250. */
  77251. transformedDirection: Vector3;
  77252. private _needProjectionMatrixCompute;
  77253. /**
  77254. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  77255. * @returns true if the information has been computed, false if it does not need to (no parenting)
  77256. */
  77257. computeTransformedInformation(): boolean;
  77258. /**
  77259. * Return the depth scale used for the shadow map.
  77260. * @returns the depth scale.
  77261. */
  77262. getDepthScale(): number;
  77263. /**
  77264. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  77265. * @param faceIndex The index of the face we are computed the direction to generate shadow
  77266. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  77267. */
  77268. getShadowDirection(faceIndex?: number): Vector3;
  77269. /**
  77270. * Returns the ShadowLight absolute position in the World.
  77271. * @returns the position vector in world space
  77272. */
  77273. getAbsolutePosition(): Vector3;
  77274. /**
  77275. * Sets the ShadowLight direction toward the passed target.
  77276. * @param target The point to target in local space
  77277. * @returns the updated ShadowLight direction
  77278. */
  77279. setDirectionToTarget(target: Vector3): Vector3;
  77280. /**
  77281. * Returns the light rotation in euler definition.
  77282. * @returns the x y z rotation in local space.
  77283. */
  77284. getRotation(): Vector3;
  77285. /**
  77286. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  77287. * @returns true if a cube texture needs to be use
  77288. */
  77289. needCube(): boolean;
  77290. /**
  77291. * Detects if the projection matrix requires to be recomputed this frame.
  77292. * @returns true if it requires to be recomputed otherwise, false.
  77293. */
  77294. needProjectionMatrixCompute(): boolean;
  77295. /**
  77296. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  77297. */
  77298. forceProjectionMatrixCompute(): void;
  77299. /** @hidden */
  77300. _initCache(): void;
  77301. /** @hidden */
  77302. _isSynchronized(): boolean;
  77303. /**
  77304. * Computes the world matrix of the node
  77305. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77306. * @returns the world matrix
  77307. */
  77308. computeWorldMatrix(force?: boolean): Matrix;
  77309. /**
  77310. * Gets the minZ used for shadow according to both the scene and the light.
  77311. * @param activeCamera The camera we are returning the min for
  77312. * @returns the depth min z
  77313. */
  77314. getDepthMinZ(activeCamera: Camera): number;
  77315. /**
  77316. * Gets the maxZ used for shadow according to both the scene and the light.
  77317. * @param activeCamera The camera we are returning the max for
  77318. * @returns the depth max z
  77319. */
  77320. getDepthMaxZ(activeCamera: Camera): number;
  77321. /**
  77322. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  77323. * @param matrix The materix to updated with the projection information
  77324. * @param viewMatrix The transform matrix of the light
  77325. * @param renderList The list of mesh to render in the map
  77326. * @returns The current light
  77327. */
  77328. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  77329. }
  77330. }
  77331. declare module BABYLON {
  77332. /**
  77333. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  77334. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  77335. */
  77336. export class EffectFallbacks implements IEffectFallbacks {
  77337. private _defines;
  77338. private _currentRank;
  77339. private _maxRank;
  77340. private _mesh;
  77341. /**
  77342. * Removes the fallback from the bound mesh.
  77343. */
  77344. unBindMesh(): void;
  77345. /**
  77346. * Adds a fallback on the specified property.
  77347. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77348. * @param define The name of the define in the shader
  77349. */
  77350. addFallback(rank: number, define: string): void;
  77351. /**
  77352. * Sets the mesh to use CPU skinning when needing to fallback.
  77353. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  77354. * @param mesh The mesh to use the fallbacks.
  77355. */
  77356. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  77357. /**
  77358. * Checks to see if more fallbacks are still availible.
  77359. */
  77360. readonly hasMoreFallbacks: boolean;
  77361. /**
  77362. * Removes the defines that should be removed when falling back.
  77363. * @param currentDefines defines the current define statements for the shader.
  77364. * @param effect defines the current effect we try to compile
  77365. * @returns The resulting defines with defines of the current rank removed.
  77366. */
  77367. reduce(currentDefines: string, effect: Effect): string;
  77368. }
  77369. }
  77370. declare module BABYLON {
  77371. /**
  77372. * "Static Class" containing the most commonly used helper while dealing with material for
  77373. * rendering purpose.
  77374. *
  77375. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  77376. *
  77377. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  77378. */
  77379. export class MaterialHelper {
  77380. /**
  77381. * Bind the current view position to an effect.
  77382. * @param effect The effect to be bound
  77383. * @param scene The scene the eyes position is used from
  77384. */
  77385. static BindEyePosition(effect: Effect, scene: Scene): void;
  77386. /**
  77387. * Helps preparing the defines values about the UVs in used in the effect.
  77388. * UVs are shared as much as we can accross channels in the shaders.
  77389. * @param texture The texture we are preparing the UVs for
  77390. * @param defines The defines to update
  77391. * @param key The channel key "diffuse", "specular"... used in the shader
  77392. */
  77393. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  77394. /**
  77395. * Binds a texture matrix value to its corrsponding uniform
  77396. * @param texture The texture to bind the matrix for
  77397. * @param uniformBuffer The uniform buffer receivin the data
  77398. * @param key The channel key "diffuse", "specular"... used in the shader
  77399. */
  77400. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  77401. /**
  77402. * Gets the current status of the fog (should it be enabled?)
  77403. * @param mesh defines the mesh to evaluate for fog support
  77404. * @param scene defines the hosting scene
  77405. * @returns true if fog must be enabled
  77406. */
  77407. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  77408. /**
  77409. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  77410. * @param mesh defines the current mesh
  77411. * @param scene defines the current scene
  77412. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  77413. * @param pointsCloud defines if point cloud rendering has to be turned on
  77414. * @param fogEnabled defines if fog has to be turned on
  77415. * @param alphaTest defines if alpha testing has to be turned on
  77416. * @param defines defines the current list of defines
  77417. */
  77418. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  77419. /**
  77420. * Helper used to prepare the list of defines associated with frame values for shader compilation
  77421. * @param scene defines the current scene
  77422. * @param engine defines the current engine
  77423. * @param defines specifies the list of active defines
  77424. * @param useInstances defines if instances have to be turned on
  77425. * @param useClipPlane defines if clip plane have to be turned on
  77426. */
  77427. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  77428. /**
  77429. * Prepares the defines for bones
  77430. * @param mesh The mesh containing the geometry data we will draw
  77431. * @param defines The defines to update
  77432. */
  77433. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  77434. /**
  77435. * Prepares the defines for morph targets
  77436. * @param mesh The mesh containing the geometry data we will draw
  77437. * @param defines The defines to update
  77438. */
  77439. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  77440. /**
  77441. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  77442. * @param mesh The mesh containing the geometry data we will draw
  77443. * @param defines The defines to update
  77444. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  77445. * @param useBones Precise whether bones should be used or not (override mesh info)
  77446. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  77447. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  77448. * @returns false if defines are considered not dirty and have not been checked
  77449. */
  77450. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  77451. /**
  77452. * Prepares the defines related to multiview
  77453. * @param scene The scene we are intending to draw
  77454. * @param defines The defines to update
  77455. */
  77456. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  77457. /**
  77458. * Prepares the defines related to the light information passed in parameter
  77459. * @param scene The scene we are intending to draw
  77460. * @param mesh The mesh the effect is compiling for
  77461. * @param light The light the effect is compiling for
  77462. * @param lightIndex The index of the light
  77463. * @param defines The defines to update
  77464. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77465. * @param state Defines the current state regarding what is needed (normals, etc...)
  77466. */
  77467. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  77468. needNormals: boolean;
  77469. needRebuild: boolean;
  77470. shadowEnabled: boolean;
  77471. specularEnabled: boolean;
  77472. lightmapMode: boolean;
  77473. }): void;
  77474. /**
  77475. * Prepares the defines related to the light information passed in parameter
  77476. * @param scene The scene we are intending to draw
  77477. * @param mesh The mesh the effect is compiling for
  77478. * @param defines The defines to update
  77479. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  77480. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  77481. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  77482. * @returns true if normals will be required for the rest of the effect
  77483. */
  77484. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  77485. /**
  77486. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  77487. * @param lightIndex defines the light index
  77488. * @param uniformsList The uniform list
  77489. * @param samplersList The sampler list
  77490. * @param projectedLightTexture defines if projected texture must be used
  77491. * @param uniformBuffersList defines an optional list of uniform buffers
  77492. */
  77493. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  77494. /**
  77495. * Prepares the uniforms and samplers list to be used in the effect
  77496. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  77497. * @param samplersList The sampler list
  77498. * @param defines The defines helping in the list generation
  77499. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  77500. */
  77501. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  77502. /**
  77503. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  77504. * @param defines The defines to update while falling back
  77505. * @param fallbacks The authorized effect fallbacks
  77506. * @param maxSimultaneousLights The maximum number of lights allowed
  77507. * @param rank the current rank of the Effect
  77508. * @returns The newly affected rank
  77509. */
  77510. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  77511. private static _TmpMorphInfluencers;
  77512. /**
  77513. * Prepares the list of attributes required for morph targets according to the effect defines.
  77514. * @param attribs The current list of supported attribs
  77515. * @param mesh The mesh to prepare the morph targets attributes for
  77516. * @param influencers The number of influencers
  77517. */
  77518. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  77519. /**
  77520. * Prepares the list of attributes required for morph targets according to the effect defines.
  77521. * @param attribs The current list of supported attribs
  77522. * @param mesh The mesh to prepare the morph targets attributes for
  77523. * @param defines The current Defines of the effect
  77524. */
  77525. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  77526. /**
  77527. * Prepares the list of attributes required for bones according to the effect defines.
  77528. * @param attribs The current list of supported attribs
  77529. * @param mesh The mesh to prepare the bones attributes for
  77530. * @param defines The current Defines of the effect
  77531. * @param fallbacks The current efffect fallback strategy
  77532. */
  77533. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  77534. /**
  77535. * Check and prepare the list of attributes required for instances according to the effect defines.
  77536. * @param attribs The current list of supported attribs
  77537. * @param defines The current MaterialDefines of the effect
  77538. */
  77539. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  77540. /**
  77541. * Add the list of attributes required for instances to the attribs array.
  77542. * @param attribs The current list of supported attribs
  77543. */
  77544. static PushAttributesForInstances(attribs: string[]): void;
  77545. /**
  77546. * Binds the light information to the effect.
  77547. * @param light The light containing the generator
  77548. * @param effect The effect we are binding the data to
  77549. * @param lightIndex The light index in the effect used to render
  77550. */
  77551. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  77552. /**
  77553. * Binds the lights information from the scene to the effect for the given mesh.
  77554. * @param light Light to bind
  77555. * @param lightIndex Light index
  77556. * @param scene The scene where the light belongs to
  77557. * @param effect The effect we are binding the data to
  77558. * @param useSpecular Defines if specular is supported
  77559. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77560. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77561. */
  77562. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77563. /**
  77564. * Binds the lights information from the scene to the effect for the given mesh.
  77565. * @param scene The scene the lights belongs to
  77566. * @param mesh The mesh we are binding the information to render
  77567. * @param effect The effect we are binding the data to
  77568. * @param defines The generated defines for the effect
  77569. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  77570. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  77571. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  77572. */
  77573. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  77574. private static _tempFogColor;
  77575. /**
  77576. * Binds the fog information from the scene to the effect for the given mesh.
  77577. * @param scene The scene the lights belongs to
  77578. * @param mesh The mesh we are binding the information to render
  77579. * @param effect The effect we are binding the data to
  77580. * @param linearSpace Defines if the fog effect is applied in linear space
  77581. */
  77582. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  77583. /**
  77584. * Binds the bones information from the mesh to the effect.
  77585. * @param mesh The mesh we are binding the information to render
  77586. * @param effect The effect we are binding the data to
  77587. */
  77588. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  77589. /**
  77590. * Binds the morph targets information from the mesh to the effect.
  77591. * @param abstractMesh The mesh we are binding the information to render
  77592. * @param effect The effect we are binding the data to
  77593. */
  77594. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  77595. /**
  77596. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  77597. * @param defines The generated defines used in the effect
  77598. * @param effect The effect we are binding the data to
  77599. * @param scene The scene we are willing to render with logarithmic scale for
  77600. */
  77601. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  77602. /**
  77603. * Binds the clip plane information from the scene to the effect.
  77604. * @param scene The scene the clip plane information are extracted from
  77605. * @param effect The effect we are binding the data to
  77606. */
  77607. static BindClipPlane(effect: Effect, scene: Scene): void;
  77608. }
  77609. }
  77610. declare module BABYLON {
  77611. /** @hidden */
  77612. export var packingFunctions: {
  77613. name: string;
  77614. shader: string;
  77615. };
  77616. }
  77617. declare module BABYLON {
  77618. /** @hidden */
  77619. export var shadowMapPixelShader: {
  77620. name: string;
  77621. shader: string;
  77622. };
  77623. }
  77624. declare module BABYLON {
  77625. /** @hidden */
  77626. export var bonesDeclaration: {
  77627. name: string;
  77628. shader: string;
  77629. };
  77630. }
  77631. declare module BABYLON {
  77632. /** @hidden */
  77633. export var morphTargetsVertexGlobalDeclaration: {
  77634. name: string;
  77635. shader: string;
  77636. };
  77637. }
  77638. declare module BABYLON {
  77639. /** @hidden */
  77640. export var morphTargetsVertexDeclaration: {
  77641. name: string;
  77642. shader: string;
  77643. };
  77644. }
  77645. declare module BABYLON {
  77646. /** @hidden */
  77647. export var instancesDeclaration: {
  77648. name: string;
  77649. shader: string;
  77650. };
  77651. }
  77652. declare module BABYLON {
  77653. /** @hidden */
  77654. export var helperFunctions: {
  77655. name: string;
  77656. shader: string;
  77657. };
  77658. }
  77659. declare module BABYLON {
  77660. /** @hidden */
  77661. export var morphTargetsVertex: {
  77662. name: string;
  77663. shader: string;
  77664. };
  77665. }
  77666. declare module BABYLON {
  77667. /** @hidden */
  77668. export var instancesVertex: {
  77669. name: string;
  77670. shader: string;
  77671. };
  77672. }
  77673. declare module BABYLON {
  77674. /** @hidden */
  77675. export var bonesVertex: {
  77676. name: string;
  77677. shader: string;
  77678. };
  77679. }
  77680. declare module BABYLON {
  77681. /** @hidden */
  77682. export var shadowMapVertexShader: {
  77683. name: string;
  77684. shader: string;
  77685. };
  77686. }
  77687. declare module BABYLON {
  77688. /** @hidden */
  77689. export var depthBoxBlurPixelShader: {
  77690. name: string;
  77691. shader: string;
  77692. };
  77693. }
  77694. declare module BABYLON {
  77695. /**
  77696. * Defines the options associated with the creation of a custom shader for a shadow generator.
  77697. */
  77698. export interface ICustomShaderOptions {
  77699. /**
  77700. * Gets or sets the custom shader name to use
  77701. */
  77702. shaderName: string;
  77703. /**
  77704. * The list of attribute names used in the shader
  77705. */
  77706. attributes?: string[];
  77707. /**
  77708. * The list of unifrom names used in the shader
  77709. */
  77710. uniforms?: string[];
  77711. /**
  77712. * The list of sampler names used in the shader
  77713. */
  77714. samplers?: string[];
  77715. /**
  77716. * The list of defines used in the shader
  77717. */
  77718. defines?: string[];
  77719. }
  77720. /**
  77721. * Interface to implement to create a shadow generator compatible with BJS.
  77722. */
  77723. export interface IShadowGenerator {
  77724. /**
  77725. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  77726. * @returns The render target texture if present otherwise, null
  77727. */
  77728. getShadowMap(): Nullable<RenderTargetTexture>;
  77729. /**
  77730. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  77731. * @returns The render target texture if the shadow map is present otherwise, null
  77732. */
  77733. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  77734. /**
  77735. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  77736. * @param subMesh The submesh we want to render in the shadow map
  77737. * @param useInstances Defines wether will draw in the map using instances
  77738. * @returns true if ready otherwise, false
  77739. */
  77740. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77741. /**
  77742. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  77743. * @param defines Defines of the material we want to update
  77744. * @param lightIndex Index of the light in the enabled light list of the material
  77745. */
  77746. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  77747. /**
  77748. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  77749. * defined in the generator but impacting the effect).
  77750. * It implies the unifroms available on the materials are the standard BJS ones.
  77751. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  77752. * @param effect The effect we are binfing the information for
  77753. */
  77754. bindShadowLight(lightIndex: string, effect: Effect): void;
  77755. /**
  77756. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  77757. * (eq to shadow prjection matrix * light transform matrix)
  77758. * @returns The transform matrix used to create the shadow map
  77759. */
  77760. getTransformMatrix(): Matrix;
  77761. /**
  77762. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  77763. * Cube and 2D textures for instance.
  77764. */
  77765. recreateShadowMap(): void;
  77766. /**
  77767. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77768. * @param onCompiled Callback triggered at the and of the effects compilation
  77769. * @param options Sets of optional options forcing the compilation with different modes
  77770. */
  77771. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  77772. useInstances: boolean;
  77773. }>): void;
  77774. /**
  77775. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  77776. * @param options Sets of optional options forcing the compilation with different modes
  77777. * @returns A promise that resolves when the compilation completes
  77778. */
  77779. forceCompilationAsync(options?: Partial<{
  77780. useInstances: boolean;
  77781. }>): Promise<void>;
  77782. /**
  77783. * Serializes the shadow generator setup to a json object.
  77784. * @returns The serialized JSON object
  77785. */
  77786. serialize(): any;
  77787. /**
  77788. * Disposes the Shadow map and related Textures and effects.
  77789. */
  77790. dispose(): void;
  77791. }
  77792. /**
  77793. * Default implementation IShadowGenerator.
  77794. * This is the main object responsible of generating shadows in the framework.
  77795. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  77796. */
  77797. export class ShadowGenerator implements IShadowGenerator {
  77798. /**
  77799. * Shadow generator mode None: no filtering applied.
  77800. */
  77801. static readonly FILTER_NONE: number;
  77802. /**
  77803. * Shadow generator mode ESM: Exponential Shadow Mapping.
  77804. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77805. */
  77806. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  77807. /**
  77808. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  77809. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  77810. */
  77811. static readonly FILTER_POISSONSAMPLING: number;
  77812. /**
  77813. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  77814. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77815. */
  77816. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  77817. /**
  77818. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  77819. * edge artifacts on steep falloff.
  77820. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77821. */
  77822. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  77823. /**
  77824. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  77825. * edge artifacts on steep falloff.
  77826. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  77827. */
  77828. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  77829. /**
  77830. * Shadow generator mode PCF: Percentage Closer Filtering
  77831. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77832. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  77833. */
  77834. static readonly FILTER_PCF: number;
  77835. /**
  77836. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  77837. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  77838. * Contact Hardening
  77839. */
  77840. static readonly FILTER_PCSS: number;
  77841. /**
  77842. * Reserved for PCF and PCSS
  77843. * Highest Quality.
  77844. *
  77845. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  77846. *
  77847. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  77848. */
  77849. static readonly QUALITY_HIGH: number;
  77850. /**
  77851. * Reserved for PCF and PCSS
  77852. * Good tradeoff for quality/perf cross devices
  77853. *
  77854. * Execute PCF on a 3*3 kernel.
  77855. *
  77856. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  77857. */
  77858. static readonly QUALITY_MEDIUM: number;
  77859. /**
  77860. * Reserved for PCF and PCSS
  77861. * The lowest quality but the fastest.
  77862. *
  77863. * Execute PCF on a 1*1 kernel.
  77864. *
  77865. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  77866. */
  77867. static readonly QUALITY_LOW: number;
  77868. /** Gets or sets the custom shader name to use */
  77869. customShaderOptions: ICustomShaderOptions;
  77870. /**
  77871. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  77872. */
  77873. onBeforeShadowMapRenderObservable: Observable<Effect>;
  77874. /**
  77875. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  77876. */
  77877. onAfterShadowMapRenderObservable: Observable<Effect>;
  77878. /**
  77879. * Observable triggered before a mesh is rendered in the shadow map.
  77880. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  77881. */
  77882. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  77883. /**
  77884. * Observable triggered after a mesh is rendered in the shadow map.
  77885. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  77886. */
  77887. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  77888. private _bias;
  77889. /**
  77890. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  77891. */
  77892. /**
  77893. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  77894. */
  77895. bias: number;
  77896. private _normalBias;
  77897. /**
  77898. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77899. */
  77900. /**
  77901. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  77902. */
  77903. normalBias: number;
  77904. private _blurBoxOffset;
  77905. /**
  77906. * Gets the blur box offset: offset applied during the blur pass.
  77907. * Only useful if useKernelBlur = false
  77908. */
  77909. /**
  77910. * Sets the blur box offset: offset applied during the blur pass.
  77911. * Only useful if useKernelBlur = false
  77912. */
  77913. blurBoxOffset: number;
  77914. private _blurScale;
  77915. /**
  77916. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  77917. * 2 means half of the size.
  77918. */
  77919. /**
  77920. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  77921. * 2 means half of the size.
  77922. */
  77923. blurScale: number;
  77924. private _blurKernel;
  77925. /**
  77926. * Gets the blur kernel: kernel size of the blur pass.
  77927. * Only useful if useKernelBlur = true
  77928. */
  77929. /**
  77930. * Sets the blur kernel: kernel size of the blur pass.
  77931. * Only useful if useKernelBlur = true
  77932. */
  77933. blurKernel: number;
  77934. private _useKernelBlur;
  77935. /**
  77936. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  77937. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77938. */
  77939. /**
  77940. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  77941. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  77942. */
  77943. useKernelBlur: boolean;
  77944. private _depthScale;
  77945. /**
  77946. * Gets the depth scale used in ESM mode.
  77947. */
  77948. /**
  77949. * Sets the depth scale used in ESM mode.
  77950. * This can override the scale stored on the light.
  77951. */
  77952. depthScale: number;
  77953. private _filter;
  77954. /**
  77955. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  77956. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77957. */
  77958. /**
  77959. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  77960. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  77961. */
  77962. filter: number;
  77963. /**
  77964. * Gets if the current filter is set to Poisson Sampling.
  77965. */
  77966. /**
  77967. * Sets the current filter to Poisson Sampling.
  77968. */
  77969. usePoissonSampling: boolean;
  77970. /**
  77971. * Gets if the current filter is set to ESM.
  77972. */
  77973. /**
  77974. * Sets the current filter is to ESM.
  77975. */
  77976. useExponentialShadowMap: boolean;
  77977. /**
  77978. * Gets if the current filter is set to filtered ESM.
  77979. */
  77980. /**
  77981. * Gets if the current filter is set to filtered ESM.
  77982. */
  77983. useBlurExponentialShadowMap: boolean;
  77984. /**
  77985. * Gets if the current filter is set to "close ESM" (using the inverse of the
  77986. * exponential to prevent steep falloff artifacts).
  77987. */
  77988. /**
  77989. * Sets the current filter to "close ESM" (using the inverse of the
  77990. * exponential to prevent steep falloff artifacts).
  77991. */
  77992. useCloseExponentialShadowMap: boolean;
  77993. /**
  77994. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  77995. * exponential to prevent steep falloff artifacts).
  77996. */
  77997. /**
  77998. * Sets the current filter to filtered "close ESM" (using the inverse of the
  77999. * exponential to prevent steep falloff artifacts).
  78000. */
  78001. useBlurCloseExponentialShadowMap: boolean;
  78002. /**
  78003. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  78004. */
  78005. /**
  78006. * Sets the current filter to "PCF" (percentage closer filtering).
  78007. */
  78008. usePercentageCloserFiltering: boolean;
  78009. private _filteringQuality;
  78010. /**
  78011. * Gets the PCF or PCSS Quality.
  78012. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78013. */
  78014. /**
  78015. * Sets the PCF or PCSS Quality.
  78016. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  78017. */
  78018. filteringQuality: number;
  78019. /**
  78020. * Gets if the current filter is set to "PCSS" (contact hardening).
  78021. */
  78022. /**
  78023. * Sets the current filter to "PCSS" (contact hardening).
  78024. */
  78025. useContactHardeningShadow: boolean;
  78026. private _contactHardeningLightSizeUVRatio;
  78027. /**
  78028. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78029. * Using a ratio helps keeping shape stability independently of the map size.
  78030. *
  78031. * It does not account for the light projection as it was having too much
  78032. * instability during the light setup or during light position changes.
  78033. *
  78034. * Only valid if useContactHardeningShadow is true.
  78035. */
  78036. /**
  78037. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  78038. * Using a ratio helps keeping shape stability independently of the map size.
  78039. *
  78040. * It does not account for the light projection as it was having too much
  78041. * instability during the light setup or during light position changes.
  78042. *
  78043. * Only valid if useContactHardeningShadow is true.
  78044. */
  78045. contactHardeningLightSizeUVRatio: number;
  78046. private _darkness;
  78047. /** Gets or sets the actual darkness of a shadow */
  78048. darkness: number;
  78049. /**
  78050. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  78051. * 0 means strongest and 1 would means no shadow.
  78052. * @returns the darkness.
  78053. */
  78054. getDarkness(): number;
  78055. /**
  78056. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  78057. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  78058. * @returns the shadow generator allowing fluent coding.
  78059. */
  78060. setDarkness(darkness: number): ShadowGenerator;
  78061. private _transparencyShadow;
  78062. /** Gets or sets the ability to have transparent shadow */
  78063. transparencyShadow: boolean;
  78064. /**
  78065. * Sets the ability to have transparent shadow (boolean).
  78066. * @param transparent True if transparent else False
  78067. * @returns the shadow generator allowing fluent coding
  78068. */
  78069. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  78070. private _shadowMap;
  78071. private _shadowMap2;
  78072. /**
  78073. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  78074. * @returns The render target texture if present otherwise, null
  78075. */
  78076. getShadowMap(): Nullable<RenderTargetTexture>;
  78077. /**
  78078. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  78079. * @returns The render target texture if the shadow map is present otherwise, null
  78080. */
  78081. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  78082. /**
  78083. * Gets the class name of that object
  78084. * @returns "ShadowGenerator"
  78085. */
  78086. getClassName(): string;
  78087. /**
  78088. * Helper function to add a mesh and its descendants to the list of shadow casters.
  78089. * @param mesh Mesh to add
  78090. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  78091. * @returns the Shadow Generator itself
  78092. */
  78093. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78094. /**
  78095. * Helper function to remove a mesh and its descendants from the list of shadow casters
  78096. * @param mesh Mesh to remove
  78097. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  78098. * @returns the Shadow Generator itself
  78099. */
  78100. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  78101. /**
  78102. * Controls the extent to which the shadows fade out at the edge of the frustum
  78103. * Used only by directionals and spots
  78104. */
  78105. frustumEdgeFalloff: number;
  78106. private _light;
  78107. /**
  78108. * Returns the associated light object.
  78109. * @returns the light generating the shadow
  78110. */
  78111. getLight(): IShadowLight;
  78112. /**
  78113. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  78114. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  78115. * It might on the other hand introduce peter panning.
  78116. */
  78117. forceBackFacesOnly: boolean;
  78118. private _scene;
  78119. private _lightDirection;
  78120. private _effect;
  78121. private _viewMatrix;
  78122. private _projectionMatrix;
  78123. private _transformMatrix;
  78124. private _cachedPosition;
  78125. private _cachedDirection;
  78126. private _cachedDefines;
  78127. private _currentRenderID;
  78128. private _boxBlurPostprocess;
  78129. private _kernelBlurXPostprocess;
  78130. private _kernelBlurYPostprocess;
  78131. private _blurPostProcesses;
  78132. private _mapSize;
  78133. private _currentFaceIndex;
  78134. private _currentFaceIndexCache;
  78135. private _textureType;
  78136. private _defaultTextureMatrix;
  78137. private _storedUniqueId;
  78138. /** @hidden */
  78139. static _SceneComponentInitialization: (scene: Scene) => void;
  78140. /**
  78141. * Creates a ShadowGenerator object.
  78142. * A ShadowGenerator is the required tool to use the shadows.
  78143. * Each light casting shadows needs to use its own ShadowGenerator.
  78144. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  78145. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  78146. * @param light The light object generating the shadows.
  78147. * @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.
  78148. */
  78149. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  78150. private _initializeGenerator;
  78151. private _initializeShadowMap;
  78152. private _initializeBlurRTTAndPostProcesses;
  78153. private _renderForShadowMap;
  78154. private _renderSubMeshForShadowMap;
  78155. private _applyFilterValues;
  78156. /**
  78157. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78158. * @param onCompiled Callback triggered at the and of the effects compilation
  78159. * @param options Sets of optional options forcing the compilation with different modes
  78160. */
  78161. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  78162. useInstances: boolean;
  78163. }>): void;
  78164. /**
  78165. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  78166. * @param options Sets of optional options forcing the compilation with different modes
  78167. * @returns A promise that resolves when the compilation completes
  78168. */
  78169. forceCompilationAsync(options?: Partial<{
  78170. useInstances: boolean;
  78171. }>): Promise<void>;
  78172. /**
  78173. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  78174. * @param subMesh The submesh we want to render in the shadow map
  78175. * @param useInstances Defines wether will draw in the map using instances
  78176. * @returns true if ready otherwise, false
  78177. */
  78178. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  78179. /**
  78180. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  78181. * @param defines Defines of the material we want to update
  78182. * @param lightIndex Index of the light in the enabled light list of the material
  78183. */
  78184. prepareDefines(defines: any, lightIndex: number): void;
  78185. /**
  78186. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  78187. * defined in the generator but impacting the effect).
  78188. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  78189. * @param effect The effect we are binfing the information for
  78190. */
  78191. bindShadowLight(lightIndex: string, effect: Effect): void;
  78192. /**
  78193. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  78194. * (eq to shadow prjection matrix * light transform matrix)
  78195. * @returns The transform matrix used to create the shadow map
  78196. */
  78197. getTransformMatrix(): Matrix;
  78198. /**
  78199. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  78200. * Cube and 2D textures for instance.
  78201. */
  78202. recreateShadowMap(): void;
  78203. private _disposeBlurPostProcesses;
  78204. private _disposeRTTandPostProcesses;
  78205. /**
  78206. * Disposes the ShadowGenerator.
  78207. * Returns nothing.
  78208. */
  78209. dispose(): void;
  78210. /**
  78211. * Serializes the shadow generator setup to a json object.
  78212. * @returns The serialized JSON object
  78213. */
  78214. serialize(): any;
  78215. /**
  78216. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  78217. * @param parsedShadowGenerator The JSON object to parse
  78218. * @param scene The scene to create the shadow map for
  78219. * @returns The parsed shadow generator
  78220. */
  78221. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  78222. }
  78223. }
  78224. declare module BABYLON {
  78225. /**
  78226. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  78227. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  78228. * 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.
  78229. */
  78230. export abstract class Light extends Node {
  78231. /**
  78232. * Falloff Default: light is falling off following the material specification:
  78233. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  78234. */
  78235. static readonly FALLOFF_DEFAULT: number;
  78236. /**
  78237. * Falloff Physical: light is falling off following the inverse squared distance law.
  78238. */
  78239. static readonly FALLOFF_PHYSICAL: number;
  78240. /**
  78241. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  78242. * to enhance interoperability with other engines.
  78243. */
  78244. static readonly FALLOFF_GLTF: number;
  78245. /**
  78246. * Falloff Standard: light is falling off like in the standard material
  78247. * to enhance interoperability with other materials.
  78248. */
  78249. static readonly FALLOFF_STANDARD: number;
  78250. /**
  78251. * If every light affecting the material is in this lightmapMode,
  78252. * material.lightmapTexture adds or multiplies
  78253. * (depends on material.useLightmapAsShadowmap)
  78254. * after every other light calculations.
  78255. */
  78256. static readonly LIGHTMAP_DEFAULT: number;
  78257. /**
  78258. * material.lightmapTexture as only diffuse lighting from this light
  78259. * adds only specular lighting from this light
  78260. * adds dynamic shadows
  78261. */
  78262. static readonly LIGHTMAP_SPECULAR: number;
  78263. /**
  78264. * material.lightmapTexture as only lighting
  78265. * no light calculation from this light
  78266. * only adds dynamic shadows from this light
  78267. */
  78268. static readonly LIGHTMAP_SHADOWSONLY: number;
  78269. /**
  78270. * Each light type uses the default quantity according to its type:
  78271. * point/spot lights use luminous intensity
  78272. * directional lights use illuminance
  78273. */
  78274. static readonly INTENSITYMODE_AUTOMATIC: number;
  78275. /**
  78276. * lumen (lm)
  78277. */
  78278. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  78279. /**
  78280. * candela (lm/sr)
  78281. */
  78282. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  78283. /**
  78284. * lux (lm/m^2)
  78285. */
  78286. static readonly INTENSITYMODE_ILLUMINANCE: number;
  78287. /**
  78288. * nit (cd/m^2)
  78289. */
  78290. static readonly INTENSITYMODE_LUMINANCE: number;
  78291. /**
  78292. * Light type const id of the point light.
  78293. */
  78294. static readonly LIGHTTYPEID_POINTLIGHT: number;
  78295. /**
  78296. * Light type const id of the directional light.
  78297. */
  78298. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  78299. /**
  78300. * Light type const id of the spot light.
  78301. */
  78302. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  78303. /**
  78304. * Light type const id of the hemispheric light.
  78305. */
  78306. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  78307. /**
  78308. * Diffuse gives the basic color to an object.
  78309. */
  78310. diffuse: Color3;
  78311. /**
  78312. * Specular produces a highlight color on an object.
  78313. * Note: This is note affecting PBR materials.
  78314. */
  78315. specular: Color3;
  78316. /**
  78317. * Defines the falloff type for this light. This lets overrriding how punctual light are
  78318. * falling off base on range or angle.
  78319. * This can be set to any values in Light.FALLOFF_x.
  78320. *
  78321. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  78322. * other types of materials.
  78323. */
  78324. falloffType: number;
  78325. /**
  78326. * Strength of the light.
  78327. * Note: By default it is define in the framework own unit.
  78328. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  78329. */
  78330. intensity: number;
  78331. private _range;
  78332. protected _inverseSquaredRange: number;
  78333. /**
  78334. * Defines how far from the source the light is impacting in scene units.
  78335. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78336. */
  78337. /**
  78338. * Defines how far from the source the light is impacting in scene units.
  78339. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  78340. */
  78341. range: number;
  78342. /**
  78343. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  78344. * of light.
  78345. */
  78346. private _photometricScale;
  78347. private _intensityMode;
  78348. /**
  78349. * Gets the photometric scale used to interpret the intensity.
  78350. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78351. */
  78352. /**
  78353. * Sets the photometric scale used to interpret the intensity.
  78354. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  78355. */
  78356. intensityMode: number;
  78357. private _radius;
  78358. /**
  78359. * Gets the light radius used by PBR Materials to simulate soft area lights.
  78360. */
  78361. /**
  78362. * sets the light radius used by PBR Materials to simulate soft area lights.
  78363. */
  78364. radius: number;
  78365. private _renderPriority;
  78366. /**
  78367. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  78368. * exceeding the number allowed of the materials.
  78369. */
  78370. renderPriority: number;
  78371. private _shadowEnabled;
  78372. /**
  78373. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78374. * the current shadow generator.
  78375. */
  78376. /**
  78377. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  78378. * the current shadow generator.
  78379. */
  78380. shadowEnabled: boolean;
  78381. private _includedOnlyMeshes;
  78382. /**
  78383. * Gets the only meshes impacted by this light.
  78384. */
  78385. /**
  78386. * Sets the only meshes impacted by this light.
  78387. */
  78388. includedOnlyMeshes: AbstractMesh[];
  78389. private _excludedMeshes;
  78390. /**
  78391. * Gets the meshes not impacted by this light.
  78392. */
  78393. /**
  78394. * Sets the meshes not impacted by this light.
  78395. */
  78396. excludedMeshes: AbstractMesh[];
  78397. private _excludeWithLayerMask;
  78398. /**
  78399. * Gets the layer id use to find what meshes are not impacted by the light.
  78400. * Inactive if 0
  78401. */
  78402. /**
  78403. * Sets the layer id use to find what meshes are not impacted by the light.
  78404. * Inactive if 0
  78405. */
  78406. excludeWithLayerMask: number;
  78407. private _includeOnlyWithLayerMask;
  78408. /**
  78409. * Gets the layer id use to find what meshes are impacted by the light.
  78410. * Inactive if 0
  78411. */
  78412. /**
  78413. * Sets the layer id use to find what meshes are impacted by the light.
  78414. * Inactive if 0
  78415. */
  78416. includeOnlyWithLayerMask: number;
  78417. private _lightmapMode;
  78418. /**
  78419. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78420. */
  78421. /**
  78422. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  78423. */
  78424. lightmapMode: number;
  78425. /**
  78426. * Shadow generator associted to the light.
  78427. * @hidden Internal use only.
  78428. */
  78429. _shadowGenerator: Nullable<IShadowGenerator>;
  78430. /**
  78431. * @hidden Internal use only.
  78432. */
  78433. _excludedMeshesIds: string[];
  78434. /**
  78435. * @hidden Internal use only.
  78436. */
  78437. _includedOnlyMeshesIds: string[];
  78438. /**
  78439. * The current light unifom buffer.
  78440. * @hidden Internal use only.
  78441. */
  78442. _uniformBuffer: UniformBuffer;
  78443. /** @hidden */
  78444. _renderId: number;
  78445. /**
  78446. * Creates a Light object in the scene.
  78447. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78448. * @param name The firendly name of the light
  78449. * @param scene The scene the light belongs too
  78450. */
  78451. constructor(name: string, scene: Scene);
  78452. protected abstract _buildUniformLayout(): void;
  78453. /**
  78454. * Sets the passed Effect "effect" with the Light information.
  78455. * @param effect The effect to update
  78456. * @param lightIndex The index of the light in the effect to update
  78457. * @returns The light
  78458. */
  78459. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  78460. /**
  78461. * Sets the passed Effect "effect" with the Light information.
  78462. * @param effect The effect to update
  78463. * @param lightDataUniformName The uniform used to store light data (position or direction)
  78464. * @returns The light
  78465. */
  78466. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  78467. /**
  78468. * Returns the string "Light".
  78469. * @returns the class name
  78470. */
  78471. getClassName(): string;
  78472. /** @hidden */
  78473. readonly _isLight: boolean;
  78474. /**
  78475. * Converts the light information to a readable string for debug purpose.
  78476. * @param fullDetails Supports for multiple levels of logging within scene loading
  78477. * @returns the human readable light info
  78478. */
  78479. toString(fullDetails?: boolean): string;
  78480. /** @hidden */
  78481. protected _syncParentEnabledState(): void;
  78482. /**
  78483. * Set the enabled state of this node.
  78484. * @param value - the new enabled state
  78485. */
  78486. setEnabled(value: boolean): void;
  78487. /**
  78488. * Returns the Light associated shadow generator if any.
  78489. * @return the associated shadow generator.
  78490. */
  78491. getShadowGenerator(): Nullable<IShadowGenerator>;
  78492. /**
  78493. * Returns a Vector3, the absolute light position in the World.
  78494. * @returns the world space position of the light
  78495. */
  78496. getAbsolutePosition(): Vector3;
  78497. /**
  78498. * Specifies if the light will affect the passed mesh.
  78499. * @param mesh The mesh to test against the light
  78500. * @return true the mesh is affected otherwise, false.
  78501. */
  78502. canAffectMesh(mesh: AbstractMesh): boolean;
  78503. /**
  78504. * Sort function to order lights for rendering.
  78505. * @param a First Light object to compare to second.
  78506. * @param b Second Light object to compare first.
  78507. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  78508. */
  78509. static CompareLightsPriority(a: Light, b: Light): number;
  78510. /**
  78511. * Releases resources associated with this node.
  78512. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  78513. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  78514. */
  78515. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78516. /**
  78517. * Returns the light type ID (integer).
  78518. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78519. */
  78520. getTypeID(): number;
  78521. /**
  78522. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  78523. * @returns the scaled intensity in intensity mode unit
  78524. */
  78525. getScaledIntensity(): number;
  78526. /**
  78527. * Returns a new Light object, named "name", from the current one.
  78528. * @param name The name of the cloned light
  78529. * @returns the new created light
  78530. */
  78531. clone(name: string): Nullable<Light>;
  78532. /**
  78533. * Serializes the current light into a Serialization object.
  78534. * @returns the serialized object.
  78535. */
  78536. serialize(): any;
  78537. /**
  78538. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  78539. * This new light is named "name" and added to the passed scene.
  78540. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  78541. * @param name The friendly name of the light
  78542. * @param scene The scene the new light will belong to
  78543. * @returns the constructor function
  78544. */
  78545. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  78546. /**
  78547. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  78548. * @param parsedLight The JSON representation of the light
  78549. * @param scene The scene to create the parsed light in
  78550. * @returns the created light after parsing
  78551. */
  78552. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  78553. private _hookArrayForExcluded;
  78554. private _hookArrayForIncludedOnly;
  78555. private _resyncMeshes;
  78556. /**
  78557. * Forces the meshes to update their light related information in their rendering used effects
  78558. * @hidden Internal Use Only
  78559. */
  78560. _markMeshesAsLightDirty(): void;
  78561. /**
  78562. * Recomputes the cached photometric scale if needed.
  78563. */
  78564. private _computePhotometricScale;
  78565. /**
  78566. * Returns the Photometric Scale according to the light type and intensity mode.
  78567. */
  78568. private _getPhotometricScale;
  78569. /**
  78570. * Reorder the light in the scene according to their defined priority.
  78571. * @hidden Internal Use Only
  78572. */
  78573. _reorderLightsInScene(): void;
  78574. /**
  78575. * Prepares the list of defines specific to the light type.
  78576. * @param defines the list of defines
  78577. * @param lightIndex defines the index of the light for the effect
  78578. */
  78579. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78580. }
  78581. }
  78582. declare module BABYLON {
  78583. /**
  78584. * Interface used to define Action
  78585. */
  78586. export interface IAction {
  78587. /**
  78588. * Trigger for the action
  78589. */
  78590. trigger: number;
  78591. /** Options of the trigger */
  78592. triggerOptions: any;
  78593. /**
  78594. * Gets the trigger parameters
  78595. * @returns the trigger parameters
  78596. */
  78597. getTriggerParameter(): any;
  78598. /**
  78599. * Internal only - executes current action event
  78600. * @hidden
  78601. */
  78602. _executeCurrent(evt?: ActionEvent): void;
  78603. /**
  78604. * Serialize placeholder for child classes
  78605. * @param parent of child
  78606. * @returns the serialized object
  78607. */
  78608. serialize(parent: any): any;
  78609. /**
  78610. * Internal only
  78611. * @hidden
  78612. */
  78613. _prepare(): void;
  78614. /**
  78615. * Internal only - manager for action
  78616. * @hidden
  78617. */
  78618. _actionManager: AbstractActionManager;
  78619. /**
  78620. * Adds action to chain of actions, may be a DoNothingAction
  78621. * @param action defines the next action to execute
  78622. * @returns The action passed in
  78623. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78624. */
  78625. then(action: IAction): IAction;
  78626. }
  78627. /**
  78628. * The action to be carried out following a trigger
  78629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  78630. */
  78631. export class Action implements IAction {
  78632. /** the trigger, with or without parameters, for the action */
  78633. triggerOptions: any;
  78634. /**
  78635. * Trigger for the action
  78636. */
  78637. trigger: number;
  78638. /**
  78639. * Internal only - manager for action
  78640. * @hidden
  78641. */
  78642. _actionManager: ActionManager;
  78643. private _nextActiveAction;
  78644. private _child;
  78645. private _condition?;
  78646. private _triggerParameter;
  78647. /**
  78648. * An event triggered prior to action being executed.
  78649. */
  78650. onBeforeExecuteObservable: Observable<Action>;
  78651. /**
  78652. * Creates a new Action
  78653. * @param triggerOptions the trigger, with or without parameters, for the action
  78654. * @param condition an optional determinant of action
  78655. */
  78656. constructor(
  78657. /** the trigger, with or without parameters, for the action */
  78658. triggerOptions: any, condition?: Condition);
  78659. /**
  78660. * Internal only
  78661. * @hidden
  78662. */
  78663. _prepare(): void;
  78664. /**
  78665. * Gets the trigger parameters
  78666. * @returns the trigger parameters
  78667. */
  78668. getTriggerParameter(): any;
  78669. /**
  78670. * Internal only - executes current action event
  78671. * @hidden
  78672. */
  78673. _executeCurrent(evt?: ActionEvent): void;
  78674. /**
  78675. * Execute placeholder for child classes
  78676. * @param evt optional action event
  78677. */
  78678. execute(evt?: ActionEvent): void;
  78679. /**
  78680. * Skips to next active action
  78681. */
  78682. skipToNextActiveAction(): void;
  78683. /**
  78684. * Adds action to chain of actions, may be a DoNothingAction
  78685. * @param action defines the next action to execute
  78686. * @returns The action passed in
  78687. * @see https://www.babylonjs-playground.com/#1T30HR#0
  78688. */
  78689. then(action: Action): Action;
  78690. /**
  78691. * Internal only
  78692. * @hidden
  78693. */
  78694. _getProperty(propertyPath: string): string;
  78695. /**
  78696. * Internal only
  78697. * @hidden
  78698. */
  78699. _getEffectiveTarget(target: any, propertyPath: string): any;
  78700. /**
  78701. * Serialize placeholder for child classes
  78702. * @param parent of child
  78703. * @returns the serialized object
  78704. */
  78705. serialize(parent: any): any;
  78706. /**
  78707. * Internal only called by serialize
  78708. * @hidden
  78709. */
  78710. protected _serialize(serializedAction: any, parent?: any): any;
  78711. /**
  78712. * Internal only
  78713. * @hidden
  78714. */
  78715. static _SerializeValueAsString: (value: any) => string;
  78716. /**
  78717. * Internal only
  78718. * @hidden
  78719. */
  78720. static _GetTargetProperty: (target: Node | Scene) => {
  78721. name: string;
  78722. targetType: string;
  78723. value: string;
  78724. };
  78725. }
  78726. }
  78727. declare module BABYLON {
  78728. /**
  78729. * A Condition applied to an Action
  78730. */
  78731. export class Condition {
  78732. /**
  78733. * Internal only - manager for action
  78734. * @hidden
  78735. */
  78736. _actionManager: ActionManager;
  78737. /**
  78738. * Internal only
  78739. * @hidden
  78740. */
  78741. _evaluationId: number;
  78742. /**
  78743. * Internal only
  78744. * @hidden
  78745. */
  78746. _currentResult: boolean;
  78747. /**
  78748. * Creates a new Condition
  78749. * @param actionManager the manager of the action the condition is applied to
  78750. */
  78751. constructor(actionManager: ActionManager);
  78752. /**
  78753. * Check if the current condition is valid
  78754. * @returns a boolean
  78755. */
  78756. isValid(): boolean;
  78757. /**
  78758. * Internal only
  78759. * @hidden
  78760. */
  78761. _getProperty(propertyPath: string): string;
  78762. /**
  78763. * Internal only
  78764. * @hidden
  78765. */
  78766. _getEffectiveTarget(target: any, propertyPath: string): any;
  78767. /**
  78768. * Serialize placeholder for child classes
  78769. * @returns the serialized object
  78770. */
  78771. serialize(): any;
  78772. /**
  78773. * Internal only
  78774. * @hidden
  78775. */
  78776. protected _serialize(serializedCondition: any): any;
  78777. }
  78778. /**
  78779. * Defines specific conditional operators as extensions of Condition
  78780. */
  78781. export class ValueCondition extends Condition {
  78782. /** path to specify the property of the target the conditional operator uses */
  78783. propertyPath: string;
  78784. /** the value compared by the conditional operator against the current value of the property */
  78785. value: any;
  78786. /** the conditional operator, default ValueCondition.IsEqual */
  78787. operator: number;
  78788. /**
  78789. * Internal only
  78790. * @hidden
  78791. */
  78792. private static _IsEqual;
  78793. /**
  78794. * Internal only
  78795. * @hidden
  78796. */
  78797. private static _IsDifferent;
  78798. /**
  78799. * Internal only
  78800. * @hidden
  78801. */
  78802. private static _IsGreater;
  78803. /**
  78804. * Internal only
  78805. * @hidden
  78806. */
  78807. private static _IsLesser;
  78808. /**
  78809. * returns the number for IsEqual
  78810. */
  78811. static readonly IsEqual: number;
  78812. /**
  78813. * Returns the number for IsDifferent
  78814. */
  78815. static readonly IsDifferent: number;
  78816. /**
  78817. * Returns the number for IsGreater
  78818. */
  78819. static readonly IsGreater: number;
  78820. /**
  78821. * Returns the number for IsLesser
  78822. */
  78823. static readonly IsLesser: number;
  78824. /**
  78825. * Internal only The action manager for the condition
  78826. * @hidden
  78827. */
  78828. _actionManager: ActionManager;
  78829. /**
  78830. * Internal only
  78831. * @hidden
  78832. */
  78833. private _target;
  78834. /**
  78835. * Internal only
  78836. * @hidden
  78837. */
  78838. private _effectiveTarget;
  78839. /**
  78840. * Internal only
  78841. * @hidden
  78842. */
  78843. private _property;
  78844. /**
  78845. * Creates a new ValueCondition
  78846. * @param actionManager manager for the action the condition applies to
  78847. * @param target for the action
  78848. * @param propertyPath path to specify the property of the target the conditional operator uses
  78849. * @param value the value compared by the conditional operator against the current value of the property
  78850. * @param operator the conditional operator, default ValueCondition.IsEqual
  78851. */
  78852. constructor(actionManager: ActionManager, target: any,
  78853. /** path to specify the property of the target the conditional operator uses */
  78854. propertyPath: string,
  78855. /** the value compared by the conditional operator against the current value of the property */
  78856. value: any,
  78857. /** the conditional operator, default ValueCondition.IsEqual */
  78858. operator?: number);
  78859. /**
  78860. * Compares the given value with the property value for the specified conditional operator
  78861. * @returns the result of the comparison
  78862. */
  78863. isValid(): boolean;
  78864. /**
  78865. * Serialize the ValueCondition into a JSON compatible object
  78866. * @returns serialization object
  78867. */
  78868. serialize(): any;
  78869. /**
  78870. * Gets the name of the conditional operator for the ValueCondition
  78871. * @param operator the conditional operator
  78872. * @returns the name
  78873. */
  78874. static GetOperatorName(operator: number): string;
  78875. }
  78876. /**
  78877. * Defines a predicate condition as an extension of Condition
  78878. */
  78879. export class PredicateCondition extends Condition {
  78880. /** defines the predicate function used to validate the condition */
  78881. predicate: () => boolean;
  78882. /**
  78883. * Internal only - manager for action
  78884. * @hidden
  78885. */
  78886. _actionManager: ActionManager;
  78887. /**
  78888. * Creates a new PredicateCondition
  78889. * @param actionManager manager for the action the condition applies to
  78890. * @param predicate defines the predicate function used to validate the condition
  78891. */
  78892. constructor(actionManager: ActionManager,
  78893. /** defines the predicate function used to validate the condition */
  78894. predicate: () => boolean);
  78895. /**
  78896. * @returns the validity of the predicate condition
  78897. */
  78898. isValid(): boolean;
  78899. }
  78900. /**
  78901. * Defines a state condition as an extension of Condition
  78902. */
  78903. export class StateCondition extends Condition {
  78904. /** Value to compare with target state */
  78905. value: string;
  78906. /**
  78907. * Internal only - manager for action
  78908. * @hidden
  78909. */
  78910. _actionManager: ActionManager;
  78911. /**
  78912. * Internal only
  78913. * @hidden
  78914. */
  78915. private _target;
  78916. /**
  78917. * Creates a new StateCondition
  78918. * @param actionManager manager for the action the condition applies to
  78919. * @param target of the condition
  78920. * @param value to compare with target state
  78921. */
  78922. constructor(actionManager: ActionManager, target: any,
  78923. /** Value to compare with target state */
  78924. value: string);
  78925. /**
  78926. * Gets a boolean indicating if the current condition is met
  78927. * @returns the validity of the state
  78928. */
  78929. isValid(): boolean;
  78930. /**
  78931. * Serialize the StateCondition into a JSON compatible object
  78932. * @returns serialization object
  78933. */
  78934. serialize(): any;
  78935. }
  78936. }
  78937. declare module BABYLON {
  78938. /**
  78939. * This defines an action responsible to toggle a boolean once triggered.
  78940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78941. */
  78942. export class SwitchBooleanAction extends Action {
  78943. /**
  78944. * The path to the boolean property in the target object
  78945. */
  78946. propertyPath: string;
  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 boolean
  78954. * @param propertyPath defines the path to the boolean property in the target object
  78955. * @param condition defines the trigger related conditions
  78956. */
  78957. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78958. /** @hidden */
  78959. _prepare(): void;
  78960. /**
  78961. * Execute the action toggle the boolean value.
  78962. */
  78963. execute(): void;
  78964. /**
  78965. * Serializes the actions and its related information.
  78966. * @param parent defines the object to serialize in
  78967. * @returns the serialized object
  78968. */
  78969. serialize(parent: any): any;
  78970. }
  78971. /**
  78972. * This defines an action responsible to set a the state field of the target
  78973. * to a desired value once triggered.
  78974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78975. */
  78976. export class SetStateAction extends Action {
  78977. /**
  78978. * The value to store in the state field.
  78979. */
  78980. value: string;
  78981. private _target;
  78982. /**
  78983. * Instantiate the action
  78984. * @param triggerOptions defines the trigger options
  78985. * @param target defines the object containing the state property
  78986. * @param value defines the value to store in the state field
  78987. * @param condition defines the trigger related conditions
  78988. */
  78989. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78990. /**
  78991. * Execute the action and store the value on the target state property.
  78992. */
  78993. execute(): void;
  78994. /**
  78995. * Serializes the actions and its related information.
  78996. * @param parent defines the object to serialize in
  78997. * @returns the serialized object
  78998. */
  78999. serialize(parent: any): any;
  79000. }
  79001. /**
  79002. * This defines an action responsible to set a property of the target
  79003. * to a desired value once triggered.
  79004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79005. */
  79006. export class SetValueAction extends Action {
  79007. /**
  79008. * The path of the property to set in the target.
  79009. */
  79010. propertyPath: string;
  79011. /**
  79012. * The value to set in the property
  79013. */
  79014. value: any;
  79015. private _target;
  79016. private _effectiveTarget;
  79017. private _property;
  79018. /**
  79019. * Instantiate the action
  79020. * @param triggerOptions defines the trigger options
  79021. * @param target defines the object containing the property
  79022. * @param propertyPath defines the path of the property to set in the target
  79023. * @param value defines the value to set in the property
  79024. * @param condition defines the trigger related conditions
  79025. */
  79026. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79027. /** @hidden */
  79028. _prepare(): void;
  79029. /**
  79030. * Execute the action and set the targetted property to the desired value.
  79031. */
  79032. execute(): void;
  79033. /**
  79034. * Serializes the actions and its related information.
  79035. * @param parent defines the object to serialize in
  79036. * @returns the serialized object
  79037. */
  79038. serialize(parent: any): any;
  79039. }
  79040. /**
  79041. * This defines an action responsible to increment the target value
  79042. * to a desired value once triggered.
  79043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79044. */
  79045. export class IncrementValueAction extends Action {
  79046. /**
  79047. * The path of the property to increment in the target.
  79048. */
  79049. propertyPath: string;
  79050. /**
  79051. * The value we should increment the property by.
  79052. */
  79053. value: any;
  79054. private _target;
  79055. private _effectiveTarget;
  79056. private _property;
  79057. /**
  79058. * Instantiate the action
  79059. * @param triggerOptions defines the trigger options
  79060. * @param target defines the object containing the property
  79061. * @param propertyPath defines the path of the property to increment in the target
  79062. * @param value defines the value value we should increment the property by
  79063. * @param condition defines the trigger related conditions
  79064. */
  79065. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  79066. /** @hidden */
  79067. _prepare(): void;
  79068. /**
  79069. * Execute the action and increment the target of the value amount.
  79070. */
  79071. execute(): void;
  79072. /**
  79073. * Serializes the actions and its related information.
  79074. * @param parent defines the object to serialize in
  79075. * @returns the serialized object
  79076. */
  79077. serialize(parent: any): any;
  79078. }
  79079. /**
  79080. * This defines an action responsible to start an animation once triggered.
  79081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79082. */
  79083. export class PlayAnimationAction extends Action {
  79084. /**
  79085. * Where the animation should start (animation frame)
  79086. */
  79087. from: number;
  79088. /**
  79089. * Where the animation should stop (animation frame)
  79090. */
  79091. to: number;
  79092. /**
  79093. * Define if the animation should loop or stop after the first play.
  79094. */
  79095. loop?: boolean;
  79096. private _target;
  79097. /**
  79098. * Instantiate the action
  79099. * @param triggerOptions defines the trigger options
  79100. * @param target defines the target animation or animation name
  79101. * @param from defines from where the animation should start (animation frame)
  79102. * @param end defines where the animation should stop (animation frame)
  79103. * @param loop defines if the animation should loop or stop after the first play
  79104. * @param condition defines the trigger related conditions
  79105. */
  79106. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  79107. /** @hidden */
  79108. _prepare(): void;
  79109. /**
  79110. * Execute the action and play the animation.
  79111. */
  79112. execute(): void;
  79113. /**
  79114. * Serializes the actions and its related information.
  79115. * @param parent defines the object to serialize in
  79116. * @returns the serialized object
  79117. */
  79118. serialize(parent: any): any;
  79119. }
  79120. /**
  79121. * This defines an action responsible to stop an animation once triggered.
  79122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79123. */
  79124. export class StopAnimationAction extends Action {
  79125. private _target;
  79126. /**
  79127. * Instantiate the action
  79128. * @param triggerOptions defines the trigger options
  79129. * @param target defines the target animation or animation name
  79130. * @param condition defines the trigger related conditions
  79131. */
  79132. constructor(triggerOptions: any, target: any, condition?: Condition);
  79133. /** @hidden */
  79134. _prepare(): void;
  79135. /**
  79136. * Execute the action and stop the animation.
  79137. */
  79138. execute(): void;
  79139. /**
  79140. * Serializes the actions and its related information.
  79141. * @param parent defines the object to serialize in
  79142. * @returns the serialized object
  79143. */
  79144. serialize(parent: any): any;
  79145. }
  79146. /**
  79147. * This defines an action responsible that does nothing once triggered.
  79148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79149. */
  79150. export class DoNothingAction extends Action {
  79151. /**
  79152. * Instantiate the action
  79153. * @param triggerOptions defines the trigger options
  79154. * @param condition defines the trigger related conditions
  79155. */
  79156. constructor(triggerOptions?: any, condition?: Condition);
  79157. /**
  79158. * Execute the action and do nothing.
  79159. */
  79160. execute(): void;
  79161. /**
  79162. * Serializes the actions and its related information.
  79163. * @param parent defines the object to serialize in
  79164. * @returns the serialized object
  79165. */
  79166. serialize(parent: any): any;
  79167. }
  79168. /**
  79169. * This defines an action responsible to trigger several actions once triggered.
  79170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79171. */
  79172. export class CombineAction extends Action {
  79173. /**
  79174. * The list of aggregated animations to run.
  79175. */
  79176. children: Action[];
  79177. /**
  79178. * Instantiate the action
  79179. * @param triggerOptions defines the trigger options
  79180. * @param children defines the list of aggregated animations to run
  79181. * @param condition defines the trigger related conditions
  79182. */
  79183. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  79184. /** @hidden */
  79185. _prepare(): void;
  79186. /**
  79187. * Execute the action and executes all the aggregated actions.
  79188. */
  79189. execute(evt: ActionEvent): void;
  79190. /**
  79191. * Serializes the actions and its related information.
  79192. * @param parent defines the object to serialize in
  79193. * @returns the serialized object
  79194. */
  79195. serialize(parent: any): any;
  79196. }
  79197. /**
  79198. * This defines an action responsible to run code (external event) once triggered.
  79199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79200. */
  79201. export class ExecuteCodeAction extends Action {
  79202. /**
  79203. * The callback function to run.
  79204. */
  79205. func: (evt: ActionEvent) => void;
  79206. /**
  79207. * Instantiate the action
  79208. * @param triggerOptions defines the trigger options
  79209. * @param func defines the callback function to run
  79210. * @param condition defines the trigger related conditions
  79211. */
  79212. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  79213. /**
  79214. * Execute the action and run the attached code.
  79215. */
  79216. execute(evt: ActionEvent): void;
  79217. }
  79218. /**
  79219. * This defines an action responsible to set the parent property of the target once triggered.
  79220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79221. */
  79222. export class SetParentAction extends Action {
  79223. private _parent;
  79224. private _target;
  79225. /**
  79226. * Instantiate the action
  79227. * @param triggerOptions defines the trigger options
  79228. * @param target defines the target containing the parent property
  79229. * @param parent defines from where the animation should start (animation frame)
  79230. * @param condition defines the trigger related conditions
  79231. */
  79232. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  79233. /** @hidden */
  79234. _prepare(): void;
  79235. /**
  79236. * Execute the action and set the parent property.
  79237. */
  79238. execute(): void;
  79239. /**
  79240. * Serializes the actions and its related information.
  79241. * @param parent defines the object to serialize in
  79242. * @returns the serialized object
  79243. */
  79244. serialize(parent: any): any;
  79245. }
  79246. }
  79247. declare module BABYLON {
  79248. /**
  79249. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  79250. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  79251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79252. */
  79253. export class ActionManager extends AbstractActionManager {
  79254. /**
  79255. * Nothing
  79256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79257. */
  79258. static readonly NothingTrigger: number;
  79259. /**
  79260. * On pick
  79261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79262. */
  79263. static readonly OnPickTrigger: number;
  79264. /**
  79265. * On left pick
  79266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79267. */
  79268. static readonly OnLeftPickTrigger: number;
  79269. /**
  79270. * On right pick
  79271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79272. */
  79273. static readonly OnRightPickTrigger: number;
  79274. /**
  79275. * On center pick
  79276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79277. */
  79278. static readonly OnCenterPickTrigger: number;
  79279. /**
  79280. * On pick down
  79281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79282. */
  79283. static readonly OnPickDownTrigger: number;
  79284. /**
  79285. * On double pick
  79286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79287. */
  79288. static readonly OnDoublePickTrigger: number;
  79289. /**
  79290. * On pick up
  79291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79292. */
  79293. static readonly OnPickUpTrigger: number;
  79294. /**
  79295. * On pick out.
  79296. * This trigger will only be raised if you also declared a OnPickDown
  79297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79298. */
  79299. static readonly OnPickOutTrigger: number;
  79300. /**
  79301. * On long press
  79302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79303. */
  79304. static readonly OnLongPressTrigger: number;
  79305. /**
  79306. * On pointer over
  79307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79308. */
  79309. static readonly OnPointerOverTrigger: number;
  79310. /**
  79311. * On pointer out
  79312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79313. */
  79314. static readonly OnPointerOutTrigger: number;
  79315. /**
  79316. * On every frame
  79317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79318. */
  79319. static readonly OnEveryFrameTrigger: number;
  79320. /**
  79321. * On intersection enter
  79322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79323. */
  79324. static readonly OnIntersectionEnterTrigger: number;
  79325. /**
  79326. * On intersection exit
  79327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79328. */
  79329. static readonly OnIntersectionExitTrigger: number;
  79330. /**
  79331. * On key down
  79332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79333. */
  79334. static readonly OnKeyDownTrigger: number;
  79335. /**
  79336. * On key up
  79337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79338. */
  79339. static readonly OnKeyUpTrigger: number;
  79340. private _scene;
  79341. /**
  79342. * Creates a new action manager
  79343. * @param scene defines the hosting scene
  79344. */
  79345. constructor(scene: Scene);
  79346. /**
  79347. * Releases all associated resources
  79348. */
  79349. dispose(): void;
  79350. /**
  79351. * Gets hosting scene
  79352. * @returns the hosting scene
  79353. */
  79354. getScene(): Scene;
  79355. /**
  79356. * Does this action manager handles actions of any of the given triggers
  79357. * @param triggers defines the triggers to be tested
  79358. * @return a boolean indicating whether one (or more) of the triggers is handled
  79359. */
  79360. hasSpecificTriggers(triggers: number[]): boolean;
  79361. /**
  79362. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  79363. * speed.
  79364. * @param triggerA defines the trigger to be tested
  79365. * @param triggerB defines the trigger to be tested
  79366. * @return a boolean indicating whether one (or more) of the triggers is handled
  79367. */
  79368. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  79369. /**
  79370. * Does this action manager handles actions of a given trigger
  79371. * @param trigger defines the trigger to be tested
  79372. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  79373. * @return whether the trigger is handled
  79374. */
  79375. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  79376. /**
  79377. * Does this action manager has pointer triggers
  79378. */
  79379. readonly hasPointerTriggers: boolean;
  79380. /**
  79381. * Does this action manager has pick triggers
  79382. */
  79383. readonly hasPickTriggers: boolean;
  79384. /**
  79385. * Registers an action to this action manager
  79386. * @param action defines the action to be registered
  79387. * @return the action amended (prepared) after registration
  79388. */
  79389. registerAction(action: IAction): Nullable<IAction>;
  79390. /**
  79391. * Unregisters an action to this action manager
  79392. * @param action defines the action to be unregistered
  79393. * @return a boolean indicating whether the action has been unregistered
  79394. */
  79395. unregisterAction(action: IAction): Boolean;
  79396. /**
  79397. * Process a specific trigger
  79398. * @param trigger defines the trigger to process
  79399. * @param evt defines the event details to be processed
  79400. */
  79401. processTrigger(trigger: number, evt?: IActionEvent): void;
  79402. /** @hidden */
  79403. _getEffectiveTarget(target: any, propertyPath: string): any;
  79404. /** @hidden */
  79405. _getProperty(propertyPath: string): string;
  79406. /**
  79407. * Serialize this manager to a JSON object
  79408. * @param name defines the property name to store this manager
  79409. * @returns a JSON representation of this manager
  79410. */
  79411. serialize(name: string): any;
  79412. /**
  79413. * Creates a new ActionManager from a JSON data
  79414. * @param parsedActions defines the JSON data to read from
  79415. * @param object defines the hosting mesh
  79416. * @param scene defines the hosting scene
  79417. */
  79418. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  79419. /**
  79420. * Get a trigger name by index
  79421. * @param trigger defines the trigger index
  79422. * @returns a trigger name
  79423. */
  79424. static GetTriggerName(trigger: number): string;
  79425. }
  79426. }
  79427. declare module BABYLON {
  79428. /**
  79429. * Class representing a ray with position and direction
  79430. */
  79431. export class Ray {
  79432. /** origin point */
  79433. origin: Vector3;
  79434. /** direction */
  79435. direction: Vector3;
  79436. /** length of the ray */
  79437. length: number;
  79438. private static readonly TmpVector3;
  79439. private _tmpRay;
  79440. /**
  79441. * Creates a new ray
  79442. * @param origin origin point
  79443. * @param direction direction
  79444. * @param length length of the ray
  79445. */
  79446. constructor(
  79447. /** origin point */
  79448. origin: Vector3,
  79449. /** direction */
  79450. direction: Vector3,
  79451. /** length of the ray */
  79452. length?: number);
  79453. /**
  79454. * Checks if the ray intersects a box
  79455. * @param minimum bound of the box
  79456. * @param maximum bound of the box
  79457. * @param intersectionTreshold extra extend to be added to the box in all direction
  79458. * @returns if the box was hit
  79459. */
  79460. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  79461. /**
  79462. * Checks if the ray intersects a box
  79463. * @param box the bounding box to check
  79464. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  79465. * @returns if the box was hit
  79466. */
  79467. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  79468. /**
  79469. * If the ray hits a sphere
  79470. * @param sphere the bounding sphere to check
  79471. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  79472. * @returns true if it hits the sphere
  79473. */
  79474. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  79475. /**
  79476. * If the ray hits a triange
  79477. * @param vertex0 triangle vertex
  79478. * @param vertex1 triangle vertex
  79479. * @param vertex2 triangle vertex
  79480. * @returns intersection information if hit
  79481. */
  79482. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  79483. /**
  79484. * Checks if ray intersects a plane
  79485. * @param plane the plane to check
  79486. * @returns the distance away it was hit
  79487. */
  79488. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  79489. /**
  79490. * Calculate the intercept of a ray on a given axis
  79491. * @param axis to check 'x' | 'y' | 'z'
  79492. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  79493. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  79494. */
  79495. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  79496. /**
  79497. * Checks if ray intersects a mesh
  79498. * @param mesh the mesh to check
  79499. * @param fastCheck if only the bounding box should checked
  79500. * @returns picking info of the intersecton
  79501. */
  79502. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  79503. /**
  79504. * Checks if ray intersects a mesh
  79505. * @param meshes the meshes to check
  79506. * @param fastCheck if only the bounding box should checked
  79507. * @param results array to store result in
  79508. * @returns Array of picking infos
  79509. */
  79510. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  79511. private _comparePickingInfo;
  79512. private static smallnum;
  79513. private static rayl;
  79514. /**
  79515. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  79516. * @param sega the first point of the segment to test the intersection against
  79517. * @param segb the second point of the segment to test the intersection against
  79518. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  79519. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  79520. */
  79521. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  79522. /**
  79523. * Update the ray from viewport position
  79524. * @param x position
  79525. * @param y y position
  79526. * @param viewportWidth viewport width
  79527. * @param viewportHeight viewport height
  79528. * @param world world matrix
  79529. * @param view view matrix
  79530. * @param projection projection matrix
  79531. * @returns this ray updated
  79532. */
  79533. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79534. /**
  79535. * Creates a ray with origin and direction of 0,0,0
  79536. * @returns the new ray
  79537. */
  79538. static Zero(): Ray;
  79539. /**
  79540. * Creates a new ray from screen space and viewport
  79541. * @param x position
  79542. * @param y y position
  79543. * @param viewportWidth viewport width
  79544. * @param viewportHeight viewport height
  79545. * @param world world matrix
  79546. * @param view view matrix
  79547. * @param projection projection matrix
  79548. * @returns new ray
  79549. */
  79550. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  79551. /**
  79552. * 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
  79553. * transformed to the given world matrix.
  79554. * @param origin The origin point
  79555. * @param end The end point
  79556. * @param world a matrix to transform the ray to. Default is the identity matrix.
  79557. * @returns the new ray
  79558. */
  79559. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  79560. /**
  79561. * Transforms a ray by a matrix
  79562. * @param ray ray to transform
  79563. * @param matrix matrix to apply
  79564. * @returns the resulting new ray
  79565. */
  79566. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  79567. /**
  79568. * Transforms a ray by a matrix
  79569. * @param ray ray to transform
  79570. * @param matrix matrix to apply
  79571. * @param result ray to store result in
  79572. */
  79573. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  79574. /**
  79575. * Unproject a ray from screen space to object space
  79576. * @param sourceX defines the screen space x coordinate to use
  79577. * @param sourceY defines the screen space y coordinate to use
  79578. * @param viewportWidth defines the current width of the viewport
  79579. * @param viewportHeight defines the current height of the viewport
  79580. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  79581. * @param view defines the view matrix to use
  79582. * @param projection defines the projection matrix to use
  79583. */
  79584. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  79585. }
  79586. /**
  79587. * Type used to define predicate used to select faces when a mesh intersection is detected
  79588. */
  79589. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  79590. interface Scene {
  79591. /** @hidden */
  79592. _tempPickingRay: Nullable<Ray>;
  79593. /** @hidden */
  79594. _cachedRayForTransform: Ray;
  79595. /** @hidden */
  79596. _pickWithRayInverseMatrix: Matrix;
  79597. /** @hidden */
  79598. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  79599. /** @hidden */
  79600. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  79601. }
  79602. }
  79603. declare module BABYLON {
  79604. /**
  79605. * Groups all the scene component constants in one place to ease maintenance.
  79606. * @hidden
  79607. */
  79608. export class SceneComponentConstants {
  79609. static readonly NAME_EFFECTLAYER: string;
  79610. static readonly NAME_LAYER: string;
  79611. static readonly NAME_LENSFLARESYSTEM: string;
  79612. static readonly NAME_BOUNDINGBOXRENDERER: string;
  79613. static readonly NAME_PARTICLESYSTEM: string;
  79614. static readonly NAME_GAMEPAD: string;
  79615. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  79616. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  79617. static readonly NAME_DEPTHRENDERER: string;
  79618. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  79619. static readonly NAME_SPRITE: string;
  79620. static readonly NAME_OUTLINERENDERER: string;
  79621. static readonly NAME_PROCEDURALTEXTURE: string;
  79622. static readonly NAME_SHADOWGENERATOR: string;
  79623. static readonly NAME_OCTREE: string;
  79624. static readonly NAME_PHYSICSENGINE: string;
  79625. static readonly NAME_AUDIO: string;
  79626. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  79627. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79628. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  79629. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  79630. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  79631. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  79632. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  79633. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  79634. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  79635. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  79636. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  79637. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  79638. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  79639. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  79640. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  79641. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  79642. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  79643. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  79644. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  79645. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  79646. static readonly STEP_AFTERRENDER_AUDIO: number;
  79647. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  79648. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  79649. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  79650. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  79651. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  79652. static readonly STEP_POINTERMOVE_SPRITE: number;
  79653. static readonly STEP_POINTERDOWN_SPRITE: number;
  79654. static readonly STEP_POINTERUP_SPRITE: number;
  79655. }
  79656. /**
  79657. * This represents a scene component.
  79658. *
  79659. * This is used to decouple the dependency the scene is having on the different workloads like
  79660. * layers, post processes...
  79661. */
  79662. export interface ISceneComponent {
  79663. /**
  79664. * The name of the component. Each component must have a unique name.
  79665. */
  79666. name: string;
  79667. /**
  79668. * The scene the component belongs to.
  79669. */
  79670. scene: Scene;
  79671. /**
  79672. * Register the component to one instance of a scene.
  79673. */
  79674. register(): void;
  79675. /**
  79676. * Rebuilds the elements related to this component in case of
  79677. * context lost for instance.
  79678. */
  79679. rebuild(): void;
  79680. /**
  79681. * Disposes the component and the associated ressources.
  79682. */
  79683. dispose(): void;
  79684. }
  79685. /**
  79686. * This represents a SERIALIZABLE scene component.
  79687. *
  79688. * This extends Scene Component to add Serialization methods on top.
  79689. */
  79690. export interface ISceneSerializableComponent extends ISceneComponent {
  79691. /**
  79692. * Adds all the elements from the container to the scene
  79693. * @param container the container holding the elements
  79694. */
  79695. addFromContainer(container: AbstractScene): void;
  79696. /**
  79697. * Removes all the elements in the container from the scene
  79698. * @param container contains the elements to remove
  79699. * @param dispose if the removed element should be disposed (default: false)
  79700. */
  79701. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  79702. /**
  79703. * Serializes the component data to the specified json object
  79704. * @param serializationObject The object to serialize to
  79705. */
  79706. serialize(serializationObject: any): void;
  79707. }
  79708. /**
  79709. * Strong typing of a Mesh related stage step action
  79710. */
  79711. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  79712. /**
  79713. * Strong typing of a Evaluate Sub Mesh related stage step action
  79714. */
  79715. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  79716. /**
  79717. * Strong typing of a Active Mesh related stage step action
  79718. */
  79719. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  79720. /**
  79721. * Strong typing of a Camera related stage step action
  79722. */
  79723. export type CameraStageAction = (camera: Camera) => void;
  79724. /**
  79725. * Strong typing of a Camera Frame buffer related stage step action
  79726. */
  79727. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  79728. /**
  79729. * Strong typing of a Render Target related stage step action
  79730. */
  79731. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  79732. /**
  79733. * Strong typing of a RenderingGroup related stage step action
  79734. */
  79735. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  79736. /**
  79737. * Strong typing of a Mesh Render related stage step action
  79738. */
  79739. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  79740. /**
  79741. * Strong typing of a simple stage step action
  79742. */
  79743. export type SimpleStageAction = () => void;
  79744. /**
  79745. * Strong typing of a render target action.
  79746. */
  79747. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  79748. /**
  79749. * Strong typing of a pointer move action.
  79750. */
  79751. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  79752. /**
  79753. * Strong typing of a pointer up/down action.
  79754. */
  79755. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  79756. /**
  79757. * Representation of a stage in the scene (Basically a list of ordered steps)
  79758. * @hidden
  79759. */
  79760. export class Stage<T extends Function> extends Array<{
  79761. index: number;
  79762. component: ISceneComponent;
  79763. action: T;
  79764. }> {
  79765. /**
  79766. * Hide ctor from the rest of the world.
  79767. * @param items The items to add.
  79768. */
  79769. private constructor();
  79770. /**
  79771. * Creates a new Stage.
  79772. * @returns A new instance of a Stage
  79773. */
  79774. static Create<T extends Function>(): Stage<T>;
  79775. /**
  79776. * Registers a step in an ordered way in the targeted stage.
  79777. * @param index Defines the position to register the step in
  79778. * @param component Defines the component attached to the step
  79779. * @param action Defines the action to launch during the step
  79780. */
  79781. registerStep(index: number, component: ISceneComponent, action: T): void;
  79782. /**
  79783. * Clears all the steps from the stage.
  79784. */
  79785. clear(): void;
  79786. }
  79787. }
  79788. declare module BABYLON {
  79789. interface Scene {
  79790. /** @hidden */
  79791. _pointerOverSprite: Nullable<Sprite>;
  79792. /** @hidden */
  79793. _pickedDownSprite: Nullable<Sprite>;
  79794. /** @hidden */
  79795. _tempSpritePickingRay: Nullable<Ray>;
  79796. /**
  79797. * All of the sprite managers added to this scene
  79798. * @see http://doc.babylonjs.com/babylon101/sprites
  79799. */
  79800. spriteManagers: Array<ISpriteManager>;
  79801. /**
  79802. * An event triggered when sprites rendering is about to start
  79803. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79804. */
  79805. onBeforeSpritesRenderingObservable: Observable<Scene>;
  79806. /**
  79807. * An event triggered when sprites rendering is done
  79808. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  79809. */
  79810. onAfterSpritesRenderingObservable: Observable<Scene>;
  79811. /** @hidden */
  79812. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79813. /** Launch a ray to try to pick a sprite in the scene
  79814. * @param x position on screen
  79815. * @param y position on screen
  79816. * @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
  79817. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79818. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79819. * @returns a PickingInfo
  79820. */
  79821. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79822. /** Use the given ray to pick a sprite in the scene
  79823. * @param ray The ray (in world space) to use to pick meshes
  79824. * @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
  79825. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  79826. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79827. * @returns a PickingInfo
  79828. */
  79829. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  79830. /** @hidden */
  79831. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79832. /** Launch a ray to try to pick sprites in the scene
  79833. * @param x position on screen
  79834. * @param y position on screen
  79835. * @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
  79836. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  79837. * @returns a PickingInfo array
  79838. */
  79839. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79840. /** Use the given ray to pick sprites in the scene
  79841. * @param ray The ray (in world space) to use to pick meshes
  79842. * @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
  79843. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  79844. * @returns a PickingInfo array
  79845. */
  79846. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  79847. /**
  79848. * Force the sprite under the pointer
  79849. * @param sprite defines the sprite to use
  79850. */
  79851. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  79852. /**
  79853. * Gets the sprite under the pointer
  79854. * @returns a Sprite or null if no sprite is under the pointer
  79855. */
  79856. getPointerOverSprite(): Nullable<Sprite>;
  79857. }
  79858. /**
  79859. * Defines the sprite scene component responsible to manage sprites
  79860. * in a given scene.
  79861. */
  79862. export class SpriteSceneComponent implements ISceneComponent {
  79863. /**
  79864. * The component name helpfull to identify the component in the list of scene components.
  79865. */
  79866. readonly name: string;
  79867. /**
  79868. * The scene the component belongs to.
  79869. */
  79870. scene: Scene;
  79871. /** @hidden */
  79872. private _spritePredicate;
  79873. /**
  79874. * Creates a new instance of the component for the given scene
  79875. * @param scene Defines the scene to register the component in
  79876. */
  79877. constructor(scene: Scene);
  79878. /**
  79879. * Registers the component in a given scene
  79880. */
  79881. register(): void;
  79882. /**
  79883. * Rebuilds the elements related to this component in case of
  79884. * context lost for instance.
  79885. */
  79886. rebuild(): void;
  79887. /**
  79888. * Disposes the component and the associated ressources.
  79889. */
  79890. dispose(): void;
  79891. private _pickSpriteButKeepRay;
  79892. private _pointerMove;
  79893. private _pointerDown;
  79894. private _pointerUp;
  79895. }
  79896. }
  79897. declare module BABYLON {
  79898. /** @hidden */
  79899. export var fogFragmentDeclaration: {
  79900. name: string;
  79901. shader: string;
  79902. };
  79903. }
  79904. declare module BABYLON {
  79905. /** @hidden */
  79906. export var fogFragment: {
  79907. name: string;
  79908. shader: string;
  79909. };
  79910. }
  79911. declare module BABYLON {
  79912. /** @hidden */
  79913. export var spritesPixelShader: {
  79914. name: string;
  79915. shader: string;
  79916. };
  79917. }
  79918. declare module BABYLON {
  79919. /** @hidden */
  79920. export var fogVertexDeclaration: {
  79921. name: string;
  79922. shader: string;
  79923. };
  79924. }
  79925. declare module BABYLON {
  79926. /** @hidden */
  79927. export var spritesVertexShader: {
  79928. name: string;
  79929. shader: string;
  79930. };
  79931. }
  79932. declare module BABYLON {
  79933. /**
  79934. * Defines the minimum interface to fullfil in order to be a sprite manager.
  79935. */
  79936. export interface ISpriteManager extends IDisposable {
  79937. /**
  79938. * Restricts the camera to viewing objects with the same layerMask.
  79939. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  79940. */
  79941. layerMask: number;
  79942. /**
  79943. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79944. */
  79945. isPickable: boolean;
  79946. /**
  79947. * Specifies the rendering group id for this mesh (0 by default)
  79948. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79949. */
  79950. renderingGroupId: number;
  79951. /**
  79952. * Defines the list of sprites managed by the manager.
  79953. */
  79954. sprites: Array<Sprite>;
  79955. /**
  79956. * Tests the intersection of a sprite with a specific ray.
  79957. * @param ray The ray we are sending to test the collision
  79958. * @param camera The camera space we are sending rays in
  79959. * @param predicate A predicate allowing excluding sprites from the list of object to test
  79960. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  79961. * @returns picking info or null.
  79962. */
  79963. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  79964. /**
  79965. * Intersects the sprites with a ray
  79966. * @param ray defines the ray to intersect with
  79967. * @param camera defines the current active camera
  79968. * @param predicate defines a predicate used to select candidate sprites
  79969. * @returns null if no hit or a PickingInfo array
  79970. */
  79971. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  79972. /**
  79973. * Renders the list of sprites on screen.
  79974. */
  79975. render(): void;
  79976. }
  79977. /**
  79978. * Class used to manage multiple sprites on the same spritesheet
  79979. * @see http://doc.babylonjs.com/babylon101/sprites
  79980. */
  79981. export class SpriteManager implements ISpriteManager {
  79982. /** defines the manager's name */
  79983. name: string;
  79984. /** Gets the list of sprites */
  79985. sprites: Sprite[];
  79986. /** Gets or sets the rendering group id (0 by default) */
  79987. renderingGroupId: number;
  79988. /** Gets or sets camera layer mask */
  79989. layerMask: number;
  79990. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  79991. fogEnabled: boolean;
  79992. /** Gets or sets a boolean indicating if the sprites are pickable */
  79993. isPickable: boolean;
  79994. /** Defines the default width of a cell in the spritesheet */
  79995. cellWidth: number;
  79996. /** Defines the default height of a cell in the spritesheet */
  79997. cellHeight: number;
  79998. /** Associative array from JSON sprite data file */
  79999. private _cellData;
  80000. /** Array of sprite names from JSON sprite data file */
  80001. private _spriteMap;
  80002. /** True when packed cell data from JSON file is ready*/
  80003. private _packedAndReady;
  80004. /**
  80005. * An event triggered when the manager is disposed.
  80006. */
  80007. onDisposeObservable: Observable<SpriteManager>;
  80008. private _onDisposeObserver;
  80009. /**
  80010. * Callback called when the manager is disposed
  80011. */
  80012. onDispose: () => void;
  80013. private _capacity;
  80014. private _fromPacked;
  80015. private _spriteTexture;
  80016. private _epsilon;
  80017. private _scene;
  80018. private _vertexData;
  80019. private _buffer;
  80020. private _vertexBuffers;
  80021. private _indexBuffer;
  80022. private _effectBase;
  80023. private _effectFog;
  80024. /**
  80025. * Gets or sets the spritesheet texture
  80026. */
  80027. texture: Texture;
  80028. /**
  80029. * Creates a new sprite manager
  80030. * @param name defines the manager's name
  80031. * @param imgUrl defines the sprite sheet url
  80032. * @param capacity defines the maximum allowed number of sprites
  80033. * @param cellSize defines the size of a sprite cell
  80034. * @param scene defines the hosting scene
  80035. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  80036. * @param samplingMode defines the smapling mode to use with spritesheet
  80037. * @param fromPacked set to false; do not alter
  80038. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  80039. */
  80040. constructor(
  80041. /** defines the manager's name */
  80042. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  80043. private _makePacked;
  80044. private _appendSpriteVertex;
  80045. /**
  80046. * Intersects the sprites with a ray
  80047. * @param ray defines the ray to intersect with
  80048. * @param camera defines the current active camera
  80049. * @param predicate defines a predicate used to select candidate sprites
  80050. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  80051. * @returns null if no hit or a PickingInfo
  80052. */
  80053. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  80054. /**
  80055. * Intersects the sprites with a ray
  80056. * @param ray defines the ray to intersect with
  80057. * @param camera defines the current active camera
  80058. * @param predicate defines a predicate used to select candidate sprites
  80059. * @returns null if no hit or a PickingInfo array
  80060. */
  80061. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  80062. /**
  80063. * Render all child sprites
  80064. */
  80065. render(): void;
  80066. /**
  80067. * Release associated resources
  80068. */
  80069. dispose(): void;
  80070. }
  80071. }
  80072. declare module BABYLON {
  80073. /**
  80074. * Class used to represent a sprite
  80075. * @see http://doc.babylonjs.com/babylon101/sprites
  80076. */
  80077. export class Sprite {
  80078. /** defines the name */
  80079. name: string;
  80080. /** Gets or sets the current world position */
  80081. position: Vector3;
  80082. /** Gets or sets the main color */
  80083. color: Color4;
  80084. /** Gets or sets the width */
  80085. width: number;
  80086. /** Gets or sets the height */
  80087. height: number;
  80088. /** Gets or sets rotation angle */
  80089. angle: number;
  80090. /** Gets or sets the cell index in the sprite sheet */
  80091. cellIndex: number;
  80092. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  80093. cellRef: string;
  80094. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  80095. invertU: number;
  80096. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  80097. invertV: number;
  80098. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  80099. disposeWhenFinishedAnimating: boolean;
  80100. /** Gets the list of attached animations */
  80101. animations: Animation[];
  80102. /** Gets or sets a boolean indicating if the sprite can be picked */
  80103. isPickable: boolean;
  80104. /**
  80105. * Gets or sets the associated action manager
  80106. */
  80107. actionManager: Nullable<ActionManager>;
  80108. private _animationStarted;
  80109. private _loopAnimation;
  80110. private _fromIndex;
  80111. private _toIndex;
  80112. private _delay;
  80113. private _direction;
  80114. private _manager;
  80115. private _time;
  80116. private _onAnimationEnd;
  80117. /**
  80118. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  80119. */
  80120. isVisible: boolean;
  80121. /**
  80122. * Gets or sets the sprite size
  80123. */
  80124. size: number;
  80125. /**
  80126. * Creates a new Sprite
  80127. * @param name defines the name
  80128. * @param manager defines the manager
  80129. */
  80130. constructor(
  80131. /** defines the name */
  80132. name: string, manager: ISpriteManager);
  80133. /**
  80134. * Starts an animation
  80135. * @param from defines the initial key
  80136. * @param to defines the end key
  80137. * @param loop defines if the animation must loop
  80138. * @param delay defines the start delay (in ms)
  80139. * @param onAnimationEnd defines a callback to call when animation ends
  80140. */
  80141. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  80142. /** Stops current animation (if any) */
  80143. stopAnimation(): void;
  80144. /** @hidden */
  80145. _animate(deltaTime: number): void;
  80146. /** Release associated resources */
  80147. dispose(): void;
  80148. }
  80149. }
  80150. declare module BABYLON {
  80151. /**
  80152. * Information about the result of picking within a scene
  80153. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  80154. */
  80155. export class PickingInfo {
  80156. /** @hidden */
  80157. _pickingUnavailable: boolean;
  80158. /**
  80159. * If the pick collided with an object
  80160. */
  80161. hit: boolean;
  80162. /**
  80163. * Distance away where the pick collided
  80164. */
  80165. distance: number;
  80166. /**
  80167. * The location of pick collision
  80168. */
  80169. pickedPoint: Nullable<Vector3>;
  80170. /**
  80171. * The mesh corresponding the the pick collision
  80172. */
  80173. pickedMesh: Nullable<AbstractMesh>;
  80174. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  80175. bu: number;
  80176. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  80177. bv: number;
  80178. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  80179. faceId: number;
  80180. /** Id of the the submesh that was picked */
  80181. subMeshId: number;
  80182. /** If a sprite was picked, this will be the sprite the pick collided with */
  80183. pickedSprite: Nullable<Sprite>;
  80184. /**
  80185. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  80186. */
  80187. originMesh: Nullable<AbstractMesh>;
  80188. /**
  80189. * The ray that was used to perform the picking.
  80190. */
  80191. ray: Nullable<Ray>;
  80192. /**
  80193. * Gets the normal correspodning to the face the pick collided with
  80194. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  80195. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  80196. * @returns The normal correspodning to the face the pick collided with
  80197. */
  80198. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  80199. /**
  80200. * Gets the texture coordinates of where the pick occured
  80201. * @returns the vector containing the coordnates of the texture
  80202. */
  80203. getTextureCoordinates(): Nullable<Vector2>;
  80204. }
  80205. }
  80206. declare module BABYLON {
  80207. /**
  80208. * Gather the list of pointer event types as constants.
  80209. */
  80210. export class PointerEventTypes {
  80211. /**
  80212. * 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.
  80213. */
  80214. static readonly POINTERDOWN: number;
  80215. /**
  80216. * The pointerup event is fired when a pointer is no longer active.
  80217. */
  80218. static readonly POINTERUP: number;
  80219. /**
  80220. * The pointermove event is fired when a pointer changes coordinates.
  80221. */
  80222. static readonly POINTERMOVE: number;
  80223. /**
  80224. * The pointerwheel event is fired when a mouse wheel has been rotated.
  80225. */
  80226. static readonly POINTERWHEEL: number;
  80227. /**
  80228. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  80229. */
  80230. static readonly POINTERPICK: number;
  80231. /**
  80232. * The pointertap event is fired when a the object has been touched and released without drag.
  80233. */
  80234. static readonly POINTERTAP: number;
  80235. /**
  80236. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  80237. */
  80238. static readonly POINTERDOUBLETAP: number;
  80239. }
  80240. /**
  80241. * Base class of pointer info types.
  80242. */
  80243. export class PointerInfoBase {
  80244. /**
  80245. * Defines the type of event (PointerEventTypes)
  80246. */
  80247. type: number;
  80248. /**
  80249. * Defines the related dom event
  80250. */
  80251. event: PointerEvent | MouseWheelEvent;
  80252. /**
  80253. * Instantiates the base class of pointers info.
  80254. * @param type Defines the type of event (PointerEventTypes)
  80255. * @param event Defines the related dom event
  80256. */
  80257. constructor(
  80258. /**
  80259. * Defines the type of event (PointerEventTypes)
  80260. */
  80261. type: number,
  80262. /**
  80263. * Defines the related dom event
  80264. */
  80265. event: PointerEvent | MouseWheelEvent);
  80266. }
  80267. /**
  80268. * This class is used to store pointer related info for the onPrePointerObservable event.
  80269. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  80270. */
  80271. export class PointerInfoPre extends PointerInfoBase {
  80272. /**
  80273. * Ray from a pointer if availible (eg. 6dof controller)
  80274. */
  80275. ray: Nullable<Ray>;
  80276. /**
  80277. * Defines the local position of the pointer on the canvas.
  80278. */
  80279. localPosition: Vector2;
  80280. /**
  80281. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  80282. */
  80283. skipOnPointerObservable: boolean;
  80284. /**
  80285. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  80286. * @param type Defines the type of event (PointerEventTypes)
  80287. * @param event Defines the related dom event
  80288. * @param localX Defines the local x coordinates of the pointer when the event occured
  80289. * @param localY Defines the local y coordinates of the pointer when the event occured
  80290. */
  80291. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  80292. }
  80293. /**
  80294. * This type contains all the data related to a pointer event in Babylon.js.
  80295. * 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.
  80296. */
  80297. export class PointerInfo extends PointerInfoBase {
  80298. /**
  80299. * Defines the picking info associated to the info (if any)\
  80300. */
  80301. pickInfo: Nullable<PickingInfo>;
  80302. /**
  80303. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  80304. * @param type Defines the type of event (PointerEventTypes)
  80305. * @param event Defines the related dom event
  80306. * @param pickInfo Defines the picking info associated to the info (if any)\
  80307. */
  80308. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  80309. /**
  80310. * Defines the picking info associated to the info (if any)\
  80311. */
  80312. pickInfo: Nullable<PickingInfo>);
  80313. }
  80314. /**
  80315. * Data relating to a touch event on the screen.
  80316. */
  80317. export interface PointerTouch {
  80318. /**
  80319. * X coordinate of touch.
  80320. */
  80321. x: number;
  80322. /**
  80323. * Y coordinate of touch.
  80324. */
  80325. y: number;
  80326. /**
  80327. * Id of touch. Unique for each finger.
  80328. */
  80329. pointerId: number;
  80330. /**
  80331. * Event type passed from DOM.
  80332. */
  80333. type: any;
  80334. }
  80335. }
  80336. declare module BABYLON {
  80337. /**
  80338. * Manage the mouse inputs to control the movement of a free camera.
  80339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80340. */
  80341. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  80342. /**
  80343. * Define if touch is enabled in the mouse input
  80344. */
  80345. touchEnabled: boolean;
  80346. /**
  80347. * Defines the camera the input is attached to.
  80348. */
  80349. camera: FreeCamera;
  80350. /**
  80351. * Defines the buttons associated with the input to handle camera move.
  80352. */
  80353. buttons: number[];
  80354. /**
  80355. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  80356. */
  80357. angularSensibility: number;
  80358. private _pointerInput;
  80359. private _onMouseMove;
  80360. private _observer;
  80361. private previousPosition;
  80362. /**
  80363. * Observable for when a pointer move event occurs containing the move offset
  80364. */
  80365. onPointerMovedObservable: Observable<{
  80366. offsetX: number;
  80367. offsetY: number;
  80368. }>;
  80369. /**
  80370. * @hidden
  80371. * If the camera should be rotated automatically based on pointer movement
  80372. */
  80373. _allowCameraRotation: boolean;
  80374. /**
  80375. * Manage the mouse inputs to control the movement of a free camera.
  80376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80377. * @param touchEnabled Defines if touch is enabled or not
  80378. */
  80379. constructor(
  80380. /**
  80381. * Define if touch is enabled in the mouse input
  80382. */
  80383. touchEnabled?: boolean);
  80384. /**
  80385. * Attach the input controls to a specific dom element to get the input from.
  80386. * @param element Defines the element the controls should be listened from
  80387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80388. */
  80389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80390. /**
  80391. * Called on JS contextmenu event.
  80392. * Override this method to provide functionality.
  80393. */
  80394. protected onContextMenu(evt: PointerEvent): void;
  80395. /**
  80396. * Detach the current controls from the specified dom element.
  80397. * @param element Defines the element to stop listening the inputs from
  80398. */
  80399. detachControl(element: Nullable<HTMLElement>): void;
  80400. /**
  80401. * Gets the class name of the current intput.
  80402. * @returns the class name
  80403. */
  80404. getClassName(): string;
  80405. /**
  80406. * Get the friendly name associated with the input class.
  80407. * @returns the input friendly name
  80408. */
  80409. getSimpleName(): string;
  80410. }
  80411. }
  80412. declare module BABYLON {
  80413. /**
  80414. * Manage the touch inputs to control the movement of a free camera.
  80415. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80416. */
  80417. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  80418. /**
  80419. * Defines the camera the input is attached to.
  80420. */
  80421. camera: FreeCamera;
  80422. /**
  80423. * Defines the touch sensibility for rotation.
  80424. * The higher the faster.
  80425. */
  80426. touchAngularSensibility: number;
  80427. /**
  80428. * Defines the touch sensibility for move.
  80429. * The higher the faster.
  80430. */
  80431. touchMoveSensibility: number;
  80432. private _offsetX;
  80433. private _offsetY;
  80434. private _pointerPressed;
  80435. private _pointerInput;
  80436. private _observer;
  80437. private _onLostFocus;
  80438. /**
  80439. * Attach the input controls to a specific dom element to get the input from.
  80440. * @param element Defines the element the controls should be listened from
  80441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80442. */
  80443. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80444. /**
  80445. * Detach the current controls from the specified dom element.
  80446. * @param element Defines the element to stop listening the inputs from
  80447. */
  80448. detachControl(element: Nullable<HTMLElement>): void;
  80449. /**
  80450. * Update the current camera state depending on the inputs that have been used this frame.
  80451. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80452. */
  80453. checkInputs(): void;
  80454. /**
  80455. * Gets the class name of the current intput.
  80456. * @returns the class name
  80457. */
  80458. getClassName(): string;
  80459. /**
  80460. * Get the friendly name associated with the input class.
  80461. * @returns the input friendly name
  80462. */
  80463. getSimpleName(): string;
  80464. }
  80465. }
  80466. declare module BABYLON {
  80467. /**
  80468. * Default Inputs manager for the FreeCamera.
  80469. * It groups all the default supported inputs for ease of use.
  80470. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80471. */
  80472. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  80473. /**
  80474. * @hidden
  80475. */
  80476. _mouseInput: Nullable<FreeCameraMouseInput>;
  80477. /**
  80478. * Instantiates a new FreeCameraInputsManager.
  80479. * @param camera Defines the camera the inputs belong to
  80480. */
  80481. constructor(camera: FreeCamera);
  80482. /**
  80483. * Add keyboard input support to the input manager.
  80484. * @returns the current input manager
  80485. */
  80486. addKeyboard(): FreeCameraInputsManager;
  80487. /**
  80488. * Add mouse input support to the input manager.
  80489. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  80490. * @returns the current input manager
  80491. */
  80492. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  80493. /**
  80494. * Removes the mouse input support from the manager
  80495. * @returns the current input manager
  80496. */
  80497. removeMouse(): FreeCameraInputsManager;
  80498. /**
  80499. * Add touch input support to the input manager.
  80500. * @returns the current input manager
  80501. */
  80502. addTouch(): FreeCameraInputsManager;
  80503. /**
  80504. * Remove all attached input methods from a camera
  80505. */
  80506. clear(): void;
  80507. }
  80508. }
  80509. declare module BABYLON {
  80510. /**
  80511. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80512. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  80513. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80514. */
  80515. export class FreeCamera extends TargetCamera {
  80516. /**
  80517. * Define the collision ellipsoid of the camera.
  80518. * This is helpful to simulate a camera body like the player body around the camera
  80519. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  80520. */
  80521. ellipsoid: Vector3;
  80522. /**
  80523. * Define an offset for the position of the ellipsoid around the camera.
  80524. * This can be helpful to determine the center of the body near the gravity center of the body
  80525. * instead of its head.
  80526. */
  80527. ellipsoidOffset: Vector3;
  80528. /**
  80529. * Enable or disable collisions of the camera with the rest of the scene objects.
  80530. */
  80531. checkCollisions: boolean;
  80532. /**
  80533. * Enable or disable gravity on the camera.
  80534. */
  80535. applyGravity: boolean;
  80536. /**
  80537. * Define the input manager associated to the camera.
  80538. */
  80539. inputs: FreeCameraInputsManager;
  80540. /**
  80541. * Gets the input sensibility for a mouse input. (default is 2000.0)
  80542. * Higher values reduce sensitivity.
  80543. */
  80544. /**
  80545. * Sets the input sensibility for a mouse input. (default is 2000.0)
  80546. * Higher values reduce sensitivity.
  80547. */
  80548. angularSensibility: number;
  80549. /**
  80550. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80551. */
  80552. keysUp: number[];
  80553. /**
  80554. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80555. */
  80556. keysDown: number[];
  80557. /**
  80558. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80559. */
  80560. keysLeft: number[];
  80561. /**
  80562. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80563. */
  80564. keysRight: number[];
  80565. /**
  80566. * Event raised when the camera collide with a mesh in the scene.
  80567. */
  80568. onCollide: (collidedMesh: AbstractMesh) => void;
  80569. private _collider;
  80570. private _needMoveForGravity;
  80571. private _oldPosition;
  80572. private _diffPosition;
  80573. private _newPosition;
  80574. /** @hidden */
  80575. _localDirection: Vector3;
  80576. /** @hidden */
  80577. _transformedDirection: Vector3;
  80578. /**
  80579. * Instantiates a Free Camera.
  80580. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  80581. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  80582. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  80583. * @param name Define the name of the camera in the scene
  80584. * @param position Define the start position of the camera in the scene
  80585. * @param scene Define the scene the camera belongs to
  80586. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  80587. */
  80588. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  80589. /**
  80590. * Attached controls to the current camera.
  80591. * @param element Defines the element the controls should be listened from
  80592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80593. */
  80594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80595. /**
  80596. * Detach the current controls from the camera.
  80597. * The camera will stop reacting to inputs.
  80598. * @param element Defines the element to stop listening the inputs from
  80599. */
  80600. detachControl(element: HTMLElement): void;
  80601. private _collisionMask;
  80602. /**
  80603. * Define a collision mask to limit the list of object the camera can collide with
  80604. */
  80605. collisionMask: number;
  80606. /** @hidden */
  80607. _collideWithWorld(displacement: Vector3): void;
  80608. private _onCollisionPositionChange;
  80609. /** @hidden */
  80610. _checkInputs(): void;
  80611. /** @hidden */
  80612. _decideIfNeedsToMove(): boolean;
  80613. /** @hidden */
  80614. _updatePosition(): void;
  80615. /**
  80616. * Destroy the camera and release the current resources hold by it.
  80617. */
  80618. dispose(): void;
  80619. /**
  80620. * Gets the current object class name.
  80621. * @return the class name
  80622. */
  80623. getClassName(): string;
  80624. }
  80625. }
  80626. declare module BABYLON {
  80627. /**
  80628. * Represents a gamepad control stick position
  80629. */
  80630. export class StickValues {
  80631. /**
  80632. * The x component of the control stick
  80633. */
  80634. x: number;
  80635. /**
  80636. * The y component of the control stick
  80637. */
  80638. y: number;
  80639. /**
  80640. * Initializes the gamepad x and y control stick values
  80641. * @param x The x component of the gamepad control stick value
  80642. * @param y The y component of the gamepad control stick value
  80643. */
  80644. constructor(
  80645. /**
  80646. * The x component of the control stick
  80647. */
  80648. x: number,
  80649. /**
  80650. * The y component of the control stick
  80651. */
  80652. y: number);
  80653. }
  80654. /**
  80655. * An interface which manages callbacks for gamepad button changes
  80656. */
  80657. export interface GamepadButtonChanges {
  80658. /**
  80659. * Called when a gamepad has been changed
  80660. */
  80661. changed: boolean;
  80662. /**
  80663. * Called when a gamepad press event has been triggered
  80664. */
  80665. pressChanged: boolean;
  80666. /**
  80667. * Called when a touch event has been triggered
  80668. */
  80669. touchChanged: boolean;
  80670. /**
  80671. * Called when a value has changed
  80672. */
  80673. valueChanged: boolean;
  80674. }
  80675. /**
  80676. * Represents a gamepad
  80677. */
  80678. export class Gamepad {
  80679. /**
  80680. * The id of the gamepad
  80681. */
  80682. id: string;
  80683. /**
  80684. * The index of the gamepad
  80685. */
  80686. index: number;
  80687. /**
  80688. * The browser gamepad
  80689. */
  80690. browserGamepad: any;
  80691. /**
  80692. * Specifies what type of gamepad this represents
  80693. */
  80694. type: number;
  80695. private _leftStick;
  80696. private _rightStick;
  80697. /** @hidden */
  80698. _isConnected: boolean;
  80699. private _leftStickAxisX;
  80700. private _leftStickAxisY;
  80701. private _rightStickAxisX;
  80702. private _rightStickAxisY;
  80703. /**
  80704. * Triggered when the left control stick has been changed
  80705. */
  80706. private _onleftstickchanged;
  80707. /**
  80708. * Triggered when the right control stick has been changed
  80709. */
  80710. private _onrightstickchanged;
  80711. /**
  80712. * Represents a gamepad controller
  80713. */
  80714. static GAMEPAD: number;
  80715. /**
  80716. * Represents a generic controller
  80717. */
  80718. static GENERIC: number;
  80719. /**
  80720. * Represents an XBox controller
  80721. */
  80722. static XBOX: number;
  80723. /**
  80724. * Represents a pose-enabled controller
  80725. */
  80726. static POSE_ENABLED: number;
  80727. /**
  80728. * Represents an Dual Shock controller
  80729. */
  80730. static DUALSHOCK: number;
  80731. /**
  80732. * Specifies whether the left control stick should be Y-inverted
  80733. */
  80734. protected _invertLeftStickY: boolean;
  80735. /**
  80736. * Specifies if the gamepad has been connected
  80737. */
  80738. readonly isConnected: boolean;
  80739. /**
  80740. * Initializes the gamepad
  80741. * @param id The id of the gamepad
  80742. * @param index The index of the gamepad
  80743. * @param browserGamepad The browser gamepad
  80744. * @param leftStickX The x component of the left joystick
  80745. * @param leftStickY The y component of the left joystick
  80746. * @param rightStickX The x component of the right joystick
  80747. * @param rightStickY The y component of the right joystick
  80748. */
  80749. constructor(
  80750. /**
  80751. * The id of the gamepad
  80752. */
  80753. id: string,
  80754. /**
  80755. * The index of the gamepad
  80756. */
  80757. index: number,
  80758. /**
  80759. * The browser gamepad
  80760. */
  80761. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  80762. /**
  80763. * Callback triggered when the left joystick has changed
  80764. * @param callback
  80765. */
  80766. onleftstickchanged(callback: (values: StickValues) => void): void;
  80767. /**
  80768. * Callback triggered when the right joystick has changed
  80769. * @param callback
  80770. */
  80771. onrightstickchanged(callback: (values: StickValues) => void): void;
  80772. /**
  80773. * Gets the left joystick
  80774. */
  80775. /**
  80776. * Sets the left joystick values
  80777. */
  80778. leftStick: StickValues;
  80779. /**
  80780. * Gets the right joystick
  80781. */
  80782. /**
  80783. * Sets the right joystick value
  80784. */
  80785. rightStick: StickValues;
  80786. /**
  80787. * Updates the gamepad joystick positions
  80788. */
  80789. update(): void;
  80790. /**
  80791. * Disposes the gamepad
  80792. */
  80793. dispose(): void;
  80794. }
  80795. /**
  80796. * Represents a generic gamepad
  80797. */
  80798. export class GenericPad extends Gamepad {
  80799. private _buttons;
  80800. private _onbuttondown;
  80801. private _onbuttonup;
  80802. /**
  80803. * Observable triggered when a button has been pressed
  80804. */
  80805. onButtonDownObservable: Observable<number>;
  80806. /**
  80807. * Observable triggered when a button has been released
  80808. */
  80809. onButtonUpObservable: Observable<number>;
  80810. /**
  80811. * Callback triggered when a button has been pressed
  80812. * @param callback Called when a button has been pressed
  80813. */
  80814. onbuttondown(callback: (buttonPressed: number) => void): void;
  80815. /**
  80816. * Callback triggered when a button has been released
  80817. * @param callback Called when a button has been released
  80818. */
  80819. onbuttonup(callback: (buttonReleased: number) => void): void;
  80820. /**
  80821. * Initializes the generic gamepad
  80822. * @param id The id of the generic gamepad
  80823. * @param index The index of the generic gamepad
  80824. * @param browserGamepad The browser gamepad
  80825. */
  80826. constructor(id: string, index: number, browserGamepad: any);
  80827. private _setButtonValue;
  80828. /**
  80829. * Updates the generic gamepad
  80830. */
  80831. update(): void;
  80832. /**
  80833. * Disposes the generic gamepad
  80834. */
  80835. dispose(): void;
  80836. }
  80837. }
  80838. declare module BABYLON {
  80839. interface Engine {
  80840. /**
  80841. * Creates a raw texture
  80842. * @param data defines the data to store in the texture
  80843. * @param width defines the width of the texture
  80844. * @param height defines the height of the texture
  80845. * @param format defines the format of the data
  80846. * @param generateMipMaps defines if the engine should generate the mip levels
  80847. * @param invertY defines if data must be stored with Y axis inverted
  80848. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80849. * @param compression defines the compression used (null by default)
  80850. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80851. * @returns the raw texture inside an InternalTexture
  80852. */
  80853. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80854. /**
  80855. * Update a raw texture
  80856. * @param texture defines the texture to update
  80857. * @param data defines the data to store in the texture
  80858. * @param format defines the format of the data
  80859. * @param invertY defines if data must be stored with Y axis inverted
  80860. */
  80861. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80862. /**
  80863. * Update a raw texture
  80864. * @param texture defines the texture to update
  80865. * @param data defines the data to store in the texture
  80866. * @param format defines the format of the data
  80867. * @param invertY defines if data must be stored with Y axis inverted
  80868. * @param compression defines the compression used (null by default)
  80869. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80870. */
  80871. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80872. /**
  80873. * Creates a new raw cube texture
  80874. * @param data defines the array of data to use to create each face
  80875. * @param size defines the size of the textures
  80876. * @param format defines the format of the data
  80877. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80878. * @param generateMipMaps defines if the engine should generate the mip levels
  80879. * @param invertY defines if data must be stored with Y axis inverted
  80880. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80881. * @param compression defines the compression used (null by default)
  80882. * @returns the cube texture as an InternalTexture
  80883. */
  80884. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80885. /**
  80886. * Update a raw cube texture
  80887. * @param texture defines the texture to udpdate
  80888. * @param data defines the data to store
  80889. * @param format defines the data format
  80890. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80891. * @param invertY defines if data must be stored with Y axis inverted
  80892. */
  80893. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80894. /**
  80895. * Update a raw cube texture
  80896. * @param texture defines the texture to udpdate
  80897. * @param data defines the data to store
  80898. * @param format defines the data format
  80899. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80900. * @param invertY defines if data must be stored with Y axis inverted
  80901. * @param compression defines the compression used (null by default)
  80902. */
  80903. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80904. /**
  80905. * Update a raw cube texture
  80906. * @param texture defines the texture to udpdate
  80907. * @param data defines the data to store
  80908. * @param format defines the data format
  80909. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80910. * @param invertY defines if data must be stored with Y axis inverted
  80911. * @param compression defines the compression used (null by default)
  80912. * @param level defines which level of the texture to update
  80913. */
  80914. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80915. /**
  80916. * Creates a new raw cube texture from a specified url
  80917. * @param url defines the url where the data is located
  80918. * @param scene defines the current scene
  80919. * @param size defines the size of the textures
  80920. * @param format defines the format of the data
  80921. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80922. * @param noMipmap defines if the engine should avoid generating the mip levels
  80923. * @param callback defines a callback used to extract texture data from loaded data
  80924. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80925. * @param onLoad defines a callback called when texture is loaded
  80926. * @param onError defines a callback called if there is an error
  80927. * @returns the cube texture as an InternalTexture
  80928. */
  80929. 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;
  80930. /**
  80931. * Creates a new raw cube texture from a specified url
  80932. * @param url defines the url where the data is located
  80933. * @param scene defines the current scene
  80934. * @param size defines the size of the textures
  80935. * @param format defines the format of the data
  80936. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80937. * @param noMipmap defines if the engine should avoid generating the mip levels
  80938. * @param callback defines a callback used to extract texture data from loaded data
  80939. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80940. * @param onLoad defines a callback called when texture is loaded
  80941. * @param onError defines a callback called if there is an error
  80942. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80943. * @param invertY defines if data must be stored with Y axis inverted
  80944. * @returns the cube texture as an InternalTexture
  80945. */
  80946. 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;
  80947. /**
  80948. * Creates a new raw 3D texture
  80949. * @param data defines the data used to create the texture
  80950. * @param width defines the width of the texture
  80951. * @param height defines the height of the texture
  80952. * @param depth defines the depth of the texture
  80953. * @param format defines the format of the texture
  80954. * @param generateMipMaps defines if the engine must generate mip levels
  80955. * @param invertY defines if data must be stored with Y axis inverted
  80956. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80957. * @param compression defines the compressed used (can be null)
  80958. * @param textureType defines the compressed used (can be null)
  80959. * @returns a new raw 3D texture (stored in an InternalTexture)
  80960. */
  80961. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80962. /**
  80963. * Update a raw 3D texture
  80964. * @param texture defines the texture to update
  80965. * @param data defines the data to store
  80966. * @param format defines the data format
  80967. * @param invertY defines if data must be stored with Y axis inverted
  80968. */
  80969. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80970. /**
  80971. * Update a raw 3D texture
  80972. * @param texture defines the texture to update
  80973. * @param data defines the data to store
  80974. * @param format defines the data format
  80975. * @param invertY defines if data must be stored with Y axis inverted
  80976. * @param compression defines the used compression (can be null)
  80977. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80978. */
  80979. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80980. /**
  80981. * Creates a new raw 2D array texture
  80982. * @param data defines the data used to create the texture
  80983. * @param width defines the width of the texture
  80984. * @param height defines the height of the texture
  80985. * @param depth defines the number of layers of the texture
  80986. * @param format defines the format of the texture
  80987. * @param generateMipMaps defines if the engine must generate mip levels
  80988. * @param invertY defines if data must be stored with Y axis inverted
  80989. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80990. * @param compression defines the compressed used (can be null)
  80991. * @param textureType defines the compressed used (can be null)
  80992. * @returns a new raw 2D array texture (stored in an InternalTexture)
  80993. */
  80994. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80995. /**
  80996. * Update a raw 2D array texture
  80997. * @param texture defines the texture to update
  80998. * @param data defines the data to store
  80999. * @param format defines the data format
  81000. * @param invertY defines if data must be stored with Y axis inverted
  81001. */
  81002. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  81003. /**
  81004. * Update a raw 2D array texture
  81005. * @param texture defines the texture to update
  81006. * @param data defines the data to store
  81007. * @param format defines the data format
  81008. * @param invertY defines if data must be stored with Y axis inverted
  81009. * @param compression defines the used compression (can be null)
  81010. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  81011. */
  81012. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  81013. }
  81014. }
  81015. declare module BABYLON {
  81016. /**
  81017. * Raw texture can help creating a texture directly from an array of data.
  81018. * This can be super useful if you either get the data from an uncompressed source or
  81019. * if you wish to create your texture pixel by pixel.
  81020. */
  81021. export class RawTexture extends Texture {
  81022. /**
  81023. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81024. */
  81025. format: number;
  81026. private _engine;
  81027. /**
  81028. * Instantiates a new RawTexture.
  81029. * Raw texture can help creating a texture directly from an array of data.
  81030. * This can be super useful if you either get the data from an uncompressed source or
  81031. * if you wish to create your texture pixel by pixel.
  81032. * @param data define the array of data to use to create the texture
  81033. * @param width define the width of the texture
  81034. * @param height define the height of the texture
  81035. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81036. * @param scene define the scene the texture belongs to
  81037. * @param generateMipMaps define whether mip maps should be generated or not
  81038. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81039. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81040. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81041. */
  81042. constructor(data: ArrayBufferView, width: number, height: number,
  81043. /**
  81044. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  81045. */
  81046. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  81047. /**
  81048. * Updates the texture underlying data.
  81049. * @param data Define the new data of the texture
  81050. */
  81051. update(data: ArrayBufferView): void;
  81052. /**
  81053. * Creates a luminance texture from some data.
  81054. * @param data Define the texture data
  81055. * @param width Define the width of the texture
  81056. * @param height Define the height of the texture
  81057. * @param scene Define the scene the texture belongs to
  81058. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81059. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81060. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81061. * @returns the luminance texture
  81062. */
  81063. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81064. /**
  81065. * Creates a luminance alpha texture from some data.
  81066. * @param data Define the texture data
  81067. * @param width Define the width of the texture
  81068. * @param height Define the height of the texture
  81069. * @param scene Define the scene the texture belongs to
  81070. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81071. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81072. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81073. * @returns the luminance alpha texture
  81074. */
  81075. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81076. /**
  81077. * Creates an alpha texture from some data.
  81078. * @param data Define the texture data
  81079. * @param width Define the width of the texture
  81080. * @param height Define the height of the texture
  81081. * @param scene Define the scene the texture belongs to
  81082. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81083. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81084. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81085. * @returns the alpha texture
  81086. */
  81087. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  81088. /**
  81089. * Creates a RGB texture from some data.
  81090. * @param data Define the texture data
  81091. * @param width Define the width of the texture
  81092. * @param height Define the height of the texture
  81093. * @param scene Define the scene the texture belongs to
  81094. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81095. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81096. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81097. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81098. * @returns the RGB alpha texture
  81099. */
  81100. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81101. /**
  81102. * Creates a RGBA texture from some data.
  81103. * @param data Define the texture data
  81104. * @param width Define the width of the texture
  81105. * @param height Define the height of the texture
  81106. * @param scene Define the scene the texture belongs to
  81107. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81108. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81109. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81110. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81111. * @returns the RGBA texture
  81112. */
  81113. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81114. /**
  81115. * Creates a R texture from some data.
  81116. * @param data Define the texture data
  81117. * @param width Define the width of the texture
  81118. * @param height Define the height of the texture
  81119. * @param scene Define the scene the texture belongs to
  81120. * @param generateMipMaps Define whether or not to create mip maps for the texture
  81121. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  81122. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  81123. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  81124. * @returns the R texture
  81125. */
  81126. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  81127. }
  81128. }
  81129. declare module BABYLON {
  81130. /**
  81131. * Interface for the size containing width and height
  81132. */
  81133. export interface ISize {
  81134. /**
  81135. * Width
  81136. */
  81137. width: number;
  81138. /**
  81139. * Heighht
  81140. */
  81141. height: number;
  81142. }
  81143. /**
  81144. * Size containing widht and height
  81145. */
  81146. export class Size implements ISize {
  81147. /**
  81148. * Width
  81149. */
  81150. width: number;
  81151. /**
  81152. * Height
  81153. */
  81154. height: number;
  81155. /**
  81156. * Creates a Size object from the given width and height (floats).
  81157. * @param width width of the new size
  81158. * @param height height of the new size
  81159. */
  81160. constructor(width: number, height: number);
  81161. /**
  81162. * Returns a string with the Size width and height
  81163. * @returns a string with the Size width and height
  81164. */
  81165. toString(): string;
  81166. /**
  81167. * "Size"
  81168. * @returns the string "Size"
  81169. */
  81170. getClassName(): string;
  81171. /**
  81172. * Returns the Size hash code.
  81173. * @returns a hash code for a unique width and height
  81174. */
  81175. getHashCode(): number;
  81176. /**
  81177. * Updates the current size from the given one.
  81178. * @param src the given size
  81179. */
  81180. copyFrom(src: Size): void;
  81181. /**
  81182. * Updates in place the current Size from the given floats.
  81183. * @param width width of the new size
  81184. * @param height height of the new size
  81185. * @returns the updated Size.
  81186. */
  81187. copyFromFloats(width: number, height: number): Size;
  81188. /**
  81189. * Updates in place the current Size from the given floats.
  81190. * @param width width to set
  81191. * @param height height to set
  81192. * @returns the updated Size.
  81193. */
  81194. set(width: number, height: number): Size;
  81195. /**
  81196. * Multiplies the width and height by numbers
  81197. * @param w factor to multiple the width by
  81198. * @param h factor to multiple the height by
  81199. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  81200. */
  81201. multiplyByFloats(w: number, h: number): Size;
  81202. /**
  81203. * Clones the size
  81204. * @returns a new Size copied from the given one.
  81205. */
  81206. clone(): Size;
  81207. /**
  81208. * True if the current Size and the given one width and height are strictly equal.
  81209. * @param other the other size to compare against
  81210. * @returns True if the current Size and the given one width and height are strictly equal.
  81211. */
  81212. equals(other: Size): boolean;
  81213. /**
  81214. * The surface of the Size : width * height (float).
  81215. */
  81216. readonly surface: number;
  81217. /**
  81218. * Create a new size of zero
  81219. * @returns a new Size set to (0.0, 0.0)
  81220. */
  81221. static Zero(): Size;
  81222. /**
  81223. * Sums the width and height of two sizes
  81224. * @param otherSize size to add to this size
  81225. * @returns a new Size set as the addition result of the current Size and the given one.
  81226. */
  81227. add(otherSize: Size): Size;
  81228. /**
  81229. * Subtracts the width and height of two
  81230. * @param otherSize size to subtract to this size
  81231. * @returns a new Size set as the subtraction result of the given one from the current Size.
  81232. */
  81233. subtract(otherSize: Size): Size;
  81234. /**
  81235. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  81236. * @param start starting size to lerp between
  81237. * @param end end size to lerp between
  81238. * @param amount amount to lerp between the start and end values
  81239. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  81240. */
  81241. static Lerp(start: Size, end: Size, amount: number): Size;
  81242. }
  81243. }
  81244. declare module BABYLON {
  81245. /**
  81246. * Defines a runtime animation
  81247. */
  81248. export class RuntimeAnimation {
  81249. private _events;
  81250. /**
  81251. * The current frame of the runtime animation
  81252. */
  81253. private _currentFrame;
  81254. /**
  81255. * The animation used by the runtime animation
  81256. */
  81257. private _animation;
  81258. /**
  81259. * The target of the runtime animation
  81260. */
  81261. private _target;
  81262. /**
  81263. * The initiating animatable
  81264. */
  81265. private _host;
  81266. /**
  81267. * The original value of the runtime animation
  81268. */
  81269. private _originalValue;
  81270. /**
  81271. * The original blend value of the runtime animation
  81272. */
  81273. private _originalBlendValue;
  81274. /**
  81275. * The offsets cache of the runtime animation
  81276. */
  81277. private _offsetsCache;
  81278. /**
  81279. * The high limits cache of the runtime animation
  81280. */
  81281. private _highLimitsCache;
  81282. /**
  81283. * Specifies if the runtime animation has been stopped
  81284. */
  81285. private _stopped;
  81286. /**
  81287. * The blending factor of the runtime animation
  81288. */
  81289. private _blendingFactor;
  81290. /**
  81291. * The BabylonJS scene
  81292. */
  81293. private _scene;
  81294. /**
  81295. * The current value of the runtime animation
  81296. */
  81297. private _currentValue;
  81298. /** @hidden */
  81299. _animationState: _IAnimationState;
  81300. /**
  81301. * The active target of the runtime animation
  81302. */
  81303. private _activeTargets;
  81304. private _currentActiveTarget;
  81305. private _directTarget;
  81306. /**
  81307. * The target path of the runtime animation
  81308. */
  81309. private _targetPath;
  81310. /**
  81311. * The weight of the runtime animation
  81312. */
  81313. private _weight;
  81314. /**
  81315. * The ratio offset of the runtime animation
  81316. */
  81317. private _ratioOffset;
  81318. /**
  81319. * The previous delay of the runtime animation
  81320. */
  81321. private _previousDelay;
  81322. /**
  81323. * The previous ratio of the runtime animation
  81324. */
  81325. private _previousRatio;
  81326. private _enableBlending;
  81327. private _keys;
  81328. private _minFrame;
  81329. private _maxFrame;
  81330. private _minValue;
  81331. private _maxValue;
  81332. private _targetIsArray;
  81333. /**
  81334. * Gets the current frame of the runtime animation
  81335. */
  81336. readonly currentFrame: number;
  81337. /**
  81338. * Gets the weight of the runtime animation
  81339. */
  81340. readonly weight: number;
  81341. /**
  81342. * Gets the current value of the runtime animation
  81343. */
  81344. readonly currentValue: any;
  81345. /**
  81346. * Gets the target path of the runtime animation
  81347. */
  81348. readonly targetPath: string;
  81349. /**
  81350. * Gets the actual target of the runtime animation
  81351. */
  81352. readonly target: any;
  81353. /** @hidden */
  81354. _onLoop: () => void;
  81355. /**
  81356. * Create a new RuntimeAnimation object
  81357. * @param target defines the target of the animation
  81358. * @param animation defines the source animation object
  81359. * @param scene defines the hosting scene
  81360. * @param host defines the initiating Animatable
  81361. */
  81362. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  81363. private _preparePath;
  81364. /**
  81365. * Gets the animation from the runtime animation
  81366. */
  81367. readonly animation: Animation;
  81368. /**
  81369. * Resets the runtime animation to the beginning
  81370. * @param restoreOriginal defines whether to restore the target property to the original value
  81371. */
  81372. reset(restoreOriginal?: boolean): void;
  81373. /**
  81374. * Specifies if the runtime animation is stopped
  81375. * @returns Boolean specifying if the runtime animation is stopped
  81376. */
  81377. isStopped(): boolean;
  81378. /**
  81379. * Disposes of the runtime animation
  81380. */
  81381. dispose(): void;
  81382. /**
  81383. * Apply the interpolated value to the target
  81384. * @param currentValue defines the value computed by the animation
  81385. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  81386. */
  81387. setValue(currentValue: any, weight: number): void;
  81388. private _getOriginalValues;
  81389. private _setValue;
  81390. /**
  81391. * Gets the loop pmode of the runtime animation
  81392. * @returns Loop Mode
  81393. */
  81394. private _getCorrectLoopMode;
  81395. /**
  81396. * Move the current animation to a given frame
  81397. * @param frame defines the frame to move to
  81398. */
  81399. goToFrame(frame: number): void;
  81400. /**
  81401. * @hidden Internal use only
  81402. */
  81403. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  81404. /**
  81405. * Execute the current animation
  81406. * @param delay defines the delay to add to the current frame
  81407. * @param from defines the lower bound of the animation range
  81408. * @param to defines the upper bound of the animation range
  81409. * @param loop defines if the current animation must loop
  81410. * @param speedRatio defines the current speed ratio
  81411. * @param weight defines the weight of the animation (default is -1 so no weight)
  81412. * @param onLoop optional callback called when animation loops
  81413. * @returns a boolean indicating if the animation is running
  81414. */
  81415. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  81416. }
  81417. }
  81418. declare module BABYLON {
  81419. /**
  81420. * Class used to store an actual running animation
  81421. */
  81422. export class Animatable {
  81423. /** defines the target object */
  81424. target: any;
  81425. /** defines the starting frame number (default is 0) */
  81426. fromFrame: number;
  81427. /** defines the ending frame number (default is 100) */
  81428. toFrame: number;
  81429. /** defines if the animation must loop (default is false) */
  81430. loopAnimation: boolean;
  81431. /** defines a callback to call when animation ends if it is not looping */
  81432. onAnimationEnd?: (() => void) | null | undefined;
  81433. /** defines a callback to call when animation loops */
  81434. onAnimationLoop?: (() => void) | null | undefined;
  81435. private _localDelayOffset;
  81436. private _pausedDelay;
  81437. private _runtimeAnimations;
  81438. private _paused;
  81439. private _scene;
  81440. private _speedRatio;
  81441. private _weight;
  81442. private _syncRoot;
  81443. /**
  81444. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  81445. * This will only apply for non looping animation (default is true)
  81446. */
  81447. disposeOnEnd: boolean;
  81448. /**
  81449. * Gets a boolean indicating if the animation has started
  81450. */
  81451. animationStarted: boolean;
  81452. /**
  81453. * Observer raised when the animation ends
  81454. */
  81455. onAnimationEndObservable: Observable<Animatable>;
  81456. /**
  81457. * Observer raised when the animation loops
  81458. */
  81459. onAnimationLoopObservable: Observable<Animatable>;
  81460. /**
  81461. * Gets the root Animatable used to synchronize and normalize animations
  81462. */
  81463. readonly syncRoot: Nullable<Animatable>;
  81464. /**
  81465. * Gets the current frame of the first RuntimeAnimation
  81466. * Used to synchronize Animatables
  81467. */
  81468. readonly masterFrame: number;
  81469. /**
  81470. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  81471. */
  81472. weight: number;
  81473. /**
  81474. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  81475. */
  81476. speedRatio: number;
  81477. /**
  81478. * Creates a new Animatable
  81479. * @param scene defines the hosting scene
  81480. * @param target defines the target object
  81481. * @param fromFrame defines the starting frame number (default is 0)
  81482. * @param toFrame defines the ending frame number (default is 100)
  81483. * @param loopAnimation defines if the animation must loop (default is false)
  81484. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  81485. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  81486. * @param animations defines a group of animation to add to the new Animatable
  81487. * @param onAnimationLoop defines a callback to call when animation loops
  81488. */
  81489. constructor(scene: Scene,
  81490. /** defines the target object */
  81491. target: any,
  81492. /** defines the starting frame number (default is 0) */
  81493. fromFrame?: number,
  81494. /** defines the ending frame number (default is 100) */
  81495. toFrame?: number,
  81496. /** defines if the animation must loop (default is false) */
  81497. loopAnimation?: boolean, speedRatio?: number,
  81498. /** defines a callback to call when animation ends if it is not looping */
  81499. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  81500. /** defines a callback to call when animation loops */
  81501. onAnimationLoop?: (() => void) | null | undefined);
  81502. /**
  81503. * Synchronize and normalize current Animatable with a source Animatable
  81504. * This is useful when using animation weights and when animations are not of the same length
  81505. * @param root defines the root Animatable to synchronize with
  81506. * @returns the current Animatable
  81507. */
  81508. syncWith(root: Animatable): Animatable;
  81509. /**
  81510. * Gets the list of runtime animations
  81511. * @returns an array of RuntimeAnimation
  81512. */
  81513. getAnimations(): RuntimeAnimation[];
  81514. /**
  81515. * Adds more animations to the current animatable
  81516. * @param target defines the target of the animations
  81517. * @param animations defines the new animations to add
  81518. */
  81519. appendAnimations(target: any, animations: Animation[]): void;
  81520. /**
  81521. * Gets the source animation for a specific property
  81522. * @param property defines the propertyu to look for
  81523. * @returns null or the source animation for the given property
  81524. */
  81525. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  81526. /**
  81527. * Gets the runtime animation for a specific property
  81528. * @param property defines the propertyu to look for
  81529. * @returns null or the runtime animation for the given property
  81530. */
  81531. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  81532. /**
  81533. * Resets the animatable to its original state
  81534. */
  81535. reset(): void;
  81536. /**
  81537. * Allows the animatable to blend with current running animations
  81538. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81539. * @param blendingSpeed defines the blending speed to use
  81540. */
  81541. enableBlending(blendingSpeed: number): void;
  81542. /**
  81543. * Disable animation blending
  81544. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81545. */
  81546. disableBlending(): void;
  81547. /**
  81548. * Jump directly to a given frame
  81549. * @param frame defines the frame to jump to
  81550. */
  81551. goToFrame(frame: number): void;
  81552. /**
  81553. * Pause the animation
  81554. */
  81555. pause(): void;
  81556. /**
  81557. * Restart the animation
  81558. */
  81559. restart(): void;
  81560. private _raiseOnAnimationEnd;
  81561. /**
  81562. * Stop and delete the current animation
  81563. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  81564. * @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)
  81565. */
  81566. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  81567. /**
  81568. * Wait asynchronously for the animation to end
  81569. * @returns a promise which will be fullfilled when the animation ends
  81570. */
  81571. waitAsync(): Promise<Animatable>;
  81572. /** @hidden */
  81573. _animate(delay: number): boolean;
  81574. }
  81575. interface Scene {
  81576. /** @hidden */
  81577. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81578. /** @hidden */
  81579. _processLateAnimationBindingsForMatrices(holder: {
  81580. totalWeight: number;
  81581. animations: RuntimeAnimation[];
  81582. originalValue: Matrix;
  81583. }): any;
  81584. /** @hidden */
  81585. _processLateAnimationBindingsForQuaternions(holder: {
  81586. totalWeight: number;
  81587. animations: RuntimeAnimation[];
  81588. originalValue: Quaternion;
  81589. }, refQuaternion: Quaternion): Quaternion;
  81590. /** @hidden */
  81591. _processLateAnimationBindings(): void;
  81592. /**
  81593. * Will start the animation sequence of a given target
  81594. * @param target defines the target
  81595. * @param from defines from which frame should animation start
  81596. * @param to defines until which frame should animation run.
  81597. * @param weight defines the weight to apply to the animation (1.0 by default)
  81598. * @param loop defines if the animation loops
  81599. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81600. * @param onAnimationEnd defines the function to be executed when the animation ends
  81601. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81602. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81603. * @param onAnimationLoop defines the callback to call when an animation loops
  81604. * @returns the animatable object created for this animation
  81605. */
  81606. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81607. /**
  81608. * Will start the animation sequence of a given target
  81609. * @param target defines the target
  81610. * @param from defines from which frame should animation start
  81611. * @param to defines until which frame should animation run.
  81612. * @param loop defines if the animation loops
  81613. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81614. * @param onAnimationEnd defines the function to be executed when the animation ends
  81615. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81616. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81617. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81618. * @param onAnimationLoop defines the callback to call when an animation loops
  81619. * @returns the animatable object created for this animation
  81620. */
  81621. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81622. /**
  81623. * Will start the animation sequence of a given target and its hierarchy
  81624. * @param target defines the target
  81625. * @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.
  81626. * @param from defines from which frame should animation start
  81627. * @param to defines until which frame should animation run.
  81628. * @param loop defines if the animation loops
  81629. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81630. * @param onAnimationEnd defines the function to be executed when the animation ends
  81631. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81632. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81633. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81634. * @param onAnimationLoop defines the callback to call when an animation loops
  81635. * @returns the list of created animatables
  81636. */
  81637. 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[];
  81638. /**
  81639. * Begin a new animation on a given node
  81640. * @param target defines the target where the animation will take place
  81641. * @param animations defines the list of animations to start
  81642. * @param from defines the initial value
  81643. * @param to defines the final value
  81644. * @param loop defines if you want animation to loop (off by default)
  81645. * @param speedRatio defines the speed ratio to apply to all animations
  81646. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81647. * @param onAnimationLoop defines the callback to call when an animation loops
  81648. * @returns the list of created animatables
  81649. */
  81650. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81651. /**
  81652. * Begin a new animation on a given node and its hierarchy
  81653. * @param target defines the root node where the animation will take place
  81654. * @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.
  81655. * @param animations defines the list of animations to start
  81656. * @param from defines the initial value
  81657. * @param to defines the final value
  81658. * @param loop defines if you want animation to loop (off by default)
  81659. * @param speedRatio defines the speed ratio to apply to all animations
  81660. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81661. * @param onAnimationLoop defines the callback to call when an animation loops
  81662. * @returns the list of animatables created for all nodes
  81663. */
  81664. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81665. /**
  81666. * Gets the animatable associated with a specific target
  81667. * @param target defines the target of the animatable
  81668. * @returns the required animatable if found
  81669. */
  81670. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81671. /**
  81672. * Gets all animatables associated with a given target
  81673. * @param target defines the target to look animatables for
  81674. * @returns an array of Animatables
  81675. */
  81676. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81677. /**
  81678. * Stops and removes all animations that have been applied to the scene
  81679. */
  81680. stopAllAnimations(): void;
  81681. /**
  81682. * Gets the current delta time used by animation engine
  81683. */
  81684. deltaTime: number;
  81685. }
  81686. interface Bone {
  81687. /**
  81688. * Copy an animation range from another bone
  81689. * @param source defines the source bone
  81690. * @param rangeName defines the range name to copy
  81691. * @param frameOffset defines the frame offset
  81692. * @param rescaleAsRequired defines if rescaling must be applied if required
  81693. * @param skelDimensionsRatio defines the scaling ratio
  81694. * @returns true if operation was successful
  81695. */
  81696. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81697. }
  81698. }
  81699. declare module BABYLON {
  81700. /**
  81701. * Class used to override all child animations of a given target
  81702. */
  81703. export class AnimationPropertiesOverride {
  81704. /**
  81705. * Gets or sets a value indicating if animation blending must be used
  81706. */
  81707. enableBlending: boolean;
  81708. /**
  81709. * Gets or sets the blending speed to use when enableBlending is true
  81710. */
  81711. blendingSpeed: number;
  81712. /**
  81713. * Gets or sets the default loop mode to use
  81714. */
  81715. loopMode: number;
  81716. }
  81717. }
  81718. declare module BABYLON {
  81719. /**
  81720. * Class used to handle skinning animations
  81721. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81722. */
  81723. export class Skeleton implements IAnimatable {
  81724. /** defines the skeleton name */
  81725. name: string;
  81726. /** defines the skeleton Id */
  81727. id: string;
  81728. /**
  81729. * Defines the list of child bones
  81730. */
  81731. bones: Bone[];
  81732. /**
  81733. * Defines an estimate of the dimension of the skeleton at rest
  81734. */
  81735. dimensionsAtRest: Vector3;
  81736. /**
  81737. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81738. */
  81739. needInitialSkinMatrix: boolean;
  81740. /**
  81741. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81742. */
  81743. overrideMesh: Nullable<AbstractMesh>;
  81744. /**
  81745. * Gets the list of animations attached to this skeleton
  81746. */
  81747. animations: Array<Animation>;
  81748. private _scene;
  81749. private _isDirty;
  81750. private _transformMatrices;
  81751. private _transformMatrixTexture;
  81752. private _meshesWithPoseMatrix;
  81753. private _animatables;
  81754. private _identity;
  81755. private _synchronizedWithMesh;
  81756. private _ranges;
  81757. private _lastAbsoluteTransformsUpdateId;
  81758. private _canUseTextureForBones;
  81759. private _uniqueId;
  81760. /** @hidden */
  81761. _numBonesWithLinkedTransformNode: number;
  81762. /** @hidden */
  81763. _hasWaitingData: Nullable<boolean>;
  81764. /**
  81765. * Specifies if the skeleton should be serialized
  81766. */
  81767. doNotSerialize: boolean;
  81768. private _useTextureToStoreBoneMatrices;
  81769. /**
  81770. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81771. * Please note that this option is not available if the hardware does not support it
  81772. */
  81773. useTextureToStoreBoneMatrices: boolean;
  81774. private _animationPropertiesOverride;
  81775. /**
  81776. * Gets or sets the animation properties override
  81777. */
  81778. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81779. /**
  81780. * List of inspectable custom properties (used by the Inspector)
  81781. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81782. */
  81783. inspectableCustomProperties: IInspectable[];
  81784. /**
  81785. * An observable triggered before computing the skeleton's matrices
  81786. */
  81787. onBeforeComputeObservable: Observable<Skeleton>;
  81788. /**
  81789. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81790. */
  81791. readonly isUsingTextureForMatrices: boolean;
  81792. /**
  81793. * Gets the unique ID of this skeleton
  81794. */
  81795. readonly uniqueId: number;
  81796. /**
  81797. * Creates a new skeleton
  81798. * @param name defines the skeleton name
  81799. * @param id defines the skeleton Id
  81800. * @param scene defines the hosting scene
  81801. */
  81802. constructor(
  81803. /** defines the skeleton name */
  81804. name: string,
  81805. /** defines the skeleton Id */
  81806. id: string, scene: Scene);
  81807. /**
  81808. * Gets the current object class name.
  81809. * @return the class name
  81810. */
  81811. getClassName(): string;
  81812. /**
  81813. * Returns an array containing the root bones
  81814. * @returns an array containing the root bones
  81815. */
  81816. getChildren(): Array<Bone>;
  81817. /**
  81818. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81819. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81820. * @returns a Float32Array containing matrices data
  81821. */
  81822. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81823. /**
  81824. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81825. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81826. * @returns a raw texture containing the data
  81827. */
  81828. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  81829. /**
  81830. * Gets the current hosting scene
  81831. * @returns a scene object
  81832. */
  81833. getScene(): Scene;
  81834. /**
  81835. * Gets a string representing the current skeleton data
  81836. * @param fullDetails defines a boolean indicating if we want a verbose version
  81837. * @returns a string representing the current skeleton data
  81838. */
  81839. toString(fullDetails?: boolean): string;
  81840. /**
  81841. * Get bone's index searching by name
  81842. * @param name defines bone's name to search for
  81843. * @return the indice of the bone. Returns -1 if not found
  81844. */
  81845. getBoneIndexByName(name: string): number;
  81846. /**
  81847. * Creater a new animation range
  81848. * @param name defines the name of the range
  81849. * @param from defines the start key
  81850. * @param to defines the end key
  81851. */
  81852. createAnimationRange(name: string, from: number, to: number): void;
  81853. /**
  81854. * Delete a specific animation range
  81855. * @param name defines the name of the range
  81856. * @param deleteFrames defines if frames must be removed as well
  81857. */
  81858. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81859. /**
  81860. * Gets a specific animation range
  81861. * @param name defines the name of the range to look for
  81862. * @returns the requested animation range or null if not found
  81863. */
  81864. getAnimationRange(name: string): Nullable<AnimationRange>;
  81865. /**
  81866. * Gets the list of all animation ranges defined on this skeleton
  81867. * @returns an array
  81868. */
  81869. getAnimationRanges(): Nullable<AnimationRange>[];
  81870. /**
  81871. * Copy animation range from a source skeleton.
  81872. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81873. * @param source defines the source skeleton
  81874. * @param name defines the name of the range to copy
  81875. * @param rescaleAsRequired defines if rescaling must be applied if required
  81876. * @returns true if operation was successful
  81877. */
  81878. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81879. /**
  81880. * Forces the skeleton to go to rest pose
  81881. */
  81882. returnToRest(): void;
  81883. private _getHighestAnimationFrame;
  81884. /**
  81885. * Begin a specific animation range
  81886. * @param name defines the name of the range to start
  81887. * @param loop defines if looping must be turned on (false by default)
  81888. * @param speedRatio defines the speed ratio to apply (1 by default)
  81889. * @param onAnimationEnd defines a callback which will be called when animation will end
  81890. * @returns a new animatable
  81891. */
  81892. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81893. /** @hidden */
  81894. _markAsDirty(): void;
  81895. /** @hidden */
  81896. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81897. /** @hidden */
  81898. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81899. private _computeTransformMatrices;
  81900. /**
  81901. * Build all resources required to render a skeleton
  81902. */
  81903. prepare(): void;
  81904. /**
  81905. * Gets the list of animatables currently running for this skeleton
  81906. * @returns an array of animatables
  81907. */
  81908. getAnimatables(): IAnimatable[];
  81909. /**
  81910. * Clone the current skeleton
  81911. * @param name defines the name of the new skeleton
  81912. * @param id defines the id of the new skeleton
  81913. * @returns the new skeleton
  81914. */
  81915. clone(name: string, id?: string): Skeleton;
  81916. /**
  81917. * Enable animation blending for this skeleton
  81918. * @param blendingSpeed defines the blending speed to apply
  81919. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81920. */
  81921. enableBlending(blendingSpeed?: number): void;
  81922. /**
  81923. * Releases all resources associated with the current skeleton
  81924. */
  81925. dispose(): void;
  81926. /**
  81927. * Serialize the skeleton in a JSON object
  81928. * @returns a JSON object
  81929. */
  81930. serialize(): any;
  81931. /**
  81932. * Creates a new skeleton from serialized data
  81933. * @param parsedSkeleton defines the serialized data
  81934. * @param scene defines the hosting scene
  81935. * @returns a new skeleton
  81936. */
  81937. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81938. /**
  81939. * Compute all node absolute transforms
  81940. * @param forceUpdate defines if computation must be done even if cache is up to date
  81941. */
  81942. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81943. /**
  81944. * Gets the root pose matrix
  81945. * @returns a matrix
  81946. */
  81947. getPoseMatrix(): Nullable<Matrix>;
  81948. /**
  81949. * Sorts bones per internal index
  81950. */
  81951. sortBones(): void;
  81952. private _sortBones;
  81953. }
  81954. }
  81955. declare module BABYLON {
  81956. /**
  81957. * Class used to store bone information
  81958. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81959. */
  81960. export class Bone extends Node {
  81961. /**
  81962. * defines the bone name
  81963. */
  81964. name: string;
  81965. private static _tmpVecs;
  81966. private static _tmpQuat;
  81967. private static _tmpMats;
  81968. /**
  81969. * Gets the list of child bones
  81970. */
  81971. children: Bone[];
  81972. /** Gets the animations associated with this bone */
  81973. animations: Animation[];
  81974. /**
  81975. * Gets or sets bone length
  81976. */
  81977. length: number;
  81978. /**
  81979. * @hidden Internal only
  81980. * Set this value to map this bone to a different index in the transform matrices
  81981. * Set this value to -1 to exclude the bone from the transform matrices
  81982. */
  81983. _index: Nullable<number>;
  81984. private _skeleton;
  81985. private _localMatrix;
  81986. private _restPose;
  81987. private _baseMatrix;
  81988. private _absoluteTransform;
  81989. private _invertedAbsoluteTransform;
  81990. private _parent;
  81991. private _scalingDeterminant;
  81992. private _worldTransform;
  81993. private _localScaling;
  81994. private _localRotation;
  81995. private _localPosition;
  81996. private _needToDecompose;
  81997. private _needToCompose;
  81998. /** @hidden */
  81999. _linkedTransformNode: Nullable<TransformNode>;
  82000. /** @hidden */
  82001. _waitingTransformNodeId: Nullable<string>;
  82002. /** @hidden */
  82003. /** @hidden */
  82004. _matrix: Matrix;
  82005. /**
  82006. * Create a new bone
  82007. * @param name defines the bone name
  82008. * @param skeleton defines the parent skeleton
  82009. * @param parentBone defines the parent (can be null if the bone is the root)
  82010. * @param localMatrix defines the local matrix
  82011. * @param restPose defines the rest pose matrix
  82012. * @param baseMatrix defines the base matrix
  82013. * @param index defines index of the bone in the hiearchy
  82014. */
  82015. constructor(
  82016. /**
  82017. * defines the bone name
  82018. */
  82019. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  82020. /**
  82021. * Gets the current object class name.
  82022. * @return the class name
  82023. */
  82024. getClassName(): string;
  82025. /**
  82026. * Gets the parent skeleton
  82027. * @returns a skeleton
  82028. */
  82029. getSkeleton(): Skeleton;
  82030. /**
  82031. * Gets parent bone
  82032. * @returns a bone or null if the bone is the root of the bone hierarchy
  82033. */
  82034. getParent(): Nullable<Bone>;
  82035. /**
  82036. * Returns an array containing the root bones
  82037. * @returns an array containing the root bones
  82038. */
  82039. getChildren(): Array<Bone>;
  82040. /**
  82041. * Gets the node index in matrix array generated for rendering
  82042. * @returns the node index
  82043. */
  82044. getIndex(): number;
  82045. /**
  82046. * Sets the parent bone
  82047. * @param parent defines the parent (can be null if the bone is the root)
  82048. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82049. */
  82050. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  82051. /**
  82052. * Gets the local matrix
  82053. * @returns a matrix
  82054. */
  82055. getLocalMatrix(): Matrix;
  82056. /**
  82057. * Gets the base matrix (initial matrix which remains unchanged)
  82058. * @returns a matrix
  82059. */
  82060. getBaseMatrix(): Matrix;
  82061. /**
  82062. * Gets the rest pose matrix
  82063. * @returns a matrix
  82064. */
  82065. getRestPose(): Matrix;
  82066. /**
  82067. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  82068. */
  82069. getWorldMatrix(): Matrix;
  82070. /**
  82071. * Sets the local matrix to rest pose matrix
  82072. */
  82073. returnToRest(): void;
  82074. /**
  82075. * Gets the inverse of the absolute transform matrix.
  82076. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  82077. * @returns a matrix
  82078. */
  82079. getInvertedAbsoluteTransform(): Matrix;
  82080. /**
  82081. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  82082. * @returns a matrix
  82083. */
  82084. getAbsoluteTransform(): Matrix;
  82085. /**
  82086. * Links with the given transform node.
  82087. * The local matrix of this bone is copied from the transform node every frame.
  82088. * @param transformNode defines the transform node to link to
  82089. */
  82090. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  82091. /**
  82092. * Gets the node used to drive the bone's transformation
  82093. * @returns a transform node or null
  82094. */
  82095. getTransformNode(): Nullable<TransformNode>;
  82096. /** Gets or sets current position (in local space) */
  82097. position: Vector3;
  82098. /** Gets or sets current rotation (in local space) */
  82099. rotation: Vector3;
  82100. /** Gets or sets current rotation quaternion (in local space) */
  82101. rotationQuaternion: Quaternion;
  82102. /** Gets or sets current scaling (in local space) */
  82103. scaling: Vector3;
  82104. /**
  82105. * Gets the animation properties override
  82106. */
  82107. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82108. private _decompose;
  82109. private _compose;
  82110. /**
  82111. * Update the base and local matrices
  82112. * @param matrix defines the new base or local matrix
  82113. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  82114. * @param updateLocalMatrix defines if the local matrix should be updated
  82115. */
  82116. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  82117. /** @hidden */
  82118. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  82119. /**
  82120. * Flag the bone as dirty (Forcing it to update everything)
  82121. */
  82122. markAsDirty(): void;
  82123. /** @hidden */
  82124. _markAsDirtyAndCompose(): void;
  82125. private _markAsDirtyAndDecompose;
  82126. /**
  82127. * Translate the bone in local or world space
  82128. * @param vec The amount to translate the bone
  82129. * @param space The space that the translation is in
  82130. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82131. */
  82132. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82133. /**
  82134. * Set the postion of the bone in local or world space
  82135. * @param position The position to set the bone
  82136. * @param space The space that the position is in
  82137. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82138. */
  82139. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82140. /**
  82141. * Set the absolute position of the bone (world space)
  82142. * @param position The position to set the bone
  82143. * @param mesh The mesh that this bone is attached to
  82144. */
  82145. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  82146. /**
  82147. * Scale the bone on the x, y and z axes (in local space)
  82148. * @param x The amount to scale the bone on the x axis
  82149. * @param y The amount to scale the bone on the y axis
  82150. * @param z The amount to scale the bone on the z axis
  82151. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  82152. */
  82153. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  82154. /**
  82155. * Set the bone scaling in local space
  82156. * @param scale defines the scaling vector
  82157. */
  82158. setScale(scale: Vector3): void;
  82159. /**
  82160. * Gets the current scaling in local space
  82161. * @returns the current scaling vector
  82162. */
  82163. getScale(): Vector3;
  82164. /**
  82165. * Gets the current scaling in local space and stores it in a target vector
  82166. * @param result defines the target vector
  82167. */
  82168. getScaleToRef(result: Vector3): void;
  82169. /**
  82170. * Set the yaw, pitch, and roll of the bone in local or world space
  82171. * @param yaw The rotation of the bone on the y axis
  82172. * @param pitch The rotation of the bone on the x axis
  82173. * @param roll The rotation of the bone on the z axis
  82174. * @param space The space that the axes of rotation are in
  82175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82176. */
  82177. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  82178. /**
  82179. * Add a rotation to the bone on an axis in local or world space
  82180. * @param axis The axis to rotate the bone on
  82181. * @param amount The amount to rotate the bone
  82182. * @param space The space that the axis is in
  82183. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82184. */
  82185. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  82186. /**
  82187. * Set the rotation of the bone to a particular axis angle in local or world space
  82188. * @param axis The axis to rotate the bone on
  82189. * @param angle The angle that the bone should be rotated to
  82190. * @param space The space that the axis is in
  82191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82192. */
  82193. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  82194. /**
  82195. * Set the euler rotation of the bone in local of world space
  82196. * @param rotation The euler rotation that the bone should be set to
  82197. * @param space The space that the rotation is in
  82198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82199. */
  82200. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  82201. /**
  82202. * Set the quaternion rotation of the bone in local of world space
  82203. * @param quat The quaternion rotation that the bone should be set to
  82204. * @param space The space that the rotation is in
  82205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82206. */
  82207. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  82208. /**
  82209. * Set the rotation matrix of the bone in local of world space
  82210. * @param rotMat The rotation matrix that the bone should be set to
  82211. * @param space The space that the rotation is in
  82212. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82213. */
  82214. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  82215. private _rotateWithMatrix;
  82216. private _getNegativeRotationToRef;
  82217. /**
  82218. * Get the position of the bone in local or world space
  82219. * @param space The space that the returned position is in
  82220. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82221. * @returns The position of the bone
  82222. */
  82223. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82224. /**
  82225. * Copy the position of the bone to a vector3 in local or world space
  82226. * @param space The space that the returned position is in
  82227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82228. * @param result The vector3 to copy the position to
  82229. */
  82230. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  82231. /**
  82232. * Get the absolute position of the bone (world space)
  82233. * @param mesh The mesh that this bone is attached to
  82234. * @returns The absolute position of the bone
  82235. */
  82236. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  82237. /**
  82238. * Copy the absolute position of the bone (world space) to the result param
  82239. * @param mesh The mesh that this bone is attached to
  82240. * @param result The vector3 to copy the absolute position to
  82241. */
  82242. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  82243. /**
  82244. * Compute the absolute transforms of this bone and its children
  82245. */
  82246. computeAbsoluteTransforms(): void;
  82247. /**
  82248. * Get the world direction from an axis that is in the local space of the bone
  82249. * @param localAxis The local direction that is used to compute the world direction
  82250. * @param mesh The mesh that this bone is attached to
  82251. * @returns The world direction
  82252. */
  82253. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82254. /**
  82255. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  82256. * @param localAxis The local direction that is used to compute the world direction
  82257. * @param mesh The mesh that this bone is attached to
  82258. * @param result The vector3 that the world direction will be copied to
  82259. */
  82260. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82261. /**
  82262. * Get the euler rotation of the bone in local or world space
  82263. * @param space The space that the rotation should be in
  82264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82265. * @returns The euler rotation
  82266. */
  82267. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  82268. /**
  82269. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  82270. * @param space The space that the rotation should be in
  82271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82272. * @param result The vector3 that the rotation should be copied to
  82273. */
  82274. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82275. /**
  82276. * Get the quaternion rotation of the bone in either local or world space
  82277. * @param space The space that the rotation should be in
  82278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82279. * @returns The quaternion rotation
  82280. */
  82281. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  82282. /**
  82283. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  82284. * @param space The space that the rotation should be in
  82285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82286. * @param result The quaternion that the rotation should be copied to
  82287. */
  82288. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  82289. /**
  82290. * Get the rotation matrix of the bone in local or world space
  82291. * @param space The space that the rotation should be in
  82292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82293. * @returns The rotation matrix
  82294. */
  82295. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  82296. /**
  82297. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  82298. * @param space The space that the rotation should be in
  82299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  82300. * @param result The quaternion that the rotation should be copied to
  82301. */
  82302. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  82303. /**
  82304. * Get the world position of a point that is in the local space of the bone
  82305. * @param position The local position
  82306. * @param mesh The mesh that this bone is attached to
  82307. * @returns The world position
  82308. */
  82309. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82310. /**
  82311. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  82312. * @param position The local position
  82313. * @param mesh The mesh that this bone is attached to
  82314. * @param result The vector3 that the world position should be copied to
  82315. */
  82316. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82317. /**
  82318. * Get the local position of a point that is in world space
  82319. * @param position The world position
  82320. * @param mesh The mesh that this bone is attached to
  82321. * @returns The local position
  82322. */
  82323. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  82324. /**
  82325. * Get the local position of a point that is in world space and copy it to the result param
  82326. * @param position The world position
  82327. * @param mesh The mesh that this bone is attached to
  82328. * @param result The vector3 that the local position should be copied to
  82329. */
  82330. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  82331. }
  82332. }
  82333. declare module BABYLON {
  82334. /**
  82335. * 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.
  82336. * @see https://doc.babylonjs.com/how_to/transformnode
  82337. */
  82338. export class TransformNode extends Node {
  82339. /**
  82340. * Object will not rotate to face the camera
  82341. */
  82342. static BILLBOARDMODE_NONE: number;
  82343. /**
  82344. * Object will rotate to face the camera but only on the x axis
  82345. */
  82346. static BILLBOARDMODE_X: number;
  82347. /**
  82348. * Object will rotate to face the camera but only on the y axis
  82349. */
  82350. static BILLBOARDMODE_Y: number;
  82351. /**
  82352. * Object will rotate to face the camera but only on the z axis
  82353. */
  82354. static BILLBOARDMODE_Z: number;
  82355. /**
  82356. * Object will rotate to face the camera
  82357. */
  82358. static BILLBOARDMODE_ALL: number;
  82359. /**
  82360. * Object will rotate to face the camera's position instead of orientation
  82361. */
  82362. static BILLBOARDMODE_USE_POSITION: number;
  82363. private _forward;
  82364. private _forwardInverted;
  82365. private _up;
  82366. private _right;
  82367. private _rightInverted;
  82368. private _position;
  82369. private _rotation;
  82370. private _rotationQuaternion;
  82371. protected _scaling: Vector3;
  82372. protected _isDirty: boolean;
  82373. private _transformToBoneReferal;
  82374. private _isAbsoluteSynced;
  82375. private _billboardMode;
  82376. /**
  82377. * Gets or sets the billboard mode. Default is 0.
  82378. *
  82379. * | Value | Type | Description |
  82380. * | --- | --- | --- |
  82381. * | 0 | BILLBOARDMODE_NONE | |
  82382. * | 1 | BILLBOARDMODE_X | |
  82383. * | 2 | BILLBOARDMODE_Y | |
  82384. * | 4 | BILLBOARDMODE_Z | |
  82385. * | 7 | BILLBOARDMODE_ALL | |
  82386. *
  82387. */
  82388. billboardMode: number;
  82389. private _preserveParentRotationForBillboard;
  82390. /**
  82391. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  82392. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  82393. */
  82394. preserveParentRotationForBillboard: boolean;
  82395. /**
  82396. * 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
  82397. */
  82398. scalingDeterminant: number;
  82399. private _infiniteDistance;
  82400. /**
  82401. * Gets or sets the distance of the object to max, often used by skybox
  82402. */
  82403. infiniteDistance: boolean;
  82404. /**
  82405. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  82406. * By default the system will update normals to compensate
  82407. */
  82408. ignoreNonUniformScaling: boolean;
  82409. /**
  82410. * 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
  82411. */
  82412. reIntegrateRotationIntoRotationQuaternion: boolean;
  82413. /** @hidden */
  82414. _poseMatrix: Nullable<Matrix>;
  82415. /** @hidden */
  82416. _localMatrix: Matrix;
  82417. private _usePivotMatrix;
  82418. private _absolutePosition;
  82419. private _absoluteScaling;
  82420. private _absoluteRotationQuaternion;
  82421. private _pivotMatrix;
  82422. private _pivotMatrixInverse;
  82423. protected _postMultiplyPivotMatrix: boolean;
  82424. protected _isWorldMatrixFrozen: boolean;
  82425. /** @hidden */
  82426. _indexInSceneTransformNodesArray: number;
  82427. /**
  82428. * An event triggered after the world matrix is updated
  82429. */
  82430. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  82431. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  82432. /**
  82433. * Gets a string identifying the name of the class
  82434. * @returns "TransformNode" string
  82435. */
  82436. getClassName(): string;
  82437. /**
  82438. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  82439. */
  82440. position: Vector3;
  82441. /**
  82442. * 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)).
  82443. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  82444. */
  82445. rotation: Vector3;
  82446. /**
  82447. * 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)).
  82448. */
  82449. scaling: Vector3;
  82450. /**
  82451. * 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).
  82452. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  82453. */
  82454. rotationQuaternion: Nullable<Quaternion>;
  82455. /**
  82456. * The forward direction of that transform in world space.
  82457. */
  82458. readonly forward: Vector3;
  82459. /**
  82460. * The up direction of that transform in world space.
  82461. */
  82462. readonly up: Vector3;
  82463. /**
  82464. * The right direction of that transform in world space.
  82465. */
  82466. readonly right: Vector3;
  82467. /**
  82468. * Copies the parameter passed Matrix into the mesh Pose matrix.
  82469. * @param matrix the matrix to copy the pose from
  82470. * @returns this TransformNode.
  82471. */
  82472. updatePoseMatrix(matrix: Matrix): TransformNode;
  82473. /**
  82474. * Returns the mesh Pose matrix.
  82475. * @returns the pose matrix
  82476. */
  82477. getPoseMatrix(): Matrix;
  82478. /** @hidden */
  82479. _isSynchronized(): boolean;
  82480. /** @hidden */
  82481. _initCache(): void;
  82482. /**
  82483. * Flag the transform node as dirty (Forcing it to update everything)
  82484. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  82485. * @returns this transform node
  82486. */
  82487. markAsDirty(property: string): TransformNode;
  82488. /**
  82489. * Returns the current mesh absolute position.
  82490. * Returns a Vector3.
  82491. */
  82492. readonly absolutePosition: Vector3;
  82493. /**
  82494. * Returns the current mesh absolute scaling.
  82495. * Returns a Vector3.
  82496. */
  82497. readonly absoluteScaling: Vector3;
  82498. /**
  82499. * Returns the current mesh absolute rotation.
  82500. * Returns a Quaternion.
  82501. */
  82502. readonly absoluteRotationQuaternion: Quaternion;
  82503. /**
  82504. * Sets a new matrix to apply before all other transformation
  82505. * @param matrix defines the transform matrix
  82506. * @returns the current TransformNode
  82507. */
  82508. setPreTransformMatrix(matrix: Matrix): TransformNode;
  82509. /**
  82510. * Sets a new pivot matrix to the current node
  82511. * @param matrix defines the new pivot matrix to use
  82512. * @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
  82513. * @returns the current TransformNode
  82514. */
  82515. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  82516. /**
  82517. * Returns the mesh pivot matrix.
  82518. * Default : Identity.
  82519. * @returns the matrix
  82520. */
  82521. getPivotMatrix(): Matrix;
  82522. /**
  82523. * Instantiate (when possible) or clone that node with its hierarchy
  82524. * @param newParent defines the new parent to use for the instance (or clone)
  82525. * @param options defines options to configure how copy is done
  82526. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  82527. * @returns an instance (or a clone) of the current node with its hiearchy
  82528. */
  82529. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  82530. doNotInstantiate: boolean;
  82531. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  82532. /**
  82533. * Prevents the World matrix to be computed any longer
  82534. * @param newWorldMatrix defines an optional matrix to use as world matrix
  82535. * @returns the TransformNode.
  82536. */
  82537. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  82538. /**
  82539. * Allows back the World matrix computation.
  82540. * @returns the TransformNode.
  82541. */
  82542. unfreezeWorldMatrix(): this;
  82543. /**
  82544. * True if the World matrix has been frozen.
  82545. */
  82546. readonly isWorldMatrixFrozen: boolean;
  82547. /**
  82548. * Retuns the mesh absolute position in the World.
  82549. * @returns a Vector3.
  82550. */
  82551. getAbsolutePosition(): Vector3;
  82552. /**
  82553. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  82554. * @param absolutePosition the absolute position to set
  82555. * @returns the TransformNode.
  82556. */
  82557. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82558. /**
  82559. * Sets the mesh position in its local space.
  82560. * @param vector3 the position to set in localspace
  82561. * @returns the TransformNode.
  82562. */
  82563. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  82564. /**
  82565. * Returns the mesh position in the local space from the current World matrix values.
  82566. * @returns a new Vector3.
  82567. */
  82568. getPositionExpressedInLocalSpace(): Vector3;
  82569. /**
  82570. * Translates the mesh along the passed Vector3 in its local space.
  82571. * @param vector3 the distance to translate in localspace
  82572. * @returns the TransformNode.
  82573. */
  82574. locallyTranslate(vector3: Vector3): TransformNode;
  82575. private static _lookAtVectorCache;
  82576. /**
  82577. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  82578. * @param targetPoint the position (must be in same space as current mesh) to look at
  82579. * @param yawCor optional yaw (y-axis) correction in radians
  82580. * @param pitchCor optional pitch (x-axis) correction in radians
  82581. * @param rollCor optional roll (z-axis) correction in radians
  82582. * @param space the choosen space of the target
  82583. * @returns the TransformNode.
  82584. */
  82585. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  82586. /**
  82587. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82588. * This Vector3 is expressed in the World space.
  82589. * @param localAxis axis to rotate
  82590. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  82591. */
  82592. getDirection(localAxis: Vector3): Vector3;
  82593. /**
  82594. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  82595. * localAxis is expressed in the mesh local space.
  82596. * result is computed in the Wordl space from the mesh World matrix.
  82597. * @param localAxis axis to rotate
  82598. * @param result the resulting transformnode
  82599. * @returns this TransformNode.
  82600. */
  82601. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  82602. /**
  82603. * Sets this transform node rotation to the given local axis.
  82604. * @param localAxis the axis in local space
  82605. * @param yawCor optional yaw (y-axis) correction in radians
  82606. * @param pitchCor optional pitch (x-axis) correction in radians
  82607. * @param rollCor optional roll (z-axis) correction in radians
  82608. * @returns this TransformNode
  82609. */
  82610. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  82611. /**
  82612. * Sets a new pivot point to the current node
  82613. * @param point defines the new pivot point to use
  82614. * @param space defines if the point is in world or local space (local by default)
  82615. * @returns the current TransformNode
  82616. */
  82617. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  82618. /**
  82619. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  82620. * @returns the pivot point
  82621. */
  82622. getPivotPoint(): Vector3;
  82623. /**
  82624. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  82625. * @param result the vector3 to store the result
  82626. * @returns this TransformNode.
  82627. */
  82628. getPivotPointToRef(result: Vector3): TransformNode;
  82629. /**
  82630. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  82631. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  82632. */
  82633. getAbsolutePivotPoint(): Vector3;
  82634. /**
  82635. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  82636. * @param result vector3 to store the result
  82637. * @returns this TransformNode.
  82638. */
  82639. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  82640. /**
  82641. * Defines the passed node as the parent of the current node.
  82642. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  82643. * @see https://doc.babylonjs.com/how_to/parenting
  82644. * @param node the node ot set as the parent
  82645. * @returns this TransformNode.
  82646. */
  82647. setParent(node: Nullable<Node>): TransformNode;
  82648. private _nonUniformScaling;
  82649. /**
  82650. * True if the scaling property of this object is non uniform eg. (1,2,1)
  82651. */
  82652. readonly nonUniformScaling: boolean;
  82653. /** @hidden */
  82654. _updateNonUniformScalingState(value: boolean): boolean;
  82655. /**
  82656. * Attach the current TransformNode to another TransformNode associated with a bone
  82657. * @param bone Bone affecting the TransformNode
  82658. * @param affectedTransformNode TransformNode associated with the bone
  82659. * @returns this object
  82660. */
  82661. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  82662. /**
  82663. * Detach the transform node if its associated with a bone
  82664. * @returns this object
  82665. */
  82666. detachFromBone(): TransformNode;
  82667. private static _rotationAxisCache;
  82668. /**
  82669. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  82670. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82671. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82672. * The passed axis is also normalized.
  82673. * @param axis the axis to rotate around
  82674. * @param amount the amount to rotate in radians
  82675. * @param space Space to rotate in (Default: local)
  82676. * @returns the TransformNode.
  82677. */
  82678. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82679. /**
  82680. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  82681. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  82682. * The passed axis is also normalized. .
  82683. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  82684. * @param point the point to rotate around
  82685. * @param axis the axis to rotate around
  82686. * @param amount the amount to rotate in radians
  82687. * @returns the TransformNode
  82688. */
  82689. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  82690. /**
  82691. * Translates the mesh along the axis vector for the passed distance in the given space.
  82692. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  82693. * @param axis the axis to translate in
  82694. * @param distance the distance to translate
  82695. * @param space Space to rotate in (Default: local)
  82696. * @returns the TransformNode.
  82697. */
  82698. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82699. /**
  82700. * Adds a rotation step to the mesh current rotation.
  82701. * x, y, z are Euler angles expressed in radians.
  82702. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  82703. * This means this rotation is made in the mesh local space only.
  82704. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  82705. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  82706. * ```javascript
  82707. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  82708. * ```
  82709. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  82710. * 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.
  82711. * @param x Rotation to add
  82712. * @param y Rotation to add
  82713. * @param z Rotation to add
  82714. * @returns the TransformNode.
  82715. */
  82716. addRotation(x: number, y: number, z: number): TransformNode;
  82717. /**
  82718. * @hidden
  82719. */
  82720. protected _getEffectiveParent(): Nullable<Node>;
  82721. /**
  82722. * Computes the world matrix of the node
  82723. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82724. * @returns the world matrix
  82725. */
  82726. computeWorldMatrix(force?: boolean): Matrix;
  82727. protected _afterComputeWorldMatrix(): void;
  82728. /**
  82729. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  82730. * @param func callback function to add
  82731. *
  82732. * @returns the TransformNode.
  82733. */
  82734. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82735. /**
  82736. * Removes a registered callback function.
  82737. * @param func callback function to remove
  82738. * @returns the TransformNode.
  82739. */
  82740. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  82741. /**
  82742. * Gets the position of the current mesh in camera space
  82743. * @param camera defines the camera to use
  82744. * @returns a position
  82745. */
  82746. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  82747. /**
  82748. * Returns the distance from the mesh to the active camera
  82749. * @param camera defines the camera to use
  82750. * @returns the distance
  82751. */
  82752. getDistanceToCamera(camera?: Nullable<Camera>): number;
  82753. /**
  82754. * Clone the current transform node
  82755. * @param name Name of the new clone
  82756. * @param newParent New parent for the clone
  82757. * @param doNotCloneChildren Do not clone children hierarchy
  82758. * @returns the new transform node
  82759. */
  82760. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  82761. /**
  82762. * Serializes the objects information.
  82763. * @param currentSerializationObject defines the object to serialize in
  82764. * @returns the serialized object
  82765. */
  82766. serialize(currentSerializationObject?: any): any;
  82767. /**
  82768. * Returns a new TransformNode object parsed from the source provided.
  82769. * @param parsedTransformNode is the source.
  82770. * @param scene the scne the object belongs to
  82771. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  82772. * @returns a new TransformNode object parsed from the source provided.
  82773. */
  82774. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  82775. /**
  82776. * Get all child-transformNodes of this node
  82777. * @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
  82778. * @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
  82779. * @returns an array of TransformNode
  82780. */
  82781. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  82782. /**
  82783. * Releases resources associated with this transform node.
  82784. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82785. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82786. */
  82787. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82788. /**
  82789. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82790. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82791. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82792. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  82793. * @returns the current mesh
  82794. */
  82795. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  82796. private _syncAbsoluteScalingAndRotation;
  82797. }
  82798. }
  82799. declare module BABYLON {
  82800. /**
  82801. * Defines the types of pose enabled controllers that are supported
  82802. */
  82803. export enum PoseEnabledControllerType {
  82804. /**
  82805. * HTC Vive
  82806. */
  82807. VIVE = 0,
  82808. /**
  82809. * Oculus Rift
  82810. */
  82811. OCULUS = 1,
  82812. /**
  82813. * Windows mixed reality
  82814. */
  82815. WINDOWS = 2,
  82816. /**
  82817. * Samsung gear VR
  82818. */
  82819. GEAR_VR = 3,
  82820. /**
  82821. * Google Daydream
  82822. */
  82823. DAYDREAM = 4,
  82824. /**
  82825. * Generic
  82826. */
  82827. GENERIC = 5
  82828. }
  82829. /**
  82830. * Defines the MutableGamepadButton interface for the state of a gamepad button
  82831. */
  82832. export interface MutableGamepadButton {
  82833. /**
  82834. * Value of the button/trigger
  82835. */
  82836. value: number;
  82837. /**
  82838. * If the button/trigger is currently touched
  82839. */
  82840. touched: boolean;
  82841. /**
  82842. * If the button/trigger is currently pressed
  82843. */
  82844. pressed: boolean;
  82845. }
  82846. /**
  82847. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  82848. * @hidden
  82849. */
  82850. export interface ExtendedGamepadButton extends GamepadButton {
  82851. /**
  82852. * If the button/trigger is currently pressed
  82853. */
  82854. readonly pressed: boolean;
  82855. /**
  82856. * If the button/trigger is currently touched
  82857. */
  82858. readonly touched: boolean;
  82859. /**
  82860. * Value of the button/trigger
  82861. */
  82862. readonly value: number;
  82863. }
  82864. /** @hidden */
  82865. export interface _GamePadFactory {
  82866. /**
  82867. * Returns wether or not the current gamepad can be created for this type of controller.
  82868. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82869. * @returns true if it can be created, otherwise false
  82870. */
  82871. canCreate(gamepadInfo: any): boolean;
  82872. /**
  82873. * Creates a new instance of the Gamepad.
  82874. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  82875. * @returns the new gamepad instance
  82876. */
  82877. create(gamepadInfo: any): Gamepad;
  82878. }
  82879. /**
  82880. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82881. */
  82882. export class PoseEnabledControllerHelper {
  82883. /** @hidden */
  82884. static _ControllerFactories: _GamePadFactory[];
  82885. /** @hidden */
  82886. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  82887. /**
  82888. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  82889. * @param vrGamepad the gamepad to initialized
  82890. * @returns a vr controller of the type the gamepad identified as
  82891. */
  82892. static InitiateController(vrGamepad: any): Gamepad;
  82893. }
  82894. /**
  82895. * Defines the PoseEnabledController object that contains state of a vr capable controller
  82896. */
  82897. export class PoseEnabledController extends Gamepad implements PoseControlled {
  82898. /**
  82899. * If the controller is used in a webXR session
  82900. */
  82901. isXR: boolean;
  82902. private _deviceRoomPosition;
  82903. private _deviceRoomRotationQuaternion;
  82904. /**
  82905. * The device position in babylon space
  82906. */
  82907. devicePosition: Vector3;
  82908. /**
  82909. * The device rotation in babylon space
  82910. */
  82911. deviceRotationQuaternion: Quaternion;
  82912. /**
  82913. * The scale factor of the device in babylon space
  82914. */
  82915. deviceScaleFactor: number;
  82916. /**
  82917. * (Likely devicePosition should be used instead) The device position in its room space
  82918. */
  82919. position: Vector3;
  82920. /**
  82921. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  82922. */
  82923. rotationQuaternion: Quaternion;
  82924. /**
  82925. * The type of controller (Eg. Windows mixed reality)
  82926. */
  82927. controllerType: PoseEnabledControllerType;
  82928. protected _calculatedPosition: Vector3;
  82929. private _calculatedRotation;
  82930. /**
  82931. * The raw pose from the device
  82932. */
  82933. rawPose: DevicePose;
  82934. private _trackPosition;
  82935. private _maxRotationDistFromHeadset;
  82936. private _draggedRoomRotation;
  82937. /**
  82938. * @hidden
  82939. */
  82940. _disableTrackPosition(fixedPosition: Vector3): void;
  82941. /**
  82942. * Internal, the mesh attached to the controller
  82943. * @hidden
  82944. */
  82945. _mesh: Nullable<AbstractMesh>;
  82946. private _poseControlledCamera;
  82947. private _leftHandSystemQuaternion;
  82948. /**
  82949. * Internal, matrix used to convert room space to babylon space
  82950. * @hidden
  82951. */
  82952. _deviceToWorld: Matrix;
  82953. /**
  82954. * Node to be used when casting a ray from the controller
  82955. * @hidden
  82956. */
  82957. _pointingPoseNode: Nullable<TransformNode>;
  82958. /**
  82959. * Name of the child mesh that can be used to cast a ray from the controller
  82960. */
  82961. static readonly POINTING_POSE: string;
  82962. /**
  82963. * Creates a new PoseEnabledController from a gamepad
  82964. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  82965. */
  82966. constructor(browserGamepad: any);
  82967. private _workingMatrix;
  82968. /**
  82969. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  82970. */
  82971. update(): void;
  82972. /**
  82973. * Updates only the pose device and mesh without doing any button event checking
  82974. */
  82975. protected _updatePoseAndMesh(): void;
  82976. /**
  82977. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  82978. * @param poseData raw pose fromthe device
  82979. */
  82980. updateFromDevice(poseData: DevicePose): void;
  82981. /**
  82982. * @hidden
  82983. */
  82984. _meshAttachedObservable: Observable<AbstractMesh>;
  82985. /**
  82986. * Attaches a mesh to the controller
  82987. * @param mesh the mesh to be attached
  82988. */
  82989. attachToMesh(mesh: AbstractMesh): void;
  82990. /**
  82991. * Attaches the controllers mesh to a camera
  82992. * @param camera the camera the mesh should be attached to
  82993. */
  82994. attachToPoseControlledCamera(camera: TargetCamera): void;
  82995. /**
  82996. * Disposes of the controller
  82997. */
  82998. dispose(): void;
  82999. /**
  83000. * The mesh that is attached to the controller
  83001. */
  83002. readonly mesh: Nullable<AbstractMesh>;
  83003. /**
  83004. * Gets the ray of the controller in the direction the controller is pointing
  83005. * @param length the length the resulting ray should be
  83006. * @returns a ray in the direction the controller is pointing
  83007. */
  83008. getForwardRay(length?: number): Ray;
  83009. }
  83010. }
  83011. declare module BABYLON {
  83012. /**
  83013. * Defines the WebVRController object that represents controllers tracked in 3D space
  83014. */
  83015. export abstract class WebVRController extends PoseEnabledController {
  83016. /**
  83017. * Internal, the default controller model for the controller
  83018. */
  83019. protected _defaultModel: Nullable<AbstractMesh>;
  83020. /**
  83021. * Fired when the trigger state has changed
  83022. */
  83023. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  83024. /**
  83025. * Fired when the main button state has changed
  83026. */
  83027. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83028. /**
  83029. * Fired when the secondary button state has changed
  83030. */
  83031. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  83032. /**
  83033. * Fired when the pad state has changed
  83034. */
  83035. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  83036. /**
  83037. * Fired when controllers stick values have changed
  83038. */
  83039. onPadValuesChangedObservable: Observable<StickValues>;
  83040. /**
  83041. * Array of button availible on the controller
  83042. */
  83043. protected _buttons: Array<MutableGamepadButton>;
  83044. private _onButtonStateChange;
  83045. /**
  83046. * Fired when a controller button's state has changed
  83047. * @param callback the callback containing the button that was modified
  83048. */
  83049. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  83050. /**
  83051. * X and Y axis corresponding to the controllers joystick
  83052. */
  83053. pad: StickValues;
  83054. /**
  83055. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  83056. */
  83057. hand: string;
  83058. /**
  83059. * The default controller model for the controller
  83060. */
  83061. readonly defaultModel: Nullable<AbstractMesh>;
  83062. /**
  83063. * Creates a new WebVRController from a gamepad
  83064. * @param vrGamepad the gamepad that the WebVRController should be created from
  83065. */
  83066. constructor(vrGamepad: any);
  83067. /**
  83068. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  83069. */
  83070. update(): void;
  83071. /**
  83072. * Function to be called when a button is modified
  83073. */
  83074. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  83075. /**
  83076. * Loads a mesh and attaches it to the controller
  83077. * @param scene the scene the mesh should be added to
  83078. * @param meshLoaded callback for when the mesh has been loaded
  83079. */
  83080. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  83081. private _setButtonValue;
  83082. private _changes;
  83083. private _checkChanges;
  83084. /**
  83085. * Disposes of th webVRCOntroller
  83086. */
  83087. dispose(): void;
  83088. }
  83089. }
  83090. declare module BABYLON {
  83091. /**
  83092. * The HemisphericLight simulates the ambient environment light,
  83093. * so the passed direction is the light reflection direction, not the incoming direction.
  83094. */
  83095. export class HemisphericLight extends Light {
  83096. /**
  83097. * The groundColor is the light in the opposite direction to the one specified during creation.
  83098. * 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.
  83099. */
  83100. groundColor: Color3;
  83101. /**
  83102. * The light reflection direction, not the incoming direction.
  83103. */
  83104. direction: Vector3;
  83105. /**
  83106. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  83107. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  83108. * The HemisphericLight can't cast shadows.
  83109. * Documentation : https://doc.babylonjs.com/babylon101/lights
  83110. * @param name The friendly name of the light
  83111. * @param direction The direction of the light reflection
  83112. * @param scene The scene the light belongs to
  83113. */
  83114. constructor(name: string, direction: Vector3, scene: Scene);
  83115. protected _buildUniformLayout(): void;
  83116. /**
  83117. * Returns the string "HemisphericLight".
  83118. * @return The class name
  83119. */
  83120. getClassName(): string;
  83121. /**
  83122. * Sets the HemisphericLight direction towards the passed target (Vector3).
  83123. * Returns the updated direction.
  83124. * @param target The target the direction should point to
  83125. * @return The computed direction
  83126. */
  83127. setDirectionToTarget(target: Vector3): Vector3;
  83128. /**
  83129. * Returns the shadow generator associated to the light.
  83130. * @returns Always null for hemispheric lights because it does not support shadows.
  83131. */
  83132. getShadowGenerator(): Nullable<IShadowGenerator>;
  83133. /**
  83134. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  83135. * @param effect The effect to update
  83136. * @param lightIndex The index of the light in the effect to update
  83137. * @returns The hemispheric light
  83138. */
  83139. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  83140. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  83141. /**
  83142. * Computes the world matrix of the node
  83143. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83144. * @param useWasUpdatedFlag defines a reserved property
  83145. * @returns the world matrix
  83146. */
  83147. computeWorldMatrix(): Matrix;
  83148. /**
  83149. * Returns the integer 3.
  83150. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  83151. */
  83152. getTypeID(): number;
  83153. /**
  83154. * Prepares the list of defines specific to the light type.
  83155. * @param defines the list of defines
  83156. * @param lightIndex defines the index of the light for the effect
  83157. */
  83158. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  83159. }
  83160. }
  83161. declare module BABYLON {
  83162. /** @hidden */
  83163. export var vrMultiviewToSingleviewPixelShader: {
  83164. name: string;
  83165. shader: string;
  83166. };
  83167. }
  83168. declare module BABYLON {
  83169. /**
  83170. * Renders to multiple views with a single draw call
  83171. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  83172. */
  83173. export class MultiviewRenderTarget extends RenderTargetTexture {
  83174. /**
  83175. * Creates a multiview render target
  83176. * @param scene scene used with the render target
  83177. * @param size the size of the render target (used for each view)
  83178. */
  83179. constructor(scene: Scene, size?: number | {
  83180. width: number;
  83181. height: number;
  83182. } | {
  83183. ratio: number;
  83184. });
  83185. /**
  83186. * @hidden
  83187. * @param faceIndex the face index, if its a cube texture
  83188. */
  83189. _bindFrameBuffer(faceIndex?: number): void;
  83190. /**
  83191. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83192. * @returns the view count
  83193. */
  83194. getViewCount(): number;
  83195. }
  83196. }
  83197. declare module BABYLON {
  83198. /**
  83199. * Represents a camera frustum
  83200. */
  83201. export class Frustum {
  83202. /**
  83203. * Gets the planes representing the frustum
  83204. * @param transform matrix to be applied to the returned planes
  83205. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  83206. */
  83207. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  83208. /**
  83209. * Gets the near frustum plane transformed by the transform matrix
  83210. * @param transform transformation matrix to be applied to the resulting frustum plane
  83211. * @param frustumPlane the resuling frustum plane
  83212. */
  83213. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83214. /**
  83215. * Gets the far frustum plane transformed by the transform matrix
  83216. * @param transform transformation matrix to be applied to the resulting frustum plane
  83217. * @param frustumPlane the resuling frustum plane
  83218. */
  83219. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83220. /**
  83221. * Gets the left frustum plane transformed by the transform matrix
  83222. * @param transform transformation matrix to be applied to the resulting frustum plane
  83223. * @param frustumPlane the resuling frustum plane
  83224. */
  83225. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83226. /**
  83227. * Gets the right frustum plane transformed by the transform matrix
  83228. * @param transform transformation matrix to be applied to the resulting frustum plane
  83229. * @param frustumPlane the resuling frustum plane
  83230. */
  83231. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83232. /**
  83233. * Gets the top frustum plane transformed by the transform matrix
  83234. * @param transform transformation matrix to be applied to the resulting frustum plane
  83235. * @param frustumPlane the resuling frustum plane
  83236. */
  83237. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83238. /**
  83239. * Gets the bottom frustum plane transformed by the transform matrix
  83240. * @param transform transformation matrix to be applied to the resulting frustum plane
  83241. * @param frustumPlane the resuling frustum plane
  83242. */
  83243. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  83244. /**
  83245. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  83246. * @param transform transformation matrix to be applied to the resulting frustum planes
  83247. * @param frustumPlanes the resuling frustum planes
  83248. */
  83249. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  83250. }
  83251. }
  83252. declare module BABYLON {
  83253. interface Engine {
  83254. /**
  83255. * Creates a new multiview render target
  83256. * @param width defines the width of the texture
  83257. * @param height defines the height of the texture
  83258. * @returns the created multiview texture
  83259. */
  83260. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  83261. /**
  83262. * Binds a multiview framebuffer to be drawn to
  83263. * @param multiviewTexture texture to bind
  83264. */
  83265. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  83266. }
  83267. interface Camera {
  83268. /**
  83269. * @hidden
  83270. * 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)
  83271. */
  83272. _useMultiviewToSingleView: boolean;
  83273. /**
  83274. * @hidden
  83275. * 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)
  83276. */
  83277. _multiviewTexture: Nullable<RenderTargetTexture>;
  83278. /**
  83279. * @hidden
  83280. * ensures the multiview texture of the camera exists and has the specified width/height
  83281. * @param width height to set on the multiview texture
  83282. * @param height width to set on the multiview texture
  83283. */
  83284. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  83285. }
  83286. interface Scene {
  83287. /** @hidden */
  83288. _transformMatrixR: Matrix;
  83289. /** @hidden */
  83290. _multiviewSceneUbo: Nullable<UniformBuffer>;
  83291. /** @hidden */
  83292. _createMultiviewUbo(): void;
  83293. /** @hidden */
  83294. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  83295. /** @hidden */
  83296. _renderMultiviewToSingleView(camera: Camera): void;
  83297. }
  83298. }
  83299. declare module BABYLON {
  83300. /**
  83301. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  83302. * This will not be used for webXR as it supports displaying texture arrays directly
  83303. */
  83304. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  83305. /**
  83306. * Initializes a VRMultiviewToSingleview
  83307. * @param name name of the post process
  83308. * @param camera camera to be applied to
  83309. * @param scaleFactor scaling factor to the size of the output texture
  83310. */
  83311. constructor(name: string, camera: Camera, scaleFactor: number);
  83312. }
  83313. }
  83314. declare module BABYLON {
  83315. /**
  83316. * Interface used to define additional presentation attributes
  83317. */
  83318. export interface IVRPresentationAttributes {
  83319. /**
  83320. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  83321. */
  83322. highRefreshRate: boolean;
  83323. /**
  83324. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  83325. */
  83326. foveationLevel: number;
  83327. }
  83328. interface Engine {
  83329. /** @hidden */
  83330. _vrDisplay: any;
  83331. /** @hidden */
  83332. _vrSupported: boolean;
  83333. /** @hidden */
  83334. _oldSize: Size;
  83335. /** @hidden */
  83336. _oldHardwareScaleFactor: number;
  83337. /** @hidden */
  83338. _vrExclusivePointerMode: boolean;
  83339. /** @hidden */
  83340. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  83341. /** @hidden */
  83342. _onVRDisplayPointerRestricted: () => void;
  83343. /** @hidden */
  83344. _onVRDisplayPointerUnrestricted: () => void;
  83345. /** @hidden */
  83346. _onVrDisplayConnect: Nullable<(display: any) => void>;
  83347. /** @hidden */
  83348. _onVrDisplayDisconnect: Nullable<() => void>;
  83349. /** @hidden */
  83350. _onVrDisplayPresentChange: Nullable<() => void>;
  83351. /**
  83352. * Observable signaled when VR display mode changes
  83353. */
  83354. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  83355. /**
  83356. * Observable signaled when VR request present is complete
  83357. */
  83358. onVRRequestPresentComplete: Observable<boolean>;
  83359. /**
  83360. * Observable signaled when VR request present starts
  83361. */
  83362. onVRRequestPresentStart: Observable<Engine>;
  83363. /**
  83364. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  83365. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  83366. */
  83367. isInVRExclusivePointerMode: boolean;
  83368. /**
  83369. * Gets a boolean indicating if a webVR device was detected
  83370. * @returns true if a webVR device was detected
  83371. */
  83372. isVRDevicePresent(): boolean;
  83373. /**
  83374. * Gets the current webVR device
  83375. * @returns the current webVR device (or null)
  83376. */
  83377. getVRDevice(): any;
  83378. /**
  83379. * Initializes a webVR display and starts listening to display change events
  83380. * The onVRDisplayChangedObservable will be notified upon these changes
  83381. * @returns A promise containing a VRDisplay and if vr is supported
  83382. */
  83383. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83384. /** @hidden */
  83385. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  83386. /**
  83387. * Gets or sets the presentation attributes used to configure VR rendering
  83388. */
  83389. vrPresentationAttributes?: IVRPresentationAttributes;
  83390. /**
  83391. * Call this function to switch to webVR mode
  83392. * Will do nothing if webVR is not supported or if there is no webVR device
  83393. * @param options the webvr options provided to the camera. mainly used for multiview
  83394. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83395. */
  83396. enableVR(options: WebVROptions): void;
  83397. /** @hidden */
  83398. _onVRFullScreenTriggered(): void;
  83399. }
  83400. }
  83401. declare module BABYLON {
  83402. /**
  83403. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  83404. * IMPORTANT!! The data is right-hand data.
  83405. * @export
  83406. * @interface DevicePose
  83407. */
  83408. export interface DevicePose {
  83409. /**
  83410. * The position of the device, values in array are [x,y,z].
  83411. */
  83412. readonly position: Nullable<Float32Array>;
  83413. /**
  83414. * The linearVelocity of the device, values in array are [x,y,z].
  83415. */
  83416. readonly linearVelocity: Nullable<Float32Array>;
  83417. /**
  83418. * The linearAcceleration of the device, values in array are [x,y,z].
  83419. */
  83420. readonly linearAcceleration: Nullable<Float32Array>;
  83421. /**
  83422. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  83423. */
  83424. readonly orientation: Nullable<Float32Array>;
  83425. /**
  83426. * The angularVelocity of the device, values in array are [x,y,z].
  83427. */
  83428. readonly angularVelocity: Nullable<Float32Array>;
  83429. /**
  83430. * The angularAcceleration of the device, values in array are [x,y,z].
  83431. */
  83432. readonly angularAcceleration: Nullable<Float32Array>;
  83433. }
  83434. /**
  83435. * Interface representing a pose controlled object in Babylon.
  83436. * A pose controlled object has both regular pose values as well as pose values
  83437. * from an external device such as a VR head mounted display
  83438. */
  83439. export interface PoseControlled {
  83440. /**
  83441. * The position of the object in babylon space.
  83442. */
  83443. position: Vector3;
  83444. /**
  83445. * The rotation quaternion of the object in babylon space.
  83446. */
  83447. rotationQuaternion: Quaternion;
  83448. /**
  83449. * The position of the device in babylon space.
  83450. */
  83451. devicePosition?: Vector3;
  83452. /**
  83453. * The rotation quaternion of the device in babylon space.
  83454. */
  83455. deviceRotationQuaternion: Quaternion;
  83456. /**
  83457. * The raw pose coming from the device.
  83458. */
  83459. rawPose: Nullable<DevicePose>;
  83460. /**
  83461. * The scale of the device to be used when translating from device space to babylon space.
  83462. */
  83463. deviceScaleFactor: number;
  83464. /**
  83465. * Updates the poseControlled values based on the input device pose.
  83466. * @param poseData the pose data to update the object with
  83467. */
  83468. updateFromDevice(poseData: DevicePose): void;
  83469. }
  83470. /**
  83471. * Set of options to customize the webVRCamera
  83472. */
  83473. export interface WebVROptions {
  83474. /**
  83475. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  83476. */
  83477. trackPosition?: boolean;
  83478. /**
  83479. * Sets the scale of the vrDevice in babylon space. (default: 1)
  83480. */
  83481. positionScale?: number;
  83482. /**
  83483. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  83484. */
  83485. displayName?: string;
  83486. /**
  83487. * Should the native controller meshes be initialized. (default: true)
  83488. */
  83489. controllerMeshes?: boolean;
  83490. /**
  83491. * Creating a default HemiLight only on controllers. (default: true)
  83492. */
  83493. defaultLightingOnControllers?: boolean;
  83494. /**
  83495. * If you don't want to use the default VR button of the helper. (default: false)
  83496. */
  83497. useCustomVRButton?: boolean;
  83498. /**
  83499. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  83500. */
  83501. customVRButton?: HTMLButtonElement;
  83502. /**
  83503. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  83504. */
  83505. rayLength?: number;
  83506. /**
  83507. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  83508. */
  83509. defaultHeight?: number;
  83510. /**
  83511. * If multiview should be used if availible (default: false)
  83512. */
  83513. useMultiview?: boolean;
  83514. }
  83515. /**
  83516. * This represents a WebVR camera.
  83517. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  83518. * @example http://doc.babylonjs.com/how_to/webvr_camera
  83519. */
  83520. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  83521. private webVROptions;
  83522. /**
  83523. * @hidden
  83524. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  83525. */
  83526. _vrDevice: any;
  83527. /**
  83528. * The rawPose of the vrDevice.
  83529. */
  83530. rawPose: Nullable<DevicePose>;
  83531. private _onVREnabled;
  83532. private _specsVersion;
  83533. private _attached;
  83534. private _frameData;
  83535. protected _descendants: Array<Node>;
  83536. private _deviceRoomPosition;
  83537. /** @hidden */
  83538. _deviceRoomRotationQuaternion: Quaternion;
  83539. private _standingMatrix;
  83540. /**
  83541. * Represents device position in babylon space.
  83542. */
  83543. devicePosition: Vector3;
  83544. /**
  83545. * Represents device rotation in babylon space.
  83546. */
  83547. deviceRotationQuaternion: Quaternion;
  83548. /**
  83549. * The scale of the device to be used when translating from device space to babylon space.
  83550. */
  83551. deviceScaleFactor: number;
  83552. private _deviceToWorld;
  83553. private _worldToDevice;
  83554. /**
  83555. * References to the webVR controllers for the vrDevice.
  83556. */
  83557. controllers: Array<WebVRController>;
  83558. /**
  83559. * Emits an event when a controller is attached.
  83560. */
  83561. onControllersAttachedObservable: Observable<WebVRController[]>;
  83562. /**
  83563. * Emits an event when a controller's mesh has been loaded;
  83564. */
  83565. onControllerMeshLoadedObservable: Observable<WebVRController>;
  83566. /**
  83567. * Emits an event when the HMD's pose has been updated.
  83568. */
  83569. onPoseUpdatedFromDeviceObservable: Observable<any>;
  83570. private _poseSet;
  83571. /**
  83572. * If the rig cameras be used as parent instead of this camera.
  83573. */
  83574. rigParenting: boolean;
  83575. private _lightOnControllers;
  83576. private _defaultHeight?;
  83577. /**
  83578. * Instantiates a WebVRFreeCamera.
  83579. * @param name The name of the WebVRFreeCamera
  83580. * @param position The starting anchor position for the camera
  83581. * @param scene The scene the camera belongs to
  83582. * @param webVROptions a set of customizable options for the webVRCamera
  83583. */
  83584. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  83585. /**
  83586. * Gets the device distance from the ground in meters.
  83587. * @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.
  83588. */
  83589. deviceDistanceToRoomGround(): number;
  83590. /**
  83591. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83592. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  83593. */
  83594. useStandingMatrix(callback?: (bool: boolean) => void): void;
  83595. /**
  83596. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  83597. * @returns A promise with a boolean set to if the standing matrix is supported.
  83598. */
  83599. useStandingMatrixAsync(): Promise<boolean>;
  83600. /**
  83601. * Disposes the camera
  83602. */
  83603. dispose(): void;
  83604. /**
  83605. * Gets a vrController by name.
  83606. * @param name The name of the controller to retreive
  83607. * @returns the controller matching the name specified or null if not found
  83608. */
  83609. getControllerByName(name: string): Nullable<WebVRController>;
  83610. private _leftController;
  83611. /**
  83612. * The controller corresponding to the users left hand.
  83613. */
  83614. readonly leftController: Nullable<WebVRController>;
  83615. private _rightController;
  83616. /**
  83617. * The controller corresponding to the users right hand.
  83618. */
  83619. readonly rightController: Nullable<WebVRController>;
  83620. /**
  83621. * Casts a ray forward from the vrCamera's gaze.
  83622. * @param length Length of the ray (default: 100)
  83623. * @returns the ray corresponding to the gaze
  83624. */
  83625. getForwardRay(length?: number): Ray;
  83626. /**
  83627. * @hidden
  83628. * Updates the camera based on device's frame data
  83629. */
  83630. _checkInputs(): void;
  83631. /**
  83632. * Updates the poseControlled values based on the input device pose.
  83633. * @param poseData Pose coming from the device
  83634. */
  83635. updateFromDevice(poseData: DevicePose): void;
  83636. private _htmlElementAttached;
  83637. private _detachIfAttached;
  83638. /**
  83639. * WebVR's attach control will start broadcasting frames to the device.
  83640. * Note that in certain browsers (chrome for example) this function must be called
  83641. * within a user-interaction callback. Example:
  83642. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  83643. *
  83644. * @param element html element to attach the vrDevice to
  83645. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  83646. */
  83647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83648. /**
  83649. * Detaches the camera from the html element and disables VR
  83650. *
  83651. * @param element html element to detach from
  83652. */
  83653. detachControl(element: HTMLElement): void;
  83654. /**
  83655. * @returns the name of this class
  83656. */
  83657. getClassName(): string;
  83658. /**
  83659. * Calls resetPose on the vrDisplay
  83660. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  83661. */
  83662. resetToCurrentRotation(): void;
  83663. /**
  83664. * @hidden
  83665. * Updates the rig cameras (left and right eye)
  83666. */
  83667. _updateRigCameras(): void;
  83668. private _workingVector;
  83669. private _oneVector;
  83670. private _workingMatrix;
  83671. private updateCacheCalled;
  83672. private _correctPositionIfNotTrackPosition;
  83673. /**
  83674. * @hidden
  83675. * Updates the cached values of the camera
  83676. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  83677. */
  83678. _updateCache(ignoreParentClass?: boolean): void;
  83679. /**
  83680. * @hidden
  83681. * Get current device position in babylon world
  83682. */
  83683. _computeDevicePosition(): void;
  83684. /**
  83685. * Updates the current device position and rotation in the babylon world
  83686. */
  83687. update(): void;
  83688. /**
  83689. * @hidden
  83690. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  83691. * @returns an identity matrix
  83692. */
  83693. _getViewMatrix(): Matrix;
  83694. private _tmpMatrix;
  83695. /**
  83696. * This function is called by the two RIG cameras.
  83697. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  83698. * @hidden
  83699. */
  83700. _getWebVRViewMatrix(): Matrix;
  83701. /** @hidden */
  83702. _getWebVRProjectionMatrix(): Matrix;
  83703. private _onGamepadConnectedObserver;
  83704. private _onGamepadDisconnectedObserver;
  83705. private _updateCacheWhenTrackingDisabledObserver;
  83706. /**
  83707. * Initializes the controllers and their meshes
  83708. */
  83709. initControllers(): void;
  83710. }
  83711. }
  83712. declare module BABYLON {
  83713. /**
  83714. * Size options for a post process
  83715. */
  83716. export type PostProcessOptions = {
  83717. width: number;
  83718. height: number;
  83719. };
  83720. /**
  83721. * PostProcess can be used to apply a shader to a texture after it has been rendered
  83722. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  83723. */
  83724. export class PostProcess {
  83725. /** Name of the PostProcess. */
  83726. name: string;
  83727. /**
  83728. * Gets or sets the unique id of the post process
  83729. */
  83730. uniqueId: number;
  83731. /**
  83732. * Width of the texture to apply the post process on
  83733. */
  83734. width: number;
  83735. /**
  83736. * Height of the texture to apply the post process on
  83737. */
  83738. height: number;
  83739. /**
  83740. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  83741. * @hidden
  83742. */
  83743. _outputTexture: Nullable<InternalTexture>;
  83744. /**
  83745. * Sampling mode used by the shader
  83746. * See https://doc.babylonjs.com/classes/3.1/texture
  83747. */
  83748. renderTargetSamplingMode: number;
  83749. /**
  83750. * Clear color to use when screen clearing
  83751. */
  83752. clearColor: Color4;
  83753. /**
  83754. * If the buffer needs to be cleared before applying the post process. (default: true)
  83755. * Should be set to false if shader will overwrite all previous pixels.
  83756. */
  83757. autoClear: boolean;
  83758. /**
  83759. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  83760. */
  83761. alphaMode: number;
  83762. /**
  83763. * Sets the setAlphaBlendConstants of the babylon engine
  83764. */
  83765. alphaConstants: Color4;
  83766. /**
  83767. * Animations to be used for the post processing
  83768. */
  83769. animations: Animation[];
  83770. /**
  83771. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  83772. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  83773. */
  83774. enablePixelPerfectMode: boolean;
  83775. /**
  83776. * Force the postprocess to be applied without taking in account viewport
  83777. */
  83778. forceFullscreenViewport: boolean;
  83779. /**
  83780. * List of inspectable custom properties (used by the Inspector)
  83781. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83782. */
  83783. inspectableCustomProperties: IInspectable[];
  83784. /**
  83785. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  83786. *
  83787. * | Value | Type | Description |
  83788. * | ----- | ----------------------------------- | ----------- |
  83789. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  83790. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  83791. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  83792. *
  83793. */
  83794. scaleMode: number;
  83795. /**
  83796. * Force textures to be a power of two (default: false)
  83797. */
  83798. alwaysForcePOT: boolean;
  83799. private _samples;
  83800. /**
  83801. * Number of sample textures (default: 1)
  83802. */
  83803. samples: number;
  83804. /**
  83805. * Modify the scale of the post process to be the same as the viewport (default: false)
  83806. */
  83807. adaptScaleToCurrentViewport: boolean;
  83808. private _camera;
  83809. private _scene;
  83810. private _engine;
  83811. private _options;
  83812. private _reusable;
  83813. private _textureType;
  83814. /**
  83815. * Smart array of input and output textures for the post process.
  83816. * @hidden
  83817. */
  83818. _textures: SmartArray<InternalTexture>;
  83819. /**
  83820. * The index in _textures that corresponds to the output texture.
  83821. * @hidden
  83822. */
  83823. _currentRenderTextureInd: number;
  83824. private _effect;
  83825. private _samplers;
  83826. private _fragmentUrl;
  83827. private _vertexUrl;
  83828. private _parameters;
  83829. private _scaleRatio;
  83830. protected _indexParameters: any;
  83831. private _shareOutputWithPostProcess;
  83832. private _texelSize;
  83833. private _forcedOutputTexture;
  83834. /**
  83835. * Returns the fragment url or shader name used in the post process.
  83836. * @returns the fragment url or name in the shader store.
  83837. */
  83838. getEffectName(): string;
  83839. /**
  83840. * An event triggered when the postprocess is activated.
  83841. */
  83842. onActivateObservable: Observable<Camera>;
  83843. private _onActivateObserver;
  83844. /**
  83845. * A function that is added to the onActivateObservable
  83846. */
  83847. onActivate: Nullable<(camera: Camera) => void>;
  83848. /**
  83849. * An event triggered when the postprocess changes its size.
  83850. */
  83851. onSizeChangedObservable: Observable<PostProcess>;
  83852. private _onSizeChangedObserver;
  83853. /**
  83854. * A function that is added to the onSizeChangedObservable
  83855. */
  83856. onSizeChanged: (postProcess: PostProcess) => void;
  83857. /**
  83858. * An event triggered when the postprocess applies its effect.
  83859. */
  83860. onApplyObservable: Observable<Effect>;
  83861. private _onApplyObserver;
  83862. /**
  83863. * A function that is added to the onApplyObservable
  83864. */
  83865. onApply: (effect: Effect) => void;
  83866. /**
  83867. * An event triggered before rendering the postprocess
  83868. */
  83869. onBeforeRenderObservable: Observable<Effect>;
  83870. private _onBeforeRenderObserver;
  83871. /**
  83872. * A function that is added to the onBeforeRenderObservable
  83873. */
  83874. onBeforeRender: (effect: Effect) => void;
  83875. /**
  83876. * An event triggered after rendering the postprocess
  83877. */
  83878. onAfterRenderObservable: Observable<Effect>;
  83879. private _onAfterRenderObserver;
  83880. /**
  83881. * A function that is added to the onAfterRenderObservable
  83882. */
  83883. onAfterRender: (efect: Effect) => void;
  83884. /**
  83885. * 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
  83886. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  83887. */
  83888. inputTexture: InternalTexture;
  83889. /**
  83890. * Gets the camera which post process is applied to.
  83891. * @returns The camera the post process is applied to.
  83892. */
  83893. getCamera(): Camera;
  83894. /**
  83895. * Gets the texel size of the postprocess.
  83896. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  83897. */
  83898. readonly texelSize: Vector2;
  83899. /**
  83900. * Creates a new instance PostProcess
  83901. * @param name The name of the PostProcess.
  83902. * @param fragmentUrl The url of the fragment shader to be used.
  83903. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  83904. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  83905. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  83906. * @param camera The camera to apply the render pass to.
  83907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  83908. * @param engine The engine which the post process will be applied. (default: current engine)
  83909. * @param reusable If the post process can be reused on the same frame. (default: false)
  83910. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  83911. * @param textureType Type of textures used when performing the post process. (default: 0)
  83912. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  83913. * @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
  83914. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  83915. */
  83916. constructor(
  83917. /** Name of the PostProcess. */
  83918. 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);
  83919. /**
  83920. * Gets a string idenfifying the name of the class
  83921. * @returns "PostProcess" string
  83922. */
  83923. getClassName(): string;
  83924. /**
  83925. * Gets the engine which this post process belongs to.
  83926. * @returns The engine the post process was enabled with.
  83927. */
  83928. getEngine(): Engine;
  83929. /**
  83930. * The effect that is created when initializing the post process.
  83931. * @returns The created effect corresponding the the postprocess.
  83932. */
  83933. getEffect(): Effect;
  83934. /**
  83935. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  83936. * @param postProcess The post process to share the output with.
  83937. * @returns This post process.
  83938. */
  83939. shareOutputWith(postProcess: PostProcess): PostProcess;
  83940. /**
  83941. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  83942. * This should be called if the post process that shares output with this post process is disabled/disposed.
  83943. */
  83944. useOwnOutput(): void;
  83945. /**
  83946. * Updates the effect with the current post process compile time values and recompiles the shader.
  83947. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  83948. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  83949. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  83950. * @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
  83951. * @param onCompiled Called when the shader has been compiled.
  83952. * @param onError Called if there is an error when compiling a shader.
  83953. */
  83954. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  83955. /**
  83956. * The post process is reusable if it can be used multiple times within one frame.
  83957. * @returns If the post process is reusable
  83958. */
  83959. isReusable(): boolean;
  83960. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  83961. markTextureDirty(): void;
  83962. /**
  83963. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  83964. * 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.
  83965. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  83966. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  83967. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  83968. * @returns The target texture that was bound to be written to.
  83969. */
  83970. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  83971. /**
  83972. * If the post process is supported.
  83973. */
  83974. readonly isSupported: boolean;
  83975. /**
  83976. * The aspect ratio of the output texture.
  83977. */
  83978. readonly aspectRatio: number;
  83979. /**
  83980. * Get a value indicating if the post-process is ready to be used
  83981. * @returns true if the post-process is ready (shader is compiled)
  83982. */
  83983. isReady(): boolean;
  83984. /**
  83985. * Binds all textures and uniforms to the shader, this will be run on every pass.
  83986. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  83987. */
  83988. apply(): Nullable<Effect>;
  83989. private _disposeTextures;
  83990. /**
  83991. * Disposes the post process.
  83992. * @param camera The camera to dispose the post process on.
  83993. */
  83994. dispose(camera?: Camera): void;
  83995. }
  83996. }
  83997. declare module BABYLON {
  83998. /** @hidden */
  83999. export var kernelBlurVaryingDeclaration: {
  84000. name: string;
  84001. shader: string;
  84002. };
  84003. }
  84004. declare module BABYLON {
  84005. /** @hidden */
  84006. export var kernelBlurFragment: {
  84007. name: string;
  84008. shader: string;
  84009. };
  84010. }
  84011. declare module BABYLON {
  84012. /** @hidden */
  84013. export var kernelBlurFragment2: {
  84014. name: string;
  84015. shader: string;
  84016. };
  84017. }
  84018. declare module BABYLON {
  84019. /** @hidden */
  84020. export var kernelBlurPixelShader: {
  84021. name: string;
  84022. shader: string;
  84023. };
  84024. }
  84025. declare module BABYLON {
  84026. /** @hidden */
  84027. export var kernelBlurVertex: {
  84028. name: string;
  84029. shader: string;
  84030. };
  84031. }
  84032. declare module BABYLON {
  84033. /** @hidden */
  84034. export var kernelBlurVertexShader: {
  84035. name: string;
  84036. shader: string;
  84037. };
  84038. }
  84039. declare module BABYLON {
  84040. /**
  84041. * The Blur Post Process which blurs an image based on a kernel and direction.
  84042. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  84043. */
  84044. export class BlurPostProcess extends PostProcess {
  84045. /** The direction in which to blur the image. */
  84046. direction: Vector2;
  84047. private blockCompilation;
  84048. protected _kernel: number;
  84049. protected _idealKernel: number;
  84050. protected _packedFloat: boolean;
  84051. private _staticDefines;
  84052. /**
  84053. * Sets the length in pixels of the blur sample region
  84054. */
  84055. /**
  84056. * Gets the length in pixels of the blur sample region
  84057. */
  84058. kernel: number;
  84059. /**
  84060. * Sets wether or not the blur needs to unpack/repack floats
  84061. */
  84062. /**
  84063. * Gets wether or not the blur is unpacking/repacking floats
  84064. */
  84065. packedFloat: boolean;
  84066. /**
  84067. * Creates a new instance BlurPostProcess
  84068. * @param name The name of the effect.
  84069. * @param direction The direction in which to blur the image.
  84070. * @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.
  84071. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  84072. * @param camera The camera to apply the render pass to.
  84073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  84074. * @param engine The engine which the post process will be applied. (default: current engine)
  84075. * @param reusable If the post process can be reused on the same frame. (default: false)
  84076. * @param textureType Type of textures used when performing the post process. (default: 0)
  84077. * @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)
  84078. */
  84079. constructor(name: string,
  84080. /** The direction in which to blur the image. */
  84081. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  84082. /**
  84083. * Updates the effect with the current post process compile time values and recompiles the shader.
  84084. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  84085. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  84086. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  84087. * @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
  84088. * @param onCompiled Called when the shader has been compiled.
  84089. * @param onError Called if there is an error when compiling a shader.
  84090. */
  84091. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84092. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  84093. /**
  84094. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  84095. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  84096. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  84097. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  84098. * The gaps between physical kernels are compensated for in the weighting of the samples
  84099. * @param idealKernel Ideal blur kernel.
  84100. * @return Nearest best kernel.
  84101. */
  84102. protected _nearestBestKernel(idealKernel: number): number;
  84103. /**
  84104. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  84105. * @param x The point on the Gaussian distribution to sample.
  84106. * @return the value of the Gaussian function at x.
  84107. */
  84108. protected _gaussianWeight(x: number): number;
  84109. /**
  84110. * Generates a string that can be used as a floating point number in GLSL.
  84111. * @param x Value to print.
  84112. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  84113. * @return GLSL float string.
  84114. */
  84115. protected _glslFloat(x: number, decimalFigures?: number): string;
  84116. }
  84117. }
  84118. declare module BABYLON {
  84119. /**
  84120. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84121. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84122. * You can then easily use it as a reflectionTexture on a flat surface.
  84123. * In case the surface is not a plane, please consider relying on reflection probes.
  84124. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84125. */
  84126. export class MirrorTexture extends RenderTargetTexture {
  84127. private scene;
  84128. /**
  84129. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  84130. * 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.
  84131. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84132. */
  84133. mirrorPlane: Plane;
  84134. /**
  84135. * Define the blur ratio used to blur the reflection if needed.
  84136. */
  84137. blurRatio: number;
  84138. /**
  84139. * Define the adaptive blur kernel used to blur the reflection if needed.
  84140. * This will autocompute the closest best match for the `blurKernel`
  84141. */
  84142. adaptiveBlurKernel: number;
  84143. /**
  84144. * Define the blur kernel used to blur the reflection if needed.
  84145. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84146. */
  84147. blurKernel: number;
  84148. /**
  84149. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  84150. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84151. */
  84152. blurKernelX: number;
  84153. /**
  84154. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  84155. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  84156. */
  84157. blurKernelY: number;
  84158. private _autoComputeBlurKernel;
  84159. protected _onRatioRescale(): void;
  84160. private _updateGammaSpace;
  84161. private _imageProcessingConfigChangeObserver;
  84162. private _transformMatrix;
  84163. private _mirrorMatrix;
  84164. private _savedViewMatrix;
  84165. private _blurX;
  84166. private _blurY;
  84167. private _adaptiveBlurKernel;
  84168. private _blurKernelX;
  84169. private _blurKernelY;
  84170. private _blurRatio;
  84171. /**
  84172. * Instantiates a Mirror Texture.
  84173. * Mirror texture can be used to simulate the view from a mirror in a scene.
  84174. * It will dynamically be rendered every frame to adapt to the camera point of view.
  84175. * You can then easily use it as a reflectionTexture on a flat surface.
  84176. * In case the surface is not a plane, please consider relying on reflection probes.
  84177. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  84178. * @param name
  84179. * @param size
  84180. * @param scene
  84181. * @param generateMipMaps
  84182. * @param type
  84183. * @param samplingMode
  84184. * @param generateDepthBuffer
  84185. */
  84186. constructor(name: string, size: number | {
  84187. width: number;
  84188. height: number;
  84189. } | {
  84190. ratio: number;
  84191. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  84192. private _preparePostProcesses;
  84193. /**
  84194. * Clone the mirror texture.
  84195. * @returns the cloned texture
  84196. */
  84197. clone(): MirrorTexture;
  84198. /**
  84199. * Serialize the texture to a JSON representation you could use in Parse later on
  84200. * @returns the serialized JSON representation
  84201. */
  84202. serialize(): any;
  84203. /**
  84204. * Dispose the texture and release its associated resources.
  84205. */
  84206. dispose(): void;
  84207. }
  84208. }
  84209. declare module BABYLON {
  84210. /**
  84211. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84212. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84213. */
  84214. export class Texture extends BaseTexture {
  84215. /**
  84216. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  84217. */
  84218. static SerializeBuffers: boolean;
  84219. /** @hidden */
  84220. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  84221. /** @hidden */
  84222. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  84223. /** @hidden */
  84224. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  84225. /** nearest is mag = nearest and min = nearest and mip = linear */
  84226. static readonly NEAREST_SAMPLINGMODE: number;
  84227. /** nearest is mag = nearest and min = nearest and mip = linear */
  84228. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  84229. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84230. static readonly BILINEAR_SAMPLINGMODE: number;
  84231. /** Bilinear is mag = linear and min = linear and mip = nearest */
  84232. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  84233. /** Trilinear is mag = linear and min = linear and mip = linear */
  84234. static readonly TRILINEAR_SAMPLINGMODE: number;
  84235. /** Trilinear is mag = linear and min = linear and mip = linear */
  84236. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  84237. /** mag = nearest and min = nearest and mip = nearest */
  84238. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  84239. /** mag = nearest and min = linear and mip = nearest */
  84240. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  84241. /** mag = nearest and min = linear and mip = linear */
  84242. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  84243. /** mag = nearest and min = linear and mip = none */
  84244. static readonly NEAREST_LINEAR: number;
  84245. /** mag = nearest and min = nearest and mip = none */
  84246. static readonly NEAREST_NEAREST: number;
  84247. /** mag = linear and min = nearest and mip = nearest */
  84248. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  84249. /** mag = linear and min = nearest and mip = linear */
  84250. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  84251. /** mag = linear and min = linear and mip = none */
  84252. static readonly LINEAR_LINEAR: number;
  84253. /** mag = linear and min = nearest and mip = none */
  84254. static readonly LINEAR_NEAREST: number;
  84255. /** Explicit coordinates mode */
  84256. static readonly EXPLICIT_MODE: number;
  84257. /** Spherical coordinates mode */
  84258. static readonly SPHERICAL_MODE: number;
  84259. /** Planar coordinates mode */
  84260. static readonly PLANAR_MODE: number;
  84261. /** Cubic coordinates mode */
  84262. static readonly CUBIC_MODE: number;
  84263. /** Projection coordinates mode */
  84264. static readonly PROJECTION_MODE: number;
  84265. /** Inverse Cubic coordinates mode */
  84266. static readonly SKYBOX_MODE: number;
  84267. /** Inverse Cubic coordinates mode */
  84268. static readonly INVCUBIC_MODE: number;
  84269. /** Equirectangular coordinates mode */
  84270. static readonly EQUIRECTANGULAR_MODE: number;
  84271. /** Equirectangular Fixed coordinates mode */
  84272. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  84273. /** Equirectangular Fixed Mirrored coordinates mode */
  84274. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  84275. /** Texture is not repeating outside of 0..1 UVs */
  84276. static readonly CLAMP_ADDRESSMODE: number;
  84277. /** Texture is repeating outside of 0..1 UVs */
  84278. static readonly WRAP_ADDRESSMODE: number;
  84279. /** Texture is repeating and mirrored */
  84280. static readonly MIRROR_ADDRESSMODE: number;
  84281. /**
  84282. * 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
  84283. */
  84284. static UseSerializedUrlIfAny: boolean;
  84285. /**
  84286. * Define the url of the texture.
  84287. */
  84288. url: Nullable<string>;
  84289. /**
  84290. * Define an offset on the texture to offset the u coordinates of the UVs
  84291. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84292. */
  84293. uOffset: number;
  84294. /**
  84295. * Define an offset on the texture to offset the v coordinates of the UVs
  84296. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  84297. */
  84298. vOffset: number;
  84299. /**
  84300. * Define an offset on the texture to scale the u coordinates of the UVs
  84301. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84302. */
  84303. uScale: number;
  84304. /**
  84305. * Define an offset on the texture to scale the v coordinates of the UVs
  84306. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  84307. */
  84308. vScale: number;
  84309. /**
  84310. * Define an offset on the texture to rotate around the u coordinates of the UVs
  84311. * @see http://doc.babylonjs.com/how_to/more_materials
  84312. */
  84313. uAng: number;
  84314. /**
  84315. * Define an offset on the texture to rotate around the v coordinates of the UVs
  84316. * @see http://doc.babylonjs.com/how_to/more_materials
  84317. */
  84318. vAng: number;
  84319. /**
  84320. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  84321. * @see http://doc.babylonjs.com/how_to/more_materials
  84322. */
  84323. wAng: number;
  84324. /**
  84325. * Defines the center of rotation (U)
  84326. */
  84327. uRotationCenter: number;
  84328. /**
  84329. * Defines the center of rotation (V)
  84330. */
  84331. vRotationCenter: number;
  84332. /**
  84333. * Defines the center of rotation (W)
  84334. */
  84335. wRotationCenter: number;
  84336. /**
  84337. * Are mip maps generated for this texture or not.
  84338. */
  84339. readonly noMipmap: boolean;
  84340. /**
  84341. * List of inspectable custom properties (used by the Inspector)
  84342. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84343. */
  84344. inspectableCustomProperties: Nullable<IInspectable[]>;
  84345. private _noMipmap;
  84346. /** @hidden */
  84347. _invertY: boolean;
  84348. private _rowGenerationMatrix;
  84349. private _cachedTextureMatrix;
  84350. private _projectionModeMatrix;
  84351. private _t0;
  84352. private _t1;
  84353. private _t2;
  84354. private _cachedUOffset;
  84355. private _cachedVOffset;
  84356. private _cachedUScale;
  84357. private _cachedVScale;
  84358. private _cachedUAng;
  84359. private _cachedVAng;
  84360. private _cachedWAng;
  84361. private _cachedProjectionMatrixId;
  84362. private _cachedCoordinatesMode;
  84363. /** @hidden */
  84364. protected _initialSamplingMode: number;
  84365. /** @hidden */
  84366. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  84367. private _deleteBuffer;
  84368. protected _format: Nullable<number>;
  84369. private _delayedOnLoad;
  84370. private _delayedOnError;
  84371. private _mimeType?;
  84372. /**
  84373. * Observable triggered once the texture has been loaded.
  84374. */
  84375. onLoadObservable: Observable<Texture>;
  84376. protected _isBlocking: boolean;
  84377. /**
  84378. * Is the texture preventing material to render while loading.
  84379. * If false, a default texture will be used instead of the loading one during the preparation step.
  84380. */
  84381. isBlocking: boolean;
  84382. /**
  84383. * Get the current sampling mode associated with the texture.
  84384. */
  84385. readonly samplingMode: number;
  84386. /**
  84387. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  84388. */
  84389. readonly invertY: boolean;
  84390. /**
  84391. * Instantiates a new texture.
  84392. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  84393. * @see http://doc.babylonjs.com/babylon101/materials#texture
  84394. * @param url defines the url of the picture to load as a texture
  84395. * @param scene defines the scene or engine the texture will belong to
  84396. * @param noMipmap defines if the texture will require mip maps or not
  84397. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  84398. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84399. * @param onLoad defines a callback triggered when the texture has been loaded
  84400. * @param onError defines a callback triggered when an error occurred during the loading session
  84401. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  84402. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  84403. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84404. * @param mimeType defines an optional mime type information
  84405. */
  84406. 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);
  84407. /**
  84408. * Update the url (and optional buffer) of this texture if url was null during construction.
  84409. * @param url the url of the texture
  84410. * @param buffer the buffer of the texture (defaults to null)
  84411. * @param onLoad callback called when the texture is loaded (defaults to null)
  84412. */
  84413. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  84414. /**
  84415. * Finish the loading sequence of a texture flagged as delayed load.
  84416. * @hidden
  84417. */
  84418. delayLoad(): void;
  84419. private _prepareRowForTextureGeneration;
  84420. /**
  84421. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  84422. * @returns the transform matrix of the texture.
  84423. */
  84424. getTextureMatrix(): Matrix;
  84425. /**
  84426. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  84427. * @returns The reflection texture transform
  84428. */
  84429. getReflectionTextureMatrix(): Matrix;
  84430. /**
  84431. * Clones the texture.
  84432. * @returns the cloned texture
  84433. */
  84434. clone(): Texture;
  84435. /**
  84436. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84437. * @returns The JSON representation of the texture
  84438. */
  84439. serialize(): any;
  84440. /**
  84441. * Get the current class name of the texture useful for serialization or dynamic coding.
  84442. * @returns "Texture"
  84443. */
  84444. getClassName(): string;
  84445. /**
  84446. * Dispose the texture and release its associated resources.
  84447. */
  84448. dispose(): void;
  84449. /**
  84450. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  84451. * @param parsedTexture Define the JSON representation of the texture
  84452. * @param scene Define the scene the parsed texture should be instantiated in
  84453. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  84454. * @returns The parsed texture if successful
  84455. */
  84456. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  84457. /**
  84458. * Creates a texture from its base 64 representation.
  84459. * @param data Define the base64 payload without the data: prefix
  84460. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84461. * @param scene Define the scene the texture should belong to
  84462. * @param noMipmap Forces the texture to not create mip map information if true
  84463. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84464. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84465. * @param onLoad define a callback triggered when the texture has been loaded
  84466. * @param onError define a callback triggered when an error occurred during the loading session
  84467. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84468. * @returns the created texture
  84469. */
  84470. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  84471. /**
  84472. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  84473. * @param data Define the base64 payload without the data: prefix
  84474. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  84475. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  84476. * @param scene Define the scene the texture should belong to
  84477. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  84478. * @param noMipmap Forces the texture to not create mip map information if true
  84479. * @param invertY define if the texture needs to be inverted on the y axis during loading
  84480. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  84481. * @param onLoad define a callback triggered when the texture has been loaded
  84482. * @param onError define a callback triggered when an error occurred during the loading session
  84483. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  84484. * @returns the created texture
  84485. */
  84486. 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;
  84487. }
  84488. }
  84489. declare module BABYLON {
  84490. /**
  84491. * PostProcessManager is used to manage one or more post processes or post process pipelines
  84492. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  84493. */
  84494. export class PostProcessManager {
  84495. private _scene;
  84496. private _indexBuffer;
  84497. private _vertexBuffers;
  84498. /**
  84499. * Creates a new instance PostProcess
  84500. * @param scene The scene that the post process is associated with.
  84501. */
  84502. constructor(scene: Scene);
  84503. private _prepareBuffers;
  84504. private _buildIndexBuffer;
  84505. /**
  84506. * Rebuilds the vertex buffers of the manager.
  84507. * @hidden
  84508. */
  84509. _rebuild(): void;
  84510. /**
  84511. * Prepares a frame to be run through a post process.
  84512. * @param sourceTexture The input texture to the post procesess. (default: null)
  84513. * @param postProcesses An array of post processes to be run. (default: null)
  84514. * @returns True if the post processes were able to be run.
  84515. * @hidden
  84516. */
  84517. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  84518. /**
  84519. * Manually render a set of post processes to a texture.
  84520. * @param postProcesses An array of post processes to be run.
  84521. * @param targetTexture The target texture to render to.
  84522. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  84523. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  84524. * @param lodLevel defines which lod of the texture to render to
  84525. */
  84526. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  84527. /**
  84528. * Finalize the result of the output of the postprocesses.
  84529. * @param doNotPresent If true the result will not be displayed to the screen.
  84530. * @param targetTexture The target texture to render to.
  84531. * @param faceIndex The index of the face to bind the target texture to.
  84532. * @param postProcesses The array of post processes to render.
  84533. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  84534. * @hidden
  84535. */
  84536. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  84537. /**
  84538. * Disposes of the post process manager.
  84539. */
  84540. dispose(): void;
  84541. }
  84542. }
  84543. declare module BABYLON {
  84544. /** Interface used by value gradients (color, factor, ...) */
  84545. export interface IValueGradient {
  84546. /**
  84547. * Gets or sets the gradient value (between 0 and 1)
  84548. */
  84549. gradient: number;
  84550. }
  84551. /** Class used to store color4 gradient */
  84552. export class ColorGradient implements IValueGradient {
  84553. /**
  84554. * Gets or sets the gradient value (between 0 and 1)
  84555. */
  84556. gradient: number;
  84557. /**
  84558. * Gets or sets first associated color
  84559. */
  84560. color1: Color4;
  84561. /**
  84562. * Gets or sets second associated color
  84563. */
  84564. color2?: Color4;
  84565. /**
  84566. * Will get a color picked randomly between color1 and color2.
  84567. * If color2 is undefined then color1 will be used
  84568. * @param result defines the target Color4 to store the result in
  84569. */
  84570. getColorToRef(result: Color4): void;
  84571. }
  84572. /** Class used to store color 3 gradient */
  84573. export class Color3Gradient implements IValueGradient {
  84574. /**
  84575. * Gets or sets the gradient value (between 0 and 1)
  84576. */
  84577. gradient: number;
  84578. /**
  84579. * Gets or sets the associated color
  84580. */
  84581. color: Color3;
  84582. }
  84583. /** Class used to store factor gradient */
  84584. export class FactorGradient implements IValueGradient {
  84585. /**
  84586. * Gets or sets the gradient value (between 0 and 1)
  84587. */
  84588. gradient: number;
  84589. /**
  84590. * Gets or sets first associated factor
  84591. */
  84592. factor1: number;
  84593. /**
  84594. * Gets or sets second associated factor
  84595. */
  84596. factor2?: number;
  84597. /**
  84598. * Will get a number picked randomly between factor1 and factor2.
  84599. * If factor2 is undefined then factor1 will be used
  84600. * @returns the picked number
  84601. */
  84602. getFactor(): number;
  84603. }
  84604. /**
  84605. * Helper used to simplify some generic gradient tasks
  84606. */
  84607. export class GradientHelper {
  84608. /**
  84609. * Gets the current gradient from an array of IValueGradient
  84610. * @param ratio defines the current ratio to get
  84611. * @param gradients defines the array of IValueGradient
  84612. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84613. */
  84614. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84615. }
  84616. }
  84617. declare module BABYLON {
  84618. interface ThinEngine {
  84619. /**
  84620. * Creates a dynamic texture
  84621. * @param width defines the width of the texture
  84622. * @param height defines the height of the texture
  84623. * @param generateMipMaps defines if the engine should generate the mip levels
  84624. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84625. * @returns the dynamic texture inside an InternalTexture
  84626. */
  84627. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84628. /**
  84629. * Update the content of a dynamic texture
  84630. * @param texture defines the texture to update
  84631. * @param canvas defines the canvas containing the source
  84632. * @param invertY defines if data must be stored with Y axis inverted
  84633. * @param premulAlpha defines if alpha is stored as premultiplied
  84634. * @param format defines the format of the data
  84635. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84636. */
  84637. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84638. }
  84639. }
  84640. declare module BABYLON {
  84641. /**
  84642. * Helper class used to generate a canvas to manipulate images
  84643. */
  84644. export class CanvasGenerator {
  84645. /**
  84646. * Create a new canvas (or offscreen canvas depending on the context)
  84647. * @param width defines the expected width
  84648. * @param height defines the expected height
  84649. * @return a new canvas or offscreen canvas
  84650. */
  84651. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84652. }
  84653. }
  84654. declare module BABYLON {
  84655. /**
  84656. * A class extending Texture allowing drawing on a texture
  84657. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84658. */
  84659. export class DynamicTexture extends Texture {
  84660. private _generateMipMaps;
  84661. private _canvas;
  84662. private _context;
  84663. private _engine;
  84664. /**
  84665. * Creates a DynamicTexture
  84666. * @param name defines the name of the texture
  84667. * @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
  84668. * @param scene defines the scene where you want the texture
  84669. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84670. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84671. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84672. */
  84673. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84674. /**
  84675. * Get the current class name of the texture useful for serialization or dynamic coding.
  84676. * @returns "DynamicTexture"
  84677. */
  84678. getClassName(): string;
  84679. /**
  84680. * Gets the current state of canRescale
  84681. */
  84682. readonly canRescale: boolean;
  84683. private _recreate;
  84684. /**
  84685. * Scales the texture
  84686. * @param ratio the scale factor to apply to both width and height
  84687. */
  84688. scale(ratio: number): void;
  84689. /**
  84690. * Resizes the texture
  84691. * @param width the new width
  84692. * @param height the new height
  84693. */
  84694. scaleTo(width: number, height: number): void;
  84695. /**
  84696. * Gets the context of the canvas used by the texture
  84697. * @returns the canvas context of the dynamic texture
  84698. */
  84699. getContext(): CanvasRenderingContext2D;
  84700. /**
  84701. * Clears the texture
  84702. */
  84703. clear(): void;
  84704. /**
  84705. * Updates the texture
  84706. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84707. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84708. */
  84709. update(invertY?: boolean, premulAlpha?: boolean): void;
  84710. /**
  84711. * Draws text onto the texture
  84712. * @param text defines the text to be drawn
  84713. * @param x defines the placement of the text from the left
  84714. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84715. * @param font defines the font to be used with font-style, font-size, font-name
  84716. * @param color defines the color used for the text
  84717. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84718. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84719. * @param update defines whether texture is immediately update (default is true)
  84720. */
  84721. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  84722. /**
  84723. * Clones the texture
  84724. * @returns the clone of the texture.
  84725. */
  84726. clone(): DynamicTexture;
  84727. /**
  84728. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84729. * @returns a serialized dynamic texture object
  84730. */
  84731. serialize(): any;
  84732. /** @hidden */
  84733. _rebuild(): void;
  84734. }
  84735. }
  84736. declare module BABYLON {
  84737. interface AbstractScene {
  84738. /**
  84739. * The list of procedural textures added to the scene
  84740. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84741. */
  84742. proceduralTextures: Array<ProceduralTexture>;
  84743. }
  84744. /**
  84745. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84746. * in a given scene.
  84747. */
  84748. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84749. /**
  84750. * The component name helpfull to identify the component in the list of scene components.
  84751. */
  84752. readonly name: string;
  84753. /**
  84754. * The scene the component belongs to.
  84755. */
  84756. scene: Scene;
  84757. /**
  84758. * Creates a new instance of the component for the given scene
  84759. * @param scene Defines the scene to register the component in
  84760. */
  84761. constructor(scene: Scene);
  84762. /**
  84763. * Registers the component in a given scene
  84764. */
  84765. register(): void;
  84766. /**
  84767. * Rebuilds the elements related to this component in case of
  84768. * context lost for instance.
  84769. */
  84770. rebuild(): void;
  84771. /**
  84772. * Disposes the component and the associated ressources.
  84773. */
  84774. dispose(): void;
  84775. private _beforeClear;
  84776. }
  84777. }
  84778. declare module BABYLON {
  84779. interface ThinEngine {
  84780. /**
  84781. * Creates a new render target cube texture
  84782. * @param size defines the size of the texture
  84783. * @param options defines the options used to create the texture
  84784. * @returns a new render target cube texture stored in an InternalTexture
  84785. */
  84786. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84787. }
  84788. }
  84789. declare module BABYLON {
  84790. /** @hidden */
  84791. export var proceduralVertexShader: {
  84792. name: string;
  84793. shader: string;
  84794. };
  84795. }
  84796. declare module BABYLON {
  84797. /**
  84798. * 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.
  84799. * This is the base class of any Procedural texture and contains most of the shareable code.
  84800. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84801. */
  84802. export class ProceduralTexture extends Texture {
  84803. isCube: boolean;
  84804. /**
  84805. * Define if the texture is enabled or not (disabled texture will not render)
  84806. */
  84807. isEnabled: boolean;
  84808. /**
  84809. * Define if the texture must be cleared before rendering (default is true)
  84810. */
  84811. autoClear: boolean;
  84812. /**
  84813. * Callback called when the texture is generated
  84814. */
  84815. onGenerated: () => void;
  84816. /**
  84817. * Event raised when the texture is generated
  84818. */
  84819. onGeneratedObservable: Observable<ProceduralTexture>;
  84820. /** @hidden */
  84821. _generateMipMaps: boolean;
  84822. /** @hidden **/
  84823. _effect: Effect;
  84824. /** @hidden */
  84825. _textures: {
  84826. [key: string]: Texture;
  84827. };
  84828. private _size;
  84829. private _currentRefreshId;
  84830. private _refreshRate;
  84831. private _vertexBuffers;
  84832. private _indexBuffer;
  84833. private _uniforms;
  84834. private _samplers;
  84835. private _fragment;
  84836. private _floats;
  84837. private _ints;
  84838. private _floatsArrays;
  84839. private _colors3;
  84840. private _colors4;
  84841. private _vectors2;
  84842. private _vectors3;
  84843. private _matrices;
  84844. private _fallbackTexture;
  84845. private _fallbackTextureUsed;
  84846. private _engine;
  84847. private _cachedDefines;
  84848. private _contentUpdateId;
  84849. private _contentData;
  84850. /**
  84851. * Instantiates a new procedural texture.
  84852. * 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.
  84853. * This is the base class of any Procedural texture and contains most of the shareable code.
  84854. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84855. * @param name Define the name of the texture
  84856. * @param size Define the size of the texture to create
  84857. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84858. * @param scene Define the scene the texture belongs to
  84859. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84860. * @param generateMipMaps Define if the texture should creates mip maps or not
  84861. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84862. */
  84863. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84864. /**
  84865. * The effect that is created when initializing the post process.
  84866. * @returns The created effect corresponding the the postprocess.
  84867. */
  84868. getEffect(): Effect;
  84869. /**
  84870. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84871. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84872. */
  84873. getContent(): Nullable<ArrayBufferView>;
  84874. private _createIndexBuffer;
  84875. /** @hidden */
  84876. _rebuild(): void;
  84877. /**
  84878. * Resets the texture in order to recreate its associated resources.
  84879. * This can be called in case of context loss
  84880. */
  84881. reset(): void;
  84882. protected _getDefines(): string;
  84883. /**
  84884. * Is the texture ready to be used ? (rendered at least once)
  84885. * @returns true if ready, otherwise, false.
  84886. */
  84887. isReady(): boolean;
  84888. /**
  84889. * Resets the refresh counter of the texture and start bak from scratch.
  84890. * Could be useful to regenerate the texture if it is setup to render only once.
  84891. */
  84892. resetRefreshCounter(): void;
  84893. /**
  84894. * Set the fragment shader to use in order to render the texture.
  84895. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84896. */
  84897. setFragment(fragment: any): void;
  84898. /**
  84899. * Define the refresh rate of the texture or the rendering frequency.
  84900. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84901. */
  84902. refreshRate: number;
  84903. /** @hidden */
  84904. _shouldRender(): boolean;
  84905. /**
  84906. * Get the size the texture is rendering at.
  84907. * @returns the size (texture is always squared)
  84908. */
  84909. getRenderSize(): number;
  84910. /**
  84911. * Resize the texture to new value.
  84912. * @param size Define the new size the texture should have
  84913. * @param generateMipMaps Define whether the new texture should create mip maps
  84914. */
  84915. resize(size: number, generateMipMaps: boolean): void;
  84916. private _checkUniform;
  84917. /**
  84918. * Set a texture in the shader program used to render.
  84919. * @param name Define the name of the uniform samplers as defined in the shader
  84920. * @param texture Define the texture to bind to this sampler
  84921. * @return the texture itself allowing "fluent" like uniform updates
  84922. */
  84923. setTexture(name: string, texture: Texture): ProceduralTexture;
  84924. /**
  84925. * Set a float in the shader.
  84926. * @param name Define the name of the uniform as defined in the shader
  84927. * @param value Define the value to give to the uniform
  84928. * @return the texture itself allowing "fluent" like uniform updates
  84929. */
  84930. setFloat(name: string, value: number): ProceduralTexture;
  84931. /**
  84932. * Set a int in the shader.
  84933. * @param name Define the name of the uniform as defined in the shader
  84934. * @param value Define the value to give to the uniform
  84935. * @return the texture itself allowing "fluent" like uniform updates
  84936. */
  84937. setInt(name: string, value: number): ProceduralTexture;
  84938. /**
  84939. * Set an array of floats in the shader.
  84940. * @param name Define the name of the uniform as defined in the shader
  84941. * @param value Define the value to give to the uniform
  84942. * @return the texture itself allowing "fluent" like uniform updates
  84943. */
  84944. setFloats(name: string, value: number[]): ProceduralTexture;
  84945. /**
  84946. * Set a vec3 in the shader from a Color3.
  84947. * @param name Define the name of the uniform as defined in the shader
  84948. * @param value Define the value to give to the uniform
  84949. * @return the texture itself allowing "fluent" like uniform updates
  84950. */
  84951. setColor3(name: string, value: Color3): ProceduralTexture;
  84952. /**
  84953. * Set a vec4 in the shader from a Color4.
  84954. * @param name Define the name of the uniform as defined in the shader
  84955. * @param value Define the value to give to the uniform
  84956. * @return the texture itself allowing "fluent" like uniform updates
  84957. */
  84958. setColor4(name: string, value: Color4): ProceduralTexture;
  84959. /**
  84960. * Set a vec2 in the shader from a Vector2.
  84961. * @param name Define the name of the uniform as defined in the shader
  84962. * @param value Define the value to give to the uniform
  84963. * @return the texture itself allowing "fluent" like uniform updates
  84964. */
  84965. setVector2(name: string, value: Vector2): ProceduralTexture;
  84966. /**
  84967. * Set a vec3 in the shader from a Vector3.
  84968. * @param name Define the name of the uniform as defined in the shader
  84969. * @param value Define the value to give to the uniform
  84970. * @return the texture itself allowing "fluent" like uniform updates
  84971. */
  84972. setVector3(name: string, value: Vector3): ProceduralTexture;
  84973. /**
  84974. * Set a mat4 in the shader from a MAtrix.
  84975. * @param name Define the name of the uniform as defined in the shader
  84976. * @param value Define the value to give to the uniform
  84977. * @return the texture itself allowing "fluent" like uniform updates
  84978. */
  84979. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84980. /**
  84981. * Render the texture to its associated render target.
  84982. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84983. */
  84984. render(useCameraPostProcess?: boolean): void;
  84985. /**
  84986. * Clone the texture.
  84987. * @returns the cloned texture
  84988. */
  84989. clone(): ProceduralTexture;
  84990. /**
  84991. * Dispose the texture and release its asoociated resources.
  84992. */
  84993. dispose(): void;
  84994. }
  84995. }
  84996. declare module BABYLON {
  84997. /**
  84998. * This represents the base class for particle system in Babylon.
  84999. * 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.
  85000. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85001. * @example https://doc.babylonjs.com/babylon101/particles
  85002. */
  85003. export class BaseParticleSystem {
  85004. /**
  85005. * Source color is added to the destination color without alpha affecting the result
  85006. */
  85007. static BLENDMODE_ONEONE: number;
  85008. /**
  85009. * Blend current color and particle color using particle’s alpha
  85010. */
  85011. static BLENDMODE_STANDARD: number;
  85012. /**
  85013. * Add current color and particle color multiplied by particle’s alpha
  85014. */
  85015. static BLENDMODE_ADD: number;
  85016. /**
  85017. * Multiply current color with particle color
  85018. */
  85019. static BLENDMODE_MULTIPLY: number;
  85020. /**
  85021. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85022. */
  85023. static BLENDMODE_MULTIPLYADD: number;
  85024. /**
  85025. * List of animations used by the particle system.
  85026. */
  85027. animations: Animation[];
  85028. /**
  85029. * The id of the Particle system.
  85030. */
  85031. id: string;
  85032. /**
  85033. * The friendly name of the Particle system.
  85034. */
  85035. name: string;
  85036. /**
  85037. * The rendering group used by the Particle system to chose when to render.
  85038. */
  85039. renderingGroupId: number;
  85040. /**
  85041. * The emitter represents the Mesh or position we are attaching the particle system to.
  85042. */
  85043. emitter: Nullable<AbstractMesh | Vector3>;
  85044. /**
  85045. * The maximum number of particles to emit per frame
  85046. */
  85047. emitRate: number;
  85048. /**
  85049. * If you want to launch only a few particles at once, that can be done, as well.
  85050. */
  85051. manualEmitCount: number;
  85052. /**
  85053. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85054. */
  85055. updateSpeed: number;
  85056. /**
  85057. * The amount of time the particle system is running (depends of the overall update speed).
  85058. */
  85059. targetStopDuration: number;
  85060. /**
  85061. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85062. */
  85063. disposeOnStop: boolean;
  85064. /**
  85065. * Minimum power of emitting particles.
  85066. */
  85067. minEmitPower: number;
  85068. /**
  85069. * Maximum power of emitting particles.
  85070. */
  85071. maxEmitPower: number;
  85072. /**
  85073. * Minimum life time of emitting particles.
  85074. */
  85075. minLifeTime: number;
  85076. /**
  85077. * Maximum life time of emitting particles.
  85078. */
  85079. maxLifeTime: number;
  85080. /**
  85081. * Minimum Size of emitting particles.
  85082. */
  85083. minSize: number;
  85084. /**
  85085. * Maximum Size of emitting particles.
  85086. */
  85087. maxSize: number;
  85088. /**
  85089. * Minimum scale of emitting particles on X axis.
  85090. */
  85091. minScaleX: number;
  85092. /**
  85093. * Maximum scale of emitting particles on X axis.
  85094. */
  85095. maxScaleX: number;
  85096. /**
  85097. * Minimum scale of emitting particles on Y axis.
  85098. */
  85099. minScaleY: number;
  85100. /**
  85101. * Maximum scale of emitting particles on Y axis.
  85102. */
  85103. maxScaleY: number;
  85104. /**
  85105. * Gets or sets the minimal initial rotation in radians.
  85106. */
  85107. minInitialRotation: number;
  85108. /**
  85109. * Gets or sets the maximal initial rotation in radians.
  85110. */
  85111. maxInitialRotation: number;
  85112. /**
  85113. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85114. */
  85115. minAngularSpeed: number;
  85116. /**
  85117. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85118. */
  85119. maxAngularSpeed: number;
  85120. /**
  85121. * The texture used to render each particle. (this can be a spritesheet)
  85122. */
  85123. particleTexture: Nullable<Texture>;
  85124. /**
  85125. * The layer mask we are rendering the particles through.
  85126. */
  85127. layerMask: number;
  85128. /**
  85129. * This can help using your own shader to render the particle system.
  85130. * The according effect will be created
  85131. */
  85132. customShader: any;
  85133. /**
  85134. * By default particle system starts as soon as they are created. This prevents the
  85135. * automatic start to happen and let you decide when to start emitting particles.
  85136. */
  85137. preventAutoStart: boolean;
  85138. private _noiseTexture;
  85139. /**
  85140. * Gets or sets a texture used to add random noise to particle positions
  85141. */
  85142. noiseTexture: Nullable<ProceduralTexture>;
  85143. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85144. noiseStrength: Vector3;
  85145. /**
  85146. * Callback triggered when the particle animation is ending.
  85147. */
  85148. onAnimationEnd: Nullable<() => void>;
  85149. /**
  85150. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85151. */
  85152. blendMode: number;
  85153. /**
  85154. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85155. * to override the particles.
  85156. */
  85157. forceDepthWrite: boolean;
  85158. /** 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 */
  85159. preWarmCycles: number;
  85160. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85161. preWarmStepOffset: number;
  85162. /**
  85163. * 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)
  85164. */
  85165. spriteCellChangeSpeed: number;
  85166. /**
  85167. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85168. */
  85169. startSpriteCellID: number;
  85170. /**
  85171. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85172. */
  85173. endSpriteCellID: number;
  85174. /**
  85175. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85176. */
  85177. spriteCellWidth: number;
  85178. /**
  85179. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85180. */
  85181. spriteCellHeight: number;
  85182. /**
  85183. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85184. */
  85185. spriteRandomStartCell: boolean;
  85186. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85187. translationPivot: Vector2;
  85188. /** @hidden */
  85189. protected _isAnimationSheetEnabled: boolean;
  85190. /**
  85191. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85192. */
  85193. beginAnimationOnStart: boolean;
  85194. /**
  85195. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85196. */
  85197. beginAnimationFrom: number;
  85198. /**
  85199. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85200. */
  85201. beginAnimationTo: number;
  85202. /**
  85203. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85204. */
  85205. beginAnimationLoop: boolean;
  85206. /**
  85207. * Gets or sets a world offset applied to all particles
  85208. */
  85209. worldOffset: Vector3;
  85210. /**
  85211. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85212. */
  85213. isAnimationSheetEnabled: boolean;
  85214. /**
  85215. * Get hosting scene
  85216. * @returns the scene
  85217. */
  85218. getScene(): Scene;
  85219. /**
  85220. * You can use gravity if you want to give an orientation to your particles.
  85221. */
  85222. gravity: Vector3;
  85223. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85224. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85225. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85226. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85227. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85228. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85229. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85230. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85231. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85232. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85233. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85234. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85235. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85236. /**
  85237. * Defines the delay in milliseconds before starting the system (0 by default)
  85238. */
  85239. startDelay: number;
  85240. /**
  85241. * Gets the current list of drag gradients.
  85242. * You must use addDragGradient and removeDragGradient to udpate this list
  85243. * @returns the list of drag gradients
  85244. */
  85245. getDragGradients(): Nullable<Array<FactorGradient>>;
  85246. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85247. limitVelocityDamping: number;
  85248. /**
  85249. * Gets the current list of limit velocity gradients.
  85250. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85251. * @returns the list of limit velocity gradients
  85252. */
  85253. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85254. /**
  85255. * Gets the current list of color gradients.
  85256. * You must use addColorGradient and removeColorGradient to udpate this list
  85257. * @returns the list of color gradients
  85258. */
  85259. getColorGradients(): Nullable<Array<ColorGradient>>;
  85260. /**
  85261. * Gets the current list of size gradients.
  85262. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85263. * @returns the list of size gradients
  85264. */
  85265. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85266. /**
  85267. * Gets the current list of color remap gradients.
  85268. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85269. * @returns the list of color remap gradients
  85270. */
  85271. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85272. /**
  85273. * Gets the current list of alpha remap gradients.
  85274. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85275. * @returns the list of alpha remap gradients
  85276. */
  85277. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85278. /**
  85279. * Gets the current list of life time gradients.
  85280. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85281. * @returns the list of life time gradients
  85282. */
  85283. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85284. /**
  85285. * Gets the current list of angular speed gradients.
  85286. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85287. * @returns the list of angular speed gradients
  85288. */
  85289. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85290. /**
  85291. * Gets the current list of velocity gradients.
  85292. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85293. * @returns the list of velocity gradients
  85294. */
  85295. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85296. /**
  85297. * Gets the current list of start size gradients.
  85298. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85299. * @returns the list of start size gradients
  85300. */
  85301. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85302. /**
  85303. * Gets the current list of emit rate gradients.
  85304. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85305. * @returns the list of emit rate gradients
  85306. */
  85307. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85308. /**
  85309. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85310. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85311. */
  85312. direction1: Vector3;
  85313. /**
  85314. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85315. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85316. */
  85317. direction2: Vector3;
  85318. /**
  85319. * 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.
  85320. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85321. */
  85322. minEmitBox: Vector3;
  85323. /**
  85324. * 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.
  85325. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85326. */
  85327. maxEmitBox: Vector3;
  85328. /**
  85329. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85330. */
  85331. color1: Color4;
  85332. /**
  85333. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85334. */
  85335. color2: Color4;
  85336. /**
  85337. * Color the particle will have at the end of its lifetime
  85338. */
  85339. colorDead: Color4;
  85340. /**
  85341. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85342. */
  85343. textureMask: Color4;
  85344. /**
  85345. * The particle emitter type defines the emitter used by the particle system.
  85346. * It can be for example box, sphere, or cone...
  85347. */
  85348. particleEmitterType: IParticleEmitterType;
  85349. /** @hidden */
  85350. _isSubEmitter: boolean;
  85351. /**
  85352. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85353. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85354. */
  85355. billboardMode: number;
  85356. protected _isBillboardBased: boolean;
  85357. /**
  85358. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85359. */
  85360. isBillboardBased: boolean;
  85361. /**
  85362. * The scene the particle system belongs to.
  85363. */
  85364. protected _scene: Scene;
  85365. /**
  85366. * Local cache of defines for image processing.
  85367. */
  85368. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85369. /**
  85370. * Default configuration related to image processing available in the standard Material.
  85371. */
  85372. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85373. /**
  85374. * Gets the image processing configuration used either in this material.
  85375. */
  85376. /**
  85377. * Sets the Default image processing configuration used either in the this material.
  85378. *
  85379. * If sets to null, the scene one is in use.
  85380. */
  85381. imageProcessingConfiguration: ImageProcessingConfiguration;
  85382. /**
  85383. * Attaches a new image processing configuration to the Standard Material.
  85384. * @param configuration
  85385. */
  85386. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85387. /** @hidden */
  85388. protected _reset(): void;
  85389. /** @hidden */
  85390. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85391. /**
  85392. * Instantiates a particle system.
  85393. * 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.
  85394. * @param name The name of the particle system
  85395. */
  85396. constructor(name: string);
  85397. /**
  85398. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85399. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85400. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85401. * @returns the emitter
  85402. */
  85403. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85404. /**
  85405. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85406. * @param radius The radius of the hemisphere to emit from
  85407. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85408. * @returns the emitter
  85409. */
  85410. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85411. /**
  85412. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85413. * @param radius The radius of the sphere to emit from
  85414. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85415. * @returns the emitter
  85416. */
  85417. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85418. /**
  85419. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85420. * @param radius The radius of the sphere to emit from
  85421. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85422. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85423. * @returns the emitter
  85424. */
  85425. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85426. /**
  85427. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85428. * @param radius The radius of the emission cylinder
  85429. * @param height The height of the emission cylinder
  85430. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85431. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85432. * @returns the emitter
  85433. */
  85434. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85435. /**
  85436. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85437. * @param radius The radius of the cylinder to emit from
  85438. * @param height The height of the emission cylinder
  85439. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85440. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85441. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85442. * @returns the emitter
  85443. */
  85444. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85445. /**
  85446. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85447. * @param radius The radius of the cone to emit from
  85448. * @param angle The base angle of the cone
  85449. * @returns the emitter
  85450. */
  85451. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85452. /**
  85453. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85454. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85455. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85456. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85457. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85458. * @returns the emitter
  85459. */
  85460. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85461. }
  85462. }
  85463. declare module BABYLON {
  85464. /**
  85465. * Type of sub emitter
  85466. */
  85467. export enum SubEmitterType {
  85468. /**
  85469. * Attached to the particle over it's lifetime
  85470. */
  85471. ATTACHED = 0,
  85472. /**
  85473. * Created when the particle dies
  85474. */
  85475. END = 1
  85476. }
  85477. /**
  85478. * Sub emitter class used to emit particles from an existing particle
  85479. */
  85480. export class SubEmitter {
  85481. /**
  85482. * the particle system to be used by the sub emitter
  85483. */
  85484. particleSystem: ParticleSystem;
  85485. /**
  85486. * Type of the submitter (Default: END)
  85487. */
  85488. type: SubEmitterType;
  85489. /**
  85490. * 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)
  85491. * Note: This only is supported when using an emitter of type Mesh
  85492. */
  85493. inheritDirection: boolean;
  85494. /**
  85495. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85496. */
  85497. inheritedVelocityAmount: number;
  85498. /**
  85499. * Creates a sub emitter
  85500. * @param particleSystem the particle system to be used by the sub emitter
  85501. */
  85502. constructor(
  85503. /**
  85504. * the particle system to be used by the sub emitter
  85505. */
  85506. particleSystem: ParticleSystem);
  85507. /**
  85508. * Clones the sub emitter
  85509. * @returns the cloned sub emitter
  85510. */
  85511. clone(): SubEmitter;
  85512. /**
  85513. * Serialize current object to a JSON object
  85514. * @returns the serialized object
  85515. */
  85516. serialize(): any;
  85517. /** @hidden */
  85518. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85519. /**
  85520. * Creates a new SubEmitter from a serialized JSON version
  85521. * @param serializationObject defines the JSON object to read from
  85522. * @param scene defines the hosting scene
  85523. * @param rootUrl defines the rootUrl for data loading
  85524. * @returns a new SubEmitter
  85525. */
  85526. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85527. /** Release associated resources */
  85528. dispose(): void;
  85529. }
  85530. }
  85531. declare module BABYLON {
  85532. /** @hidden */
  85533. export var clipPlaneFragmentDeclaration: {
  85534. name: string;
  85535. shader: string;
  85536. };
  85537. }
  85538. declare module BABYLON {
  85539. /** @hidden */
  85540. export var imageProcessingDeclaration: {
  85541. name: string;
  85542. shader: string;
  85543. };
  85544. }
  85545. declare module BABYLON {
  85546. /** @hidden */
  85547. export var imageProcessingFunctions: {
  85548. name: string;
  85549. shader: string;
  85550. };
  85551. }
  85552. declare module BABYLON {
  85553. /** @hidden */
  85554. export var clipPlaneFragment: {
  85555. name: string;
  85556. shader: string;
  85557. };
  85558. }
  85559. declare module BABYLON {
  85560. /** @hidden */
  85561. export var particlesPixelShader: {
  85562. name: string;
  85563. shader: string;
  85564. };
  85565. }
  85566. declare module BABYLON {
  85567. /** @hidden */
  85568. export var clipPlaneVertexDeclaration: {
  85569. name: string;
  85570. shader: string;
  85571. };
  85572. }
  85573. declare module BABYLON {
  85574. /** @hidden */
  85575. export var clipPlaneVertex: {
  85576. name: string;
  85577. shader: string;
  85578. };
  85579. }
  85580. declare module BABYLON {
  85581. /** @hidden */
  85582. export var particlesVertexShader: {
  85583. name: string;
  85584. shader: string;
  85585. };
  85586. }
  85587. declare module BABYLON {
  85588. /**
  85589. * This represents a particle system in Babylon.
  85590. * 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.
  85591. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85592. * @example https://doc.babylonjs.com/babylon101/particles
  85593. */
  85594. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85595. /**
  85596. * Billboard mode will only apply to Y axis
  85597. */
  85598. static readonly BILLBOARDMODE_Y: number;
  85599. /**
  85600. * Billboard mode will apply to all axes
  85601. */
  85602. static readonly BILLBOARDMODE_ALL: number;
  85603. /**
  85604. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85605. */
  85606. static readonly BILLBOARDMODE_STRETCHED: number;
  85607. /**
  85608. * This function can be defined to provide custom update for active particles.
  85609. * This function will be called instead of regular update (age, position, color, etc.).
  85610. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85611. */
  85612. updateFunction: (particles: Particle[]) => void;
  85613. private _emitterWorldMatrix;
  85614. /**
  85615. * This function can be defined to specify initial direction for every new particle.
  85616. * It by default use the emitterType defined function
  85617. */
  85618. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  85619. /**
  85620. * This function can be defined to specify initial position for every new particle.
  85621. * It by default use the emitterType defined function
  85622. */
  85623. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  85624. /**
  85625. * @hidden
  85626. */
  85627. _inheritedVelocityOffset: Vector3;
  85628. /**
  85629. * An event triggered when the system is disposed
  85630. */
  85631. onDisposeObservable: Observable<ParticleSystem>;
  85632. private _onDisposeObserver;
  85633. /**
  85634. * Sets a callback that will be triggered when the system is disposed
  85635. */
  85636. onDispose: () => void;
  85637. private _particles;
  85638. private _epsilon;
  85639. private _capacity;
  85640. private _stockParticles;
  85641. private _newPartsExcess;
  85642. private _vertexData;
  85643. private _vertexBuffer;
  85644. private _vertexBuffers;
  85645. private _spriteBuffer;
  85646. private _indexBuffer;
  85647. private _effect;
  85648. private _customEffect;
  85649. private _cachedDefines;
  85650. private _scaledColorStep;
  85651. private _colorDiff;
  85652. private _scaledDirection;
  85653. private _scaledGravity;
  85654. private _currentRenderId;
  85655. private _alive;
  85656. private _useInstancing;
  85657. private _started;
  85658. private _stopped;
  85659. private _actualFrame;
  85660. private _scaledUpdateSpeed;
  85661. private _vertexBufferSize;
  85662. /** @hidden */
  85663. _currentEmitRateGradient: Nullable<FactorGradient>;
  85664. /** @hidden */
  85665. _currentEmitRate1: number;
  85666. /** @hidden */
  85667. _currentEmitRate2: number;
  85668. /** @hidden */
  85669. _currentStartSizeGradient: Nullable<FactorGradient>;
  85670. /** @hidden */
  85671. _currentStartSize1: number;
  85672. /** @hidden */
  85673. _currentStartSize2: number;
  85674. private readonly _rawTextureWidth;
  85675. private _rampGradientsTexture;
  85676. private _useRampGradients;
  85677. /** Gets or sets a boolean indicating that ramp gradients must be used
  85678. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85679. */
  85680. useRampGradients: boolean;
  85681. /**
  85682. * 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.
  85683. * 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: [])
  85684. */
  85685. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85686. private _subEmitters;
  85687. /**
  85688. * @hidden
  85689. * If the particle systems emitter should be disposed when the particle system is disposed
  85690. */
  85691. _disposeEmitterOnDispose: boolean;
  85692. /**
  85693. * The current active Sub-systems, this property is used by the root particle system only.
  85694. */
  85695. activeSubSystems: Array<ParticleSystem>;
  85696. private _rootParticleSystem;
  85697. /**
  85698. * Gets the current list of active particles
  85699. */
  85700. readonly particles: Particle[];
  85701. /**
  85702. * Returns the string "ParticleSystem"
  85703. * @returns a string containing the class name
  85704. */
  85705. getClassName(): string;
  85706. /**
  85707. * Instantiates a particle system.
  85708. * 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.
  85709. * @param name The name of the particle system
  85710. * @param capacity The max number of particles alive at the same time
  85711. * @param scene The scene the particle system belongs to
  85712. * @param customEffect a custom effect used to change the way particles are rendered by default
  85713. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  85714. * @param epsilon Offset used to render the particles
  85715. */
  85716. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  85717. private _addFactorGradient;
  85718. private _removeFactorGradient;
  85719. /**
  85720. * Adds a new life time gradient
  85721. * @param gradient defines the gradient to use (between 0 and 1)
  85722. * @param factor defines the life time factor to affect to the specified gradient
  85723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85724. * @returns the current particle system
  85725. */
  85726. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85727. /**
  85728. * Remove a specific life time gradient
  85729. * @param gradient defines the gradient to remove
  85730. * @returns the current particle system
  85731. */
  85732. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85733. /**
  85734. * Adds a new size gradient
  85735. * @param gradient defines the gradient to use (between 0 and 1)
  85736. * @param factor defines the size factor to affect to the specified gradient
  85737. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85738. * @returns the current particle system
  85739. */
  85740. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85741. /**
  85742. * Remove a specific size gradient
  85743. * @param gradient defines the gradient to remove
  85744. * @returns the current particle system
  85745. */
  85746. removeSizeGradient(gradient: number): IParticleSystem;
  85747. /**
  85748. * Adds a new color remap gradient
  85749. * @param gradient defines the gradient to use (between 0 and 1)
  85750. * @param min defines the color remap minimal range
  85751. * @param max defines the color remap maximal range
  85752. * @returns the current particle system
  85753. */
  85754. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85755. /**
  85756. * Remove a specific color remap gradient
  85757. * @param gradient defines the gradient to remove
  85758. * @returns the current particle system
  85759. */
  85760. removeColorRemapGradient(gradient: number): IParticleSystem;
  85761. /**
  85762. * Adds a new alpha remap gradient
  85763. * @param gradient defines the gradient to use (between 0 and 1)
  85764. * @param min defines the alpha remap minimal range
  85765. * @param max defines the alpha remap maximal range
  85766. * @returns the current particle system
  85767. */
  85768. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85769. /**
  85770. * Remove a specific alpha remap gradient
  85771. * @param gradient defines the gradient to remove
  85772. * @returns the current particle system
  85773. */
  85774. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85775. /**
  85776. * Adds a new angular speed gradient
  85777. * @param gradient defines the gradient to use (between 0 and 1)
  85778. * @param factor defines the angular speed to affect to the specified gradient
  85779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85780. * @returns the current particle system
  85781. */
  85782. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85783. /**
  85784. * Remove a specific angular speed gradient
  85785. * @param gradient defines the gradient to remove
  85786. * @returns the current particle system
  85787. */
  85788. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85789. /**
  85790. * Adds a new velocity gradient
  85791. * @param gradient defines the gradient to use (between 0 and 1)
  85792. * @param factor defines the velocity to affect to the specified gradient
  85793. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85794. * @returns the current particle system
  85795. */
  85796. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85797. /**
  85798. * Remove a specific velocity gradient
  85799. * @param gradient defines the gradient to remove
  85800. * @returns the current particle system
  85801. */
  85802. removeVelocityGradient(gradient: number): IParticleSystem;
  85803. /**
  85804. * Adds a new limit velocity gradient
  85805. * @param gradient defines the gradient to use (between 0 and 1)
  85806. * @param factor defines the limit velocity value to affect to the specified gradient
  85807. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85808. * @returns the current particle system
  85809. */
  85810. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85811. /**
  85812. * Remove a specific limit velocity gradient
  85813. * @param gradient defines the gradient to remove
  85814. * @returns the current particle system
  85815. */
  85816. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85817. /**
  85818. * Adds a new drag gradient
  85819. * @param gradient defines the gradient to use (between 0 and 1)
  85820. * @param factor defines the drag value to affect to the specified gradient
  85821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85822. * @returns the current particle system
  85823. */
  85824. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85825. /**
  85826. * Remove a specific drag gradient
  85827. * @param gradient defines the gradient to remove
  85828. * @returns the current particle system
  85829. */
  85830. removeDragGradient(gradient: number): IParticleSystem;
  85831. /**
  85832. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85833. * @param gradient defines the gradient to use (between 0 and 1)
  85834. * @param factor defines the emit rate value to affect to the specified gradient
  85835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85836. * @returns the current particle system
  85837. */
  85838. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85839. /**
  85840. * Remove a specific emit rate gradient
  85841. * @param gradient defines the gradient to remove
  85842. * @returns the current particle system
  85843. */
  85844. removeEmitRateGradient(gradient: number): IParticleSystem;
  85845. /**
  85846. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85847. * @param gradient defines the gradient to use (between 0 and 1)
  85848. * @param factor defines the start size value to affect to the specified gradient
  85849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85850. * @returns the current particle system
  85851. */
  85852. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85853. /**
  85854. * Remove a specific start size gradient
  85855. * @param gradient defines the gradient to remove
  85856. * @returns the current particle system
  85857. */
  85858. removeStartSizeGradient(gradient: number): IParticleSystem;
  85859. private _createRampGradientTexture;
  85860. /**
  85861. * Gets the current list of ramp gradients.
  85862. * You must use addRampGradient and removeRampGradient to udpate this list
  85863. * @returns the list of ramp gradients
  85864. */
  85865. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85866. /**
  85867. * Adds a new ramp gradient used to remap particle colors
  85868. * @param gradient defines the gradient to use (between 0 and 1)
  85869. * @param color defines the color to affect to the specified gradient
  85870. * @returns the current particle system
  85871. */
  85872. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85873. /**
  85874. * Remove a specific ramp gradient
  85875. * @param gradient defines the gradient to remove
  85876. * @returns the current particle system
  85877. */
  85878. removeRampGradient(gradient: number): ParticleSystem;
  85879. /**
  85880. * Adds a new color gradient
  85881. * @param gradient defines the gradient to use (between 0 and 1)
  85882. * @param color1 defines the color to affect to the specified gradient
  85883. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85884. * @returns this particle system
  85885. */
  85886. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85887. /**
  85888. * Remove a specific color gradient
  85889. * @param gradient defines the gradient to remove
  85890. * @returns this particle system
  85891. */
  85892. removeColorGradient(gradient: number): IParticleSystem;
  85893. private _fetchR;
  85894. protected _reset(): void;
  85895. private _resetEffect;
  85896. private _createVertexBuffers;
  85897. private _createIndexBuffer;
  85898. /**
  85899. * Gets the maximum number of particles active at the same time.
  85900. * @returns The max number of active particles.
  85901. */
  85902. getCapacity(): number;
  85903. /**
  85904. * Gets whether there are still active particles in the system.
  85905. * @returns True if it is alive, otherwise false.
  85906. */
  85907. isAlive(): boolean;
  85908. /**
  85909. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85910. * @returns True if it has been started, otherwise false.
  85911. */
  85912. isStarted(): boolean;
  85913. private _prepareSubEmitterInternalArray;
  85914. /**
  85915. * Starts the particle system and begins to emit
  85916. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85917. */
  85918. start(delay?: number): void;
  85919. /**
  85920. * Stops the particle system.
  85921. * @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.
  85922. */
  85923. stop(stopSubEmitters?: boolean): void;
  85924. /**
  85925. * Remove all active particles
  85926. */
  85927. reset(): void;
  85928. /**
  85929. * @hidden (for internal use only)
  85930. */
  85931. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85932. /**
  85933. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85934. * Its lifetime will start back at 0.
  85935. */
  85936. recycleParticle: (particle: Particle) => void;
  85937. private _stopSubEmitters;
  85938. private _createParticle;
  85939. private _removeFromRoot;
  85940. private _emitFromParticle;
  85941. private _update;
  85942. /** @hidden */
  85943. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85944. /** @hidden */
  85945. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85946. /** @hidden */
  85947. private _getEffect;
  85948. /**
  85949. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85950. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85951. */
  85952. animate(preWarmOnly?: boolean): void;
  85953. private _appendParticleVertices;
  85954. /**
  85955. * Rebuilds the particle system.
  85956. */
  85957. rebuild(): void;
  85958. /**
  85959. * Is this system ready to be used/rendered
  85960. * @return true if the system is ready
  85961. */
  85962. isReady(): boolean;
  85963. private _render;
  85964. /**
  85965. * Renders the particle system in its current state.
  85966. * @returns the current number of particles
  85967. */
  85968. render(): number;
  85969. /**
  85970. * Disposes the particle system and free the associated resources
  85971. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85972. */
  85973. dispose(disposeTexture?: boolean): void;
  85974. /**
  85975. * Clones the particle system.
  85976. * @param name The name of the cloned object
  85977. * @param newEmitter The new emitter to use
  85978. * @returns the cloned particle system
  85979. */
  85980. clone(name: string, newEmitter: any): ParticleSystem;
  85981. /**
  85982. * Serializes the particle system to a JSON object.
  85983. * @returns the JSON object
  85984. */
  85985. serialize(): any;
  85986. /** @hidden */
  85987. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85988. /** @hidden */
  85989. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85990. /**
  85991. * Parses a JSON object to create a particle system.
  85992. * @param parsedParticleSystem The JSON object to parse
  85993. * @param scene The scene to create the particle system in
  85994. * @param rootUrl The root url to use to load external dependencies like texture
  85995. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85996. * @returns the Parsed particle system
  85997. */
  85998. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85999. }
  86000. }
  86001. declare module BABYLON {
  86002. /**
  86003. * A particle represents one of the element emitted by a particle system.
  86004. * This is mainly define by its coordinates, direction, velocity and age.
  86005. */
  86006. export class Particle {
  86007. /**
  86008. * The particle system the particle belongs to.
  86009. */
  86010. particleSystem: ParticleSystem;
  86011. private static _Count;
  86012. /**
  86013. * Unique ID of the particle
  86014. */
  86015. id: number;
  86016. /**
  86017. * The world position of the particle in the scene.
  86018. */
  86019. position: Vector3;
  86020. /**
  86021. * The world direction of the particle in the scene.
  86022. */
  86023. direction: Vector3;
  86024. /**
  86025. * The color of the particle.
  86026. */
  86027. color: Color4;
  86028. /**
  86029. * The color change of the particle per step.
  86030. */
  86031. colorStep: Color4;
  86032. /**
  86033. * Defines how long will the life of the particle be.
  86034. */
  86035. lifeTime: number;
  86036. /**
  86037. * The current age of the particle.
  86038. */
  86039. age: number;
  86040. /**
  86041. * The current size of the particle.
  86042. */
  86043. size: number;
  86044. /**
  86045. * The current scale of the particle.
  86046. */
  86047. scale: Vector2;
  86048. /**
  86049. * The current angle of the particle.
  86050. */
  86051. angle: number;
  86052. /**
  86053. * Defines how fast is the angle changing.
  86054. */
  86055. angularSpeed: number;
  86056. /**
  86057. * Defines the cell index used by the particle to be rendered from a sprite.
  86058. */
  86059. cellIndex: number;
  86060. /**
  86061. * The information required to support color remapping
  86062. */
  86063. remapData: Vector4;
  86064. /** @hidden */
  86065. _randomCellOffset?: number;
  86066. /** @hidden */
  86067. _initialDirection: Nullable<Vector3>;
  86068. /** @hidden */
  86069. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86070. /** @hidden */
  86071. _initialStartSpriteCellID: number;
  86072. /** @hidden */
  86073. _initialEndSpriteCellID: number;
  86074. /** @hidden */
  86075. _currentColorGradient: Nullable<ColorGradient>;
  86076. /** @hidden */
  86077. _currentColor1: Color4;
  86078. /** @hidden */
  86079. _currentColor2: Color4;
  86080. /** @hidden */
  86081. _currentSizeGradient: Nullable<FactorGradient>;
  86082. /** @hidden */
  86083. _currentSize1: number;
  86084. /** @hidden */
  86085. _currentSize2: number;
  86086. /** @hidden */
  86087. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86088. /** @hidden */
  86089. _currentAngularSpeed1: number;
  86090. /** @hidden */
  86091. _currentAngularSpeed2: number;
  86092. /** @hidden */
  86093. _currentVelocityGradient: Nullable<FactorGradient>;
  86094. /** @hidden */
  86095. _currentVelocity1: number;
  86096. /** @hidden */
  86097. _currentVelocity2: number;
  86098. /** @hidden */
  86099. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86100. /** @hidden */
  86101. _currentLimitVelocity1: number;
  86102. /** @hidden */
  86103. _currentLimitVelocity2: number;
  86104. /** @hidden */
  86105. _currentDragGradient: Nullable<FactorGradient>;
  86106. /** @hidden */
  86107. _currentDrag1: number;
  86108. /** @hidden */
  86109. _currentDrag2: number;
  86110. /** @hidden */
  86111. _randomNoiseCoordinates1: Vector3;
  86112. /** @hidden */
  86113. _randomNoiseCoordinates2: Vector3;
  86114. /**
  86115. * Creates a new instance Particle
  86116. * @param particleSystem the particle system the particle belongs to
  86117. */
  86118. constructor(
  86119. /**
  86120. * The particle system the particle belongs to.
  86121. */
  86122. particleSystem: ParticleSystem);
  86123. private updateCellInfoFromSystem;
  86124. /**
  86125. * Defines how the sprite cell index is updated for the particle
  86126. */
  86127. updateCellIndex(): void;
  86128. /** @hidden */
  86129. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86130. /** @hidden */
  86131. _inheritParticleInfoToSubEmitters(): void;
  86132. /** @hidden */
  86133. _reset(): void;
  86134. /**
  86135. * Copy the properties of particle to another one.
  86136. * @param other the particle to copy the information to.
  86137. */
  86138. copyTo(other: Particle): void;
  86139. }
  86140. }
  86141. declare module BABYLON {
  86142. /**
  86143. * Particle emitter represents a volume emitting particles.
  86144. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86145. */
  86146. export interface IParticleEmitterType {
  86147. /**
  86148. * Called by the particle System when the direction is computed for the created particle.
  86149. * @param worldMatrix is the world matrix of the particle system
  86150. * @param directionToUpdate is the direction vector to update with the result
  86151. * @param particle is the particle we are computed the direction for
  86152. */
  86153. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86154. /**
  86155. * Called by the particle System when the position is computed for the created particle.
  86156. * @param worldMatrix is the world matrix of the particle system
  86157. * @param positionToUpdate is the position vector to update with the result
  86158. * @param particle is the particle we are computed the position for
  86159. */
  86160. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86161. /**
  86162. * Clones the current emitter and returns a copy of it
  86163. * @returns the new emitter
  86164. */
  86165. clone(): IParticleEmitterType;
  86166. /**
  86167. * Called by the GPUParticleSystem to setup the update shader
  86168. * @param effect defines the update shader
  86169. */
  86170. applyToShader(effect: Effect): void;
  86171. /**
  86172. * Returns a string to use to update the GPU particles update shader
  86173. * @returns the effect defines string
  86174. */
  86175. getEffectDefines(): string;
  86176. /**
  86177. * Returns a string representing the class name
  86178. * @returns a string containing the class name
  86179. */
  86180. getClassName(): string;
  86181. /**
  86182. * Serializes the particle system to a JSON object.
  86183. * @returns the JSON object
  86184. */
  86185. serialize(): any;
  86186. /**
  86187. * Parse properties from a JSON object
  86188. * @param serializationObject defines the JSON object
  86189. */
  86190. parse(serializationObject: any): void;
  86191. }
  86192. }
  86193. declare module BABYLON {
  86194. /**
  86195. * Particle emitter emitting particles from the inside of a box.
  86196. * It emits the particles randomly between 2 given directions.
  86197. */
  86198. export class BoxParticleEmitter implements IParticleEmitterType {
  86199. /**
  86200. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86201. */
  86202. direction1: Vector3;
  86203. /**
  86204. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86205. */
  86206. direction2: Vector3;
  86207. /**
  86208. * 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.
  86209. */
  86210. minEmitBox: Vector3;
  86211. /**
  86212. * 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.
  86213. */
  86214. maxEmitBox: Vector3;
  86215. /**
  86216. * Creates a new instance BoxParticleEmitter
  86217. */
  86218. constructor();
  86219. /**
  86220. * Called by the particle System when the direction is computed for the created particle.
  86221. * @param worldMatrix is the world matrix of the particle system
  86222. * @param directionToUpdate is the direction vector to update with the result
  86223. * @param particle is the particle we are computed the direction for
  86224. */
  86225. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86226. /**
  86227. * Called by the particle System when the position is computed for the created particle.
  86228. * @param worldMatrix is the world matrix of the particle system
  86229. * @param positionToUpdate is the position vector to update with the result
  86230. * @param particle is the particle we are computed the position for
  86231. */
  86232. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86233. /**
  86234. * Clones the current emitter and returns a copy of it
  86235. * @returns the new emitter
  86236. */
  86237. clone(): BoxParticleEmitter;
  86238. /**
  86239. * Called by the GPUParticleSystem to setup the update shader
  86240. * @param effect defines the update shader
  86241. */
  86242. applyToShader(effect: Effect): void;
  86243. /**
  86244. * Returns a string to use to update the GPU particles update shader
  86245. * @returns a string containng the defines string
  86246. */
  86247. getEffectDefines(): string;
  86248. /**
  86249. * Returns the string "BoxParticleEmitter"
  86250. * @returns a string containing the class name
  86251. */
  86252. getClassName(): string;
  86253. /**
  86254. * Serializes the particle system to a JSON object.
  86255. * @returns the JSON object
  86256. */
  86257. serialize(): any;
  86258. /**
  86259. * Parse properties from a JSON object
  86260. * @param serializationObject defines the JSON object
  86261. */
  86262. parse(serializationObject: any): void;
  86263. }
  86264. }
  86265. declare module BABYLON {
  86266. /**
  86267. * Particle emitter emitting particles from the inside of a cone.
  86268. * It emits the particles alongside the cone volume from the base to the particle.
  86269. * The emission direction might be randomized.
  86270. */
  86271. export class ConeParticleEmitter implements IParticleEmitterType {
  86272. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86273. directionRandomizer: number;
  86274. private _radius;
  86275. private _angle;
  86276. private _height;
  86277. /**
  86278. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86279. */
  86280. radiusRange: number;
  86281. /**
  86282. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86283. */
  86284. heightRange: number;
  86285. /**
  86286. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86287. */
  86288. emitFromSpawnPointOnly: boolean;
  86289. /**
  86290. * Gets or sets the radius of the emission cone
  86291. */
  86292. radius: number;
  86293. /**
  86294. * Gets or sets the angle of the emission cone
  86295. */
  86296. angle: number;
  86297. private _buildHeight;
  86298. /**
  86299. * Creates a new instance ConeParticleEmitter
  86300. * @param radius the radius of the emission cone (1 by default)
  86301. * @param angle the cone base angle (PI by default)
  86302. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86303. */
  86304. constructor(radius?: number, angle?: number,
  86305. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86306. directionRandomizer?: number);
  86307. /**
  86308. * Called by the particle System when the direction is computed for the created particle.
  86309. * @param worldMatrix is the world matrix of the particle system
  86310. * @param directionToUpdate is the direction vector to update with the result
  86311. * @param particle is the particle we are computed the direction for
  86312. */
  86313. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86314. /**
  86315. * Called by the particle System when the position is computed for the created particle.
  86316. * @param worldMatrix is the world matrix of the particle system
  86317. * @param positionToUpdate is the position vector to update with the result
  86318. * @param particle is the particle we are computed the position for
  86319. */
  86320. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86321. /**
  86322. * Clones the current emitter and returns a copy of it
  86323. * @returns the new emitter
  86324. */
  86325. clone(): ConeParticleEmitter;
  86326. /**
  86327. * Called by the GPUParticleSystem to setup the update shader
  86328. * @param effect defines the update shader
  86329. */
  86330. applyToShader(effect: Effect): void;
  86331. /**
  86332. * Returns a string to use to update the GPU particles update shader
  86333. * @returns a string containng the defines string
  86334. */
  86335. getEffectDefines(): string;
  86336. /**
  86337. * Returns the string "ConeParticleEmitter"
  86338. * @returns a string containing the class name
  86339. */
  86340. getClassName(): string;
  86341. /**
  86342. * Serializes the particle system to a JSON object.
  86343. * @returns the JSON object
  86344. */
  86345. serialize(): any;
  86346. /**
  86347. * Parse properties from a JSON object
  86348. * @param serializationObject defines the JSON object
  86349. */
  86350. parse(serializationObject: any): void;
  86351. }
  86352. }
  86353. declare module BABYLON {
  86354. /**
  86355. * Particle emitter emitting particles from the inside of a cylinder.
  86356. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86357. */
  86358. export class CylinderParticleEmitter implements IParticleEmitterType {
  86359. /**
  86360. * The radius of the emission cylinder.
  86361. */
  86362. radius: number;
  86363. /**
  86364. * The height of the emission cylinder.
  86365. */
  86366. height: number;
  86367. /**
  86368. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86369. */
  86370. radiusRange: number;
  86371. /**
  86372. * How much to randomize the particle direction [0-1].
  86373. */
  86374. directionRandomizer: number;
  86375. /**
  86376. * Creates a new instance CylinderParticleEmitter
  86377. * @param radius the radius of the emission cylinder (1 by default)
  86378. * @param height the height of the emission cylinder (1 by default)
  86379. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86380. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86381. */
  86382. constructor(
  86383. /**
  86384. * The radius of the emission cylinder.
  86385. */
  86386. radius?: number,
  86387. /**
  86388. * The height of the emission cylinder.
  86389. */
  86390. height?: number,
  86391. /**
  86392. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86393. */
  86394. radiusRange?: number,
  86395. /**
  86396. * How much to randomize the particle direction [0-1].
  86397. */
  86398. directionRandomizer?: number);
  86399. /**
  86400. * Called by the particle System when the direction is computed for the created particle.
  86401. * @param worldMatrix is the world matrix of the particle system
  86402. * @param directionToUpdate is the direction vector to update with the result
  86403. * @param particle is the particle we are computed the direction for
  86404. */
  86405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86406. /**
  86407. * Called by the particle System when the position is computed for the created particle.
  86408. * @param worldMatrix is the world matrix of the particle system
  86409. * @param positionToUpdate is the position vector to update with the result
  86410. * @param particle is the particle we are computed the position for
  86411. */
  86412. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86413. /**
  86414. * Clones the current emitter and returns a copy of it
  86415. * @returns the new emitter
  86416. */
  86417. clone(): CylinderParticleEmitter;
  86418. /**
  86419. * Called by the GPUParticleSystem to setup the update shader
  86420. * @param effect defines the update shader
  86421. */
  86422. applyToShader(effect: Effect): void;
  86423. /**
  86424. * Returns a string to use to update the GPU particles update shader
  86425. * @returns a string containng the defines string
  86426. */
  86427. getEffectDefines(): string;
  86428. /**
  86429. * Returns the string "CylinderParticleEmitter"
  86430. * @returns a string containing the class name
  86431. */
  86432. getClassName(): string;
  86433. /**
  86434. * Serializes the particle system to a JSON object.
  86435. * @returns the JSON object
  86436. */
  86437. serialize(): any;
  86438. /**
  86439. * Parse properties from a JSON object
  86440. * @param serializationObject defines the JSON object
  86441. */
  86442. parse(serializationObject: any): void;
  86443. }
  86444. /**
  86445. * Particle emitter emitting particles from the inside of a cylinder.
  86446. * It emits the particles randomly between two vectors.
  86447. */
  86448. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86449. /**
  86450. * The min limit of the emission direction.
  86451. */
  86452. direction1: Vector3;
  86453. /**
  86454. * The max limit of the emission direction.
  86455. */
  86456. direction2: Vector3;
  86457. /**
  86458. * Creates a new instance CylinderDirectedParticleEmitter
  86459. * @param radius the radius of the emission cylinder (1 by default)
  86460. * @param height the height of the emission cylinder (1 by default)
  86461. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86462. * @param direction1 the min limit of the emission direction (up vector by default)
  86463. * @param direction2 the max limit of the emission direction (up vector by default)
  86464. */
  86465. constructor(radius?: number, height?: number, radiusRange?: number,
  86466. /**
  86467. * The min limit of the emission direction.
  86468. */
  86469. direction1?: Vector3,
  86470. /**
  86471. * The max limit of the emission direction.
  86472. */
  86473. direction2?: Vector3);
  86474. /**
  86475. * Called by the particle System when the direction is computed for the created particle.
  86476. * @param worldMatrix is the world matrix of the particle system
  86477. * @param directionToUpdate is the direction vector to update with the result
  86478. * @param particle is the particle we are computed the direction for
  86479. */
  86480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86481. /**
  86482. * Clones the current emitter and returns a copy of it
  86483. * @returns the new emitter
  86484. */
  86485. clone(): CylinderDirectedParticleEmitter;
  86486. /**
  86487. * Called by the GPUParticleSystem to setup the update shader
  86488. * @param effect defines the update shader
  86489. */
  86490. applyToShader(effect: Effect): void;
  86491. /**
  86492. * Returns a string to use to update the GPU particles update shader
  86493. * @returns a string containng the defines string
  86494. */
  86495. getEffectDefines(): string;
  86496. /**
  86497. * Returns the string "CylinderDirectedParticleEmitter"
  86498. * @returns a string containing the class name
  86499. */
  86500. getClassName(): string;
  86501. /**
  86502. * Serializes the particle system to a JSON object.
  86503. * @returns the JSON object
  86504. */
  86505. serialize(): any;
  86506. /**
  86507. * Parse properties from a JSON object
  86508. * @param serializationObject defines the JSON object
  86509. */
  86510. parse(serializationObject: any): void;
  86511. }
  86512. }
  86513. declare module BABYLON {
  86514. /**
  86515. * Particle emitter emitting particles from the inside of a hemisphere.
  86516. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86517. */
  86518. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86519. /**
  86520. * The radius of the emission hemisphere.
  86521. */
  86522. radius: number;
  86523. /**
  86524. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86525. */
  86526. radiusRange: number;
  86527. /**
  86528. * How much to randomize the particle direction [0-1].
  86529. */
  86530. directionRandomizer: number;
  86531. /**
  86532. * Creates a new instance HemisphericParticleEmitter
  86533. * @param radius the radius of the emission hemisphere (1 by default)
  86534. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86535. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86536. */
  86537. constructor(
  86538. /**
  86539. * The radius of the emission hemisphere.
  86540. */
  86541. radius?: number,
  86542. /**
  86543. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86544. */
  86545. radiusRange?: number,
  86546. /**
  86547. * How much to randomize the particle direction [0-1].
  86548. */
  86549. directionRandomizer?: number);
  86550. /**
  86551. * Called by the particle System when the direction is computed for the created particle.
  86552. * @param worldMatrix is the world matrix of the particle system
  86553. * @param directionToUpdate is the direction vector to update with the result
  86554. * @param particle is the particle we are computed the direction for
  86555. */
  86556. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86557. /**
  86558. * Called by the particle System when the position is computed for the created particle.
  86559. * @param worldMatrix is the world matrix of the particle system
  86560. * @param positionToUpdate is the position vector to update with the result
  86561. * @param particle is the particle we are computed the position for
  86562. */
  86563. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86564. /**
  86565. * Clones the current emitter and returns a copy of it
  86566. * @returns the new emitter
  86567. */
  86568. clone(): HemisphericParticleEmitter;
  86569. /**
  86570. * Called by the GPUParticleSystem to setup the update shader
  86571. * @param effect defines the update shader
  86572. */
  86573. applyToShader(effect: Effect): void;
  86574. /**
  86575. * Returns a string to use to update the GPU particles update shader
  86576. * @returns a string containng the defines string
  86577. */
  86578. getEffectDefines(): string;
  86579. /**
  86580. * Returns the string "HemisphericParticleEmitter"
  86581. * @returns a string containing the class name
  86582. */
  86583. getClassName(): string;
  86584. /**
  86585. * Serializes the particle system to a JSON object.
  86586. * @returns the JSON object
  86587. */
  86588. serialize(): any;
  86589. /**
  86590. * Parse properties from a JSON object
  86591. * @param serializationObject defines the JSON object
  86592. */
  86593. parse(serializationObject: any): void;
  86594. }
  86595. }
  86596. declare module BABYLON {
  86597. /**
  86598. * Particle emitter emitting particles from a point.
  86599. * It emits the particles randomly between 2 given directions.
  86600. */
  86601. export class PointParticleEmitter implements IParticleEmitterType {
  86602. /**
  86603. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86604. */
  86605. direction1: Vector3;
  86606. /**
  86607. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86608. */
  86609. direction2: Vector3;
  86610. /**
  86611. * Creates a new instance PointParticleEmitter
  86612. */
  86613. constructor();
  86614. /**
  86615. * Called by the particle System when the direction is computed for the created particle.
  86616. * @param worldMatrix is the world matrix of the particle system
  86617. * @param directionToUpdate is the direction vector to update with the result
  86618. * @param particle is the particle we are computed the direction for
  86619. */
  86620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86621. /**
  86622. * Called by the particle System when the position is computed for the created particle.
  86623. * @param worldMatrix is the world matrix of the particle system
  86624. * @param positionToUpdate is the position vector to update with the result
  86625. * @param particle is the particle we are computed the position for
  86626. */
  86627. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86628. /**
  86629. * Clones the current emitter and returns a copy of it
  86630. * @returns the new emitter
  86631. */
  86632. clone(): PointParticleEmitter;
  86633. /**
  86634. * Called by the GPUParticleSystem to setup the update shader
  86635. * @param effect defines the update shader
  86636. */
  86637. applyToShader(effect: Effect): void;
  86638. /**
  86639. * Returns a string to use to update the GPU particles update shader
  86640. * @returns a string containng the defines string
  86641. */
  86642. getEffectDefines(): string;
  86643. /**
  86644. * Returns the string "PointParticleEmitter"
  86645. * @returns a string containing the class name
  86646. */
  86647. getClassName(): string;
  86648. /**
  86649. * Serializes the particle system to a JSON object.
  86650. * @returns the JSON object
  86651. */
  86652. serialize(): any;
  86653. /**
  86654. * Parse properties from a JSON object
  86655. * @param serializationObject defines the JSON object
  86656. */
  86657. parse(serializationObject: any): void;
  86658. }
  86659. }
  86660. declare module BABYLON {
  86661. /**
  86662. * Particle emitter emitting particles from the inside of a sphere.
  86663. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86664. */
  86665. export class SphereParticleEmitter implements IParticleEmitterType {
  86666. /**
  86667. * The radius of the emission sphere.
  86668. */
  86669. radius: number;
  86670. /**
  86671. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86672. */
  86673. radiusRange: number;
  86674. /**
  86675. * How much to randomize the particle direction [0-1].
  86676. */
  86677. directionRandomizer: number;
  86678. /**
  86679. * Creates a new instance SphereParticleEmitter
  86680. * @param radius the radius of the emission sphere (1 by default)
  86681. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86682. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86683. */
  86684. constructor(
  86685. /**
  86686. * The radius of the emission sphere.
  86687. */
  86688. radius?: number,
  86689. /**
  86690. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86691. */
  86692. radiusRange?: number,
  86693. /**
  86694. * How much to randomize the particle direction [0-1].
  86695. */
  86696. directionRandomizer?: number);
  86697. /**
  86698. * Called by the particle System when the direction is computed for the created particle.
  86699. * @param worldMatrix is the world matrix of the particle system
  86700. * @param directionToUpdate is the direction vector to update with the result
  86701. * @param particle is the particle we are computed the direction for
  86702. */
  86703. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86704. /**
  86705. * Called by the particle System when the position is computed for the created particle.
  86706. * @param worldMatrix is the world matrix of the particle system
  86707. * @param positionToUpdate is the position vector to update with the result
  86708. * @param particle is the particle we are computed the position for
  86709. */
  86710. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86711. /**
  86712. * Clones the current emitter and returns a copy of it
  86713. * @returns the new emitter
  86714. */
  86715. clone(): SphereParticleEmitter;
  86716. /**
  86717. * Called by the GPUParticleSystem to setup the update shader
  86718. * @param effect defines the update shader
  86719. */
  86720. applyToShader(effect: Effect): void;
  86721. /**
  86722. * Returns a string to use to update the GPU particles update shader
  86723. * @returns a string containng the defines string
  86724. */
  86725. getEffectDefines(): string;
  86726. /**
  86727. * Returns the string "SphereParticleEmitter"
  86728. * @returns a string containing the class name
  86729. */
  86730. getClassName(): string;
  86731. /**
  86732. * Serializes the particle system to a JSON object.
  86733. * @returns the JSON object
  86734. */
  86735. serialize(): any;
  86736. /**
  86737. * Parse properties from a JSON object
  86738. * @param serializationObject defines the JSON object
  86739. */
  86740. parse(serializationObject: any): void;
  86741. }
  86742. /**
  86743. * Particle emitter emitting particles from the inside of a sphere.
  86744. * It emits the particles randomly between two vectors.
  86745. */
  86746. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  86747. /**
  86748. * The min limit of the emission direction.
  86749. */
  86750. direction1: Vector3;
  86751. /**
  86752. * The max limit of the emission direction.
  86753. */
  86754. direction2: Vector3;
  86755. /**
  86756. * Creates a new instance SphereDirectedParticleEmitter
  86757. * @param radius the radius of the emission sphere (1 by default)
  86758. * @param direction1 the min limit of the emission direction (up vector by default)
  86759. * @param direction2 the max limit of the emission direction (up vector by default)
  86760. */
  86761. constructor(radius?: number,
  86762. /**
  86763. * The min limit of the emission direction.
  86764. */
  86765. direction1?: Vector3,
  86766. /**
  86767. * The max limit of the emission direction.
  86768. */
  86769. direction2?: Vector3);
  86770. /**
  86771. * Called by the particle System when the direction is computed for the created particle.
  86772. * @param worldMatrix is the world matrix of the particle system
  86773. * @param directionToUpdate is the direction vector to update with the result
  86774. * @param particle is the particle we are computed the direction for
  86775. */
  86776. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86777. /**
  86778. * Clones the current emitter and returns a copy of it
  86779. * @returns the new emitter
  86780. */
  86781. clone(): SphereDirectedParticleEmitter;
  86782. /**
  86783. * Called by the GPUParticleSystem to setup the update shader
  86784. * @param effect defines the update shader
  86785. */
  86786. applyToShader(effect: Effect): void;
  86787. /**
  86788. * Returns a string to use to update the GPU particles update shader
  86789. * @returns a string containng the defines string
  86790. */
  86791. getEffectDefines(): string;
  86792. /**
  86793. * Returns the string "SphereDirectedParticleEmitter"
  86794. * @returns a string containing the class name
  86795. */
  86796. getClassName(): string;
  86797. /**
  86798. * Serializes the particle system to a JSON object.
  86799. * @returns the JSON object
  86800. */
  86801. serialize(): any;
  86802. /**
  86803. * Parse properties from a JSON object
  86804. * @param serializationObject defines the JSON object
  86805. */
  86806. parse(serializationObject: any): void;
  86807. }
  86808. }
  86809. declare module BABYLON {
  86810. /**
  86811. * Interface representing a particle system in Babylon.js.
  86812. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86813. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86814. */
  86815. export interface IParticleSystem {
  86816. /**
  86817. * List of animations used by the particle system.
  86818. */
  86819. animations: Animation[];
  86820. /**
  86821. * The id of the Particle system.
  86822. */
  86823. id: string;
  86824. /**
  86825. * The name of the Particle system.
  86826. */
  86827. name: string;
  86828. /**
  86829. * The emitter represents the Mesh or position we are attaching the particle system to.
  86830. */
  86831. emitter: Nullable<AbstractMesh | Vector3>;
  86832. /**
  86833. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86834. */
  86835. isBillboardBased: boolean;
  86836. /**
  86837. * The rendering group used by the Particle system to chose when to render.
  86838. */
  86839. renderingGroupId: number;
  86840. /**
  86841. * The layer mask we are rendering the particles through.
  86842. */
  86843. layerMask: number;
  86844. /**
  86845. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86846. */
  86847. updateSpeed: number;
  86848. /**
  86849. * The amount of time the particle system is running (depends of the overall update speed).
  86850. */
  86851. targetStopDuration: number;
  86852. /**
  86853. * The texture used to render each particle. (this can be a spritesheet)
  86854. */
  86855. particleTexture: Nullable<Texture>;
  86856. /**
  86857. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86858. */
  86859. blendMode: number;
  86860. /**
  86861. * Minimum life time of emitting particles.
  86862. */
  86863. minLifeTime: number;
  86864. /**
  86865. * Maximum life time of emitting particles.
  86866. */
  86867. maxLifeTime: number;
  86868. /**
  86869. * Minimum Size of emitting particles.
  86870. */
  86871. minSize: number;
  86872. /**
  86873. * Maximum Size of emitting particles.
  86874. */
  86875. maxSize: number;
  86876. /**
  86877. * Minimum scale of emitting particles on X axis.
  86878. */
  86879. minScaleX: number;
  86880. /**
  86881. * Maximum scale of emitting particles on X axis.
  86882. */
  86883. maxScaleX: number;
  86884. /**
  86885. * Minimum scale of emitting particles on Y axis.
  86886. */
  86887. minScaleY: number;
  86888. /**
  86889. * Maximum scale of emitting particles on Y axis.
  86890. */
  86891. maxScaleY: number;
  86892. /**
  86893. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86894. */
  86895. color1: Color4;
  86896. /**
  86897. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86898. */
  86899. color2: Color4;
  86900. /**
  86901. * Color the particle will have at the end of its lifetime.
  86902. */
  86903. colorDead: Color4;
  86904. /**
  86905. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86906. */
  86907. emitRate: number;
  86908. /**
  86909. * You can use gravity if you want to give an orientation to your particles.
  86910. */
  86911. gravity: Vector3;
  86912. /**
  86913. * Minimum power of emitting particles.
  86914. */
  86915. minEmitPower: number;
  86916. /**
  86917. * Maximum power of emitting particles.
  86918. */
  86919. maxEmitPower: number;
  86920. /**
  86921. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86922. */
  86923. minAngularSpeed: number;
  86924. /**
  86925. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86926. */
  86927. maxAngularSpeed: number;
  86928. /**
  86929. * Gets or sets the minimal initial rotation in radians.
  86930. */
  86931. minInitialRotation: number;
  86932. /**
  86933. * Gets or sets the maximal initial rotation in radians.
  86934. */
  86935. maxInitialRotation: number;
  86936. /**
  86937. * The particle emitter type defines the emitter used by the particle system.
  86938. * It can be for example box, sphere, or cone...
  86939. */
  86940. particleEmitterType: Nullable<IParticleEmitterType>;
  86941. /**
  86942. * Defines the delay in milliseconds before starting the system (0 by default)
  86943. */
  86944. startDelay: number;
  86945. /**
  86946. * 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
  86947. */
  86948. preWarmCycles: number;
  86949. /**
  86950. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86951. */
  86952. preWarmStepOffset: number;
  86953. /**
  86954. * 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)
  86955. */
  86956. spriteCellChangeSpeed: number;
  86957. /**
  86958. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86959. */
  86960. startSpriteCellID: number;
  86961. /**
  86962. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86963. */
  86964. endSpriteCellID: number;
  86965. /**
  86966. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86967. */
  86968. spriteCellWidth: number;
  86969. /**
  86970. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86971. */
  86972. spriteCellHeight: number;
  86973. /**
  86974. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86975. */
  86976. spriteRandomStartCell: boolean;
  86977. /**
  86978. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86979. */
  86980. isAnimationSheetEnabled: boolean;
  86981. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86982. translationPivot: Vector2;
  86983. /**
  86984. * Gets or sets a texture used to add random noise to particle positions
  86985. */
  86986. noiseTexture: Nullable<BaseTexture>;
  86987. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86988. noiseStrength: Vector3;
  86989. /**
  86990. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86991. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86992. */
  86993. billboardMode: number;
  86994. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86995. limitVelocityDamping: number;
  86996. /**
  86997. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86998. */
  86999. beginAnimationOnStart: boolean;
  87000. /**
  87001. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87002. */
  87003. beginAnimationFrom: number;
  87004. /**
  87005. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87006. */
  87007. beginAnimationTo: number;
  87008. /**
  87009. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87010. */
  87011. beginAnimationLoop: boolean;
  87012. /**
  87013. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87014. */
  87015. disposeOnStop: boolean;
  87016. /**
  87017. * Gets the maximum number of particles active at the same time.
  87018. * @returns The max number of active particles.
  87019. */
  87020. getCapacity(): number;
  87021. /**
  87022. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87023. * @returns True if it has been started, otherwise false.
  87024. */
  87025. isStarted(): boolean;
  87026. /**
  87027. * Animates the particle system for this frame.
  87028. */
  87029. animate(): void;
  87030. /**
  87031. * Renders the particle system in its current state.
  87032. * @returns the current number of particles
  87033. */
  87034. render(): number;
  87035. /**
  87036. * Dispose the particle system and frees its associated resources.
  87037. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87038. */
  87039. dispose(disposeTexture?: boolean): void;
  87040. /**
  87041. * Clones the particle system.
  87042. * @param name The name of the cloned object
  87043. * @param newEmitter The new emitter to use
  87044. * @returns the cloned particle system
  87045. */
  87046. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87047. /**
  87048. * Serializes the particle system to a JSON object.
  87049. * @returns the JSON object
  87050. */
  87051. serialize(): any;
  87052. /**
  87053. * Rebuild the particle system
  87054. */
  87055. rebuild(): void;
  87056. /**
  87057. * Starts the particle system and begins to emit
  87058. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87059. */
  87060. start(delay?: number): void;
  87061. /**
  87062. * Stops the particle system.
  87063. */
  87064. stop(): void;
  87065. /**
  87066. * Remove all active particles
  87067. */
  87068. reset(): void;
  87069. /**
  87070. * Is this system ready to be used/rendered
  87071. * @return true if the system is ready
  87072. */
  87073. isReady(): boolean;
  87074. /**
  87075. * Adds a new color gradient
  87076. * @param gradient defines the gradient to use (between 0 and 1)
  87077. * @param color1 defines the color to affect to the specified gradient
  87078. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87079. * @returns the current particle system
  87080. */
  87081. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87082. /**
  87083. * Remove a specific color gradient
  87084. * @param gradient defines the gradient to remove
  87085. * @returns the current particle system
  87086. */
  87087. removeColorGradient(gradient: number): IParticleSystem;
  87088. /**
  87089. * Adds a new size gradient
  87090. * @param gradient defines the gradient to use (between 0 and 1)
  87091. * @param factor defines the size factor to affect to the specified gradient
  87092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87093. * @returns the current particle system
  87094. */
  87095. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87096. /**
  87097. * Remove a specific size gradient
  87098. * @param gradient defines the gradient to remove
  87099. * @returns the current particle system
  87100. */
  87101. removeSizeGradient(gradient: number): IParticleSystem;
  87102. /**
  87103. * Gets the current list of color gradients.
  87104. * You must use addColorGradient and removeColorGradient to udpate this list
  87105. * @returns the list of color gradients
  87106. */
  87107. getColorGradients(): Nullable<Array<ColorGradient>>;
  87108. /**
  87109. * Gets the current list of size gradients.
  87110. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87111. * @returns the list of size gradients
  87112. */
  87113. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87114. /**
  87115. * Gets the current list of angular speed gradients.
  87116. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87117. * @returns the list of angular speed gradients
  87118. */
  87119. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87120. /**
  87121. * Adds a new angular speed gradient
  87122. * @param gradient defines the gradient to use (between 0 and 1)
  87123. * @param factor defines the angular speed to affect to the specified gradient
  87124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87125. * @returns the current particle system
  87126. */
  87127. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87128. /**
  87129. * Remove a specific angular speed gradient
  87130. * @param gradient defines the gradient to remove
  87131. * @returns the current particle system
  87132. */
  87133. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87134. /**
  87135. * Gets the current list of velocity gradients.
  87136. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87137. * @returns the list of velocity gradients
  87138. */
  87139. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87140. /**
  87141. * Adds a new velocity gradient
  87142. * @param gradient defines the gradient to use (between 0 and 1)
  87143. * @param factor defines the velocity to affect to the specified gradient
  87144. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87145. * @returns the current particle system
  87146. */
  87147. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87148. /**
  87149. * Remove a specific velocity gradient
  87150. * @param gradient defines the gradient to remove
  87151. * @returns the current particle system
  87152. */
  87153. removeVelocityGradient(gradient: number): IParticleSystem;
  87154. /**
  87155. * Gets the current list of limit velocity gradients.
  87156. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87157. * @returns the list of limit velocity gradients
  87158. */
  87159. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87160. /**
  87161. * Adds a new limit velocity gradient
  87162. * @param gradient defines the gradient to use (between 0 and 1)
  87163. * @param factor defines the limit velocity to affect to the specified gradient
  87164. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87165. * @returns the current particle system
  87166. */
  87167. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87168. /**
  87169. * Remove a specific limit velocity gradient
  87170. * @param gradient defines the gradient to remove
  87171. * @returns the current particle system
  87172. */
  87173. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87174. /**
  87175. * Adds a new drag gradient
  87176. * @param gradient defines the gradient to use (between 0 and 1)
  87177. * @param factor defines the drag to affect to the specified gradient
  87178. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87179. * @returns the current particle system
  87180. */
  87181. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87182. /**
  87183. * Remove a specific drag gradient
  87184. * @param gradient defines the gradient to remove
  87185. * @returns the current particle system
  87186. */
  87187. removeDragGradient(gradient: number): IParticleSystem;
  87188. /**
  87189. * Gets the current list of drag gradients.
  87190. * You must use addDragGradient and removeDragGradient to udpate this list
  87191. * @returns the list of drag gradients
  87192. */
  87193. getDragGradients(): Nullable<Array<FactorGradient>>;
  87194. /**
  87195. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87196. * @param gradient defines the gradient to use (between 0 and 1)
  87197. * @param factor defines the emit rate to affect to the specified gradient
  87198. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87199. * @returns the current particle system
  87200. */
  87201. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87202. /**
  87203. * Remove a specific emit rate gradient
  87204. * @param gradient defines the gradient to remove
  87205. * @returns the current particle system
  87206. */
  87207. removeEmitRateGradient(gradient: number): IParticleSystem;
  87208. /**
  87209. * Gets the current list of emit rate gradients.
  87210. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87211. * @returns the list of emit rate gradients
  87212. */
  87213. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87214. /**
  87215. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87216. * @param gradient defines the gradient to use (between 0 and 1)
  87217. * @param factor defines the start size to affect to the specified gradient
  87218. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87219. * @returns the current particle system
  87220. */
  87221. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87222. /**
  87223. * Remove a specific start size gradient
  87224. * @param gradient defines the gradient to remove
  87225. * @returns the current particle system
  87226. */
  87227. removeStartSizeGradient(gradient: number): IParticleSystem;
  87228. /**
  87229. * Gets the current list of start size gradients.
  87230. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87231. * @returns the list of start size gradients
  87232. */
  87233. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87234. /**
  87235. * Adds a new life time gradient
  87236. * @param gradient defines the gradient to use (between 0 and 1)
  87237. * @param factor defines the life time factor to affect to the specified gradient
  87238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87239. * @returns the current particle system
  87240. */
  87241. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87242. /**
  87243. * Remove a specific life time gradient
  87244. * @param gradient defines the gradient to remove
  87245. * @returns the current particle system
  87246. */
  87247. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87248. /**
  87249. * Gets the current list of life time gradients.
  87250. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87251. * @returns the list of life time gradients
  87252. */
  87253. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87254. /**
  87255. * Gets the current list of color gradients.
  87256. * You must use addColorGradient and removeColorGradient to udpate this list
  87257. * @returns the list of color gradients
  87258. */
  87259. getColorGradients(): Nullable<Array<ColorGradient>>;
  87260. /**
  87261. * Adds a new ramp gradient used to remap particle colors
  87262. * @param gradient defines the gradient to use (between 0 and 1)
  87263. * @param color defines the color to affect to the specified gradient
  87264. * @returns the current particle system
  87265. */
  87266. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87267. /**
  87268. * Gets the current list of ramp gradients.
  87269. * You must use addRampGradient and removeRampGradient to udpate this list
  87270. * @returns the list of ramp gradients
  87271. */
  87272. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87273. /** Gets or sets a boolean indicating that ramp gradients must be used
  87274. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87275. */
  87276. useRampGradients: boolean;
  87277. /**
  87278. * Adds a new color remap gradient
  87279. * @param gradient defines the gradient to use (between 0 and 1)
  87280. * @param min defines the color remap minimal range
  87281. * @param max defines the color remap maximal range
  87282. * @returns the current particle system
  87283. */
  87284. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87285. /**
  87286. * Gets the current list of color remap gradients.
  87287. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87288. * @returns the list of color remap gradients
  87289. */
  87290. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87291. /**
  87292. * Adds a new alpha remap gradient
  87293. * @param gradient defines the gradient to use (between 0 and 1)
  87294. * @param min defines the alpha remap minimal range
  87295. * @param max defines the alpha remap maximal range
  87296. * @returns the current particle system
  87297. */
  87298. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87299. /**
  87300. * Gets the current list of alpha remap gradients.
  87301. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87302. * @returns the list of alpha remap gradients
  87303. */
  87304. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87305. /**
  87306. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87307. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87308. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87309. * @returns the emitter
  87310. */
  87311. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87312. /**
  87313. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87314. * @param radius The radius of the hemisphere to emit from
  87315. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87316. * @returns the emitter
  87317. */
  87318. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87319. /**
  87320. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87321. * @param radius The radius of the sphere to emit from
  87322. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87323. * @returns the emitter
  87324. */
  87325. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87326. /**
  87327. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87328. * @param radius The radius of the sphere to emit from
  87329. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87330. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87331. * @returns the emitter
  87332. */
  87333. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87334. /**
  87335. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87336. * @param radius The radius of the emission cylinder
  87337. * @param height The height of the emission cylinder
  87338. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87339. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87340. * @returns the emitter
  87341. */
  87342. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87343. /**
  87344. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87345. * @param radius The radius of the cylinder to emit from
  87346. * @param height The height of the emission cylinder
  87347. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87348. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87349. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87350. * @returns the emitter
  87351. */
  87352. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87353. /**
  87354. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87355. * @param radius The radius of the cone to emit from
  87356. * @param angle The base angle of the cone
  87357. * @returns the emitter
  87358. */
  87359. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87360. /**
  87361. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87362. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87363. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87364. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87365. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87366. * @returns the emitter
  87367. */
  87368. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87369. /**
  87370. * Get hosting scene
  87371. * @returns the scene
  87372. */
  87373. getScene(): Scene;
  87374. }
  87375. }
  87376. declare module BABYLON {
  87377. /**
  87378. * Creates an instance based on a source mesh.
  87379. */
  87380. export class InstancedMesh extends AbstractMesh {
  87381. private _sourceMesh;
  87382. private _currentLOD;
  87383. /** @hidden */
  87384. _indexInSourceMeshInstanceArray: number;
  87385. constructor(name: string, source: Mesh);
  87386. /**
  87387. * Returns the string "InstancedMesh".
  87388. */
  87389. getClassName(): string;
  87390. /** Gets the list of lights affecting that mesh */
  87391. readonly lightSources: Light[];
  87392. _resyncLightSources(): void;
  87393. _resyncLighSource(light: Light): void;
  87394. _removeLightSource(light: Light, dispose: boolean): void;
  87395. /**
  87396. * If the source mesh receives shadows
  87397. */
  87398. readonly receiveShadows: boolean;
  87399. /**
  87400. * The material of the source mesh
  87401. */
  87402. readonly material: Nullable<Material>;
  87403. /**
  87404. * Visibility of the source mesh
  87405. */
  87406. readonly visibility: number;
  87407. /**
  87408. * Skeleton of the source mesh
  87409. */
  87410. readonly skeleton: Nullable<Skeleton>;
  87411. /**
  87412. * Rendering ground id of the source mesh
  87413. */
  87414. renderingGroupId: number;
  87415. /**
  87416. * Returns the total number of vertices (integer).
  87417. */
  87418. getTotalVertices(): number;
  87419. /**
  87420. * Returns a positive integer : the total number of indices in this mesh geometry.
  87421. * @returns the numner of indices or zero if the mesh has no geometry.
  87422. */
  87423. getTotalIndices(): number;
  87424. /**
  87425. * The source mesh of the instance
  87426. */
  87427. readonly sourceMesh: Mesh;
  87428. /**
  87429. * Is this node ready to be used/rendered
  87430. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87431. * @return {boolean} is it ready
  87432. */
  87433. isReady(completeCheck?: boolean): boolean;
  87434. /**
  87435. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87436. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  87437. * @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.
  87438. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  87439. */
  87440. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  87441. /**
  87442. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87443. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87444. * The `data` are either a numeric array either a Float32Array.
  87445. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  87446. * 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).
  87447. * Note that a new underlying VertexBuffer object is created each call.
  87448. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87449. *
  87450. * Possible `kind` values :
  87451. * - VertexBuffer.PositionKind
  87452. * - VertexBuffer.UVKind
  87453. * - VertexBuffer.UV2Kind
  87454. * - VertexBuffer.UV3Kind
  87455. * - VertexBuffer.UV4Kind
  87456. * - VertexBuffer.UV5Kind
  87457. * - VertexBuffer.UV6Kind
  87458. * - VertexBuffer.ColorKind
  87459. * - VertexBuffer.MatricesIndicesKind
  87460. * - VertexBuffer.MatricesIndicesExtraKind
  87461. * - VertexBuffer.MatricesWeightsKind
  87462. * - VertexBuffer.MatricesWeightsExtraKind
  87463. *
  87464. * Returns the Mesh.
  87465. */
  87466. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87467. /**
  87468. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87469. * If the mesh has no geometry, it is simply returned as it is.
  87470. * The `data` are either a numeric array either a Float32Array.
  87471. * No new underlying VertexBuffer object is created.
  87472. * 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.
  87473. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  87474. *
  87475. * Possible `kind` values :
  87476. * - VertexBuffer.PositionKind
  87477. * - VertexBuffer.UVKind
  87478. * - VertexBuffer.UV2Kind
  87479. * - VertexBuffer.UV3Kind
  87480. * - VertexBuffer.UV4Kind
  87481. * - VertexBuffer.UV5Kind
  87482. * - VertexBuffer.UV6Kind
  87483. * - VertexBuffer.ColorKind
  87484. * - VertexBuffer.MatricesIndicesKind
  87485. * - VertexBuffer.MatricesIndicesExtraKind
  87486. * - VertexBuffer.MatricesWeightsKind
  87487. * - VertexBuffer.MatricesWeightsExtraKind
  87488. *
  87489. * Returns the Mesh.
  87490. */
  87491. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87492. /**
  87493. * Sets the mesh indices.
  87494. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  87495. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87496. * This method creates a new index buffer each call.
  87497. * Returns the Mesh.
  87498. */
  87499. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  87500. /**
  87501. * Boolean : True if the mesh owns the requested kind of data.
  87502. */
  87503. isVerticesDataPresent(kind: string): boolean;
  87504. /**
  87505. * Returns an array of indices (IndicesArray).
  87506. */
  87507. getIndices(): Nullable<IndicesArray>;
  87508. readonly _positions: Nullable<Vector3[]>;
  87509. /**
  87510. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87511. * This means the mesh underlying bounding box and sphere are recomputed.
  87512. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87513. * @returns the current mesh
  87514. */
  87515. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  87516. /** @hidden */
  87517. _preActivate(): InstancedMesh;
  87518. /** @hidden */
  87519. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87520. /** @hidden */
  87521. _postActivate(): void;
  87522. getWorldMatrix(): Matrix;
  87523. readonly isAnInstance: boolean;
  87524. /**
  87525. * Returns the current associated LOD AbstractMesh.
  87526. */
  87527. getLOD(camera: Camera): AbstractMesh;
  87528. /** @hidden */
  87529. _syncSubMeshes(): InstancedMesh;
  87530. /** @hidden */
  87531. _generatePointsArray(): boolean;
  87532. /**
  87533. * Creates a new InstancedMesh from the current mesh.
  87534. * - name (string) : the cloned mesh name
  87535. * - newParent (optional Node) : the optional Node to parent the clone to.
  87536. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  87537. *
  87538. * Returns the clone.
  87539. */
  87540. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87541. /**
  87542. * Disposes the InstancedMesh.
  87543. * Returns nothing.
  87544. */
  87545. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87546. }
  87547. interface Mesh {
  87548. /**
  87549. * Register a custom buffer that will be instanced
  87550. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87551. * @param kind defines the buffer kind
  87552. * @param stride defines the stride in floats
  87553. */
  87554. registerInstancedBuffer(kind: string, stride: number): void;
  87555. /** @hidden */
  87556. _userInstancedBuffersStorage: {
  87557. data: {
  87558. [key: string]: Float32Array;
  87559. };
  87560. sizes: {
  87561. [key: string]: number;
  87562. };
  87563. vertexBuffers: {
  87564. [key: string]: Nullable<VertexBuffer>;
  87565. };
  87566. strides: {
  87567. [key: string]: number;
  87568. };
  87569. };
  87570. }
  87571. interface AbstractMesh {
  87572. /**
  87573. * Object used to store instanced buffers defined by user
  87574. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  87575. */
  87576. instancedBuffers: {
  87577. [key: string]: any;
  87578. };
  87579. }
  87580. }
  87581. declare module BABYLON {
  87582. /**
  87583. * Defines the options associated with the creation of a shader material.
  87584. */
  87585. export interface IShaderMaterialOptions {
  87586. /**
  87587. * Does the material work in alpha blend mode
  87588. */
  87589. needAlphaBlending: boolean;
  87590. /**
  87591. * Does the material work in alpha test mode
  87592. */
  87593. needAlphaTesting: boolean;
  87594. /**
  87595. * The list of attribute names used in the shader
  87596. */
  87597. attributes: string[];
  87598. /**
  87599. * The list of unifrom names used in the shader
  87600. */
  87601. uniforms: string[];
  87602. /**
  87603. * The list of UBO names used in the shader
  87604. */
  87605. uniformBuffers: string[];
  87606. /**
  87607. * The list of sampler names used in the shader
  87608. */
  87609. samplers: string[];
  87610. /**
  87611. * The list of defines used in the shader
  87612. */
  87613. defines: string[];
  87614. }
  87615. /**
  87616. * 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.
  87617. *
  87618. * This returned material effects how the mesh will look based on the code in the shaders.
  87619. *
  87620. * @see http://doc.babylonjs.com/how_to/shader_material
  87621. */
  87622. export class ShaderMaterial extends Material {
  87623. private _shaderPath;
  87624. private _options;
  87625. private _textures;
  87626. private _textureArrays;
  87627. private _floats;
  87628. private _ints;
  87629. private _floatsArrays;
  87630. private _colors3;
  87631. private _colors3Arrays;
  87632. private _colors4;
  87633. private _colors4Arrays;
  87634. private _vectors2;
  87635. private _vectors3;
  87636. private _vectors4;
  87637. private _matrices;
  87638. private _matrixArrays;
  87639. private _matrices3x3;
  87640. private _matrices2x2;
  87641. private _vectors2Arrays;
  87642. private _vectors3Arrays;
  87643. private _vectors4Arrays;
  87644. private _cachedWorldViewMatrix;
  87645. private _cachedWorldViewProjectionMatrix;
  87646. private _renderId;
  87647. private _multiview;
  87648. /**
  87649. * Instantiate a new shader material.
  87650. * 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.
  87651. * This returned material effects how the mesh will look based on the code in the shaders.
  87652. * @see http://doc.babylonjs.com/how_to/shader_material
  87653. * @param name Define the name of the material in the scene
  87654. * @param scene Define the scene the material belongs to
  87655. * @param shaderPath Defines the route to the shader code in one of three ways:
  87656. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  87657. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  87658. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  87659. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  87660. * @param options Define the options used to create the shader
  87661. */
  87662. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  87663. /**
  87664. * Gets the shader path used to define the shader code
  87665. * It can be modified to trigger a new compilation
  87666. */
  87667. /**
  87668. * Sets the shader path used to define the shader code
  87669. * It can be modified to trigger a new compilation
  87670. */
  87671. shaderPath: any;
  87672. /**
  87673. * Gets the options used to compile the shader.
  87674. * They can be modified to trigger a new compilation
  87675. */
  87676. readonly options: IShaderMaterialOptions;
  87677. /**
  87678. * Gets the current class name of the material e.g. "ShaderMaterial"
  87679. * Mainly use in serialization.
  87680. * @returns the class name
  87681. */
  87682. getClassName(): string;
  87683. /**
  87684. * Specifies if the material will require alpha blending
  87685. * @returns a boolean specifying if alpha blending is needed
  87686. */
  87687. needAlphaBlending(): boolean;
  87688. /**
  87689. * Specifies if this material should be rendered in alpha test mode
  87690. * @returns a boolean specifying if an alpha test is needed.
  87691. */
  87692. needAlphaTesting(): boolean;
  87693. private _checkUniform;
  87694. /**
  87695. * Set a texture in the shader.
  87696. * @param name Define the name of the uniform samplers as defined in the shader
  87697. * @param texture Define the texture to bind to this sampler
  87698. * @return the material itself allowing "fluent" like uniform updates
  87699. */
  87700. setTexture(name: string, texture: Texture): ShaderMaterial;
  87701. /**
  87702. * Set a texture array in the shader.
  87703. * @param name Define the name of the uniform sampler array as defined in the shader
  87704. * @param textures Define the list of textures to bind to this sampler
  87705. * @return the material itself allowing "fluent" like uniform updates
  87706. */
  87707. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  87708. /**
  87709. * Set a float in the shader.
  87710. * @param name Define the name of the uniform as defined in the shader
  87711. * @param value Define the value to give to the uniform
  87712. * @return the material itself allowing "fluent" like uniform updates
  87713. */
  87714. setFloat(name: string, value: number): ShaderMaterial;
  87715. /**
  87716. * Set a int in the shader.
  87717. * @param name Define the name of the uniform as defined in the shader
  87718. * @param value Define the value to give to the uniform
  87719. * @return the material itself allowing "fluent" like uniform updates
  87720. */
  87721. setInt(name: string, value: number): ShaderMaterial;
  87722. /**
  87723. * Set an array of floats in the shader.
  87724. * @param name Define the name of the uniform as defined in the shader
  87725. * @param value Define the value to give to the uniform
  87726. * @return the material itself allowing "fluent" like uniform updates
  87727. */
  87728. setFloats(name: string, value: number[]): ShaderMaterial;
  87729. /**
  87730. * Set a vec3 in the shader from a Color3.
  87731. * @param name Define the name of the uniform as defined in the shader
  87732. * @param value Define the value to give to the uniform
  87733. * @return the material itself allowing "fluent" like uniform updates
  87734. */
  87735. setColor3(name: string, value: Color3): ShaderMaterial;
  87736. /**
  87737. * Set a vec3 array in the shader from a Color3 array.
  87738. * @param name Define the name of the uniform as defined in the shader
  87739. * @param value Define the value to give to the uniform
  87740. * @return the material itself allowing "fluent" like uniform updates
  87741. */
  87742. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  87743. /**
  87744. * Set a vec4 in the shader from a Color4.
  87745. * @param name Define the name of the uniform as defined in the shader
  87746. * @param value Define the value to give to the uniform
  87747. * @return the material itself allowing "fluent" like uniform updates
  87748. */
  87749. setColor4(name: string, value: Color4): ShaderMaterial;
  87750. /**
  87751. * Set a vec4 array in the shader from a Color4 array.
  87752. * @param name Define the name of the uniform as defined in the shader
  87753. * @param value Define the value to give to the uniform
  87754. * @return the material itself allowing "fluent" like uniform updates
  87755. */
  87756. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  87757. /**
  87758. * Set a vec2 in the shader from a Vector2.
  87759. * @param name Define the name of the uniform as defined in the shader
  87760. * @param value Define the value to give to the uniform
  87761. * @return the material itself allowing "fluent" like uniform updates
  87762. */
  87763. setVector2(name: string, value: Vector2): ShaderMaterial;
  87764. /**
  87765. * Set a vec3 in the shader from a Vector3.
  87766. * @param name Define the name of the uniform as defined in the shader
  87767. * @param value Define the value to give to the uniform
  87768. * @return the material itself allowing "fluent" like uniform updates
  87769. */
  87770. setVector3(name: string, value: Vector3): ShaderMaterial;
  87771. /**
  87772. * Set a vec4 in the shader from a Vector4.
  87773. * @param name Define the name of the uniform as defined in the shader
  87774. * @param value Define the value to give to the uniform
  87775. * @return the material itself allowing "fluent" like uniform updates
  87776. */
  87777. setVector4(name: string, value: Vector4): ShaderMaterial;
  87778. /**
  87779. * Set a mat4 in the shader from a Matrix.
  87780. * @param name Define the name of the uniform as defined in the shader
  87781. * @param value Define the value to give to the uniform
  87782. * @return the material itself allowing "fluent" like uniform updates
  87783. */
  87784. setMatrix(name: string, value: Matrix): ShaderMaterial;
  87785. /**
  87786. * Set a float32Array in the shader from a matrix array.
  87787. * @param name Define the name of the uniform as defined in the shader
  87788. * @param value Define the value to give to the uniform
  87789. * @return the material itself allowing "fluent" like uniform updates
  87790. */
  87791. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  87792. /**
  87793. * Set a mat3 in the shader from a Float32Array.
  87794. * @param name Define the name of the uniform as defined in the shader
  87795. * @param value Define the value to give to the uniform
  87796. * @return the material itself allowing "fluent" like uniform updates
  87797. */
  87798. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  87799. /**
  87800. * Set a mat2 in the shader from a Float32Array.
  87801. * @param name Define the name of the uniform as defined in the shader
  87802. * @param value Define the value to give to the uniform
  87803. * @return the material itself allowing "fluent" like uniform updates
  87804. */
  87805. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  87806. /**
  87807. * Set a vec2 array in the shader from a number array.
  87808. * @param name Define the name of the uniform as defined in the shader
  87809. * @param value Define the value to give to the uniform
  87810. * @return the material itself allowing "fluent" like uniform updates
  87811. */
  87812. setArray2(name: string, value: number[]): ShaderMaterial;
  87813. /**
  87814. * Set a vec3 array in the shader from a number array.
  87815. * @param name Define the name of the uniform as defined in the shader
  87816. * @param value Define the value to give to the uniform
  87817. * @return the material itself allowing "fluent" like uniform updates
  87818. */
  87819. setArray3(name: string, value: number[]): ShaderMaterial;
  87820. /**
  87821. * Set a vec4 array in the shader from a number array.
  87822. * @param name Define the name of the uniform as defined in the shader
  87823. * @param value Define the value to give to the uniform
  87824. * @return the material itself allowing "fluent" like uniform updates
  87825. */
  87826. setArray4(name: string, value: number[]): ShaderMaterial;
  87827. private _checkCache;
  87828. /**
  87829. * Specifies that the submesh is ready to be used
  87830. * @param mesh defines the mesh to check
  87831. * @param subMesh defines which submesh to check
  87832. * @param useInstances specifies that instances should be used
  87833. * @returns a boolean indicating that the submesh is ready or not
  87834. */
  87835. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87836. /**
  87837. * Checks if the material is ready to render the requested mesh
  87838. * @param mesh Define the mesh to render
  87839. * @param useInstances Define whether or not the material is used with instances
  87840. * @returns true if ready, otherwise false
  87841. */
  87842. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87843. /**
  87844. * Binds the world matrix to the material
  87845. * @param world defines the world transformation matrix
  87846. */
  87847. bindOnlyWorldMatrix(world: Matrix): void;
  87848. /**
  87849. * Binds the material to the mesh
  87850. * @param world defines the world transformation matrix
  87851. * @param mesh defines the mesh to bind the material to
  87852. */
  87853. bind(world: Matrix, mesh?: Mesh): void;
  87854. /**
  87855. * Gets the active textures from the material
  87856. * @returns an array of textures
  87857. */
  87858. getActiveTextures(): BaseTexture[];
  87859. /**
  87860. * Specifies if the material uses a texture
  87861. * @param texture defines the texture to check against the material
  87862. * @returns a boolean specifying if the material uses the texture
  87863. */
  87864. hasTexture(texture: BaseTexture): boolean;
  87865. /**
  87866. * Makes a duplicate of the material, and gives it a new name
  87867. * @param name defines the new name for the duplicated material
  87868. * @returns the cloned material
  87869. */
  87870. clone(name: string): ShaderMaterial;
  87871. /**
  87872. * Disposes the material
  87873. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87874. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87875. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87876. */
  87877. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87878. /**
  87879. * Serializes this material in a JSON representation
  87880. * @returns the serialized material object
  87881. */
  87882. serialize(): any;
  87883. /**
  87884. * Creates a shader material from parsed shader material data
  87885. * @param source defines the JSON represnetation of the material
  87886. * @param scene defines the hosting scene
  87887. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87888. * @returns a new material
  87889. */
  87890. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  87891. }
  87892. }
  87893. declare module BABYLON {
  87894. /** @hidden */
  87895. export var colorPixelShader: {
  87896. name: string;
  87897. shader: string;
  87898. };
  87899. }
  87900. declare module BABYLON {
  87901. /** @hidden */
  87902. export var colorVertexShader: {
  87903. name: string;
  87904. shader: string;
  87905. };
  87906. }
  87907. declare module BABYLON {
  87908. /**
  87909. * Line mesh
  87910. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87911. */
  87912. export class LinesMesh extends Mesh {
  87913. /**
  87914. * If vertex color should be applied to the mesh
  87915. */
  87916. readonly useVertexColor?: boolean | undefined;
  87917. /**
  87918. * If vertex alpha should be applied to the mesh
  87919. */
  87920. readonly useVertexAlpha?: boolean | undefined;
  87921. /**
  87922. * Color of the line (Default: White)
  87923. */
  87924. color: Color3;
  87925. /**
  87926. * Alpha of the line (Default: 1)
  87927. */
  87928. alpha: number;
  87929. /**
  87930. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  87931. * This margin is expressed in world space coordinates, so its value may vary.
  87932. * Default value is 0.1
  87933. */
  87934. intersectionThreshold: number;
  87935. private _colorShader;
  87936. private color4;
  87937. /**
  87938. * Creates a new LinesMesh
  87939. * @param name defines the name
  87940. * @param scene defines the hosting scene
  87941. * @param parent defines the parent mesh if any
  87942. * @param source defines the optional source LinesMesh used to clone data from
  87943. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87944. * When false, achieved by calling a clone(), also passing False.
  87945. * This will make creation of children, recursive.
  87946. * @param useVertexColor defines if this LinesMesh supports vertex color
  87947. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87948. */
  87949. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  87950. /**
  87951. * If vertex color should be applied to the mesh
  87952. */
  87953. useVertexColor?: boolean | undefined,
  87954. /**
  87955. * If vertex alpha should be applied to the mesh
  87956. */
  87957. useVertexAlpha?: boolean | undefined);
  87958. private _addClipPlaneDefine;
  87959. private _removeClipPlaneDefine;
  87960. isReady(): boolean;
  87961. /**
  87962. * Returns the string "LineMesh"
  87963. */
  87964. getClassName(): string;
  87965. /**
  87966. * @hidden
  87967. */
  87968. /**
  87969. * @hidden
  87970. */
  87971. material: Material;
  87972. /**
  87973. * @hidden
  87974. */
  87975. readonly checkCollisions: boolean;
  87976. /** @hidden */
  87977. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87978. /** @hidden */
  87979. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87980. /**
  87981. * Disposes of the line mesh
  87982. * @param doNotRecurse If children should be disposed
  87983. */
  87984. dispose(doNotRecurse?: boolean): void;
  87985. /**
  87986. * Returns a new LineMesh object cloned from the current one.
  87987. */
  87988. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87989. /**
  87990. * Creates a new InstancedLinesMesh object from the mesh model.
  87991. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87992. * @param name defines the name of the new instance
  87993. * @returns a new InstancedLinesMesh
  87994. */
  87995. createInstance(name: string): InstancedLinesMesh;
  87996. }
  87997. /**
  87998. * Creates an instance based on a source LinesMesh
  87999. */
  88000. export class InstancedLinesMesh extends InstancedMesh {
  88001. /**
  88002. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88003. * This margin is expressed in world space coordinates, so its value may vary.
  88004. * Initilized with the intersectionThreshold value of the source LinesMesh
  88005. */
  88006. intersectionThreshold: number;
  88007. constructor(name: string, source: LinesMesh);
  88008. /**
  88009. * Returns the string "InstancedLinesMesh".
  88010. */
  88011. getClassName(): string;
  88012. }
  88013. }
  88014. declare module BABYLON {
  88015. /** @hidden */
  88016. export var linePixelShader: {
  88017. name: string;
  88018. shader: string;
  88019. };
  88020. }
  88021. declare module BABYLON {
  88022. /** @hidden */
  88023. export var lineVertexShader: {
  88024. name: string;
  88025. shader: string;
  88026. };
  88027. }
  88028. declare module BABYLON {
  88029. interface AbstractMesh {
  88030. /**
  88031. * Gets the edgesRenderer associated with the mesh
  88032. */
  88033. edgesRenderer: Nullable<EdgesRenderer>;
  88034. }
  88035. interface LinesMesh {
  88036. /**
  88037. * Enables the edge rendering mode on the mesh.
  88038. * This mode makes the mesh edges visible
  88039. * @param epsilon defines the maximal distance between two angles to detect a face
  88040. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88041. * @returns the currentAbstractMesh
  88042. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88043. */
  88044. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88045. }
  88046. interface InstancedLinesMesh {
  88047. /**
  88048. * Enables the edge rendering mode on the mesh.
  88049. * This mode makes the mesh edges visible
  88050. * @param epsilon defines the maximal distance between two angles to detect a face
  88051. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88052. * @returns the current InstancedLinesMesh
  88053. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88054. */
  88055. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88056. }
  88057. /**
  88058. * Defines the minimum contract an Edges renderer should follow.
  88059. */
  88060. export interface IEdgesRenderer extends IDisposable {
  88061. /**
  88062. * Gets or sets a boolean indicating if the edgesRenderer is active
  88063. */
  88064. isEnabled: boolean;
  88065. /**
  88066. * Renders the edges of the attached mesh,
  88067. */
  88068. render(): void;
  88069. /**
  88070. * Checks wether or not the edges renderer is ready to render.
  88071. * @return true if ready, otherwise false.
  88072. */
  88073. isReady(): boolean;
  88074. }
  88075. /**
  88076. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88077. */
  88078. export class EdgesRenderer implements IEdgesRenderer {
  88079. /**
  88080. * Define the size of the edges with an orthographic camera
  88081. */
  88082. edgesWidthScalerForOrthographic: number;
  88083. /**
  88084. * Define the size of the edges with a perspective camera
  88085. */
  88086. edgesWidthScalerForPerspective: number;
  88087. protected _source: AbstractMesh;
  88088. protected _linesPositions: number[];
  88089. protected _linesNormals: number[];
  88090. protected _linesIndices: number[];
  88091. protected _epsilon: number;
  88092. protected _indicesCount: number;
  88093. protected _lineShader: ShaderMaterial;
  88094. protected _ib: DataBuffer;
  88095. protected _buffers: {
  88096. [key: string]: Nullable<VertexBuffer>;
  88097. };
  88098. protected _checkVerticesInsteadOfIndices: boolean;
  88099. private _meshRebuildObserver;
  88100. private _meshDisposeObserver;
  88101. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  88102. isEnabled: boolean;
  88103. /**
  88104. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  88105. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  88106. * @param source Mesh used to create edges
  88107. * @param epsilon sum of angles in adjacency to check for edge
  88108. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88109. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88110. */
  88111. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88112. protected _prepareRessources(): void;
  88113. /** @hidden */
  88114. _rebuild(): void;
  88115. /**
  88116. * Releases the required resources for the edges renderer
  88117. */
  88118. dispose(): void;
  88119. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88120. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88121. /**
  88122. * Checks if the pair of p0 and p1 is en edge
  88123. * @param faceIndex
  88124. * @param edge
  88125. * @param faceNormals
  88126. * @param p0
  88127. * @param p1
  88128. * @private
  88129. */
  88130. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  88131. /**
  88132. * push line into the position, normal and index buffer
  88133. * @protected
  88134. */
  88135. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  88136. /**
  88137. * Generates lines edges from adjacencjes
  88138. * @private
  88139. */
  88140. _generateEdgesLines(): void;
  88141. /**
  88142. * Checks wether or not the edges renderer is ready to render.
  88143. * @return true if ready, otherwise false.
  88144. */
  88145. isReady(): boolean;
  88146. /**
  88147. * Renders the edges of the attached mesh,
  88148. */
  88149. render(): void;
  88150. }
  88151. /**
  88152. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  88153. */
  88154. export class LineEdgesRenderer extends EdgesRenderer {
  88155. /**
  88156. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  88157. * @param source LineMesh used to generate edges
  88158. * @param epsilon not important (specified angle for edge detection)
  88159. * @param checkVerticesInsteadOfIndices not important for LineMesh
  88160. */
  88161. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  88162. /**
  88163. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  88164. */
  88165. _generateEdgesLines(): void;
  88166. }
  88167. }
  88168. declare module BABYLON {
  88169. /**
  88170. * This represents the object necessary to create a rendering group.
  88171. * This is exclusively used and created by the rendering manager.
  88172. * To modify the behavior, you use the available helpers in your scene or meshes.
  88173. * @hidden
  88174. */
  88175. export class RenderingGroup {
  88176. index: number;
  88177. private static _zeroVector;
  88178. private _scene;
  88179. private _opaqueSubMeshes;
  88180. private _transparentSubMeshes;
  88181. private _alphaTestSubMeshes;
  88182. private _depthOnlySubMeshes;
  88183. private _particleSystems;
  88184. private _spriteManagers;
  88185. private _opaqueSortCompareFn;
  88186. private _alphaTestSortCompareFn;
  88187. private _transparentSortCompareFn;
  88188. private _renderOpaque;
  88189. private _renderAlphaTest;
  88190. private _renderTransparent;
  88191. /** @hidden */
  88192. _edgesRenderers: SmartArray<IEdgesRenderer>;
  88193. onBeforeTransparentRendering: () => void;
  88194. /**
  88195. * Set the opaque sort comparison function.
  88196. * If null the sub meshes will be render in the order they were created
  88197. */
  88198. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88199. /**
  88200. * Set the alpha test sort comparison function.
  88201. * If null the sub meshes will be render in the order they were created
  88202. */
  88203. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88204. /**
  88205. * Set the transparent sort comparison function.
  88206. * If null the sub meshes will be render in the order they were created
  88207. */
  88208. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  88209. /**
  88210. * Creates a new rendering group.
  88211. * @param index The rendering group index
  88212. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  88213. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  88214. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  88215. */
  88216. 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>);
  88217. /**
  88218. * Render all the sub meshes contained in the group.
  88219. * @param customRenderFunction Used to override the default render behaviour of the group.
  88220. * @returns true if rendered some submeshes.
  88221. */
  88222. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  88223. /**
  88224. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  88225. * @param subMeshes The submeshes to render
  88226. */
  88227. private renderOpaqueSorted;
  88228. /**
  88229. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  88230. * @param subMeshes The submeshes to render
  88231. */
  88232. private renderAlphaTestSorted;
  88233. /**
  88234. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  88235. * @param subMeshes The submeshes to render
  88236. */
  88237. private renderTransparentSorted;
  88238. /**
  88239. * Renders the submeshes in a specified order.
  88240. * @param subMeshes The submeshes to sort before render
  88241. * @param sortCompareFn The comparison function use to sort
  88242. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  88243. * @param transparent Specifies to activate blending if true
  88244. */
  88245. private static renderSorted;
  88246. /**
  88247. * Renders the submeshes in the order they were dispatched (no sort applied).
  88248. * @param subMeshes The submeshes to render
  88249. */
  88250. private static renderUnsorted;
  88251. /**
  88252. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88253. * are rendered back to front if in the same alpha index.
  88254. *
  88255. * @param a The first submesh
  88256. * @param b The second submesh
  88257. * @returns The result of the comparison
  88258. */
  88259. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  88260. /**
  88261. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88262. * are rendered back to front.
  88263. *
  88264. * @param a The first submesh
  88265. * @param b The second submesh
  88266. * @returns The result of the comparison
  88267. */
  88268. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  88269. /**
  88270. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  88271. * are rendered front to back (prevent overdraw).
  88272. *
  88273. * @param a The first submesh
  88274. * @param b The second submesh
  88275. * @returns The result of the comparison
  88276. */
  88277. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  88278. /**
  88279. * Resets the different lists of submeshes to prepare a new frame.
  88280. */
  88281. prepare(): void;
  88282. dispose(): void;
  88283. /**
  88284. * Inserts the submesh in its correct queue depending on its material.
  88285. * @param subMesh The submesh to dispatch
  88286. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88287. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88288. */
  88289. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88290. dispatchSprites(spriteManager: ISpriteManager): void;
  88291. dispatchParticles(particleSystem: IParticleSystem): void;
  88292. private _renderParticles;
  88293. private _renderSprites;
  88294. }
  88295. }
  88296. declare module BABYLON {
  88297. /**
  88298. * Interface describing the different options available in the rendering manager
  88299. * regarding Auto Clear between groups.
  88300. */
  88301. export interface IRenderingManagerAutoClearSetup {
  88302. /**
  88303. * Defines whether or not autoclear is enable.
  88304. */
  88305. autoClear: boolean;
  88306. /**
  88307. * Defines whether or not to autoclear the depth buffer.
  88308. */
  88309. depth: boolean;
  88310. /**
  88311. * Defines whether or not to autoclear the stencil buffer.
  88312. */
  88313. stencil: boolean;
  88314. }
  88315. /**
  88316. * This class is used by the onRenderingGroupObservable
  88317. */
  88318. export class RenderingGroupInfo {
  88319. /**
  88320. * The Scene that being rendered
  88321. */
  88322. scene: Scene;
  88323. /**
  88324. * The camera currently used for the rendering pass
  88325. */
  88326. camera: Nullable<Camera>;
  88327. /**
  88328. * The ID of the renderingGroup being processed
  88329. */
  88330. renderingGroupId: number;
  88331. }
  88332. /**
  88333. * This is the manager responsible of all the rendering for meshes sprites and particles.
  88334. * It is enable to manage the different groups as well as the different necessary sort functions.
  88335. * This should not be used directly aside of the few static configurations
  88336. */
  88337. export class RenderingManager {
  88338. /**
  88339. * The max id used for rendering groups (not included)
  88340. */
  88341. static MAX_RENDERINGGROUPS: number;
  88342. /**
  88343. * The min id used for rendering groups (included)
  88344. */
  88345. static MIN_RENDERINGGROUPS: number;
  88346. /**
  88347. * Used to globally prevent autoclearing scenes.
  88348. */
  88349. static AUTOCLEAR: boolean;
  88350. /**
  88351. * @hidden
  88352. */
  88353. _useSceneAutoClearSetup: boolean;
  88354. private _scene;
  88355. private _renderingGroups;
  88356. private _depthStencilBufferAlreadyCleaned;
  88357. private _autoClearDepthStencil;
  88358. private _customOpaqueSortCompareFn;
  88359. private _customAlphaTestSortCompareFn;
  88360. private _customTransparentSortCompareFn;
  88361. private _renderingGroupInfo;
  88362. /**
  88363. * Instantiates a new rendering group for a particular scene
  88364. * @param scene Defines the scene the groups belongs to
  88365. */
  88366. constructor(scene: Scene);
  88367. private _clearDepthStencilBuffer;
  88368. /**
  88369. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  88370. * @hidden
  88371. */
  88372. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  88373. /**
  88374. * Resets the different information of the group to prepare a new frame
  88375. * @hidden
  88376. */
  88377. reset(): void;
  88378. /**
  88379. * Dispose and release the group and its associated resources.
  88380. * @hidden
  88381. */
  88382. dispose(): void;
  88383. /**
  88384. * Clear the info related to rendering groups preventing retention points during dispose.
  88385. */
  88386. freeRenderingGroups(): void;
  88387. private _prepareRenderingGroup;
  88388. /**
  88389. * Add a sprite manager to the rendering manager in order to render it this frame.
  88390. * @param spriteManager Define the sprite manager to render
  88391. */
  88392. dispatchSprites(spriteManager: ISpriteManager): void;
  88393. /**
  88394. * Add a particle system to the rendering manager in order to render it this frame.
  88395. * @param particleSystem Define the particle system to render
  88396. */
  88397. dispatchParticles(particleSystem: IParticleSystem): void;
  88398. /**
  88399. * Add a submesh to the manager in order to render it this frame
  88400. * @param subMesh The submesh to dispatch
  88401. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  88402. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  88403. */
  88404. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  88405. /**
  88406. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88407. * This allowed control for front to back rendering or reversly depending of the special needs.
  88408. *
  88409. * @param renderingGroupId The rendering group id corresponding to its index
  88410. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88411. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88412. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88413. */
  88414. 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;
  88415. /**
  88416. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88417. *
  88418. * @param renderingGroupId The rendering group id corresponding to its index
  88419. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88420. * @param depth Automatically clears depth between groups if true and autoClear is true.
  88421. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  88422. */
  88423. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  88424. /**
  88425. * Gets the current auto clear configuration for one rendering group of the rendering
  88426. * manager.
  88427. * @param index the rendering group index to get the information for
  88428. * @returns The auto clear setup for the requested rendering group
  88429. */
  88430. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  88431. }
  88432. }
  88433. declare module BABYLON {
  88434. /**
  88435. * This Helps creating a texture that will be created from a camera in your scene.
  88436. * It is basically a dynamic texture that could be used to create special effects for instance.
  88437. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  88438. */
  88439. export class RenderTargetTexture extends Texture {
  88440. isCube: boolean;
  88441. /**
  88442. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  88443. */
  88444. static readonly REFRESHRATE_RENDER_ONCE: number;
  88445. /**
  88446. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  88447. */
  88448. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  88449. /**
  88450. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  88451. * the central point of your effect and can save a lot of performances.
  88452. */
  88453. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  88454. /**
  88455. * Use this predicate to dynamically define the list of mesh you want to render.
  88456. * If set, the renderList property will be overwritten.
  88457. */
  88458. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  88459. private _renderList;
  88460. /**
  88461. * Use this list to define the list of mesh you want to render.
  88462. */
  88463. renderList: Nullable<Array<AbstractMesh>>;
  88464. private _hookArray;
  88465. /**
  88466. * Define if particles should be rendered in your texture.
  88467. */
  88468. renderParticles: boolean;
  88469. /**
  88470. * Define if sprites should be rendered in your texture.
  88471. */
  88472. renderSprites: boolean;
  88473. /**
  88474. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  88475. */
  88476. coordinatesMode: number;
  88477. /**
  88478. * Define the camera used to render the texture.
  88479. */
  88480. activeCamera: Nullable<Camera>;
  88481. /**
  88482. * Override the render function of the texture with your own one.
  88483. */
  88484. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  88485. /**
  88486. * Define if camera post processes should be use while rendering the texture.
  88487. */
  88488. useCameraPostProcesses: boolean;
  88489. /**
  88490. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  88491. */
  88492. ignoreCameraViewport: boolean;
  88493. private _postProcessManager;
  88494. private _postProcesses;
  88495. private _resizeObserver;
  88496. /**
  88497. * An event triggered when the texture is unbind.
  88498. */
  88499. onBeforeBindObservable: Observable<RenderTargetTexture>;
  88500. /**
  88501. * An event triggered when the texture is unbind.
  88502. */
  88503. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  88504. private _onAfterUnbindObserver;
  88505. /**
  88506. * Set a after unbind callback in the texture.
  88507. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  88508. */
  88509. onAfterUnbind: () => void;
  88510. /**
  88511. * An event triggered before rendering the texture
  88512. */
  88513. onBeforeRenderObservable: Observable<number>;
  88514. private _onBeforeRenderObserver;
  88515. /**
  88516. * Set a before render callback in the texture.
  88517. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  88518. */
  88519. onBeforeRender: (faceIndex: number) => void;
  88520. /**
  88521. * An event triggered after rendering the texture
  88522. */
  88523. onAfterRenderObservable: Observable<number>;
  88524. private _onAfterRenderObserver;
  88525. /**
  88526. * Set a after render callback in the texture.
  88527. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  88528. */
  88529. onAfterRender: (faceIndex: number) => void;
  88530. /**
  88531. * An event triggered after the texture clear
  88532. */
  88533. onClearObservable: Observable<Engine>;
  88534. private _onClearObserver;
  88535. /**
  88536. * Set a clear callback in the texture.
  88537. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  88538. */
  88539. onClear: (Engine: Engine) => void;
  88540. /**
  88541. * An event triggered when the texture is resized.
  88542. */
  88543. onResizeObservable: Observable<RenderTargetTexture>;
  88544. /**
  88545. * Define the clear color of the Render Target if it should be different from the scene.
  88546. */
  88547. clearColor: Color4;
  88548. protected _size: number | {
  88549. width: number;
  88550. height: number;
  88551. };
  88552. protected _initialSizeParameter: number | {
  88553. width: number;
  88554. height: number;
  88555. } | {
  88556. ratio: number;
  88557. };
  88558. protected _sizeRatio: Nullable<number>;
  88559. /** @hidden */
  88560. _generateMipMaps: boolean;
  88561. protected _renderingManager: RenderingManager;
  88562. /** @hidden */
  88563. _waitingRenderList: string[];
  88564. protected _doNotChangeAspectRatio: boolean;
  88565. protected _currentRefreshId: number;
  88566. protected _refreshRate: number;
  88567. protected _textureMatrix: Matrix;
  88568. protected _samples: number;
  88569. protected _renderTargetOptions: RenderTargetCreationOptions;
  88570. /**
  88571. * Gets render target creation options that were used.
  88572. */
  88573. readonly renderTargetOptions: RenderTargetCreationOptions;
  88574. protected _engine: Engine;
  88575. protected _onRatioRescale(): void;
  88576. /**
  88577. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  88578. * It must define where the camera used to render the texture is set
  88579. */
  88580. boundingBoxPosition: Vector3;
  88581. private _boundingBoxSize;
  88582. /**
  88583. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  88584. * When defined, the cubemap will switch to local mode
  88585. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88586. * @example https://www.babylonjs-playground.com/#RNASML
  88587. */
  88588. boundingBoxSize: Vector3;
  88589. /**
  88590. * In case the RTT has been created with a depth texture, get the associated
  88591. * depth texture.
  88592. * Otherwise, return null.
  88593. */
  88594. depthStencilTexture: Nullable<InternalTexture>;
  88595. /**
  88596. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  88597. * or used a shadow, depth texture...
  88598. * @param name The friendly name of the texture
  88599. * @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)
  88600. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  88601. * @param generateMipMaps True if mip maps need to be generated after render.
  88602. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  88603. * @param type The type of the buffer in the RTT (int, half float, float...)
  88604. * @param isCube True if a cube texture needs to be created
  88605. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  88606. * @param generateDepthBuffer True to generate a depth buffer
  88607. * @param generateStencilBuffer True to generate a stencil buffer
  88608. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  88609. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  88610. * @param delayAllocation if the texture allocation should be delayed (default: false)
  88611. */
  88612. constructor(name: string, size: number | {
  88613. width: number;
  88614. height: number;
  88615. } | {
  88616. ratio: number;
  88617. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  88618. /**
  88619. * Creates a depth stencil texture.
  88620. * This is only available in WebGL 2 or with the depth texture extension available.
  88621. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  88622. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  88623. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  88624. */
  88625. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  88626. private _processSizeParameter;
  88627. /**
  88628. * Define the number of samples to use in case of MSAA.
  88629. * It defaults to one meaning no MSAA has been enabled.
  88630. */
  88631. samples: number;
  88632. /**
  88633. * Resets the refresh counter of the texture and start bak from scratch.
  88634. * Could be useful to regenerate the texture if it is setup to render only once.
  88635. */
  88636. resetRefreshCounter(): void;
  88637. /**
  88638. * Define the refresh rate of the texture or the rendering frequency.
  88639. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88640. */
  88641. refreshRate: number;
  88642. /**
  88643. * Adds a post process to the render target rendering passes.
  88644. * @param postProcess define the post process to add
  88645. */
  88646. addPostProcess(postProcess: PostProcess): void;
  88647. /**
  88648. * Clear all the post processes attached to the render target
  88649. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  88650. */
  88651. clearPostProcesses(dispose?: boolean): void;
  88652. /**
  88653. * Remove one of the post process from the list of attached post processes to the texture
  88654. * @param postProcess define the post process to remove from the list
  88655. */
  88656. removePostProcess(postProcess: PostProcess): void;
  88657. /** @hidden */
  88658. _shouldRender(): boolean;
  88659. /**
  88660. * Gets the actual render size of the texture.
  88661. * @returns the width of the render size
  88662. */
  88663. getRenderSize(): number;
  88664. /**
  88665. * Gets the actual render width of the texture.
  88666. * @returns the width of the render size
  88667. */
  88668. getRenderWidth(): number;
  88669. /**
  88670. * Gets the actual render height of the texture.
  88671. * @returns the height of the render size
  88672. */
  88673. getRenderHeight(): number;
  88674. /**
  88675. * Get if the texture can be rescaled or not.
  88676. */
  88677. readonly canRescale: boolean;
  88678. /**
  88679. * Resize the texture using a ratio.
  88680. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  88681. */
  88682. scale(ratio: number): void;
  88683. /**
  88684. * Get the texture reflection matrix used to rotate/transform the reflection.
  88685. * @returns the reflection matrix
  88686. */
  88687. getReflectionTextureMatrix(): Matrix;
  88688. /**
  88689. * Resize the texture to a new desired size.
  88690. * Be carrefull as it will recreate all the data in the new texture.
  88691. * @param size Define the new size. It can be:
  88692. * - a number for squared texture,
  88693. * - an object containing { width: number, height: number }
  88694. * - or an object containing a ratio { ratio: number }
  88695. */
  88696. resize(size: number | {
  88697. width: number;
  88698. height: number;
  88699. } | {
  88700. ratio: number;
  88701. }): void;
  88702. /**
  88703. * Renders all the objects from the render list into the texture.
  88704. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  88705. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  88706. */
  88707. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  88708. private _bestReflectionRenderTargetDimension;
  88709. /**
  88710. * @hidden
  88711. * @param faceIndex face index to bind to if this is a cubetexture
  88712. */
  88713. _bindFrameBuffer(faceIndex?: number): void;
  88714. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  88715. private renderToTarget;
  88716. /**
  88717. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88718. * This allowed control for front to back rendering or reversly depending of the special needs.
  88719. *
  88720. * @param renderingGroupId The rendering group id corresponding to its index
  88721. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88722. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88723. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88724. */
  88725. 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;
  88726. /**
  88727. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88728. *
  88729. * @param renderingGroupId The rendering group id corresponding to its index
  88730. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88731. */
  88732. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  88733. /**
  88734. * Clones the texture.
  88735. * @returns the cloned texture
  88736. */
  88737. clone(): RenderTargetTexture;
  88738. /**
  88739. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  88740. * @returns The JSON representation of the texture
  88741. */
  88742. serialize(): any;
  88743. /**
  88744. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  88745. */
  88746. disposeFramebufferObjects(): void;
  88747. /**
  88748. * Dispose the texture and release its associated resources.
  88749. */
  88750. dispose(): void;
  88751. /** @hidden */
  88752. _rebuild(): void;
  88753. /**
  88754. * Clear the info related to rendering groups preventing retention point in material dispose.
  88755. */
  88756. freeRenderingGroups(): void;
  88757. /**
  88758. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  88759. * @returns the view count
  88760. */
  88761. getViewCount(): number;
  88762. }
  88763. }
  88764. declare module BABYLON {
  88765. /**
  88766. * Options for compiling materials.
  88767. */
  88768. export interface IMaterialCompilationOptions {
  88769. /**
  88770. * Defines whether clip planes are enabled.
  88771. */
  88772. clipPlane: boolean;
  88773. /**
  88774. * Defines whether instances are enabled.
  88775. */
  88776. useInstances: boolean;
  88777. }
  88778. /**
  88779. * Base class for the main features of a material in Babylon.js
  88780. */
  88781. export class Material implements IAnimatable {
  88782. /**
  88783. * Returns the triangle fill mode
  88784. */
  88785. static readonly TriangleFillMode: number;
  88786. /**
  88787. * Returns the wireframe mode
  88788. */
  88789. static readonly WireFrameFillMode: number;
  88790. /**
  88791. * Returns the point fill mode
  88792. */
  88793. static readonly PointFillMode: number;
  88794. /**
  88795. * Returns the point list draw mode
  88796. */
  88797. static readonly PointListDrawMode: number;
  88798. /**
  88799. * Returns the line list draw mode
  88800. */
  88801. static readonly LineListDrawMode: number;
  88802. /**
  88803. * Returns the line loop draw mode
  88804. */
  88805. static readonly LineLoopDrawMode: number;
  88806. /**
  88807. * Returns the line strip draw mode
  88808. */
  88809. static readonly LineStripDrawMode: number;
  88810. /**
  88811. * Returns the triangle strip draw mode
  88812. */
  88813. static readonly TriangleStripDrawMode: number;
  88814. /**
  88815. * Returns the triangle fan draw mode
  88816. */
  88817. static readonly TriangleFanDrawMode: number;
  88818. /**
  88819. * Stores the clock-wise side orientation
  88820. */
  88821. static readonly ClockWiseSideOrientation: number;
  88822. /**
  88823. * Stores the counter clock-wise side orientation
  88824. */
  88825. static readonly CounterClockWiseSideOrientation: number;
  88826. /**
  88827. * The dirty texture flag value
  88828. */
  88829. static readonly TextureDirtyFlag: number;
  88830. /**
  88831. * The dirty light flag value
  88832. */
  88833. static readonly LightDirtyFlag: number;
  88834. /**
  88835. * The dirty fresnel flag value
  88836. */
  88837. static readonly FresnelDirtyFlag: number;
  88838. /**
  88839. * The dirty attribute flag value
  88840. */
  88841. static readonly AttributesDirtyFlag: number;
  88842. /**
  88843. * The dirty misc flag value
  88844. */
  88845. static readonly MiscDirtyFlag: number;
  88846. /**
  88847. * The all dirty flag value
  88848. */
  88849. static readonly AllDirtyFlag: number;
  88850. /**
  88851. * The ID of the material
  88852. */
  88853. id: string;
  88854. /**
  88855. * Gets or sets the unique id of the material
  88856. */
  88857. uniqueId: number;
  88858. /**
  88859. * The name of the material
  88860. */
  88861. name: string;
  88862. /**
  88863. * Gets or sets user defined metadata
  88864. */
  88865. metadata: any;
  88866. /**
  88867. * For internal use only. Please do not use.
  88868. */
  88869. reservedDataStore: any;
  88870. /**
  88871. * Specifies if the ready state should be checked on each call
  88872. */
  88873. checkReadyOnEveryCall: boolean;
  88874. /**
  88875. * Specifies if the ready state should be checked once
  88876. */
  88877. checkReadyOnlyOnce: boolean;
  88878. /**
  88879. * The state of the material
  88880. */
  88881. state: string;
  88882. /**
  88883. * The alpha value of the material
  88884. */
  88885. protected _alpha: number;
  88886. /**
  88887. * List of inspectable custom properties (used by the Inspector)
  88888. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88889. */
  88890. inspectableCustomProperties: IInspectable[];
  88891. /**
  88892. * Sets the alpha value of the material
  88893. */
  88894. /**
  88895. * Gets the alpha value of the material
  88896. */
  88897. alpha: number;
  88898. /**
  88899. * Specifies if back face culling is enabled
  88900. */
  88901. protected _backFaceCulling: boolean;
  88902. /**
  88903. * Sets the back-face culling state
  88904. */
  88905. /**
  88906. * Gets the back-face culling state
  88907. */
  88908. backFaceCulling: boolean;
  88909. /**
  88910. * Stores the value for side orientation
  88911. */
  88912. sideOrientation: number;
  88913. /**
  88914. * Callback triggered when the material is compiled
  88915. */
  88916. onCompiled: Nullable<(effect: Effect) => void>;
  88917. /**
  88918. * Callback triggered when an error occurs
  88919. */
  88920. onError: Nullable<(effect: Effect, errors: string) => void>;
  88921. /**
  88922. * Callback triggered to get the render target textures
  88923. */
  88924. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  88925. /**
  88926. * Gets a boolean indicating that current material needs to register RTT
  88927. */
  88928. readonly hasRenderTargetTextures: boolean;
  88929. /**
  88930. * Specifies if the material should be serialized
  88931. */
  88932. doNotSerialize: boolean;
  88933. /**
  88934. * @hidden
  88935. */
  88936. _storeEffectOnSubMeshes: boolean;
  88937. /**
  88938. * Stores the animations for the material
  88939. */
  88940. animations: Nullable<Array<Animation>>;
  88941. /**
  88942. * An event triggered when the material is disposed
  88943. */
  88944. onDisposeObservable: Observable<Material>;
  88945. /**
  88946. * An observer which watches for dispose events
  88947. */
  88948. private _onDisposeObserver;
  88949. private _onUnBindObservable;
  88950. /**
  88951. * Called during a dispose event
  88952. */
  88953. onDispose: () => void;
  88954. private _onBindObservable;
  88955. /**
  88956. * An event triggered when the material is bound
  88957. */
  88958. readonly onBindObservable: Observable<AbstractMesh>;
  88959. /**
  88960. * An observer which watches for bind events
  88961. */
  88962. private _onBindObserver;
  88963. /**
  88964. * Called during a bind event
  88965. */
  88966. onBind: (Mesh: AbstractMesh) => void;
  88967. /**
  88968. * An event triggered when the material is unbound
  88969. */
  88970. readonly onUnBindObservable: Observable<Material>;
  88971. /**
  88972. * Stores the value of the alpha mode
  88973. */
  88974. private _alphaMode;
  88975. /**
  88976. * Sets the value of the alpha mode.
  88977. *
  88978. * | Value | Type | Description |
  88979. * | --- | --- | --- |
  88980. * | 0 | ALPHA_DISABLE | |
  88981. * | 1 | ALPHA_ADD | |
  88982. * | 2 | ALPHA_COMBINE | |
  88983. * | 3 | ALPHA_SUBTRACT | |
  88984. * | 4 | ALPHA_MULTIPLY | |
  88985. * | 5 | ALPHA_MAXIMIZED | |
  88986. * | 6 | ALPHA_ONEONE | |
  88987. * | 7 | ALPHA_PREMULTIPLIED | |
  88988. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  88989. * | 9 | ALPHA_INTERPOLATE | |
  88990. * | 10 | ALPHA_SCREENMODE | |
  88991. *
  88992. */
  88993. /**
  88994. * Gets the value of the alpha mode
  88995. */
  88996. alphaMode: number;
  88997. /**
  88998. * Stores the state of the need depth pre-pass value
  88999. */
  89000. private _needDepthPrePass;
  89001. /**
  89002. * Sets the need depth pre-pass value
  89003. */
  89004. /**
  89005. * Gets the depth pre-pass value
  89006. */
  89007. needDepthPrePass: boolean;
  89008. /**
  89009. * Specifies if depth writing should be disabled
  89010. */
  89011. disableDepthWrite: boolean;
  89012. /**
  89013. * Specifies if depth writing should be forced
  89014. */
  89015. forceDepthWrite: boolean;
  89016. /**
  89017. * Specifies the depth function that should be used. 0 means the default engine function
  89018. */
  89019. depthFunction: number;
  89020. /**
  89021. * Specifies if there should be a separate pass for culling
  89022. */
  89023. separateCullingPass: boolean;
  89024. /**
  89025. * Stores the state specifing if fog should be enabled
  89026. */
  89027. private _fogEnabled;
  89028. /**
  89029. * Sets the state for enabling fog
  89030. */
  89031. /**
  89032. * Gets the value of the fog enabled state
  89033. */
  89034. fogEnabled: boolean;
  89035. /**
  89036. * Stores the size of points
  89037. */
  89038. pointSize: number;
  89039. /**
  89040. * Stores the z offset value
  89041. */
  89042. zOffset: number;
  89043. /**
  89044. * Gets a value specifying if wireframe mode is enabled
  89045. */
  89046. /**
  89047. * Sets the state of wireframe mode
  89048. */
  89049. wireframe: boolean;
  89050. /**
  89051. * Gets the value specifying if point clouds are enabled
  89052. */
  89053. /**
  89054. * Sets the state of point cloud mode
  89055. */
  89056. pointsCloud: boolean;
  89057. /**
  89058. * Gets the material fill mode
  89059. */
  89060. /**
  89061. * Sets the material fill mode
  89062. */
  89063. fillMode: number;
  89064. /**
  89065. * @hidden
  89066. * Stores the effects for the material
  89067. */
  89068. _effect: Nullable<Effect>;
  89069. /**
  89070. * @hidden
  89071. * Specifies if the material was previously ready
  89072. */
  89073. _wasPreviouslyReady: boolean;
  89074. /**
  89075. * Specifies if uniform buffers should be used
  89076. */
  89077. private _useUBO;
  89078. /**
  89079. * Stores a reference to the scene
  89080. */
  89081. private _scene;
  89082. /**
  89083. * Stores the fill mode state
  89084. */
  89085. private _fillMode;
  89086. /**
  89087. * Specifies if the depth write state should be cached
  89088. */
  89089. private _cachedDepthWriteState;
  89090. /**
  89091. * Specifies if the depth function state should be cached
  89092. */
  89093. private _cachedDepthFunctionState;
  89094. /**
  89095. * Stores the uniform buffer
  89096. */
  89097. protected _uniformBuffer: UniformBuffer;
  89098. /** @hidden */
  89099. _indexInSceneMaterialArray: number;
  89100. /** @hidden */
  89101. meshMap: Nullable<{
  89102. [id: string]: AbstractMesh | undefined;
  89103. }>;
  89104. /**
  89105. * Creates a material instance
  89106. * @param name defines the name of the material
  89107. * @param scene defines the scene to reference
  89108. * @param doNotAdd specifies if the material should be added to the scene
  89109. */
  89110. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  89111. /**
  89112. * Returns a string representation of the current material
  89113. * @param fullDetails defines a boolean indicating which levels of logging is desired
  89114. * @returns a string with material information
  89115. */
  89116. toString(fullDetails?: boolean): string;
  89117. /**
  89118. * Gets the class name of the material
  89119. * @returns a string with the class name of the material
  89120. */
  89121. getClassName(): string;
  89122. /**
  89123. * Specifies if updates for the material been locked
  89124. */
  89125. readonly isFrozen: boolean;
  89126. /**
  89127. * Locks updates for the material
  89128. */
  89129. freeze(): void;
  89130. /**
  89131. * Unlocks updates for the material
  89132. */
  89133. unfreeze(): void;
  89134. /**
  89135. * Specifies if the material is ready to be used
  89136. * @param mesh defines the mesh to check
  89137. * @param useInstances specifies if instances should be used
  89138. * @returns a boolean indicating if the material is ready to be used
  89139. */
  89140. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89141. /**
  89142. * Specifies that the submesh is ready to be used
  89143. * @param mesh defines the mesh to check
  89144. * @param subMesh defines which submesh to check
  89145. * @param useInstances specifies that instances should be used
  89146. * @returns a boolean indicating that the submesh is ready or not
  89147. */
  89148. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89149. /**
  89150. * Returns the material effect
  89151. * @returns the effect associated with the material
  89152. */
  89153. getEffect(): Nullable<Effect>;
  89154. /**
  89155. * Returns the current scene
  89156. * @returns a Scene
  89157. */
  89158. getScene(): Scene;
  89159. /**
  89160. * Specifies if the material will require alpha blending
  89161. * @returns a boolean specifying if alpha blending is needed
  89162. */
  89163. needAlphaBlending(): boolean;
  89164. /**
  89165. * Specifies if the mesh will require alpha blending
  89166. * @param mesh defines the mesh to check
  89167. * @returns a boolean specifying if alpha blending is needed for the mesh
  89168. */
  89169. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  89170. /**
  89171. * Specifies if this material should be rendered in alpha test mode
  89172. * @returns a boolean specifying if an alpha test is needed.
  89173. */
  89174. needAlphaTesting(): boolean;
  89175. /**
  89176. * Gets the texture used for the alpha test
  89177. * @returns the texture to use for alpha testing
  89178. */
  89179. getAlphaTestTexture(): Nullable<BaseTexture>;
  89180. /**
  89181. * Marks the material to indicate that it needs to be re-calculated
  89182. */
  89183. markDirty(): void;
  89184. /** @hidden */
  89185. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  89186. /**
  89187. * Binds the material to the mesh
  89188. * @param world defines the world transformation matrix
  89189. * @param mesh defines the mesh to bind the material to
  89190. */
  89191. bind(world: Matrix, mesh?: Mesh): void;
  89192. /**
  89193. * Binds the submesh to the material
  89194. * @param world defines the world transformation matrix
  89195. * @param mesh defines the mesh containing the submesh
  89196. * @param subMesh defines the submesh to bind the material to
  89197. */
  89198. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  89199. /**
  89200. * Binds the world matrix to the material
  89201. * @param world defines the world transformation matrix
  89202. */
  89203. bindOnlyWorldMatrix(world: Matrix): void;
  89204. /**
  89205. * Binds the scene's uniform buffer to the effect.
  89206. * @param effect defines the effect to bind to the scene uniform buffer
  89207. * @param sceneUbo defines the uniform buffer storing scene data
  89208. */
  89209. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  89210. /**
  89211. * Binds the view matrix to the effect
  89212. * @param effect defines the effect to bind the view matrix to
  89213. */
  89214. bindView(effect: Effect): void;
  89215. /**
  89216. * Binds the view projection matrix to the effect
  89217. * @param effect defines the effect to bind the view projection matrix to
  89218. */
  89219. bindViewProjection(effect: Effect): void;
  89220. /**
  89221. * Specifies if material alpha testing should be turned on for the mesh
  89222. * @param mesh defines the mesh to check
  89223. */
  89224. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  89225. /**
  89226. * Processes to execute after binding the material to a mesh
  89227. * @param mesh defines the rendered mesh
  89228. */
  89229. protected _afterBind(mesh?: Mesh): void;
  89230. /**
  89231. * Unbinds the material from the mesh
  89232. */
  89233. unbind(): void;
  89234. /**
  89235. * Gets the active textures from the material
  89236. * @returns an array of textures
  89237. */
  89238. getActiveTextures(): BaseTexture[];
  89239. /**
  89240. * Specifies if the material uses a texture
  89241. * @param texture defines the texture to check against the material
  89242. * @returns a boolean specifying if the material uses the texture
  89243. */
  89244. hasTexture(texture: BaseTexture): boolean;
  89245. /**
  89246. * Makes a duplicate of the material, and gives it a new name
  89247. * @param name defines the new name for the duplicated material
  89248. * @returns the cloned material
  89249. */
  89250. clone(name: string): Nullable<Material>;
  89251. /**
  89252. * Gets the meshes bound to the material
  89253. * @returns an array of meshes bound to the material
  89254. */
  89255. getBindedMeshes(): AbstractMesh[];
  89256. /**
  89257. * Force shader compilation
  89258. * @param mesh defines the mesh associated with this material
  89259. * @param onCompiled defines a function to execute once the material is compiled
  89260. * @param options defines the options to configure the compilation
  89261. * @param onError defines a function to execute if the material fails compiling
  89262. */
  89263. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  89264. /**
  89265. * Force shader compilation
  89266. * @param mesh defines the mesh that will use this material
  89267. * @param options defines additional options for compiling the shaders
  89268. * @returns a promise that resolves when the compilation completes
  89269. */
  89270. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  89271. private static readonly _AllDirtyCallBack;
  89272. private static readonly _ImageProcessingDirtyCallBack;
  89273. private static readonly _TextureDirtyCallBack;
  89274. private static readonly _FresnelDirtyCallBack;
  89275. private static readonly _MiscDirtyCallBack;
  89276. private static readonly _LightsDirtyCallBack;
  89277. private static readonly _AttributeDirtyCallBack;
  89278. private static _FresnelAndMiscDirtyCallBack;
  89279. private static _TextureAndMiscDirtyCallBack;
  89280. private static readonly _DirtyCallbackArray;
  89281. private static readonly _RunDirtyCallBacks;
  89282. /**
  89283. * Marks a define in the material to indicate that it needs to be re-computed
  89284. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  89285. */
  89286. markAsDirty(flag: number): void;
  89287. /**
  89288. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  89289. * @param func defines a function which checks material defines against the submeshes
  89290. */
  89291. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  89292. /**
  89293. * Indicates that we need to re-calculated for all submeshes
  89294. */
  89295. protected _markAllSubMeshesAsAllDirty(): void;
  89296. /**
  89297. * Indicates that image processing needs to be re-calculated for all submeshes
  89298. */
  89299. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  89300. /**
  89301. * Indicates that textures need to be re-calculated for all submeshes
  89302. */
  89303. protected _markAllSubMeshesAsTexturesDirty(): void;
  89304. /**
  89305. * Indicates that fresnel needs to be re-calculated for all submeshes
  89306. */
  89307. protected _markAllSubMeshesAsFresnelDirty(): void;
  89308. /**
  89309. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  89310. */
  89311. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  89312. /**
  89313. * Indicates that lights need to be re-calculated for all submeshes
  89314. */
  89315. protected _markAllSubMeshesAsLightsDirty(): void;
  89316. /**
  89317. * Indicates that attributes need to be re-calculated for all submeshes
  89318. */
  89319. protected _markAllSubMeshesAsAttributesDirty(): void;
  89320. /**
  89321. * Indicates that misc needs to be re-calculated for all submeshes
  89322. */
  89323. protected _markAllSubMeshesAsMiscDirty(): void;
  89324. /**
  89325. * Indicates that textures and misc need to be re-calculated for all submeshes
  89326. */
  89327. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  89328. /**
  89329. * Disposes the material
  89330. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89331. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89332. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89333. */
  89334. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89335. /** @hidden */
  89336. private releaseVertexArrayObject;
  89337. /**
  89338. * Serializes this material
  89339. * @returns the serialized material object
  89340. */
  89341. serialize(): any;
  89342. /**
  89343. * Creates a material from parsed material data
  89344. * @param parsedMaterial defines parsed material data
  89345. * @param scene defines the hosting scene
  89346. * @param rootUrl defines the root URL to use to load textures
  89347. * @returns a new material
  89348. */
  89349. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  89350. }
  89351. }
  89352. declare module BABYLON {
  89353. /**
  89354. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89355. * separate meshes. This can be use to improve performances.
  89356. * @see http://doc.babylonjs.com/how_to/multi_materials
  89357. */
  89358. export class MultiMaterial extends Material {
  89359. private _subMaterials;
  89360. /**
  89361. * Gets or Sets the list of Materials used within the multi material.
  89362. * They need to be ordered according to the submeshes order in the associated mesh
  89363. */
  89364. subMaterials: Nullable<Material>[];
  89365. /**
  89366. * Function used to align with Node.getChildren()
  89367. * @returns the list of Materials used within the multi material
  89368. */
  89369. getChildren(): Nullable<Material>[];
  89370. /**
  89371. * Instantiates a new Multi Material
  89372. * A multi-material is used to apply different materials to different parts of the same object without the need of
  89373. * separate meshes. This can be use to improve performances.
  89374. * @see http://doc.babylonjs.com/how_to/multi_materials
  89375. * @param name Define the name in the scene
  89376. * @param scene Define the scene the material belongs to
  89377. */
  89378. constructor(name: string, scene: Scene);
  89379. private _hookArray;
  89380. /**
  89381. * Get one of the submaterial by its index in the submaterials array
  89382. * @param index The index to look the sub material at
  89383. * @returns The Material if the index has been defined
  89384. */
  89385. getSubMaterial(index: number): Nullable<Material>;
  89386. /**
  89387. * Get the list of active textures for the whole sub materials list.
  89388. * @returns All the textures that will be used during the rendering
  89389. */
  89390. getActiveTextures(): BaseTexture[];
  89391. /**
  89392. * Gets the current class name of the material e.g. "MultiMaterial"
  89393. * Mainly use in serialization.
  89394. * @returns the class name
  89395. */
  89396. getClassName(): string;
  89397. /**
  89398. * Checks if the material is ready to render the requested sub mesh
  89399. * @param mesh Define the mesh the submesh belongs to
  89400. * @param subMesh Define the sub mesh to look readyness for
  89401. * @param useInstances Define whether or not the material is used with instances
  89402. * @returns true if ready, otherwise false
  89403. */
  89404. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89405. /**
  89406. * Clones the current material and its related sub materials
  89407. * @param name Define the name of the newly cloned material
  89408. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  89409. * @returns the cloned material
  89410. */
  89411. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  89412. /**
  89413. * Serializes the materials into a JSON representation.
  89414. * @returns the JSON representation
  89415. */
  89416. serialize(): any;
  89417. /**
  89418. * Dispose the material and release its associated resources
  89419. * @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)
  89420. * @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)
  89421. * @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)
  89422. */
  89423. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  89424. /**
  89425. * Creates a MultiMaterial from parsed MultiMaterial data.
  89426. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  89427. * @param scene defines the hosting scene
  89428. * @returns a new MultiMaterial
  89429. */
  89430. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  89431. }
  89432. }
  89433. declare module BABYLON {
  89434. /**
  89435. * Base class for submeshes
  89436. */
  89437. export class BaseSubMesh {
  89438. /** @hidden */
  89439. _materialDefines: Nullable<MaterialDefines>;
  89440. /** @hidden */
  89441. _materialEffect: Nullable<Effect>;
  89442. /**
  89443. * Gets associated effect
  89444. */
  89445. readonly effect: Nullable<Effect>;
  89446. /**
  89447. * Sets associated effect (effect used to render this submesh)
  89448. * @param effect defines the effect to associate with
  89449. * @param defines defines the set of defines used to compile this effect
  89450. */
  89451. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  89452. }
  89453. /**
  89454. * Defines a subdivision inside a mesh
  89455. */
  89456. export class SubMesh extends BaseSubMesh implements ICullable {
  89457. /** the material index to use */
  89458. materialIndex: number;
  89459. /** vertex index start */
  89460. verticesStart: number;
  89461. /** vertices count */
  89462. verticesCount: number;
  89463. /** index start */
  89464. indexStart: number;
  89465. /** indices count */
  89466. indexCount: number;
  89467. /** @hidden */
  89468. _linesIndexCount: number;
  89469. private _mesh;
  89470. private _renderingMesh;
  89471. private _boundingInfo;
  89472. private _linesIndexBuffer;
  89473. /** @hidden */
  89474. _lastColliderWorldVertices: Nullable<Vector3[]>;
  89475. /** @hidden */
  89476. _trianglePlanes: Plane[];
  89477. /** @hidden */
  89478. _lastColliderTransformMatrix: Nullable<Matrix>;
  89479. /** @hidden */
  89480. _renderId: number;
  89481. /** @hidden */
  89482. _alphaIndex: number;
  89483. /** @hidden */
  89484. _distanceToCamera: number;
  89485. /** @hidden */
  89486. _id: number;
  89487. private _currentMaterial;
  89488. /**
  89489. * Add a new submesh to a mesh
  89490. * @param materialIndex defines the material index to use
  89491. * @param verticesStart defines vertex index start
  89492. * @param verticesCount defines vertices count
  89493. * @param indexStart defines index start
  89494. * @param indexCount defines indices count
  89495. * @param mesh defines the parent mesh
  89496. * @param renderingMesh defines an optional rendering mesh
  89497. * @param createBoundingBox defines if bounding box should be created for this submesh
  89498. * @returns the new submesh
  89499. */
  89500. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  89501. /**
  89502. * Creates a new submesh
  89503. * @param materialIndex defines the material index to use
  89504. * @param verticesStart defines vertex index start
  89505. * @param verticesCount defines vertices count
  89506. * @param indexStart defines index start
  89507. * @param indexCount defines indices count
  89508. * @param mesh defines the parent mesh
  89509. * @param renderingMesh defines an optional rendering mesh
  89510. * @param createBoundingBox defines if bounding box should be created for this submesh
  89511. */
  89512. constructor(
  89513. /** the material index to use */
  89514. materialIndex: number,
  89515. /** vertex index start */
  89516. verticesStart: number,
  89517. /** vertices count */
  89518. verticesCount: number,
  89519. /** index start */
  89520. indexStart: number,
  89521. /** indices count */
  89522. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  89523. /**
  89524. * Returns true if this submesh covers the entire parent mesh
  89525. * @ignorenaming
  89526. */
  89527. readonly IsGlobal: boolean;
  89528. /**
  89529. * Returns the submesh BoudingInfo object
  89530. * @returns current bounding info (or mesh's one if the submesh is global)
  89531. */
  89532. getBoundingInfo(): BoundingInfo;
  89533. /**
  89534. * Sets the submesh BoundingInfo
  89535. * @param boundingInfo defines the new bounding info to use
  89536. * @returns the SubMesh
  89537. */
  89538. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  89539. /**
  89540. * Returns the mesh of the current submesh
  89541. * @return the parent mesh
  89542. */
  89543. getMesh(): AbstractMesh;
  89544. /**
  89545. * Returns the rendering mesh of the submesh
  89546. * @returns the rendering mesh (could be different from parent mesh)
  89547. */
  89548. getRenderingMesh(): Mesh;
  89549. /**
  89550. * Returns the submesh material
  89551. * @returns null or the current material
  89552. */
  89553. getMaterial(): Nullable<Material>;
  89554. /**
  89555. * Sets a new updated BoundingInfo object to the submesh
  89556. * @param data defines an optional position array to use to determine the bounding info
  89557. * @returns the SubMesh
  89558. */
  89559. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  89560. /** @hidden */
  89561. _checkCollision(collider: Collider): boolean;
  89562. /**
  89563. * Updates the submesh BoundingInfo
  89564. * @param world defines the world matrix to use to update the bounding info
  89565. * @returns the submesh
  89566. */
  89567. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  89568. /**
  89569. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  89570. * @param frustumPlanes defines the frustum planes
  89571. * @returns true if the submesh is intersecting with the frustum
  89572. */
  89573. isInFrustum(frustumPlanes: Plane[]): boolean;
  89574. /**
  89575. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  89576. * @param frustumPlanes defines the frustum planes
  89577. * @returns true if the submesh is inside the frustum
  89578. */
  89579. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89580. /**
  89581. * Renders the submesh
  89582. * @param enableAlphaMode defines if alpha needs to be used
  89583. * @returns the submesh
  89584. */
  89585. render(enableAlphaMode: boolean): SubMesh;
  89586. /**
  89587. * @hidden
  89588. */
  89589. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  89590. /**
  89591. * Checks if the submesh intersects with a ray
  89592. * @param ray defines the ray to test
  89593. * @returns true is the passed ray intersects the submesh bounding box
  89594. */
  89595. canIntersects(ray: Ray): boolean;
  89596. /**
  89597. * Intersects current submesh with a ray
  89598. * @param ray defines the ray to test
  89599. * @param positions defines mesh's positions array
  89600. * @param indices defines mesh's indices array
  89601. * @param fastCheck defines if only bounding info should be used
  89602. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89603. * @returns intersection info or null if no intersection
  89604. */
  89605. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  89606. /** @hidden */
  89607. private _intersectLines;
  89608. /** @hidden */
  89609. private _intersectUnIndexedLines;
  89610. /** @hidden */
  89611. private _intersectTriangles;
  89612. /** @hidden */
  89613. private _intersectUnIndexedTriangles;
  89614. /** @hidden */
  89615. _rebuild(): void;
  89616. /**
  89617. * Creates a new submesh from the passed mesh
  89618. * @param newMesh defines the new hosting mesh
  89619. * @param newRenderingMesh defines an optional rendering mesh
  89620. * @returns the new submesh
  89621. */
  89622. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  89623. /**
  89624. * Release associated resources
  89625. */
  89626. dispose(): void;
  89627. /**
  89628. * Gets the class name
  89629. * @returns the string "SubMesh".
  89630. */
  89631. getClassName(): string;
  89632. /**
  89633. * Creates a new submesh from indices data
  89634. * @param materialIndex the index of the main mesh material
  89635. * @param startIndex the index where to start the copy in the mesh indices array
  89636. * @param indexCount the number of indices to copy then from the startIndex
  89637. * @param mesh the main mesh to create the submesh from
  89638. * @param renderingMesh the optional rendering mesh
  89639. * @returns a new submesh
  89640. */
  89641. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  89642. }
  89643. }
  89644. declare module BABYLON {
  89645. /**
  89646. * Class used to represent data loading progression
  89647. */
  89648. export class SceneLoaderFlags {
  89649. private static _ForceFullSceneLoadingForIncremental;
  89650. private static _ShowLoadingScreen;
  89651. private static _CleanBoneMatrixWeights;
  89652. private static _loggingLevel;
  89653. /**
  89654. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  89655. */
  89656. static ForceFullSceneLoadingForIncremental: boolean;
  89657. /**
  89658. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  89659. */
  89660. static ShowLoadingScreen: boolean;
  89661. /**
  89662. * Defines the current logging level (while loading the scene)
  89663. * @ignorenaming
  89664. */
  89665. static loggingLevel: number;
  89666. /**
  89667. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  89668. */
  89669. static CleanBoneMatrixWeights: boolean;
  89670. }
  89671. }
  89672. declare module BABYLON {
  89673. /**
  89674. * Class used to store geometry data (vertex buffers + index buffer)
  89675. */
  89676. export class Geometry implements IGetSetVerticesData {
  89677. /**
  89678. * Gets or sets the ID of the geometry
  89679. */
  89680. id: string;
  89681. /**
  89682. * Gets or sets the unique ID of the geometry
  89683. */
  89684. uniqueId: number;
  89685. /**
  89686. * Gets the delay loading state of the geometry (none by default which means not delayed)
  89687. */
  89688. delayLoadState: number;
  89689. /**
  89690. * Gets the file containing the data to load when running in delay load state
  89691. */
  89692. delayLoadingFile: Nullable<string>;
  89693. /**
  89694. * Callback called when the geometry is updated
  89695. */
  89696. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  89697. private _scene;
  89698. private _engine;
  89699. private _meshes;
  89700. private _totalVertices;
  89701. /** @hidden */
  89702. _indices: IndicesArray;
  89703. /** @hidden */
  89704. _vertexBuffers: {
  89705. [key: string]: VertexBuffer;
  89706. };
  89707. private _isDisposed;
  89708. private _extend;
  89709. private _boundingBias;
  89710. /** @hidden */
  89711. _delayInfo: Array<string>;
  89712. private _indexBuffer;
  89713. private _indexBufferIsUpdatable;
  89714. /** @hidden */
  89715. _boundingInfo: Nullable<BoundingInfo>;
  89716. /** @hidden */
  89717. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  89718. /** @hidden */
  89719. _softwareSkinningFrameId: number;
  89720. private _vertexArrayObjects;
  89721. private _updatable;
  89722. /** @hidden */
  89723. _positions: Nullable<Vector3[]>;
  89724. /**
  89725. * 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
  89726. */
  89727. /**
  89728. * 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
  89729. */
  89730. boundingBias: Vector2;
  89731. /**
  89732. * Static function used to attach a new empty geometry to a mesh
  89733. * @param mesh defines the mesh to attach the geometry to
  89734. * @returns the new Geometry
  89735. */
  89736. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  89737. /**
  89738. * Creates a new geometry
  89739. * @param id defines the unique ID
  89740. * @param scene defines the hosting scene
  89741. * @param vertexData defines the VertexData used to get geometry data
  89742. * @param updatable defines if geometry must be updatable (false by default)
  89743. * @param mesh defines the mesh that will be associated with the geometry
  89744. */
  89745. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  89746. /**
  89747. * Gets the current extend of the geometry
  89748. */
  89749. readonly extend: {
  89750. minimum: Vector3;
  89751. maximum: Vector3;
  89752. };
  89753. /**
  89754. * Gets the hosting scene
  89755. * @returns the hosting Scene
  89756. */
  89757. getScene(): Scene;
  89758. /**
  89759. * Gets the hosting engine
  89760. * @returns the hosting Engine
  89761. */
  89762. getEngine(): Engine;
  89763. /**
  89764. * Defines if the geometry is ready to use
  89765. * @returns true if the geometry is ready to be used
  89766. */
  89767. isReady(): boolean;
  89768. /**
  89769. * Gets a value indicating that the geometry should not be serialized
  89770. */
  89771. readonly doNotSerialize: boolean;
  89772. /** @hidden */
  89773. _rebuild(): void;
  89774. /**
  89775. * Affects all geometry data in one call
  89776. * @param vertexData defines the geometry data
  89777. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  89778. */
  89779. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  89780. /**
  89781. * Set specific vertex data
  89782. * @param kind defines the data kind (Position, normal, etc...)
  89783. * @param data defines the vertex data to use
  89784. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  89785. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  89786. */
  89787. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  89788. /**
  89789. * Removes a specific vertex data
  89790. * @param kind defines the data kind (Position, normal, etc...)
  89791. */
  89792. removeVerticesData(kind: string): void;
  89793. /**
  89794. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  89795. * @param buffer defines the vertex buffer to use
  89796. * @param totalVertices defines the total number of vertices for position kind (could be null)
  89797. */
  89798. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  89799. /**
  89800. * Update a specific vertex buffer
  89801. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  89802. * It will do nothing if the buffer is not updatable
  89803. * @param kind defines the data kind (Position, normal, etc...)
  89804. * @param data defines the data to use
  89805. * @param offset defines the offset in the target buffer where to store the data
  89806. * @param useBytes set to true if the offset is in bytes
  89807. */
  89808. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  89809. /**
  89810. * Update a specific vertex buffer
  89811. * This function will create a new buffer if the current one is not updatable
  89812. * @param kind defines the data kind (Position, normal, etc...)
  89813. * @param data defines the data to use
  89814. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  89815. */
  89816. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  89817. private _updateBoundingInfo;
  89818. /** @hidden */
  89819. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  89820. /**
  89821. * Gets total number of vertices
  89822. * @returns the total number of vertices
  89823. */
  89824. getTotalVertices(): number;
  89825. /**
  89826. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89827. * @param kind defines the data kind (Position, normal, etc...)
  89828. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89829. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89830. * @returns a float array containing vertex data
  89831. */
  89832. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89833. /**
  89834. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  89835. * @param kind defines the data kind (Position, normal, etc...)
  89836. * @returns true if the vertex buffer with the specified kind is updatable
  89837. */
  89838. isVertexBufferUpdatable(kind: string): boolean;
  89839. /**
  89840. * Gets a specific vertex buffer
  89841. * @param kind defines the data kind (Position, normal, etc...)
  89842. * @returns a VertexBuffer
  89843. */
  89844. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89845. /**
  89846. * Returns all vertex buffers
  89847. * @return an object holding all vertex buffers indexed by kind
  89848. */
  89849. getVertexBuffers(): Nullable<{
  89850. [key: string]: VertexBuffer;
  89851. }>;
  89852. /**
  89853. * Gets a boolean indicating if specific vertex buffer is present
  89854. * @param kind defines the data kind (Position, normal, etc...)
  89855. * @returns true if data is present
  89856. */
  89857. isVerticesDataPresent(kind: string): boolean;
  89858. /**
  89859. * Gets a list of all attached data kinds (Position, normal, etc...)
  89860. * @returns a list of string containing all kinds
  89861. */
  89862. getVerticesDataKinds(): string[];
  89863. /**
  89864. * Update index buffer
  89865. * @param indices defines the indices to store in the index buffer
  89866. * @param offset defines the offset in the target buffer where to store the data
  89867. * @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)
  89868. */
  89869. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  89870. /**
  89871. * Creates a new index buffer
  89872. * @param indices defines the indices to store in the index buffer
  89873. * @param totalVertices defines the total number of vertices (could be null)
  89874. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  89875. */
  89876. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  89877. /**
  89878. * Return the total number of indices
  89879. * @returns the total number of indices
  89880. */
  89881. getTotalIndices(): number;
  89882. /**
  89883. * Gets the index buffer array
  89884. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89885. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89886. * @returns the index buffer array
  89887. */
  89888. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89889. /**
  89890. * Gets the index buffer
  89891. * @return the index buffer
  89892. */
  89893. getIndexBuffer(): Nullable<DataBuffer>;
  89894. /** @hidden */
  89895. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  89896. /**
  89897. * Release the associated resources for a specific mesh
  89898. * @param mesh defines the source mesh
  89899. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  89900. */
  89901. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  89902. /**
  89903. * Apply current geometry to a given mesh
  89904. * @param mesh defines the mesh to apply geometry to
  89905. */
  89906. applyToMesh(mesh: Mesh): void;
  89907. private _updateExtend;
  89908. private _applyToMesh;
  89909. private notifyUpdate;
  89910. /**
  89911. * Load the geometry if it was flagged as delay loaded
  89912. * @param scene defines the hosting scene
  89913. * @param onLoaded defines a callback called when the geometry is loaded
  89914. */
  89915. load(scene: Scene, onLoaded?: () => void): void;
  89916. private _queueLoad;
  89917. /**
  89918. * Invert the geometry to move from a right handed system to a left handed one.
  89919. */
  89920. toLeftHanded(): void;
  89921. /** @hidden */
  89922. _resetPointsArrayCache(): void;
  89923. /** @hidden */
  89924. _generatePointsArray(): boolean;
  89925. /**
  89926. * Gets a value indicating if the geometry is disposed
  89927. * @returns true if the geometry was disposed
  89928. */
  89929. isDisposed(): boolean;
  89930. private _disposeVertexArrayObjects;
  89931. /**
  89932. * Free all associated resources
  89933. */
  89934. dispose(): void;
  89935. /**
  89936. * Clone the current geometry into a new geometry
  89937. * @param id defines the unique ID of the new geometry
  89938. * @returns a new geometry object
  89939. */
  89940. copy(id: string): Geometry;
  89941. /**
  89942. * Serialize the current geometry info (and not the vertices data) into a JSON object
  89943. * @return a JSON representation of the current geometry data (without the vertices data)
  89944. */
  89945. serialize(): any;
  89946. private toNumberArray;
  89947. /**
  89948. * Serialize all vertices data into a JSON oject
  89949. * @returns a JSON representation of the current geometry data
  89950. */
  89951. serializeVerticeData(): any;
  89952. /**
  89953. * Extracts a clone of a mesh geometry
  89954. * @param mesh defines the source mesh
  89955. * @param id defines the unique ID of the new geometry object
  89956. * @returns the new geometry object
  89957. */
  89958. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  89959. /**
  89960. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  89961. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89962. * Be aware Math.random() could cause collisions, but:
  89963. * "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"
  89964. * @returns a string containing a new GUID
  89965. */
  89966. static RandomId(): string;
  89967. /** @hidden */
  89968. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  89969. private static _CleanMatricesWeights;
  89970. /**
  89971. * Create a new geometry from persisted data (Using .babylon file format)
  89972. * @param parsedVertexData defines the persisted data
  89973. * @param scene defines the hosting scene
  89974. * @param rootUrl defines the root url to use to load assets (like delayed data)
  89975. * @returns the new geometry object
  89976. */
  89977. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  89978. }
  89979. }
  89980. declare module BABYLON {
  89981. /**
  89982. * Define an interface for all classes that will get and set the data on vertices
  89983. */
  89984. export interface IGetSetVerticesData {
  89985. /**
  89986. * Gets a boolean indicating if specific vertex data is present
  89987. * @param kind defines the vertex data kind to use
  89988. * @returns true is data kind is present
  89989. */
  89990. isVerticesDataPresent(kind: string): boolean;
  89991. /**
  89992. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  89993. * @param kind defines the data kind (Position, normal, etc...)
  89994. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  89995. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89996. * @returns a float array containing vertex data
  89997. */
  89998. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89999. /**
  90000. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90001. * @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.
  90002. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90003. * @returns the indices array or an empty array if the mesh has no geometry
  90004. */
  90005. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90006. /**
  90007. * Set specific vertex data
  90008. * @param kind defines the data kind (Position, normal, etc...)
  90009. * @param data defines the vertex data to use
  90010. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  90011. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  90012. */
  90013. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  90014. /**
  90015. * Update a specific associated vertex buffer
  90016. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90017. * - VertexBuffer.PositionKind
  90018. * - VertexBuffer.UVKind
  90019. * - VertexBuffer.UV2Kind
  90020. * - VertexBuffer.UV3Kind
  90021. * - VertexBuffer.UV4Kind
  90022. * - VertexBuffer.UV5Kind
  90023. * - VertexBuffer.UV6Kind
  90024. * - VertexBuffer.ColorKind
  90025. * - VertexBuffer.MatricesIndicesKind
  90026. * - VertexBuffer.MatricesIndicesExtraKind
  90027. * - VertexBuffer.MatricesWeightsKind
  90028. * - VertexBuffer.MatricesWeightsExtraKind
  90029. * @param data defines the data source
  90030. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90031. * @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)
  90032. */
  90033. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  90034. /**
  90035. * Creates a new index buffer
  90036. * @param indices defines the indices to store in the index buffer
  90037. * @param totalVertices defines the total number of vertices (could be null)
  90038. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  90039. */
  90040. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  90041. }
  90042. /**
  90043. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  90044. */
  90045. export class VertexData {
  90046. /**
  90047. * Mesh side orientation : usually the external or front surface
  90048. */
  90049. static readonly FRONTSIDE: number;
  90050. /**
  90051. * Mesh side orientation : usually the internal or back surface
  90052. */
  90053. static readonly BACKSIDE: number;
  90054. /**
  90055. * Mesh side orientation : both internal and external or front and back surfaces
  90056. */
  90057. static readonly DOUBLESIDE: number;
  90058. /**
  90059. * Mesh side orientation : by default, `FRONTSIDE`
  90060. */
  90061. static readonly DEFAULTSIDE: number;
  90062. /**
  90063. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  90064. */
  90065. positions: Nullable<FloatArray>;
  90066. /**
  90067. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  90068. */
  90069. normals: Nullable<FloatArray>;
  90070. /**
  90071. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  90072. */
  90073. tangents: Nullable<FloatArray>;
  90074. /**
  90075. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90076. */
  90077. uvs: Nullable<FloatArray>;
  90078. /**
  90079. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90080. */
  90081. uvs2: Nullable<FloatArray>;
  90082. /**
  90083. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90084. */
  90085. uvs3: Nullable<FloatArray>;
  90086. /**
  90087. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90088. */
  90089. uvs4: Nullable<FloatArray>;
  90090. /**
  90091. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90092. */
  90093. uvs5: Nullable<FloatArray>;
  90094. /**
  90095. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  90096. */
  90097. uvs6: Nullable<FloatArray>;
  90098. /**
  90099. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  90100. */
  90101. colors: Nullable<FloatArray>;
  90102. /**
  90103. * 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).
  90104. */
  90105. matricesIndices: Nullable<FloatArray>;
  90106. /**
  90107. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  90108. */
  90109. matricesWeights: Nullable<FloatArray>;
  90110. /**
  90111. * An array extending the number of possible indices
  90112. */
  90113. matricesIndicesExtra: Nullable<FloatArray>;
  90114. /**
  90115. * An array extending the number of possible weights when the number of indices is extended
  90116. */
  90117. matricesWeightsExtra: Nullable<FloatArray>;
  90118. /**
  90119. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  90120. */
  90121. indices: Nullable<IndicesArray>;
  90122. /**
  90123. * Uses the passed data array to set the set the values for the specified kind of data
  90124. * @param data a linear array of floating numbers
  90125. * @param kind the type of data that is being set, eg positions, colors etc
  90126. */
  90127. set(data: FloatArray, kind: string): void;
  90128. /**
  90129. * Associates the vertexData to the passed Mesh.
  90130. * Sets it as updatable or not (default `false`)
  90131. * @param mesh the mesh the vertexData is applied to
  90132. * @param updatable when used and having the value true allows new data to update the vertexData
  90133. * @returns the VertexData
  90134. */
  90135. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  90136. /**
  90137. * Associates the vertexData to the passed Geometry.
  90138. * Sets it as updatable or not (default `false`)
  90139. * @param geometry the geometry the vertexData is applied to
  90140. * @param updatable when used and having the value true allows new data to update the vertexData
  90141. * @returns VertexData
  90142. */
  90143. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  90144. /**
  90145. * Updates the associated mesh
  90146. * @param mesh the mesh to be updated
  90147. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90148. * @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
  90149. * @returns VertexData
  90150. */
  90151. updateMesh(mesh: Mesh): VertexData;
  90152. /**
  90153. * Updates the associated geometry
  90154. * @param geometry the geometry to be updated
  90155. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90156. * @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
  90157. * @returns VertexData.
  90158. */
  90159. updateGeometry(geometry: Geometry): VertexData;
  90160. private _applyTo;
  90161. private _update;
  90162. /**
  90163. * Transforms each position and each normal of the vertexData according to the passed Matrix
  90164. * @param matrix the transforming matrix
  90165. * @returns the VertexData
  90166. */
  90167. transform(matrix: Matrix): VertexData;
  90168. /**
  90169. * Merges the passed VertexData into the current one
  90170. * @param other the VertexData to be merged into the current one
  90171. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  90172. * @returns the modified VertexData
  90173. */
  90174. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  90175. private _mergeElement;
  90176. private _validate;
  90177. /**
  90178. * Serializes the VertexData
  90179. * @returns a serialized object
  90180. */
  90181. serialize(): any;
  90182. /**
  90183. * Extracts the vertexData from a mesh
  90184. * @param mesh the mesh from which to extract the VertexData
  90185. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  90186. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90187. * @returns the object VertexData associated to the passed mesh
  90188. */
  90189. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90190. /**
  90191. * Extracts the vertexData from the geometry
  90192. * @param geometry the geometry from which to extract the VertexData
  90193. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  90194. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  90195. * @returns the object VertexData associated to the passed mesh
  90196. */
  90197. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  90198. private static _ExtractFrom;
  90199. /**
  90200. * Creates the VertexData for a Ribbon
  90201. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  90202. * * pathArray array of paths, each of which an array of successive Vector3
  90203. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  90204. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  90205. * * 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
  90206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90207. * * 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)
  90208. * * 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)
  90209. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  90210. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  90211. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  90212. * @returns the VertexData of the ribbon
  90213. */
  90214. static CreateRibbon(options: {
  90215. pathArray: Vector3[][];
  90216. closeArray?: boolean;
  90217. closePath?: boolean;
  90218. offset?: number;
  90219. sideOrientation?: number;
  90220. frontUVs?: Vector4;
  90221. backUVs?: Vector4;
  90222. invertUV?: boolean;
  90223. uvs?: Vector2[];
  90224. colors?: Color4[];
  90225. }): VertexData;
  90226. /**
  90227. * Creates the VertexData for a box
  90228. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90229. * * size sets the width, height and depth of the box to the value of size, optional default 1
  90230. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  90231. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  90232. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  90233. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90234. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90235. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90236. * * 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)
  90237. * * 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)
  90238. * @returns the VertexData of the box
  90239. */
  90240. static CreateBox(options: {
  90241. size?: number;
  90242. width?: number;
  90243. height?: number;
  90244. depth?: number;
  90245. faceUV?: Vector4[];
  90246. faceColors?: Color4[];
  90247. sideOrientation?: number;
  90248. frontUVs?: Vector4;
  90249. backUVs?: Vector4;
  90250. }): VertexData;
  90251. /**
  90252. * Creates the VertexData for a tiled box
  90253. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90254. * * faceTiles sets the pattern, tile size and number of tiles for a face
  90255. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  90256. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  90257. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90258. * @returns the VertexData of the box
  90259. */
  90260. static CreateTiledBox(options: {
  90261. pattern?: number;
  90262. width?: number;
  90263. height?: number;
  90264. depth?: number;
  90265. tileSize?: number;
  90266. tileWidth?: number;
  90267. tileHeight?: number;
  90268. alignHorizontal?: number;
  90269. alignVertical?: number;
  90270. faceUV?: Vector4[];
  90271. faceColors?: Color4[];
  90272. sideOrientation?: number;
  90273. }): VertexData;
  90274. /**
  90275. * Creates the VertexData for a tiled plane
  90276. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90277. * * pattern a limited pattern arrangement depending on the number
  90278. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  90279. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  90280. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  90281. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90282. * * 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)
  90283. * * 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)
  90284. * @returns the VertexData of the tiled plane
  90285. */
  90286. static CreateTiledPlane(options: {
  90287. pattern?: number;
  90288. tileSize?: number;
  90289. tileWidth?: number;
  90290. tileHeight?: number;
  90291. size?: number;
  90292. width?: number;
  90293. height?: number;
  90294. alignHorizontal?: number;
  90295. alignVertical?: number;
  90296. sideOrientation?: number;
  90297. frontUVs?: Vector4;
  90298. backUVs?: Vector4;
  90299. }): VertexData;
  90300. /**
  90301. * Creates the VertexData for an ellipsoid, defaults to a sphere
  90302. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90303. * * segments sets the number of horizontal strips optional, default 32
  90304. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  90305. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  90306. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  90307. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  90308. * * 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
  90309. * * 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
  90310. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90311. * * 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)
  90312. * * 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)
  90313. * @returns the VertexData of the ellipsoid
  90314. */
  90315. static CreateSphere(options: {
  90316. segments?: number;
  90317. diameter?: number;
  90318. diameterX?: number;
  90319. diameterY?: number;
  90320. diameterZ?: number;
  90321. arc?: number;
  90322. slice?: number;
  90323. sideOrientation?: number;
  90324. frontUVs?: Vector4;
  90325. backUVs?: Vector4;
  90326. }): VertexData;
  90327. /**
  90328. * Creates the VertexData for a cylinder, cone or prism
  90329. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90330. * * height sets the height (y direction) of the cylinder, optional, default 2
  90331. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  90332. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  90333. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  90334. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90335. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  90336. * * 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
  90337. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90338. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90339. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  90340. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  90341. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90342. * * 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)
  90343. * * 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)
  90344. * @returns the VertexData of the cylinder, cone or prism
  90345. */
  90346. static CreateCylinder(options: {
  90347. height?: number;
  90348. diameterTop?: number;
  90349. diameterBottom?: number;
  90350. diameter?: number;
  90351. tessellation?: number;
  90352. subdivisions?: number;
  90353. arc?: number;
  90354. faceColors?: Color4[];
  90355. faceUV?: Vector4[];
  90356. hasRings?: boolean;
  90357. enclose?: boolean;
  90358. sideOrientation?: number;
  90359. frontUVs?: Vector4;
  90360. backUVs?: Vector4;
  90361. }): VertexData;
  90362. /**
  90363. * Creates the VertexData for a torus
  90364. * @param options an object used to set the following optional parameters for the box, required but can be empty
  90365. * * diameter the diameter of the torus, optional default 1
  90366. * * thickness the diameter of the tube forming the torus, optional default 0.5
  90367. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  90368. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90369. * * 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)
  90370. * * 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)
  90371. * @returns the VertexData of the torus
  90372. */
  90373. static CreateTorus(options: {
  90374. diameter?: number;
  90375. thickness?: number;
  90376. tessellation?: number;
  90377. sideOrientation?: number;
  90378. frontUVs?: Vector4;
  90379. backUVs?: Vector4;
  90380. }): VertexData;
  90381. /**
  90382. * Creates the VertexData of the LineSystem
  90383. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  90384. * - lines an array of lines, each line being an array of successive Vector3
  90385. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  90386. * @returns the VertexData of the LineSystem
  90387. */
  90388. static CreateLineSystem(options: {
  90389. lines: Vector3[][];
  90390. colors?: Nullable<Color4[][]>;
  90391. }): VertexData;
  90392. /**
  90393. * Create the VertexData for a DashedLines
  90394. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  90395. * - points an array successive Vector3
  90396. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  90397. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  90398. * - dashNb the intended total number of dashes, optional, default 200
  90399. * @returns the VertexData for the DashedLines
  90400. */
  90401. static CreateDashedLines(options: {
  90402. points: Vector3[];
  90403. dashSize?: number;
  90404. gapSize?: number;
  90405. dashNb?: number;
  90406. }): VertexData;
  90407. /**
  90408. * Creates the VertexData for a Ground
  90409. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90410. * - width the width (x direction) of the ground, optional, default 1
  90411. * - height the height (z direction) of the ground, optional, default 1
  90412. * - subdivisions the number of subdivisions per side, optional, default 1
  90413. * @returns the VertexData of the Ground
  90414. */
  90415. static CreateGround(options: {
  90416. width?: number;
  90417. height?: number;
  90418. subdivisions?: number;
  90419. subdivisionsX?: number;
  90420. subdivisionsY?: number;
  90421. }): VertexData;
  90422. /**
  90423. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  90424. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  90425. * * xmin the ground minimum X coordinate, optional, default -1
  90426. * * zmin the ground minimum Z coordinate, optional, default -1
  90427. * * xmax the ground maximum X coordinate, optional, default 1
  90428. * * zmax the ground maximum Z coordinate, optional, default 1
  90429. * * 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}
  90430. * * 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}
  90431. * @returns the VertexData of the TiledGround
  90432. */
  90433. static CreateTiledGround(options: {
  90434. xmin: number;
  90435. zmin: number;
  90436. xmax: number;
  90437. zmax: number;
  90438. subdivisions?: {
  90439. w: number;
  90440. h: number;
  90441. };
  90442. precision?: {
  90443. w: number;
  90444. h: number;
  90445. };
  90446. }): VertexData;
  90447. /**
  90448. * Creates the VertexData of the Ground designed from a heightmap
  90449. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  90450. * * width the width (x direction) of the ground
  90451. * * height the height (z direction) of the ground
  90452. * * subdivisions the number of subdivisions per side
  90453. * * minHeight the minimum altitude on the ground, optional, default 0
  90454. * * maxHeight the maximum altitude on the ground, optional default 1
  90455. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  90456. * * buffer the array holding the image color data
  90457. * * bufferWidth the width of image
  90458. * * bufferHeight the height of image
  90459. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  90460. * @returns the VertexData of the Ground designed from a heightmap
  90461. */
  90462. static CreateGroundFromHeightMap(options: {
  90463. width: number;
  90464. height: number;
  90465. subdivisions: number;
  90466. minHeight: number;
  90467. maxHeight: number;
  90468. colorFilter: Color3;
  90469. buffer: Uint8Array;
  90470. bufferWidth: number;
  90471. bufferHeight: number;
  90472. alphaFilter: number;
  90473. }): VertexData;
  90474. /**
  90475. * Creates the VertexData for a Plane
  90476. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  90477. * * size sets the width and height of the plane to the value of size, optional default 1
  90478. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  90479. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  90480. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90481. * * 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)
  90482. * * 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)
  90483. * @returns the VertexData of the box
  90484. */
  90485. static CreatePlane(options: {
  90486. size?: number;
  90487. width?: number;
  90488. height?: number;
  90489. sideOrientation?: number;
  90490. frontUVs?: Vector4;
  90491. backUVs?: Vector4;
  90492. }): VertexData;
  90493. /**
  90494. * Creates the VertexData of the Disc or regular Polygon
  90495. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  90496. * * radius the radius of the disc, optional default 0.5
  90497. * * tessellation the number of polygon sides, optional, default 64
  90498. * * 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
  90499. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90500. * * 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)
  90501. * * 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)
  90502. * @returns the VertexData of the box
  90503. */
  90504. static CreateDisc(options: {
  90505. radius?: number;
  90506. tessellation?: number;
  90507. arc?: number;
  90508. sideOrientation?: number;
  90509. frontUVs?: Vector4;
  90510. backUVs?: Vector4;
  90511. }): VertexData;
  90512. /**
  90513. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  90514. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  90515. * @param polygon a mesh built from polygonTriangulation.build()
  90516. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90517. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90518. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90519. * @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)
  90520. * @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)
  90521. * @returns the VertexData of the Polygon
  90522. */
  90523. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  90524. /**
  90525. * Creates the VertexData of the IcoSphere
  90526. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  90527. * * radius the radius of the IcoSphere, optional default 1
  90528. * * radiusX allows stretching in the x direction, optional, default radius
  90529. * * radiusY allows stretching in the y direction, optional, default radius
  90530. * * radiusZ allows stretching in the z direction, optional, default radius
  90531. * * flat when true creates a flat shaded mesh, optional, default true
  90532. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90533. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90534. * * 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)
  90535. * * 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)
  90536. * @returns the VertexData of the IcoSphere
  90537. */
  90538. static CreateIcoSphere(options: {
  90539. radius?: number;
  90540. radiusX?: number;
  90541. radiusY?: number;
  90542. radiusZ?: number;
  90543. flat?: boolean;
  90544. subdivisions?: number;
  90545. sideOrientation?: number;
  90546. frontUVs?: Vector4;
  90547. backUVs?: Vector4;
  90548. }): VertexData;
  90549. /**
  90550. * Creates the VertexData for a Polyhedron
  90551. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  90552. * * type provided types are:
  90553. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  90554. * * 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)
  90555. * * size the size of the IcoSphere, optional default 1
  90556. * * sizeX allows stretching in the x direction, optional, default size
  90557. * * sizeY allows stretching in the y direction, optional, default size
  90558. * * sizeZ allows stretching in the z direction, optional, default size
  90559. * * 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
  90560. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  90561. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  90562. * * flat when true creates a flat shaded mesh, optional, default true
  90563. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  90564. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90565. * * 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)
  90566. * * 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)
  90567. * @returns the VertexData of the Polyhedron
  90568. */
  90569. static CreatePolyhedron(options: {
  90570. type?: number;
  90571. size?: number;
  90572. sizeX?: number;
  90573. sizeY?: number;
  90574. sizeZ?: number;
  90575. custom?: any;
  90576. faceUV?: Vector4[];
  90577. faceColors?: Color4[];
  90578. flat?: boolean;
  90579. sideOrientation?: number;
  90580. frontUVs?: Vector4;
  90581. backUVs?: Vector4;
  90582. }): VertexData;
  90583. /**
  90584. * Creates the VertexData for a TorusKnot
  90585. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  90586. * * radius the radius of the torus knot, optional, default 2
  90587. * * tube the thickness of the tube, optional, default 0.5
  90588. * * radialSegments the number of sides on each tube segments, optional, default 32
  90589. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  90590. * * p the number of windings around the z axis, optional, default 2
  90591. * * q the number of windings around the x axis, optional, default 3
  90592. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90593. * * 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)
  90594. * * 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)
  90595. * @returns the VertexData of the Torus Knot
  90596. */
  90597. static CreateTorusKnot(options: {
  90598. radius?: number;
  90599. tube?: number;
  90600. radialSegments?: number;
  90601. tubularSegments?: number;
  90602. p?: number;
  90603. q?: number;
  90604. sideOrientation?: number;
  90605. frontUVs?: Vector4;
  90606. backUVs?: Vector4;
  90607. }): VertexData;
  90608. /**
  90609. * Compute normals for given positions and indices
  90610. * @param positions an array of vertex positions, [...., x, y, z, ......]
  90611. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  90612. * @param normals an array of vertex normals, [...., x, y, z, ......]
  90613. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  90614. * * facetNormals : optional array of facet normals (vector3)
  90615. * * facetPositions : optional array of facet positions (vector3)
  90616. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  90617. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  90618. * * bInfo : optional bounding info, required for facetPartitioning computation
  90619. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  90620. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  90621. * * useRightHandedSystem: optional boolean to for right handed system computation
  90622. * * depthSort : optional boolean to enable the facet depth sort computation
  90623. * * distanceTo : optional Vector3 to compute the facet depth from this location
  90624. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  90625. */
  90626. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  90627. facetNormals?: any;
  90628. facetPositions?: any;
  90629. facetPartitioning?: any;
  90630. ratio?: number;
  90631. bInfo?: any;
  90632. bbSize?: Vector3;
  90633. subDiv?: any;
  90634. useRightHandedSystem?: boolean;
  90635. depthSort?: boolean;
  90636. distanceTo?: Vector3;
  90637. depthSortedFacets?: any;
  90638. }): void;
  90639. /** @hidden */
  90640. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  90641. /**
  90642. * Applies VertexData created from the imported parameters to the geometry
  90643. * @param parsedVertexData the parsed data from an imported file
  90644. * @param geometry the geometry to apply the VertexData to
  90645. */
  90646. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  90647. }
  90648. }
  90649. declare module BABYLON {
  90650. /**
  90651. * Defines a target to use with MorphTargetManager
  90652. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90653. */
  90654. export class MorphTarget implements IAnimatable {
  90655. /** defines the name of the target */
  90656. name: string;
  90657. /**
  90658. * Gets or sets the list of animations
  90659. */
  90660. animations: Animation[];
  90661. private _scene;
  90662. private _positions;
  90663. private _normals;
  90664. private _tangents;
  90665. private _uvs;
  90666. private _influence;
  90667. private _uniqueId;
  90668. /**
  90669. * Observable raised when the influence changes
  90670. */
  90671. onInfluenceChanged: Observable<boolean>;
  90672. /** @hidden */
  90673. _onDataLayoutChanged: Observable<void>;
  90674. /**
  90675. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  90676. */
  90677. influence: number;
  90678. /**
  90679. * Gets or sets the id of the morph Target
  90680. */
  90681. id: string;
  90682. private _animationPropertiesOverride;
  90683. /**
  90684. * Gets or sets the animation properties override
  90685. */
  90686. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90687. /**
  90688. * Creates a new MorphTarget
  90689. * @param name defines the name of the target
  90690. * @param influence defines the influence to use
  90691. * @param scene defines the scene the morphtarget belongs to
  90692. */
  90693. constructor(
  90694. /** defines the name of the target */
  90695. name: string, influence?: number, scene?: Nullable<Scene>);
  90696. /**
  90697. * Gets the unique ID of this manager
  90698. */
  90699. readonly uniqueId: number;
  90700. /**
  90701. * Gets a boolean defining if the target contains position data
  90702. */
  90703. readonly hasPositions: boolean;
  90704. /**
  90705. * Gets a boolean defining if the target contains normal data
  90706. */
  90707. readonly hasNormals: boolean;
  90708. /**
  90709. * Gets a boolean defining if the target contains tangent data
  90710. */
  90711. readonly hasTangents: boolean;
  90712. /**
  90713. * Gets a boolean defining if the target contains texture coordinates data
  90714. */
  90715. readonly hasUVs: boolean;
  90716. /**
  90717. * Affects position data to this target
  90718. * @param data defines the position data to use
  90719. */
  90720. setPositions(data: Nullable<FloatArray>): void;
  90721. /**
  90722. * Gets the position data stored in this target
  90723. * @returns a FloatArray containing the position data (or null if not present)
  90724. */
  90725. getPositions(): Nullable<FloatArray>;
  90726. /**
  90727. * Affects normal data to this target
  90728. * @param data defines the normal data to use
  90729. */
  90730. setNormals(data: Nullable<FloatArray>): void;
  90731. /**
  90732. * Gets the normal data stored in this target
  90733. * @returns a FloatArray containing the normal data (or null if not present)
  90734. */
  90735. getNormals(): Nullable<FloatArray>;
  90736. /**
  90737. * Affects tangent data to this target
  90738. * @param data defines the tangent data to use
  90739. */
  90740. setTangents(data: Nullable<FloatArray>): void;
  90741. /**
  90742. * Gets the tangent data stored in this target
  90743. * @returns a FloatArray containing the tangent data (or null if not present)
  90744. */
  90745. getTangents(): Nullable<FloatArray>;
  90746. /**
  90747. * Affects texture coordinates data to this target
  90748. * @param data defines the texture coordinates data to use
  90749. */
  90750. setUVs(data: Nullable<FloatArray>): void;
  90751. /**
  90752. * Gets the texture coordinates data stored in this target
  90753. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  90754. */
  90755. getUVs(): Nullable<FloatArray>;
  90756. /**
  90757. * Clone the current target
  90758. * @returns a new MorphTarget
  90759. */
  90760. clone(): MorphTarget;
  90761. /**
  90762. * Serializes the current target into a Serialization object
  90763. * @returns the serialized object
  90764. */
  90765. serialize(): any;
  90766. /**
  90767. * Returns the string "MorphTarget"
  90768. * @returns "MorphTarget"
  90769. */
  90770. getClassName(): string;
  90771. /**
  90772. * Creates a new target from serialized data
  90773. * @param serializationObject defines the serialized data to use
  90774. * @returns a new MorphTarget
  90775. */
  90776. static Parse(serializationObject: any): MorphTarget;
  90777. /**
  90778. * Creates a MorphTarget from mesh data
  90779. * @param mesh defines the source mesh
  90780. * @param name defines the name to use for the new target
  90781. * @param influence defines the influence to attach to the target
  90782. * @returns a new MorphTarget
  90783. */
  90784. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  90785. }
  90786. }
  90787. declare module BABYLON {
  90788. /**
  90789. * This class is used to deform meshes using morphing between different targets
  90790. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90791. */
  90792. export class MorphTargetManager {
  90793. private _targets;
  90794. private _targetInfluenceChangedObservers;
  90795. private _targetDataLayoutChangedObservers;
  90796. private _activeTargets;
  90797. private _scene;
  90798. private _influences;
  90799. private _supportsNormals;
  90800. private _supportsTangents;
  90801. private _supportsUVs;
  90802. private _vertexCount;
  90803. private _uniqueId;
  90804. private _tempInfluences;
  90805. /**
  90806. * Gets or sets a boolean indicating if normals must be morphed
  90807. */
  90808. enableNormalMorphing: boolean;
  90809. /**
  90810. * Gets or sets a boolean indicating if tangents must be morphed
  90811. */
  90812. enableTangentMorphing: boolean;
  90813. /**
  90814. * Gets or sets a boolean indicating if UV must be morphed
  90815. */
  90816. enableUVMorphing: boolean;
  90817. /**
  90818. * Creates a new MorphTargetManager
  90819. * @param scene defines the current scene
  90820. */
  90821. constructor(scene?: Nullable<Scene>);
  90822. /**
  90823. * Gets the unique ID of this manager
  90824. */
  90825. readonly uniqueId: number;
  90826. /**
  90827. * Gets the number of vertices handled by this manager
  90828. */
  90829. readonly vertexCount: number;
  90830. /**
  90831. * Gets a boolean indicating if this manager supports morphing of normals
  90832. */
  90833. readonly supportsNormals: boolean;
  90834. /**
  90835. * Gets a boolean indicating if this manager supports morphing of tangents
  90836. */
  90837. readonly supportsTangents: boolean;
  90838. /**
  90839. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  90840. */
  90841. readonly supportsUVs: boolean;
  90842. /**
  90843. * Gets the number of targets stored in this manager
  90844. */
  90845. readonly numTargets: number;
  90846. /**
  90847. * Gets the number of influencers (ie. the number of targets with influences > 0)
  90848. */
  90849. readonly numInfluencers: number;
  90850. /**
  90851. * Gets the list of influences (one per target)
  90852. */
  90853. readonly influences: Float32Array;
  90854. /**
  90855. * Gets the active target at specified index. An active target is a target with an influence > 0
  90856. * @param index defines the index to check
  90857. * @returns the requested target
  90858. */
  90859. getActiveTarget(index: number): MorphTarget;
  90860. /**
  90861. * Gets the target at specified index
  90862. * @param index defines the index to check
  90863. * @returns the requested target
  90864. */
  90865. getTarget(index: number): MorphTarget;
  90866. /**
  90867. * Add a new target to this manager
  90868. * @param target defines the target to add
  90869. */
  90870. addTarget(target: MorphTarget): void;
  90871. /**
  90872. * Removes a target from the manager
  90873. * @param target defines the target to remove
  90874. */
  90875. removeTarget(target: MorphTarget): void;
  90876. /**
  90877. * Clone the current manager
  90878. * @returns a new MorphTargetManager
  90879. */
  90880. clone(): MorphTargetManager;
  90881. /**
  90882. * Serializes the current manager into a Serialization object
  90883. * @returns the serialized object
  90884. */
  90885. serialize(): any;
  90886. private _syncActiveTargets;
  90887. /**
  90888. * Syncrhonize the targets with all the meshes using this morph target manager
  90889. */
  90890. synchronize(): void;
  90891. /**
  90892. * Creates a new MorphTargetManager from serialized data
  90893. * @param serializationObject defines the serialized data
  90894. * @param scene defines the hosting scene
  90895. * @returns the new MorphTargetManager
  90896. */
  90897. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  90898. }
  90899. }
  90900. declare module BABYLON {
  90901. /**
  90902. * Class used to represent a specific level of detail of a mesh
  90903. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90904. */
  90905. export class MeshLODLevel {
  90906. /** Defines the distance where this level should start being displayed */
  90907. distance: number;
  90908. /** Defines the mesh to use to render this level */
  90909. mesh: Nullable<Mesh>;
  90910. /**
  90911. * Creates a new LOD level
  90912. * @param distance defines the distance where this level should star being displayed
  90913. * @param mesh defines the mesh to use to render this level
  90914. */
  90915. constructor(
  90916. /** Defines the distance where this level should start being displayed */
  90917. distance: number,
  90918. /** Defines the mesh to use to render this level */
  90919. mesh: Nullable<Mesh>);
  90920. }
  90921. }
  90922. declare module BABYLON {
  90923. /**
  90924. * Mesh representing the gorund
  90925. */
  90926. export class GroundMesh extends Mesh {
  90927. /** If octree should be generated */
  90928. generateOctree: boolean;
  90929. private _heightQuads;
  90930. /** @hidden */
  90931. _subdivisionsX: number;
  90932. /** @hidden */
  90933. _subdivisionsY: number;
  90934. /** @hidden */
  90935. _width: number;
  90936. /** @hidden */
  90937. _height: number;
  90938. /** @hidden */
  90939. _minX: number;
  90940. /** @hidden */
  90941. _maxX: number;
  90942. /** @hidden */
  90943. _minZ: number;
  90944. /** @hidden */
  90945. _maxZ: number;
  90946. constructor(name: string, scene: Scene);
  90947. /**
  90948. * "GroundMesh"
  90949. * @returns "GroundMesh"
  90950. */
  90951. getClassName(): string;
  90952. /**
  90953. * The minimum of x and y subdivisions
  90954. */
  90955. readonly subdivisions: number;
  90956. /**
  90957. * X subdivisions
  90958. */
  90959. readonly subdivisionsX: number;
  90960. /**
  90961. * Y subdivisions
  90962. */
  90963. readonly subdivisionsY: number;
  90964. /**
  90965. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  90966. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  90967. * @param chunksCount the number of subdivisions for x and y
  90968. * @param octreeBlocksSize (Default: 32)
  90969. */
  90970. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  90971. /**
  90972. * Returns a height (y) value in the Worl system :
  90973. * the ground altitude at the coordinates (x, z) expressed in the World system.
  90974. * @param x x coordinate
  90975. * @param z z coordinate
  90976. * @returns the ground y position if (x, z) are outside the ground surface.
  90977. */
  90978. getHeightAtCoordinates(x: number, z: number): number;
  90979. /**
  90980. * Returns a normalized vector (Vector3) orthogonal to the ground
  90981. * at the ground coordinates (x, z) expressed in the World system.
  90982. * @param x x coordinate
  90983. * @param z z coordinate
  90984. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  90985. */
  90986. getNormalAtCoordinates(x: number, z: number): Vector3;
  90987. /**
  90988. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  90989. * at the ground coordinates (x, z) expressed in the World system.
  90990. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  90991. * @param x x coordinate
  90992. * @param z z coordinate
  90993. * @param ref vector to store the result
  90994. * @returns the GroundMesh.
  90995. */
  90996. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  90997. /**
  90998. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  90999. * if the ground has been updated.
  91000. * This can be used in the render loop.
  91001. * @returns the GroundMesh.
  91002. */
  91003. updateCoordinateHeights(): GroundMesh;
  91004. private _getFacetAt;
  91005. private _initHeightQuads;
  91006. private _computeHeightQuads;
  91007. /**
  91008. * Serializes this ground mesh
  91009. * @param serializationObject object to write serialization to
  91010. */
  91011. serialize(serializationObject: any): void;
  91012. /**
  91013. * Parses a serialized ground mesh
  91014. * @param parsedMesh the serialized mesh
  91015. * @param scene the scene to create the ground mesh in
  91016. * @returns the created ground mesh
  91017. */
  91018. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  91019. }
  91020. }
  91021. declare module BABYLON {
  91022. /**
  91023. * Interface for Physics-Joint data
  91024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91025. */
  91026. export interface PhysicsJointData {
  91027. /**
  91028. * The main pivot of the joint
  91029. */
  91030. mainPivot?: Vector3;
  91031. /**
  91032. * The connected pivot of the joint
  91033. */
  91034. connectedPivot?: Vector3;
  91035. /**
  91036. * The main axis of the joint
  91037. */
  91038. mainAxis?: Vector3;
  91039. /**
  91040. * The connected axis of the joint
  91041. */
  91042. connectedAxis?: Vector3;
  91043. /**
  91044. * The collision of the joint
  91045. */
  91046. collision?: boolean;
  91047. /**
  91048. * Native Oimo/Cannon/Energy data
  91049. */
  91050. nativeParams?: any;
  91051. }
  91052. /**
  91053. * This is a holder class for the physics joint created by the physics plugin
  91054. * It holds a set of functions to control the underlying joint
  91055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91056. */
  91057. export class PhysicsJoint {
  91058. /**
  91059. * The type of the physics joint
  91060. */
  91061. type: number;
  91062. /**
  91063. * The data for the physics joint
  91064. */
  91065. jointData: PhysicsJointData;
  91066. private _physicsJoint;
  91067. protected _physicsPlugin: IPhysicsEnginePlugin;
  91068. /**
  91069. * Initializes the physics joint
  91070. * @param type The type of the physics joint
  91071. * @param jointData The data for the physics joint
  91072. */
  91073. constructor(
  91074. /**
  91075. * The type of the physics joint
  91076. */
  91077. type: number,
  91078. /**
  91079. * The data for the physics joint
  91080. */
  91081. jointData: PhysicsJointData);
  91082. /**
  91083. * Gets the physics joint
  91084. */
  91085. /**
  91086. * Sets the physics joint
  91087. */
  91088. physicsJoint: any;
  91089. /**
  91090. * Sets the physics plugin
  91091. */
  91092. physicsPlugin: IPhysicsEnginePlugin;
  91093. /**
  91094. * Execute a function that is physics-plugin specific.
  91095. * @param {Function} func the function that will be executed.
  91096. * It accepts two parameters: the physics world and the physics joint
  91097. */
  91098. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  91099. /**
  91100. * Distance-Joint type
  91101. */
  91102. static DistanceJoint: number;
  91103. /**
  91104. * Hinge-Joint type
  91105. */
  91106. static HingeJoint: number;
  91107. /**
  91108. * Ball-and-Socket joint type
  91109. */
  91110. static BallAndSocketJoint: number;
  91111. /**
  91112. * Wheel-Joint type
  91113. */
  91114. static WheelJoint: number;
  91115. /**
  91116. * Slider-Joint type
  91117. */
  91118. static SliderJoint: number;
  91119. /**
  91120. * Prismatic-Joint type
  91121. */
  91122. static PrismaticJoint: number;
  91123. /**
  91124. * Universal-Joint type
  91125. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  91126. */
  91127. static UniversalJoint: number;
  91128. /**
  91129. * Hinge-Joint 2 type
  91130. */
  91131. static Hinge2Joint: number;
  91132. /**
  91133. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  91134. */
  91135. static PointToPointJoint: number;
  91136. /**
  91137. * Spring-Joint type
  91138. */
  91139. static SpringJoint: number;
  91140. /**
  91141. * Lock-Joint type
  91142. */
  91143. static LockJoint: number;
  91144. }
  91145. /**
  91146. * A class representing a physics distance joint
  91147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91148. */
  91149. export class DistanceJoint extends PhysicsJoint {
  91150. /**
  91151. *
  91152. * @param jointData The data for the Distance-Joint
  91153. */
  91154. constructor(jointData: DistanceJointData);
  91155. /**
  91156. * Update the predefined distance.
  91157. * @param maxDistance The maximum preferred distance
  91158. * @param minDistance The minimum preferred distance
  91159. */
  91160. updateDistance(maxDistance: number, minDistance?: number): void;
  91161. }
  91162. /**
  91163. * Represents a Motor-Enabled Joint
  91164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91165. */
  91166. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  91167. /**
  91168. * Initializes the Motor-Enabled Joint
  91169. * @param type The type of the joint
  91170. * @param jointData The physica joint data for the joint
  91171. */
  91172. constructor(type: number, jointData: PhysicsJointData);
  91173. /**
  91174. * Set the motor values.
  91175. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91176. * @param force the force to apply
  91177. * @param maxForce max force for this motor.
  91178. */
  91179. setMotor(force?: number, maxForce?: number): void;
  91180. /**
  91181. * Set the motor's limits.
  91182. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91183. * @param upperLimit The upper limit of the motor
  91184. * @param lowerLimit The lower limit of the motor
  91185. */
  91186. setLimit(upperLimit: number, lowerLimit?: number): void;
  91187. }
  91188. /**
  91189. * This class represents a single physics Hinge-Joint
  91190. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91191. */
  91192. export class HingeJoint extends MotorEnabledJoint {
  91193. /**
  91194. * Initializes the Hinge-Joint
  91195. * @param jointData The joint data for the Hinge-Joint
  91196. */
  91197. constructor(jointData: PhysicsJointData);
  91198. /**
  91199. * Set the motor values.
  91200. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91201. * @param {number} force the force to apply
  91202. * @param {number} maxForce max force for this motor.
  91203. */
  91204. setMotor(force?: number, maxForce?: number): void;
  91205. /**
  91206. * Set the motor's limits.
  91207. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91208. * @param upperLimit The upper limit of the motor
  91209. * @param lowerLimit The lower limit of the motor
  91210. */
  91211. setLimit(upperLimit: number, lowerLimit?: number): void;
  91212. }
  91213. /**
  91214. * This class represents a dual hinge physics joint (same as wheel joint)
  91215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91216. */
  91217. export class Hinge2Joint extends MotorEnabledJoint {
  91218. /**
  91219. * Initializes the Hinge2-Joint
  91220. * @param jointData The joint data for the Hinge2-Joint
  91221. */
  91222. constructor(jointData: PhysicsJointData);
  91223. /**
  91224. * Set the motor values.
  91225. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91226. * @param {number} targetSpeed the speed the motor is to reach
  91227. * @param {number} maxForce max force for this motor.
  91228. * @param {motorIndex} the motor's index, 0 or 1.
  91229. */
  91230. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  91231. /**
  91232. * Set the motor limits.
  91233. * Attention, this function is plugin specific. Engines won't react 100% the same.
  91234. * @param {number} upperLimit the upper limit
  91235. * @param {number} lowerLimit lower limit
  91236. * @param {motorIndex} the motor's index, 0 or 1.
  91237. */
  91238. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91239. }
  91240. /**
  91241. * Interface for a motor enabled joint
  91242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91243. */
  91244. export interface IMotorEnabledJoint {
  91245. /**
  91246. * Physics joint
  91247. */
  91248. physicsJoint: any;
  91249. /**
  91250. * Sets the motor of the motor-enabled joint
  91251. * @param force The force of the motor
  91252. * @param maxForce The maximum force of the motor
  91253. * @param motorIndex The index of the motor
  91254. */
  91255. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  91256. /**
  91257. * Sets the limit of the motor
  91258. * @param upperLimit The upper limit of the motor
  91259. * @param lowerLimit The lower limit of the motor
  91260. * @param motorIndex The index of the motor
  91261. */
  91262. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91263. }
  91264. /**
  91265. * Joint data for a Distance-Joint
  91266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91267. */
  91268. export interface DistanceJointData extends PhysicsJointData {
  91269. /**
  91270. * Max distance the 2 joint objects can be apart
  91271. */
  91272. maxDistance: number;
  91273. }
  91274. /**
  91275. * Joint data from a spring joint
  91276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91277. */
  91278. export interface SpringJointData extends PhysicsJointData {
  91279. /**
  91280. * Length of the spring
  91281. */
  91282. length: number;
  91283. /**
  91284. * Stiffness of the spring
  91285. */
  91286. stiffness: number;
  91287. /**
  91288. * Damping of the spring
  91289. */
  91290. damping: number;
  91291. /** this callback will be called when applying the force to the impostors. */
  91292. forceApplicationCallback: () => void;
  91293. }
  91294. }
  91295. declare module BABYLON {
  91296. /**
  91297. * Holds the data for the raycast result
  91298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91299. */
  91300. export class PhysicsRaycastResult {
  91301. private _hasHit;
  91302. private _hitDistance;
  91303. private _hitNormalWorld;
  91304. private _hitPointWorld;
  91305. private _rayFromWorld;
  91306. private _rayToWorld;
  91307. /**
  91308. * Gets if there was a hit
  91309. */
  91310. readonly hasHit: boolean;
  91311. /**
  91312. * Gets the distance from the hit
  91313. */
  91314. readonly hitDistance: number;
  91315. /**
  91316. * Gets the hit normal/direction in the world
  91317. */
  91318. readonly hitNormalWorld: Vector3;
  91319. /**
  91320. * Gets the hit point in the world
  91321. */
  91322. readonly hitPointWorld: Vector3;
  91323. /**
  91324. * Gets the ray "start point" of the ray in the world
  91325. */
  91326. readonly rayFromWorld: Vector3;
  91327. /**
  91328. * Gets the ray "end point" of the ray in the world
  91329. */
  91330. readonly rayToWorld: Vector3;
  91331. /**
  91332. * Sets the hit data (normal & point in world space)
  91333. * @param hitNormalWorld defines the normal in world space
  91334. * @param hitPointWorld defines the point in world space
  91335. */
  91336. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  91337. /**
  91338. * Sets the distance from the start point to the hit point
  91339. * @param distance
  91340. */
  91341. setHitDistance(distance: number): void;
  91342. /**
  91343. * Calculates the distance manually
  91344. */
  91345. calculateHitDistance(): void;
  91346. /**
  91347. * Resets all the values to default
  91348. * @param from The from point on world space
  91349. * @param to The to point on world space
  91350. */
  91351. reset(from?: Vector3, to?: Vector3): void;
  91352. }
  91353. /**
  91354. * Interface for the size containing width and height
  91355. */
  91356. interface IXYZ {
  91357. /**
  91358. * X
  91359. */
  91360. x: number;
  91361. /**
  91362. * Y
  91363. */
  91364. y: number;
  91365. /**
  91366. * Z
  91367. */
  91368. z: number;
  91369. }
  91370. }
  91371. declare module BABYLON {
  91372. /**
  91373. * Interface used to describe a physics joint
  91374. */
  91375. export interface PhysicsImpostorJoint {
  91376. /** Defines the main impostor to which the joint is linked */
  91377. mainImpostor: PhysicsImpostor;
  91378. /** Defines the impostor that is connected to the main impostor using this joint */
  91379. connectedImpostor: PhysicsImpostor;
  91380. /** Defines the joint itself */
  91381. joint: PhysicsJoint;
  91382. }
  91383. /** @hidden */
  91384. export interface IPhysicsEnginePlugin {
  91385. world: any;
  91386. name: string;
  91387. setGravity(gravity: Vector3): void;
  91388. setTimeStep(timeStep: number): void;
  91389. getTimeStep(): number;
  91390. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  91391. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91392. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  91393. generatePhysicsBody(impostor: PhysicsImpostor): void;
  91394. removePhysicsBody(impostor: PhysicsImpostor): void;
  91395. generateJoint(joint: PhysicsImpostorJoint): void;
  91396. removeJoint(joint: PhysicsImpostorJoint): void;
  91397. isSupported(): boolean;
  91398. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  91399. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  91400. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91401. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  91402. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91403. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  91404. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  91405. getBodyMass(impostor: PhysicsImpostor): number;
  91406. getBodyFriction(impostor: PhysicsImpostor): number;
  91407. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  91408. getBodyRestitution(impostor: PhysicsImpostor): number;
  91409. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  91410. getBodyPressure?(impostor: PhysicsImpostor): number;
  91411. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  91412. getBodyStiffness?(impostor: PhysicsImpostor): number;
  91413. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  91414. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  91415. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  91416. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  91417. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  91418. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91419. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  91420. sleepBody(impostor: PhysicsImpostor): void;
  91421. wakeUpBody(impostor: PhysicsImpostor): void;
  91422. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91423. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  91424. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  91425. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  91426. getRadius(impostor: PhysicsImpostor): number;
  91427. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  91428. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  91429. dispose(): void;
  91430. }
  91431. /**
  91432. * Interface used to define a physics engine
  91433. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  91434. */
  91435. export interface IPhysicsEngine {
  91436. /**
  91437. * Gets the gravity vector used by the simulation
  91438. */
  91439. gravity: Vector3;
  91440. /**
  91441. * Sets the gravity vector used by the simulation
  91442. * @param gravity defines the gravity vector to use
  91443. */
  91444. setGravity(gravity: Vector3): void;
  91445. /**
  91446. * Set the time step of the physics engine.
  91447. * Default is 1/60.
  91448. * To slow it down, enter 1/600 for example.
  91449. * To speed it up, 1/30
  91450. * @param newTimeStep the new timestep to apply to this world.
  91451. */
  91452. setTimeStep(newTimeStep: number): void;
  91453. /**
  91454. * Get the time step of the physics engine.
  91455. * @returns the current time step
  91456. */
  91457. getTimeStep(): number;
  91458. /**
  91459. * Release all resources
  91460. */
  91461. dispose(): void;
  91462. /**
  91463. * Gets the name of the current physics plugin
  91464. * @returns the name of the plugin
  91465. */
  91466. getPhysicsPluginName(): string;
  91467. /**
  91468. * Adding a new impostor for the impostor tracking.
  91469. * This will be done by the impostor itself.
  91470. * @param impostor the impostor to add
  91471. */
  91472. addImpostor(impostor: PhysicsImpostor): void;
  91473. /**
  91474. * Remove an impostor from the engine.
  91475. * This impostor and its mesh will not longer be updated by the physics engine.
  91476. * @param impostor the impostor to remove
  91477. */
  91478. removeImpostor(impostor: PhysicsImpostor): void;
  91479. /**
  91480. * Add a joint to the physics engine
  91481. * @param mainImpostor defines the main impostor to which the joint is added.
  91482. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  91483. * @param joint defines the joint that will connect both impostors.
  91484. */
  91485. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91486. /**
  91487. * Removes a joint from the simulation
  91488. * @param mainImpostor defines the impostor used with the joint
  91489. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  91490. * @param joint defines the joint to remove
  91491. */
  91492. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  91493. /**
  91494. * Gets the current plugin used to run the simulation
  91495. * @returns current plugin
  91496. */
  91497. getPhysicsPlugin(): IPhysicsEnginePlugin;
  91498. /**
  91499. * Gets the list of physic impostors
  91500. * @returns an array of PhysicsImpostor
  91501. */
  91502. getImpostors(): Array<PhysicsImpostor>;
  91503. /**
  91504. * Gets the impostor for a physics enabled object
  91505. * @param object defines the object impersonated by the impostor
  91506. * @returns the PhysicsImpostor or null if not found
  91507. */
  91508. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  91509. /**
  91510. * Gets the impostor for a physics body object
  91511. * @param body defines physics body used by the impostor
  91512. * @returns the PhysicsImpostor or null if not found
  91513. */
  91514. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  91515. /**
  91516. * Does a raycast in the physics world
  91517. * @param from when should the ray start?
  91518. * @param to when should the ray end?
  91519. * @returns PhysicsRaycastResult
  91520. */
  91521. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  91522. /**
  91523. * Called by the scene. No need to call it.
  91524. * @param delta defines the timespam between frames
  91525. */
  91526. _step(delta: number): void;
  91527. }
  91528. }
  91529. declare module BABYLON {
  91530. /**
  91531. * The interface for the physics imposter parameters
  91532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91533. */
  91534. export interface PhysicsImpostorParameters {
  91535. /**
  91536. * The mass of the physics imposter
  91537. */
  91538. mass: number;
  91539. /**
  91540. * The friction of the physics imposter
  91541. */
  91542. friction?: number;
  91543. /**
  91544. * The coefficient of restitution of the physics imposter
  91545. */
  91546. restitution?: number;
  91547. /**
  91548. * The native options of the physics imposter
  91549. */
  91550. nativeOptions?: any;
  91551. /**
  91552. * Specifies if the parent should be ignored
  91553. */
  91554. ignoreParent?: boolean;
  91555. /**
  91556. * Specifies if bi-directional transformations should be disabled
  91557. */
  91558. disableBidirectionalTransformation?: boolean;
  91559. /**
  91560. * The pressure inside the physics imposter, soft object only
  91561. */
  91562. pressure?: number;
  91563. /**
  91564. * The stiffness the physics imposter, soft object only
  91565. */
  91566. stiffness?: number;
  91567. /**
  91568. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  91569. */
  91570. velocityIterations?: number;
  91571. /**
  91572. * The number of iterations used in maintaining consistent vertex positions, soft object only
  91573. */
  91574. positionIterations?: number;
  91575. /**
  91576. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  91577. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  91578. * Add to fix multiple points
  91579. */
  91580. fixedPoints?: number;
  91581. /**
  91582. * The collision margin around a soft object
  91583. */
  91584. margin?: number;
  91585. /**
  91586. * The collision margin around a soft object
  91587. */
  91588. damping?: number;
  91589. /**
  91590. * The path for a rope based on an extrusion
  91591. */
  91592. path?: any;
  91593. /**
  91594. * The shape of an extrusion used for a rope based on an extrusion
  91595. */
  91596. shape?: any;
  91597. }
  91598. /**
  91599. * Interface for a physics-enabled object
  91600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91601. */
  91602. export interface IPhysicsEnabledObject {
  91603. /**
  91604. * The position of the physics-enabled object
  91605. */
  91606. position: Vector3;
  91607. /**
  91608. * The rotation of the physics-enabled object
  91609. */
  91610. rotationQuaternion: Nullable<Quaternion>;
  91611. /**
  91612. * The scale of the physics-enabled object
  91613. */
  91614. scaling: Vector3;
  91615. /**
  91616. * The rotation of the physics-enabled object
  91617. */
  91618. rotation?: Vector3;
  91619. /**
  91620. * The parent of the physics-enabled object
  91621. */
  91622. parent?: any;
  91623. /**
  91624. * The bounding info of the physics-enabled object
  91625. * @returns The bounding info of the physics-enabled object
  91626. */
  91627. getBoundingInfo(): BoundingInfo;
  91628. /**
  91629. * Computes the world matrix
  91630. * @param force Specifies if the world matrix should be computed by force
  91631. * @returns A world matrix
  91632. */
  91633. computeWorldMatrix(force: boolean): Matrix;
  91634. /**
  91635. * Gets the world matrix
  91636. * @returns A world matrix
  91637. */
  91638. getWorldMatrix?(): Matrix;
  91639. /**
  91640. * Gets the child meshes
  91641. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  91642. * @returns An array of abstract meshes
  91643. */
  91644. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  91645. /**
  91646. * Gets the vertex data
  91647. * @param kind The type of vertex data
  91648. * @returns A nullable array of numbers, or a float32 array
  91649. */
  91650. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  91651. /**
  91652. * Gets the indices from the mesh
  91653. * @returns A nullable array of index arrays
  91654. */
  91655. getIndices?(): Nullable<IndicesArray>;
  91656. /**
  91657. * Gets the scene from the mesh
  91658. * @returns the indices array or null
  91659. */
  91660. getScene?(): Scene;
  91661. /**
  91662. * Gets the absolute position from the mesh
  91663. * @returns the absolute position
  91664. */
  91665. getAbsolutePosition(): Vector3;
  91666. /**
  91667. * Gets the absolute pivot point from the mesh
  91668. * @returns the absolute pivot point
  91669. */
  91670. getAbsolutePivotPoint(): Vector3;
  91671. /**
  91672. * Rotates the mesh
  91673. * @param axis The axis of rotation
  91674. * @param amount The amount of rotation
  91675. * @param space The space of the rotation
  91676. * @returns The rotation transform node
  91677. */
  91678. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  91679. /**
  91680. * Translates the mesh
  91681. * @param axis The axis of translation
  91682. * @param distance The distance of translation
  91683. * @param space The space of the translation
  91684. * @returns The transform node
  91685. */
  91686. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  91687. /**
  91688. * Sets the absolute position of the mesh
  91689. * @param absolutePosition The absolute position of the mesh
  91690. * @returns The transform node
  91691. */
  91692. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  91693. /**
  91694. * Gets the class name of the mesh
  91695. * @returns The class name
  91696. */
  91697. getClassName(): string;
  91698. }
  91699. /**
  91700. * Represents a physics imposter
  91701. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  91702. */
  91703. export class PhysicsImpostor {
  91704. /**
  91705. * The physics-enabled object used as the physics imposter
  91706. */
  91707. object: IPhysicsEnabledObject;
  91708. /**
  91709. * The type of the physics imposter
  91710. */
  91711. type: number;
  91712. private _options;
  91713. private _scene?;
  91714. /**
  91715. * The default object size of the imposter
  91716. */
  91717. static DEFAULT_OBJECT_SIZE: Vector3;
  91718. /**
  91719. * The identity quaternion of the imposter
  91720. */
  91721. static IDENTITY_QUATERNION: Quaternion;
  91722. /** @hidden */
  91723. _pluginData: any;
  91724. private _physicsEngine;
  91725. private _physicsBody;
  91726. private _bodyUpdateRequired;
  91727. private _onBeforePhysicsStepCallbacks;
  91728. private _onAfterPhysicsStepCallbacks;
  91729. /** @hidden */
  91730. _onPhysicsCollideCallbacks: Array<{
  91731. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  91732. otherImpostors: Array<PhysicsImpostor>;
  91733. }>;
  91734. private _deltaPosition;
  91735. private _deltaRotation;
  91736. private _deltaRotationConjugated;
  91737. /** @hidden */
  91738. _isFromLine: boolean;
  91739. private _parent;
  91740. private _isDisposed;
  91741. private static _tmpVecs;
  91742. private static _tmpQuat;
  91743. /**
  91744. * Specifies if the physics imposter is disposed
  91745. */
  91746. readonly isDisposed: boolean;
  91747. /**
  91748. * Gets the mass of the physics imposter
  91749. */
  91750. mass: number;
  91751. /**
  91752. * Gets the coefficient of friction
  91753. */
  91754. /**
  91755. * Sets the coefficient of friction
  91756. */
  91757. friction: number;
  91758. /**
  91759. * Gets the coefficient of restitution
  91760. */
  91761. /**
  91762. * Sets the coefficient of restitution
  91763. */
  91764. restitution: number;
  91765. /**
  91766. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  91767. */
  91768. /**
  91769. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  91770. */
  91771. pressure: number;
  91772. /**
  91773. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91774. */
  91775. /**
  91776. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  91777. */
  91778. stiffness: number;
  91779. /**
  91780. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91781. */
  91782. /**
  91783. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  91784. */
  91785. velocityIterations: number;
  91786. /**
  91787. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91788. */
  91789. /**
  91790. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  91791. */
  91792. positionIterations: number;
  91793. /**
  91794. * The unique id of the physics imposter
  91795. * set by the physics engine when adding this impostor to the array
  91796. */
  91797. uniqueId: number;
  91798. /**
  91799. * @hidden
  91800. */
  91801. soft: boolean;
  91802. /**
  91803. * @hidden
  91804. */
  91805. segments: number;
  91806. private _joints;
  91807. /**
  91808. * Initializes the physics imposter
  91809. * @param object The physics-enabled object used as the physics imposter
  91810. * @param type The type of the physics imposter
  91811. * @param _options The options for the physics imposter
  91812. * @param _scene The Babylon scene
  91813. */
  91814. constructor(
  91815. /**
  91816. * The physics-enabled object used as the physics imposter
  91817. */
  91818. object: IPhysicsEnabledObject,
  91819. /**
  91820. * The type of the physics imposter
  91821. */
  91822. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  91823. /**
  91824. * This function will completly initialize this impostor.
  91825. * It will create a new body - but only if this mesh has no parent.
  91826. * If it has, this impostor will not be used other than to define the impostor
  91827. * of the child mesh.
  91828. * @hidden
  91829. */
  91830. _init(): void;
  91831. private _getPhysicsParent;
  91832. /**
  91833. * Should a new body be generated.
  91834. * @returns boolean specifying if body initialization is required
  91835. */
  91836. isBodyInitRequired(): boolean;
  91837. /**
  91838. * Sets the updated scaling
  91839. * @param updated Specifies if the scaling is updated
  91840. */
  91841. setScalingUpdated(): void;
  91842. /**
  91843. * Force a regeneration of this or the parent's impostor's body.
  91844. * Use under cautious - This will remove all joints already implemented.
  91845. */
  91846. forceUpdate(): void;
  91847. /**
  91848. * Gets the body that holds this impostor. Either its own, or its parent.
  91849. */
  91850. /**
  91851. * Set the physics body. Used mainly by the physics engine/plugin
  91852. */
  91853. physicsBody: any;
  91854. /**
  91855. * Get the parent of the physics imposter
  91856. * @returns Physics imposter or null
  91857. */
  91858. /**
  91859. * Sets the parent of the physics imposter
  91860. */
  91861. parent: Nullable<PhysicsImpostor>;
  91862. /**
  91863. * Resets the update flags
  91864. */
  91865. resetUpdateFlags(): void;
  91866. /**
  91867. * Gets the object extend size
  91868. * @returns the object extend size
  91869. */
  91870. getObjectExtendSize(): Vector3;
  91871. /**
  91872. * Gets the object center
  91873. * @returns The object center
  91874. */
  91875. getObjectCenter(): Vector3;
  91876. /**
  91877. * Get a specific parametes from the options parameter
  91878. * @param paramName The object parameter name
  91879. * @returns The object parameter
  91880. */
  91881. getParam(paramName: string): any;
  91882. /**
  91883. * Sets a specific parameter in the options given to the physics plugin
  91884. * @param paramName The parameter name
  91885. * @param value The value of the parameter
  91886. */
  91887. setParam(paramName: string, value: number): void;
  91888. /**
  91889. * Specifically change the body's mass option. Won't recreate the physics body object
  91890. * @param mass The mass of the physics imposter
  91891. */
  91892. setMass(mass: number): void;
  91893. /**
  91894. * Gets the linear velocity
  91895. * @returns linear velocity or null
  91896. */
  91897. getLinearVelocity(): Nullable<Vector3>;
  91898. /**
  91899. * Sets the linear velocity
  91900. * @param velocity linear velocity or null
  91901. */
  91902. setLinearVelocity(velocity: Nullable<Vector3>): void;
  91903. /**
  91904. * Gets the angular velocity
  91905. * @returns angular velocity or null
  91906. */
  91907. getAngularVelocity(): Nullable<Vector3>;
  91908. /**
  91909. * Sets the angular velocity
  91910. * @param velocity The velocity or null
  91911. */
  91912. setAngularVelocity(velocity: Nullable<Vector3>): void;
  91913. /**
  91914. * Execute a function with the physics plugin native code
  91915. * Provide a function the will have two variables - the world object and the physics body object
  91916. * @param func The function to execute with the physics plugin native code
  91917. */
  91918. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  91919. /**
  91920. * Register a function that will be executed before the physics world is stepping forward
  91921. * @param func The function to execute before the physics world is stepped forward
  91922. */
  91923. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91924. /**
  91925. * Unregister a function that will be executed before the physics world is stepping forward
  91926. * @param func The function to execute before the physics world is stepped forward
  91927. */
  91928. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91929. /**
  91930. * Register a function that will be executed after the physics step
  91931. * @param func The function to execute after physics step
  91932. */
  91933. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91934. /**
  91935. * Unregisters a function that will be executed after the physics step
  91936. * @param func The function to execute after physics step
  91937. */
  91938. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  91939. /**
  91940. * register a function that will be executed when this impostor collides against a different body
  91941. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  91942. * @param func Callback that is executed on collision
  91943. */
  91944. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  91945. /**
  91946. * Unregisters the physics imposter on contact
  91947. * @param collideAgainst The physics object to collide against
  91948. * @param func Callback to execute on collision
  91949. */
  91950. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  91951. private _tmpQuat;
  91952. private _tmpQuat2;
  91953. /**
  91954. * Get the parent rotation
  91955. * @returns The parent rotation
  91956. */
  91957. getParentsRotation(): Quaternion;
  91958. /**
  91959. * this function is executed by the physics engine.
  91960. */
  91961. beforeStep: () => void;
  91962. /**
  91963. * this function is executed by the physics engine
  91964. */
  91965. afterStep: () => void;
  91966. /**
  91967. * Legacy collision detection event support
  91968. */
  91969. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  91970. /**
  91971. * event and body object due to cannon's event-based architecture.
  91972. */
  91973. onCollide: (e: {
  91974. body: any;
  91975. }) => void;
  91976. /**
  91977. * Apply a force
  91978. * @param force The force to apply
  91979. * @param contactPoint The contact point for the force
  91980. * @returns The physics imposter
  91981. */
  91982. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91983. /**
  91984. * Apply an impulse
  91985. * @param force The impulse force
  91986. * @param contactPoint The contact point for the impulse force
  91987. * @returns The physics imposter
  91988. */
  91989. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  91990. /**
  91991. * A help function to create a joint
  91992. * @param otherImpostor A physics imposter used to create a joint
  91993. * @param jointType The type of joint
  91994. * @param jointData The data for the joint
  91995. * @returns The physics imposter
  91996. */
  91997. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  91998. /**
  91999. * Add a joint to this impostor with a different impostor
  92000. * @param otherImpostor A physics imposter used to add a joint
  92001. * @param joint The joint to add
  92002. * @returns The physics imposter
  92003. */
  92004. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  92005. /**
  92006. * Add an anchor to a cloth impostor
  92007. * @param otherImpostor rigid impostor to anchor to
  92008. * @param width ratio across width from 0 to 1
  92009. * @param height ratio up height from 0 to 1
  92010. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  92011. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  92012. * @returns impostor the soft imposter
  92013. */
  92014. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92015. /**
  92016. * Add a hook to a rope impostor
  92017. * @param otherImpostor rigid impostor to anchor to
  92018. * @param length ratio across rope from 0 to 1
  92019. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  92020. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  92021. * @returns impostor the rope imposter
  92022. */
  92023. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  92024. /**
  92025. * Will keep this body still, in a sleep mode.
  92026. * @returns the physics imposter
  92027. */
  92028. sleep(): PhysicsImpostor;
  92029. /**
  92030. * Wake the body up.
  92031. * @returns The physics imposter
  92032. */
  92033. wakeUp(): PhysicsImpostor;
  92034. /**
  92035. * Clones the physics imposter
  92036. * @param newObject The physics imposter clones to this physics-enabled object
  92037. * @returns A nullable physics imposter
  92038. */
  92039. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  92040. /**
  92041. * Disposes the physics imposter
  92042. */
  92043. dispose(): void;
  92044. /**
  92045. * Sets the delta position
  92046. * @param position The delta position amount
  92047. */
  92048. setDeltaPosition(position: Vector3): void;
  92049. /**
  92050. * Sets the delta rotation
  92051. * @param rotation The delta rotation amount
  92052. */
  92053. setDeltaRotation(rotation: Quaternion): void;
  92054. /**
  92055. * Gets the box size of the physics imposter and stores the result in the input parameter
  92056. * @param result Stores the box size
  92057. * @returns The physics imposter
  92058. */
  92059. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  92060. /**
  92061. * Gets the radius of the physics imposter
  92062. * @returns Radius of the physics imposter
  92063. */
  92064. getRadius(): number;
  92065. /**
  92066. * Sync a bone with this impostor
  92067. * @param bone The bone to sync to the impostor.
  92068. * @param boneMesh The mesh that the bone is influencing.
  92069. * @param jointPivot The pivot of the joint / bone in local space.
  92070. * @param distToJoint Optional distance from the impostor to the joint.
  92071. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92072. */
  92073. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  92074. /**
  92075. * Sync impostor to a bone
  92076. * @param bone The bone that the impostor will be synced to.
  92077. * @param boneMesh The mesh that the bone is influencing.
  92078. * @param jointPivot The pivot of the joint / bone in local space.
  92079. * @param distToJoint Optional distance from the impostor to the joint.
  92080. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  92081. * @param boneAxis Optional vector3 axis the bone is aligned with
  92082. */
  92083. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  92084. /**
  92085. * No-Imposter type
  92086. */
  92087. static NoImpostor: number;
  92088. /**
  92089. * Sphere-Imposter type
  92090. */
  92091. static SphereImpostor: number;
  92092. /**
  92093. * Box-Imposter type
  92094. */
  92095. static BoxImpostor: number;
  92096. /**
  92097. * Plane-Imposter type
  92098. */
  92099. static PlaneImpostor: number;
  92100. /**
  92101. * Mesh-imposter type
  92102. */
  92103. static MeshImpostor: number;
  92104. /**
  92105. * Capsule-Impostor type (Ammo.js plugin only)
  92106. */
  92107. static CapsuleImpostor: number;
  92108. /**
  92109. * Cylinder-Imposter type
  92110. */
  92111. static CylinderImpostor: number;
  92112. /**
  92113. * Particle-Imposter type
  92114. */
  92115. static ParticleImpostor: number;
  92116. /**
  92117. * Heightmap-Imposter type
  92118. */
  92119. static HeightmapImpostor: number;
  92120. /**
  92121. * ConvexHull-Impostor type (Ammo.js plugin only)
  92122. */
  92123. static ConvexHullImpostor: number;
  92124. /**
  92125. * Rope-Imposter type
  92126. */
  92127. static RopeImpostor: number;
  92128. /**
  92129. * Cloth-Imposter type
  92130. */
  92131. static ClothImpostor: number;
  92132. /**
  92133. * Softbody-Imposter type
  92134. */
  92135. static SoftbodyImpostor: number;
  92136. }
  92137. }
  92138. declare module BABYLON {
  92139. /**
  92140. * @hidden
  92141. **/
  92142. export class _CreationDataStorage {
  92143. closePath?: boolean;
  92144. closeArray?: boolean;
  92145. idx: number[];
  92146. dashSize: number;
  92147. gapSize: number;
  92148. path3D: Path3D;
  92149. pathArray: Vector3[][];
  92150. arc: number;
  92151. radius: number;
  92152. cap: number;
  92153. tessellation: number;
  92154. }
  92155. /**
  92156. * @hidden
  92157. **/
  92158. class _InstanceDataStorage {
  92159. visibleInstances: any;
  92160. batchCache: _InstancesBatch;
  92161. instancesBufferSize: number;
  92162. instancesBuffer: Nullable<Buffer>;
  92163. instancesData: Float32Array;
  92164. overridenInstanceCount: number;
  92165. isFrozen: boolean;
  92166. previousBatch: Nullable<_InstancesBatch>;
  92167. hardwareInstancedRendering: boolean;
  92168. sideOrientation: number;
  92169. manualUpdate: boolean;
  92170. }
  92171. /**
  92172. * @hidden
  92173. **/
  92174. export class _InstancesBatch {
  92175. mustReturn: boolean;
  92176. visibleInstances: Nullable<InstancedMesh[]>[];
  92177. renderSelf: boolean[];
  92178. hardwareInstancedRendering: boolean[];
  92179. }
  92180. /**
  92181. * Class used to represent renderable models
  92182. */
  92183. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  92184. /**
  92185. * Mesh side orientation : usually the external or front surface
  92186. */
  92187. static readonly FRONTSIDE: number;
  92188. /**
  92189. * Mesh side orientation : usually the internal or back surface
  92190. */
  92191. static readonly BACKSIDE: number;
  92192. /**
  92193. * Mesh side orientation : both internal and external or front and back surfaces
  92194. */
  92195. static readonly DOUBLESIDE: number;
  92196. /**
  92197. * Mesh side orientation : by default, `FRONTSIDE`
  92198. */
  92199. static readonly DEFAULTSIDE: number;
  92200. /**
  92201. * Mesh cap setting : no cap
  92202. */
  92203. static readonly NO_CAP: number;
  92204. /**
  92205. * Mesh cap setting : one cap at the beginning of the mesh
  92206. */
  92207. static readonly CAP_START: number;
  92208. /**
  92209. * Mesh cap setting : one cap at the end of the mesh
  92210. */
  92211. static readonly CAP_END: number;
  92212. /**
  92213. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  92214. */
  92215. static readonly CAP_ALL: number;
  92216. /**
  92217. * Mesh pattern setting : no flip or rotate
  92218. */
  92219. static readonly NO_FLIP: number;
  92220. /**
  92221. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  92222. */
  92223. static readonly FLIP_TILE: number;
  92224. /**
  92225. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  92226. */
  92227. static readonly ROTATE_TILE: number;
  92228. /**
  92229. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  92230. */
  92231. static readonly FLIP_ROW: number;
  92232. /**
  92233. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  92234. */
  92235. static readonly ROTATE_ROW: number;
  92236. /**
  92237. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  92238. */
  92239. static readonly FLIP_N_ROTATE_TILE: number;
  92240. /**
  92241. * Mesh pattern setting : rotate pattern and rotate
  92242. */
  92243. static readonly FLIP_N_ROTATE_ROW: number;
  92244. /**
  92245. * Mesh tile positioning : part tiles same on left/right or top/bottom
  92246. */
  92247. static readonly CENTER: number;
  92248. /**
  92249. * Mesh tile positioning : part tiles on left
  92250. */
  92251. static readonly LEFT: number;
  92252. /**
  92253. * Mesh tile positioning : part tiles on right
  92254. */
  92255. static readonly RIGHT: number;
  92256. /**
  92257. * Mesh tile positioning : part tiles on top
  92258. */
  92259. static readonly TOP: number;
  92260. /**
  92261. * Mesh tile positioning : part tiles on bottom
  92262. */
  92263. static readonly BOTTOM: number;
  92264. /**
  92265. * Gets the default side orientation.
  92266. * @param orientation the orientation to value to attempt to get
  92267. * @returns the default orientation
  92268. * @hidden
  92269. */
  92270. static _GetDefaultSideOrientation(orientation?: number): number;
  92271. private _internalMeshDataInfo;
  92272. /**
  92273. * An event triggered before rendering the mesh
  92274. */
  92275. readonly onBeforeRenderObservable: Observable<Mesh>;
  92276. /**
  92277. * An event triggered before binding the mesh
  92278. */
  92279. readonly onBeforeBindObservable: Observable<Mesh>;
  92280. /**
  92281. * An event triggered after rendering the mesh
  92282. */
  92283. readonly onAfterRenderObservable: Observable<Mesh>;
  92284. /**
  92285. * An event triggered before drawing the mesh
  92286. */
  92287. readonly onBeforeDrawObservable: Observable<Mesh>;
  92288. private _onBeforeDrawObserver;
  92289. /**
  92290. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  92291. */
  92292. onBeforeDraw: () => void;
  92293. readonly hasInstances: boolean;
  92294. /**
  92295. * Gets the delay loading state of the mesh (when delay loading is turned on)
  92296. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  92297. */
  92298. delayLoadState: number;
  92299. /**
  92300. * Gets the list of instances created from this mesh
  92301. * it is not supposed to be modified manually.
  92302. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  92303. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92304. */
  92305. instances: InstancedMesh[];
  92306. /**
  92307. * Gets the file containing delay loading data for this mesh
  92308. */
  92309. delayLoadingFile: string;
  92310. /** @hidden */
  92311. _binaryInfo: any;
  92312. /**
  92313. * User defined function used to change how LOD level selection is done
  92314. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  92315. */
  92316. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  92317. /**
  92318. * Gets or sets the morph target manager
  92319. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  92320. */
  92321. morphTargetManager: Nullable<MorphTargetManager>;
  92322. /** @hidden */
  92323. _creationDataStorage: Nullable<_CreationDataStorage>;
  92324. /** @hidden */
  92325. _geometry: Nullable<Geometry>;
  92326. /** @hidden */
  92327. _delayInfo: Array<string>;
  92328. /** @hidden */
  92329. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  92330. /** @hidden */
  92331. _instanceDataStorage: _InstanceDataStorage;
  92332. private _effectiveMaterial;
  92333. /** @hidden */
  92334. _shouldGenerateFlatShading: boolean;
  92335. /** @hidden */
  92336. _originalBuilderSideOrientation: number;
  92337. /**
  92338. * Use this property to change the original side orientation defined at construction time
  92339. */
  92340. overrideMaterialSideOrientation: Nullable<number>;
  92341. /**
  92342. * Gets the source mesh (the one used to clone this one from)
  92343. */
  92344. readonly source: Nullable<Mesh>;
  92345. /**
  92346. * Gets or sets a boolean indicating that this mesh does not use index buffer
  92347. */
  92348. isUnIndexed: boolean;
  92349. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  92350. readonly worldMatrixInstancedBuffer: Float32Array;
  92351. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  92352. manualUpdateOfWorldMatrixInstancedBuffer: boolean;
  92353. /**
  92354. * @constructor
  92355. * @param name The value used by scene.getMeshByName() to do a lookup.
  92356. * @param scene The scene to add this mesh to.
  92357. * @param parent The parent of this mesh, if it has one
  92358. * @param source An optional Mesh from which geometry is shared, cloned.
  92359. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  92360. * When false, achieved by calling a clone(), also passing False.
  92361. * This will make creation of children, recursive.
  92362. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  92363. */
  92364. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  92365. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92366. doNotInstantiate: boolean;
  92367. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92368. /**
  92369. * Gets the class name
  92370. * @returns the string "Mesh".
  92371. */
  92372. getClassName(): string;
  92373. /** @hidden */
  92374. readonly _isMesh: boolean;
  92375. /**
  92376. * Returns a description of this mesh
  92377. * @param fullDetails define if full details about this mesh must be used
  92378. * @returns a descriptive string representing this mesh
  92379. */
  92380. toString(fullDetails?: boolean): string;
  92381. /** @hidden */
  92382. _unBindEffect(): void;
  92383. /**
  92384. * Gets a boolean indicating if this mesh has LOD
  92385. */
  92386. readonly hasLODLevels: boolean;
  92387. /**
  92388. * Gets the list of MeshLODLevel associated with the current mesh
  92389. * @returns an array of MeshLODLevel
  92390. */
  92391. getLODLevels(): MeshLODLevel[];
  92392. private _sortLODLevels;
  92393. /**
  92394. * Add a mesh as LOD level triggered at the given distance.
  92395. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92396. * @param distance The distance from the center of the object to show this level
  92397. * @param mesh The mesh to be added as LOD level (can be null)
  92398. * @return This mesh (for chaining)
  92399. */
  92400. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  92401. /**
  92402. * Returns the LOD level mesh at the passed distance or null if not found.
  92403. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92404. * @param distance The distance from the center of the object to show this level
  92405. * @returns a Mesh or `null`
  92406. */
  92407. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  92408. /**
  92409. * Remove a mesh from the LOD array
  92410. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92411. * @param mesh defines the mesh to be removed
  92412. * @return This mesh (for chaining)
  92413. */
  92414. removeLODLevel(mesh: Mesh): Mesh;
  92415. /**
  92416. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  92417. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  92418. * @param camera defines the camera to use to compute distance
  92419. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  92420. * @return This mesh (for chaining)
  92421. */
  92422. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  92423. /**
  92424. * Gets the mesh internal Geometry object
  92425. */
  92426. readonly geometry: Nullable<Geometry>;
  92427. /**
  92428. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  92429. * @returns the total number of vertices
  92430. */
  92431. getTotalVertices(): number;
  92432. /**
  92433. * Returns the content of an associated vertex buffer
  92434. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92435. * - VertexBuffer.PositionKind
  92436. * - VertexBuffer.UVKind
  92437. * - VertexBuffer.UV2Kind
  92438. * - VertexBuffer.UV3Kind
  92439. * - VertexBuffer.UV4Kind
  92440. * - VertexBuffer.UV5Kind
  92441. * - VertexBuffer.UV6Kind
  92442. * - VertexBuffer.ColorKind
  92443. * - VertexBuffer.MatricesIndicesKind
  92444. * - VertexBuffer.MatricesIndicesExtraKind
  92445. * - VertexBuffer.MatricesWeightsKind
  92446. * - VertexBuffer.MatricesWeightsExtraKind
  92447. * @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
  92448. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  92449. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  92450. */
  92451. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  92452. /**
  92453. * Returns the mesh VertexBuffer object from the requested `kind`
  92454. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92455. * - VertexBuffer.PositionKind
  92456. * - VertexBuffer.NormalKind
  92457. * - VertexBuffer.UVKind
  92458. * - VertexBuffer.UV2Kind
  92459. * - VertexBuffer.UV3Kind
  92460. * - VertexBuffer.UV4Kind
  92461. * - VertexBuffer.UV5Kind
  92462. * - VertexBuffer.UV6Kind
  92463. * - VertexBuffer.ColorKind
  92464. * - VertexBuffer.MatricesIndicesKind
  92465. * - VertexBuffer.MatricesIndicesExtraKind
  92466. * - VertexBuffer.MatricesWeightsKind
  92467. * - VertexBuffer.MatricesWeightsExtraKind
  92468. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  92469. */
  92470. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  92471. /**
  92472. * Tests if a specific vertex buffer is associated with this mesh
  92473. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92474. * - VertexBuffer.PositionKind
  92475. * - VertexBuffer.NormalKind
  92476. * - VertexBuffer.UVKind
  92477. * - VertexBuffer.UV2Kind
  92478. * - VertexBuffer.UV3Kind
  92479. * - VertexBuffer.UV4Kind
  92480. * - VertexBuffer.UV5Kind
  92481. * - VertexBuffer.UV6Kind
  92482. * - VertexBuffer.ColorKind
  92483. * - VertexBuffer.MatricesIndicesKind
  92484. * - VertexBuffer.MatricesIndicesExtraKind
  92485. * - VertexBuffer.MatricesWeightsKind
  92486. * - VertexBuffer.MatricesWeightsExtraKind
  92487. * @returns a boolean
  92488. */
  92489. isVerticesDataPresent(kind: string): boolean;
  92490. /**
  92491. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  92492. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  92493. * - VertexBuffer.PositionKind
  92494. * - VertexBuffer.UVKind
  92495. * - VertexBuffer.UV2Kind
  92496. * - VertexBuffer.UV3Kind
  92497. * - VertexBuffer.UV4Kind
  92498. * - VertexBuffer.UV5Kind
  92499. * - VertexBuffer.UV6Kind
  92500. * - VertexBuffer.ColorKind
  92501. * - VertexBuffer.MatricesIndicesKind
  92502. * - VertexBuffer.MatricesIndicesExtraKind
  92503. * - VertexBuffer.MatricesWeightsKind
  92504. * - VertexBuffer.MatricesWeightsExtraKind
  92505. * @returns a boolean
  92506. */
  92507. isVertexBufferUpdatable(kind: string): boolean;
  92508. /**
  92509. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  92510. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  92511. * - VertexBuffer.PositionKind
  92512. * - VertexBuffer.NormalKind
  92513. * - VertexBuffer.UVKind
  92514. * - VertexBuffer.UV2Kind
  92515. * - VertexBuffer.UV3Kind
  92516. * - VertexBuffer.UV4Kind
  92517. * - VertexBuffer.UV5Kind
  92518. * - VertexBuffer.UV6Kind
  92519. * - VertexBuffer.ColorKind
  92520. * - VertexBuffer.MatricesIndicesKind
  92521. * - VertexBuffer.MatricesIndicesExtraKind
  92522. * - VertexBuffer.MatricesWeightsKind
  92523. * - VertexBuffer.MatricesWeightsExtraKind
  92524. * @returns an array of strings
  92525. */
  92526. getVerticesDataKinds(): string[];
  92527. /**
  92528. * Returns a positive integer : the total number of indices in this mesh geometry.
  92529. * @returns the numner of indices or zero if the mesh has no geometry.
  92530. */
  92531. getTotalIndices(): number;
  92532. /**
  92533. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  92534. * @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.
  92535. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  92536. * @returns the indices array or an empty array if the mesh has no geometry
  92537. */
  92538. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  92539. readonly isBlocked: boolean;
  92540. /**
  92541. * Determine if the current mesh is ready to be rendered
  92542. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92543. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  92544. * @returns true if all associated assets are ready (material, textures, shaders)
  92545. */
  92546. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  92547. /**
  92548. * 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.
  92549. */
  92550. readonly areNormalsFrozen: boolean;
  92551. /**
  92552. * 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.
  92553. * @returns the current mesh
  92554. */
  92555. freezeNormals(): Mesh;
  92556. /**
  92557. * 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
  92558. * @returns the current mesh
  92559. */
  92560. unfreezeNormals(): Mesh;
  92561. /**
  92562. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  92563. */
  92564. overridenInstanceCount: number;
  92565. /** @hidden */
  92566. _preActivate(): Mesh;
  92567. /** @hidden */
  92568. _preActivateForIntermediateRendering(renderId: number): Mesh;
  92569. /** @hidden */
  92570. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  92571. /**
  92572. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92573. * This means the mesh underlying bounding box and sphere are recomputed.
  92574. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92575. * @returns the current mesh
  92576. */
  92577. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  92578. /** @hidden */
  92579. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  92580. /**
  92581. * This function will subdivide the mesh into multiple submeshes
  92582. * @param count defines the expected number of submeshes
  92583. */
  92584. subdivide(count: number): void;
  92585. /**
  92586. * Copy a FloatArray into a specific associated vertex buffer
  92587. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92588. * - VertexBuffer.PositionKind
  92589. * - VertexBuffer.UVKind
  92590. * - VertexBuffer.UV2Kind
  92591. * - VertexBuffer.UV3Kind
  92592. * - VertexBuffer.UV4Kind
  92593. * - VertexBuffer.UV5Kind
  92594. * - VertexBuffer.UV6Kind
  92595. * - VertexBuffer.ColorKind
  92596. * - VertexBuffer.MatricesIndicesKind
  92597. * - VertexBuffer.MatricesIndicesExtraKind
  92598. * - VertexBuffer.MatricesWeightsKind
  92599. * - VertexBuffer.MatricesWeightsExtraKind
  92600. * @param data defines the data source
  92601. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92602. * @param stride defines the data stride size (can be null)
  92603. * @returns the current mesh
  92604. */
  92605. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92606. /**
  92607. * Delete a vertex buffer associated with this mesh
  92608. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  92609. * - VertexBuffer.PositionKind
  92610. * - VertexBuffer.UVKind
  92611. * - VertexBuffer.UV2Kind
  92612. * - VertexBuffer.UV3Kind
  92613. * - VertexBuffer.UV4Kind
  92614. * - VertexBuffer.UV5Kind
  92615. * - VertexBuffer.UV6Kind
  92616. * - VertexBuffer.ColorKind
  92617. * - VertexBuffer.MatricesIndicesKind
  92618. * - VertexBuffer.MatricesIndicesExtraKind
  92619. * - VertexBuffer.MatricesWeightsKind
  92620. * - VertexBuffer.MatricesWeightsExtraKind
  92621. */
  92622. removeVerticesData(kind: string): void;
  92623. /**
  92624. * Flags an associated vertex buffer as updatable
  92625. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  92626. * - VertexBuffer.PositionKind
  92627. * - VertexBuffer.UVKind
  92628. * - VertexBuffer.UV2Kind
  92629. * - VertexBuffer.UV3Kind
  92630. * - VertexBuffer.UV4Kind
  92631. * - VertexBuffer.UV5Kind
  92632. * - VertexBuffer.UV6Kind
  92633. * - VertexBuffer.ColorKind
  92634. * - VertexBuffer.MatricesIndicesKind
  92635. * - VertexBuffer.MatricesIndicesExtraKind
  92636. * - VertexBuffer.MatricesWeightsKind
  92637. * - VertexBuffer.MatricesWeightsExtraKind
  92638. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  92639. */
  92640. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  92641. /**
  92642. * Sets the mesh global Vertex Buffer
  92643. * @param buffer defines the buffer to use
  92644. * @returns the current mesh
  92645. */
  92646. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  92647. /**
  92648. * Update a specific associated vertex buffer
  92649. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  92650. * - VertexBuffer.PositionKind
  92651. * - VertexBuffer.UVKind
  92652. * - VertexBuffer.UV2Kind
  92653. * - VertexBuffer.UV3Kind
  92654. * - VertexBuffer.UV4Kind
  92655. * - VertexBuffer.UV5Kind
  92656. * - VertexBuffer.UV6Kind
  92657. * - VertexBuffer.ColorKind
  92658. * - VertexBuffer.MatricesIndicesKind
  92659. * - VertexBuffer.MatricesIndicesExtraKind
  92660. * - VertexBuffer.MatricesWeightsKind
  92661. * - VertexBuffer.MatricesWeightsExtraKind
  92662. * @param data defines the data source
  92663. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  92664. * @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)
  92665. * @returns the current mesh
  92666. */
  92667. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92668. /**
  92669. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  92670. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  92671. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  92672. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  92673. * @returns the current mesh
  92674. */
  92675. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  92676. /**
  92677. * Creates a un-shared specific occurence of the geometry for the mesh.
  92678. * @returns the current mesh
  92679. */
  92680. makeGeometryUnique(): Mesh;
  92681. /**
  92682. * Set the index buffer of this mesh
  92683. * @param indices defines the source data
  92684. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  92685. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  92686. * @returns the current mesh
  92687. */
  92688. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  92689. /**
  92690. * Update the current index buffer
  92691. * @param indices defines the source data
  92692. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92693. * @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)
  92694. * @returns the current mesh
  92695. */
  92696. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92697. /**
  92698. * Invert the geometry to move from a right handed system to a left handed one.
  92699. * @returns the current mesh
  92700. */
  92701. toLeftHanded(): Mesh;
  92702. /** @hidden */
  92703. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  92704. /** @hidden */
  92705. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  92706. /**
  92707. * Registers for this mesh a javascript function called just before the rendering process
  92708. * @param func defines the function to call before rendering this mesh
  92709. * @returns the current mesh
  92710. */
  92711. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92712. /**
  92713. * Disposes a previously registered javascript function called before the rendering
  92714. * @param func defines the function to remove
  92715. * @returns the current mesh
  92716. */
  92717. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  92718. /**
  92719. * Registers for this mesh a javascript function called just after the rendering is complete
  92720. * @param func defines the function to call after rendering this mesh
  92721. * @returns the current mesh
  92722. */
  92723. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92724. /**
  92725. * Disposes a previously registered javascript function called after the rendering.
  92726. * @param func defines the function to remove
  92727. * @returns the current mesh
  92728. */
  92729. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  92730. /** @hidden */
  92731. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  92732. /** @hidden */
  92733. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  92734. /** @hidden */
  92735. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  92736. /** @hidden */
  92737. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  92738. /** @hidden */
  92739. _rebuild(): void;
  92740. /** @hidden */
  92741. _freeze(): void;
  92742. /** @hidden */
  92743. _unFreeze(): void;
  92744. /**
  92745. * 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
  92746. * @param subMesh defines the subMesh to render
  92747. * @param enableAlphaMode defines if alpha mode can be changed
  92748. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  92749. * @returns the current mesh
  92750. */
  92751. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  92752. private _onBeforeDraw;
  92753. /**
  92754. * Renormalize the mesh and patch it up if there are no weights
  92755. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  92756. * However in the case of zero weights then we set just a single influence to 1.
  92757. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  92758. */
  92759. cleanMatrixWeights(): void;
  92760. private normalizeSkinFourWeights;
  92761. private normalizeSkinWeightsAndExtra;
  92762. /**
  92763. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  92764. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  92765. * the user know there was an issue with importing the mesh
  92766. * @returns a validation object with skinned, valid and report string
  92767. */
  92768. validateSkinning(): {
  92769. skinned: boolean;
  92770. valid: boolean;
  92771. report: string;
  92772. };
  92773. /** @hidden */
  92774. _checkDelayState(): Mesh;
  92775. private _queueLoad;
  92776. /**
  92777. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92778. * A mesh is in the frustum if its bounding box intersects the frustum
  92779. * @param frustumPlanes defines the frustum to test
  92780. * @returns true if the mesh is in the frustum planes
  92781. */
  92782. isInFrustum(frustumPlanes: Plane[]): boolean;
  92783. /**
  92784. * Sets the mesh material by the material or multiMaterial `id` property
  92785. * @param id is a string identifying the material or the multiMaterial
  92786. * @returns the current mesh
  92787. */
  92788. setMaterialByID(id: string): Mesh;
  92789. /**
  92790. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  92791. * @returns an array of IAnimatable
  92792. */
  92793. getAnimatables(): IAnimatable[];
  92794. /**
  92795. * Modifies the mesh geometry according to the passed transformation matrix.
  92796. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  92797. * The mesh normals are modified using the same transformation.
  92798. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92799. * @param transform defines the transform matrix to use
  92800. * @see http://doc.babylonjs.com/resources/baking_transformations
  92801. * @returns the current mesh
  92802. */
  92803. bakeTransformIntoVertices(transform: Matrix): Mesh;
  92804. /**
  92805. * Modifies the mesh geometry according to its own current World Matrix.
  92806. * The mesh World Matrix is then reset.
  92807. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  92808. * Note that, under the hood, this method sets a new VertexBuffer each call.
  92809. * @see http://doc.babylonjs.com/resources/baking_transformations
  92810. * @returns the current mesh
  92811. */
  92812. bakeCurrentTransformIntoVertices(): Mesh;
  92813. /** @hidden */
  92814. readonly _positions: Nullable<Vector3[]>;
  92815. /** @hidden */
  92816. _resetPointsArrayCache(): Mesh;
  92817. /** @hidden */
  92818. _generatePointsArray(): boolean;
  92819. /**
  92820. * Returns a new Mesh object generated from the current mesh properties.
  92821. * This method must not get confused with createInstance()
  92822. * @param name is a string, the name given to the new mesh
  92823. * @param newParent can be any Node object (default `null`)
  92824. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  92825. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  92826. * @returns a new mesh
  92827. */
  92828. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  92829. /**
  92830. * Releases resources associated with this mesh.
  92831. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92832. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92833. */
  92834. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92835. /** @hidden */
  92836. _disposeInstanceSpecificData(): void;
  92837. /**
  92838. * Modifies the mesh geometry according to a displacement map.
  92839. * 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.
  92840. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92841. * @param url is a string, the URL from the image file is to be downloaded.
  92842. * @param minHeight is the lower limit of the displacement.
  92843. * @param maxHeight is the upper limit of the displacement.
  92844. * @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.
  92845. * @param uvOffset is an optional vector2 used to offset UV.
  92846. * @param uvScale is an optional vector2 used to scale UV.
  92847. * @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.
  92848. * @returns the Mesh.
  92849. */
  92850. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92851. /**
  92852. * Modifies the mesh geometry according to a displacementMap buffer.
  92853. * 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.
  92854. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  92855. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  92856. * @param heightMapWidth is the width of the buffer image.
  92857. * @param heightMapHeight is the height of the buffer image.
  92858. * @param minHeight is the lower limit of the displacement.
  92859. * @param maxHeight is the upper limit of the displacement.
  92860. * @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.
  92861. * @param uvOffset is an optional vector2 used to offset UV.
  92862. * @param uvScale is an optional vector2 used to scale UV.
  92863. * @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.
  92864. * @returns the Mesh.
  92865. */
  92866. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  92867. /**
  92868. * Modify the mesh to get a flat shading rendering.
  92869. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  92870. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  92871. * @returns current mesh
  92872. */
  92873. convertToFlatShadedMesh(): Mesh;
  92874. /**
  92875. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  92876. * In other words, more vertices, no more indices and a single bigger VBO.
  92877. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  92878. * @returns current mesh
  92879. */
  92880. convertToUnIndexedMesh(): Mesh;
  92881. /**
  92882. * Inverses facet orientations.
  92883. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92884. * @param flipNormals will also inverts the normals
  92885. * @returns current mesh
  92886. */
  92887. flipFaces(flipNormals?: boolean): Mesh;
  92888. /**
  92889. * Increase the number of facets and hence vertices in a mesh
  92890. * Vertex normals are interpolated from existing vertex normals
  92891. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92892. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  92893. */
  92894. increaseVertices(numberPerEdge: number): void;
  92895. /**
  92896. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  92897. * This will undo any application of covertToFlatShadedMesh
  92898. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  92899. */
  92900. forceSharedVertices(): void;
  92901. /** @hidden */
  92902. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  92903. /** @hidden */
  92904. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  92905. /**
  92906. * Creates a new InstancedMesh object from the mesh model.
  92907. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  92908. * @param name defines the name of the new instance
  92909. * @returns a new InstancedMesh
  92910. */
  92911. createInstance(name: string): InstancedMesh;
  92912. /**
  92913. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  92914. * After this call, all the mesh instances have the same submeshes than the current mesh.
  92915. * @returns the current mesh
  92916. */
  92917. synchronizeInstances(): Mesh;
  92918. /**
  92919. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  92920. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  92921. * This should be used together with the simplification to avoid disappearing triangles.
  92922. * @param successCallback an optional success callback to be called after the optimization finished.
  92923. * @returns the current mesh
  92924. */
  92925. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  92926. /**
  92927. * Serialize current mesh
  92928. * @param serializationObject defines the object which will receive the serialization data
  92929. */
  92930. serialize(serializationObject: any): void;
  92931. /** @hidden */
  92932. _syncGeometryWithMorphTargetManager(): void;
  92933. /** @hidden */
  92934. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  92935. /**
  92936. * Returns a new Mesh object parsed from the source provided.
  92937. * @param parsedMesh is the source
  92938. * @param scene defines the hosting scene
  92939. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  92940. * @returns a new Mesh
  92941. */
  92942. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  92943. /**
  92944. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  92945. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  92946. * @param name defines the name of the mesh to create
  92947. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  92948. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  92949. * @param closePath creates a seam between the first and the last points of each path of the path array
  92950. * @param offset is taken in account only if the `pathArray` is containing a single path
  92951. * @param scene defines the hosting scene
  92952. * @param updatable defines if the mesh must be flagged as updatable
  92953. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92954. * @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)
  92955. * @returns a new Mesh
  92956. */
  92957. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  92958. /**
  92959. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  92960. * @param name defines the name of the mesh to create
  92961. * @param radius sets the radius size (float) of the polygon (default 0.5)
  92962. * @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
  92963. * @param scene defines the hosting scene
  92964. * @param updatable defines if the mesh must be flagged as updatable
  92965. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92966. * @returns a new Mesh
  92967. */
  92968. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92969. /**
  92970. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  92971. * @param name defines the name of the mesh to create
  92972. * @param size sets the size (float) of each box side (default 1)
  92973. * @param scene defines the hosting scene
  92974. * @param updatable defines if the mesh must be flagged as updatable
  92975. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92976. * @returns a new Mesh
  92977. */
  92978. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  92979. /**
  92980. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  92981. * @param name defines the name of the mesh to create
  92982. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92983. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92984. * @param scene defines the hosting scene
  92985. * @param updatable defines if the mesh must be flagged as updatable
  92986. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  92987. * @returns a new Mesh
  92988. */
  92989. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  92990. /**
  92991. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  92992. * @param name defines the name of the mesh to create
  92993. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  92994. * @param diameter sets the diameter size (float) of the sphere (default 1)
  92995. * @param scene defines the hosting scene
  92996. * @returns a new Mesh
  92997. */
  92998. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  92999. /**
  93000. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  93001. * @param name defines the name of the mesh to create
  93002. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  93003. * @param diameterTop set the top cap diameter (floats, default 1)
  93004. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  93005. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  93006. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  93007. * @param scene defines the hosting scene
  93008. * @param updatable defines if the mesh must be flagged as updatable
  93009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93010. * @returns a new Mesh
  93011. */
  93012. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  93013. /**
  93014. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  93015. * @param name defines the name of the mesh to create
  93016. * @param diameter sets the diameter size (float) of the torus (default 1)
  93017. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  93018. * @param tessellation sets the number of torus sides (postive integer, default 16)
  93019. * @param scene defines the hosting scene
  93020. * @param updatable defines if the mesh must be flagged as updatable
  93021. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93022. * @returns a new Mesh
  93023. */
  93024. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93025. /**
  93026. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  93027. * @param name defines the name of the mesh to create
  93028. * @param radius sets the global radius size (float) of the torus knot (default 2)
  93029. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  93030. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  93031. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  93032. * @param p the number of windings on X axis (positive integers, default 2)
  93033. * @param q the number of windings on Y axis (positive integers, default 3)
  93034. * @param scene defines the hosting scene
  93035. * @param updatable defines if the mesh must be flagged as updatable
  93036. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93037. * @returns a new Mesh
  93038. */
  93039. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93040. /**
  93041. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  93042. * @param name defines the name of the mesh to create
  93043. * @param points is an array successive Vector3
  93044. * @param scene defines the hosting scene
  93045. * @param updatable defines if the mesh must be flagged as updatable
  93046. * @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).
  93047. * @returns a new Mesh
  93048. */
  93049. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  93050. /**
  93051. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  93052. * @param name defines the name of the mesh to create
  93053. * @param points is an array successive Vector3
  93054. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  93055. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  93056. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  93057. * @param scene defines the hosting scene
  93058. * @param updatable defines if the mesh must be flagged as updatable
  93059. * @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)
  93060. * @returns a new Mesh
  93061. */
  93062. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  93063. /**
  93064. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  93065. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  93066. * 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.
  93067. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93068. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  93069. * Remember you can only change the shape positions, not their number when updating a polygon.
  93070. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  93071. * @param name defines the name of the mesh to create
  93072. * @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
  93073. * @param scene defines the hosting scene
  93074. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93075. * @param updatable defines if the mesh must be flagged as updatable
  93076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93077. * @param earcutInjection can be used to inject your own earcut reference
  93078. * @returns a new Mesh
  93079. */
  93080. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93081. /**
  93082. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  93083. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  93084. * @param name defines the name of the mesh to create
  93085. * @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
  93086. * @param depth defines the height of extrusion
  93087. * @param scene defines the hosting scene
  93088. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  93089. * @param updatable defines if the mesh must be flagged as updatable
  93090. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93091. * @param earcutInjection can be used to inject your own earcut reference
  93092. * @returns a new Mesh
  93093. */
  93094. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  93095. /**
  93096. * Creates an extruded shape mesh.
  93097. * 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
  93098. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93099. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93100. * @param name defines the name of the mesh to create
  93101. * @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
  93102. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93103. * @param scale is the value to scale the shape
  93104. * @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
  93105. * @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
  93106. * @param scene defines the hosting scene
  93107. * @param updatable defines if the mesh must be flagged as updatable
  93108. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93109. * @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)
  93110. * @returns a new Mesh
  93111. */
  93112. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93113. /**
  93114. * Creates an custom extruded shape mesh.
  93115. * The custom extrusion is a parametric shape.
  93116. * It has no predefined shape. Its final shape will depend on the input parameters.
  93117. * Please consider using the same method from the MeshBuilder class instead
  93118. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  93119. * @param name defines the name of the mesh to create
  93120. * @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
  93121. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  93122. * @param scaleFunction is a custom Javascript function called on each path point
  93123. * @param rotationFunction is a custom Javascript function called on each path point
  93124. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  93125. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  93126. * @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
  93127. * @param scene defines the hosting scene
  93128. * @param updatable defines if the mesh must be flagged as updatable
  93129. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93130. * @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)
  93131. * @returns a new Mesh
  93132. */
  93133. 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;
  93134. /**
  93135. * Creates lathe mesh.
  93136. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  93137. * Please consider using the same method from the MeshBuilder class instead
  93138. * @param name defines the name of the mesh to create
  93139. * @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
  93140. * @param radius is the radius value of the lathe
  93141. * @param tessellation is the side number of the lathe.
  93142. * @param scene defines the hosting scene
  93143. * @param updatable defines if the mesh must be flagged as updatable
  93144. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93145. * @returns a new Mesh
  93146. */
  93147. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93148. /**
  93149. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  93150. * @param name defines the name of the mesh to create
  93151. * @param size sets the size (float) of both sides of the plane at once (default 1)
  93152. * @param scene defines the hosting scene
  93153. * @param updatable defines if the mesh must be flagged as updatable
  93154. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93155. * @returns a new Mesh
  93156. */
  93157. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  93158. /**
  93159. * Creates a ground mesh.
  93160. * Please consider using the same method from the MeshBuilder class instead
  93161. * @param name defines the name of the mesh to create
  93162. * @param width set the width of the ground
  93163. * @param height set the height of the ground
  93164. * @param subdivisions sets the number of subdivisions per side
  93165. * @param scene defines the hosting scene
  93166. * @param updatable defines if the mesh must be flagged as updatable
  93167. * @returns a new Mesh
  93168. */
  93169. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  93170. /**
  93171. * Creates a tiled ground mesh.
  93172. * Please consider using the same method from the MeshBuilder class instead
  93173. * @param name defines the name of the mesh to create
  93174. * @param xmin set the ground minimum X coordinate
  93175. * @param zmin set the ground minimum Y coordinate
  93176. * @param xmax set the ground maximum X coordinate
  93177. * @param zmax set the ground maximum Z coordinate
  93178. * @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
  93179. * @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
  93180. * @param scene defines the hosting scene
  93181. * @param updatable defines if the mesh must be flagged as updatable
  93182. * @returns a new Mesh
  93183. */
  93184. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  93185. w: number;
  93186. h: number;
  93187. }, precision: {
  93188. w: number;
  93189. h: number;
  93190. }, scene: Scene, updatable?: boolean): Mesh;
  93191. /**
  93192. * Creates a ground mesh from a height map.
  93193. * Please consider using the same method from the MeshBuilder class instead
  93194. * @see http://doc.babylonjs.com/babylon101/height_map
  93195. * @param name defines the name of the mesh to create
  93196. * @param url sets the URL of the height map image resource
  93197. * @param width set the ground width size
  93198. * @param height set the ground height size
  93199. * @param subdivisions sets the number of subdivision per side
  93200. * @param minHeight is the minimum altitude on the ground
  93201. * @param maxHeight is the maximum altitude on the ground
  93202. * @param scene defines the hosting scene
  93203. * @param updatable defines if the mesh must be flagged as updatable
  93204. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  93205. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  93206. * @returns a new Mesh
  93207. */
  93208. 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;
  93209. /**
  93210. * Creates a tube mesh.
  93211. * The tube is a parametric shape.
  93212. * It has no predefined shape. Its final shape will depend on the input parameters.
  93213. * Please consider using the same method from the MeshBuilder class instead
  93214. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  93215. * @param name defines the name of the mesh to create
  93216. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  93217. * @param radius sets the tube radius size
  93218. * @param tessellation is the number of sides on the tubular surface
  93219. * @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
  93220. * @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
  93221. * @param scene defines the hosting scene
  93222. * @param updatable defines if the mesh must be flagged as updatable
  93223. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  93224. * @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)
  93225. * @returns a new Mesh
  93226. */
  93227. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  93228. (i: number, distance: number): number;
  93229. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  93230. /**
  93231. * Creates a polyhedron mesh.
  93232. * Please consider using the same method from the MeshBuilder class instead.
  93233. * * 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
  93234. * * The parameter `size` (positive float, default 1) sets the polygon size
  93235. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  93236. * * 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`
  93237. * * 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
  93238. * * 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)`)
  93239. * * 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
  93240. * * 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
  93241. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93242. * * If you create a double-sided mesh, you can choose what parts of 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
  93243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93244. * @param name defines the name of the mesh to create
  93245. * @param options defines the options used to create the mesh
  93246. * @param scene defines the hosting scene
  93247. * @returns a new Mesh
  93248. */
  93249. static CreatePolyhedron(name: string, options: {
  93250. type?: number;
  93251. size?: number;
  93252. sizeX?: number;
  93253. sizeY?: number;
  93254. sizeZ?: number;
  93255. custom?: any;
  93256. faceUV?: Vector4[];
  93257. faceColors?: Color4[];
  93258. updatable?: boolean;
  93259. sideOrientation?: number;
  93260. }, scene: Scene): Mesh;
  93261. /**
  93262. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  93263. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  93264. * * 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`)
  93265. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  93266. * * 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
  93267. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93268. * * If you create a double-sided mesh, you can choose what parts of 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
  93269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93270. * @param name defines the name of the mesh
  93271. * @param options defines the options used to create the mesh
  93272. * @param scene defines the hosting scene
  93273. * @returns a new Mesh
  93274. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  93275. */
  93276. static CreateIcoSphere(name: string, options: {
  93277. radius?: number;
  93278. flat?: boolean;
  93279. subdivisions?: number;
  93280. sideOrientation?: number;
  93281. updatable?: boolean;
  93282. }, scene: Scene): Mesh;
  93283. /**
  93284. * Creates a decal mesh.
  93285. * Please consider using the same method from the MeshBuilder class instead.
  93286. * A decal is a mesh usually applied as a model onto the surface of another mesh
  93287. * @param name defines the name of the mesh
  93288. * @param sourceMesh defines the mesh receiving the decal
  93289. * @param position sets the position of the decal in world coordinates
  93290. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  93291. * @param size sets the decal scaling
  93292. * @param angle sets the angle to rotate the decal
  93293. * @returns a new Mesh
  93294. */
  93295. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  93296. /**
  93297. * Prepare internal position array for software CPU skinning
  93298. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  93299. */
  93300. setPositionsForCPUSkinning(): Float32Array;
  93301. /**
  93302. * Prepare internal normal array for software CPU skinning
  93303. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  93304. */
  93305. setNormalsForCPUSkinning(): Float32Array;
  93306. /**
  93307. * Updates the vertex buffer by applying transformation from the bones
  93308. * @param skeleton defines the skeleton to apply to current mesh
  93309. * @returns the current mesh
  93310. */
  93311. applySkeleton(skeleton: Skeleton): Mesh;
  93312. /**
  93313. * 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
  93314. * @param meshes defines the list of meshes to scan
  93315. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  93316. */
  93317. static MinMax(meshes: AbstractMesh[]): {
  93318. min: Vector3;
  93319. max: Vector3;
  93320. };
  93321. /**
  93322. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  93323. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  93324. * @returns a vector3
  93325. */
  93326. static Center(meshesOrMinMaxVector: {
  93327. min: Vector3;
  93328. max: Vector3;
  93329. } | AbstractMesh[]): Vector3;
  93330. /**
  93331. * Merge the array of meshes into a single mesh for performance reasons.
  93332. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  93333. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  93334. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  93335. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  93336. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  93337. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  93338. * @returns a new mesh
  93339. */
  93340. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  93341. /** @hidden */
  93342. addInstance(instance: InstancedMesh): void;
  93343. /** @hidden */
  93344. removeInstance(instance: InstancedMesh): void;
  93345. }
  93346. }
  93347. declare module BABYLON {
  93348. /**
  93349. * This is the base class of all the camera used in the application.
  93350. * @see http://doc.babylonjs.com/features/cameras
  93351. */
  93352. export class Camera extends Node {
  93353. /** @hidden */
  93354. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93355. /**
  93356. * This is the default projection mode used by the cameras.
  93357. * It helps recreating a feeling of perspective and better appreciate depth.
  93358. * This is the best way to simulate real life cameras.
  93359. */
  93360. static readonly PERSPECTIVE_CAMERA: number;
  93361. /**
  93362. * This helps creating camera with an orthographic mode.
  93363. * 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.
  93364. */
  93365. static readonly ORTHOGRAPHIC_CAMERA: number;
  93366. /**
  93367. * This is the default FOV mode for perspective cameras.
  93368. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93369. */
  93370. static readonly FOVMODE_VERTICAL_FIXED: number;
  93371. /**
  93372. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93373. */
  93374. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93375. /**
  93376. * This specifies ther is no need for a camera rig.
  93377. * Basically only one eye is rendered corresponding to the camera.
  93378. */
  93379. static readonly RIG_MODE_NONE: number;
  93380. /**
  93381. * Simulates a camera Rig with one blue eye and one red eye.
  93382. * This can be use with 3d blue and red glasses.
  93383. */
  93384. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93385. /**
  93386. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93387. */
  93388. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93389. /**
  93390. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93391. */
  93392. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93393. /**
  93394. * Defines that both eyes of the camera will be rendered over under each other.
  93395. */
  93396. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93397. /**
  93398. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93399. */
  93400. static readonly RIG_MODE_VR: number;
  93401. /**
  93402. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93403. */
  93404. static readonly RIG_MODE_WEBVR: number;
  93405. /**
  93406. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93407. */
  93408. static readonly RIG_MODE_CUSTOM: number;
  93409. /**
  93410. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93411. */
  93412. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93413. /**
  93414. * Define the input manager associated with the camera.
  93415. */
  93416. inputs: CameraInputsManager<Camera>;
  93417. /** @hidden */
  93418. _position: Vector3;
  93419. /**
  93420. * Define the current local position of the camera in the scene
  93421. */
  93422. position: Vector3;
  93423. /**
  93424. * The vector the camera should consider as up.
  93425. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93426. */
  93427. upVector: Vector3;
  93428. /**
  93429. * Define the current limit on the left side for an orthographic camera
  93430. * In scene unit
  93431. */
  93432. orthoLeft: Nullable<number>;
  93433. /**
  93434. * Define the current limit on the right side for an orthographic camera
  93435. * In scene unit
  93436. */
  93437. orthoRight: Nullable<number>;
  93438. /**
  93439. * Define the current limit on the bottom side for an orthographic camera
  93440. * In scene unit
  93441. */
  93442. orthoBottom: Nullable<number>;
  93443. /**
  93444. * Define the current limit on the top side for an orthographic camera
  93445. * In scene unit
  93446. */
  93447. orthoTop: Nullable<number>;
  93448. /**
  93449. * Field Of View is set in Radians. (default is 0.8)
  93450. */
  93451. fov: number;
  93452. /**
  93453. * Define the minimum distance the camera can see from.
  93454. * This is important to note that the depth buffer are not infinite and the closer it starts
  93455. * the more your scene might encounter depth fighting issue.
  93456. */
  93457. minZ: number;
  93458. /**
  93459. * Define the maximum distance the camera can see to.
  93460. * This is important to note that the depth buffer are not infinite and the further it end
  93461. * the more your scene might encounter depth fighting issue.
  93462. */
  93463. maxZ: number;
  93464. /**
  93465. * Define the default inertia of the camera.
  93466. * This helps giving a smooth feeling to the camera movement.
  93467. */
  93468. inertia: number;
  93469. /**
  93470. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93471. */
  93472. mode: number;
  93473. /**
  93474. * Define wether the camera is intermediate.
  93475. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93476. */
  93477. isIntermediate: boolean;
  93478. /**
  93479. * Define the viewport of the camera.
  93480. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93481. */
  93482. viewport: Viewport;
  93483. /**
  93484. * Restricts the camera to viewing objects with the same layerMask.
  93485. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93486. */
  93487. layerMask: number;
  93488. /**
  93489. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93490. */
  93491. fovMode: number;
  93492. /**
  93493. * Rig mode of the camera.
  93494. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93495. * This is normally controlled byt the camera themselves as internal use.
  93496. */
  93497. cameraRigMode: number;
  93498. /**
  93499. * Defines the distance between both "eyes" in case of a RIG
  93500. */
  93501. interaxialDistance: number;
  93502. /**
  93503. * Defines if stereoscopic rendering is done side by side or over under.
  93504. */
  93505. isStereoscopicSideBySide: boolean;
  93506. /**
  93507. * 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
  93508. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93509. * else in the scene. (Eg. security camera)
  93510. *
  93511. * 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)
  93512. */
  93513. customRenderTargets: RenderTargetTexture[];
  93514. /**
  93515. * When set, the camera will render to this render target instead of the default canvas
  93516. *
  93517. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  93518. */
  93519. outputRenderTarget: Nullable<RenderTargetTexture>;
  93520. /**
  93521. * Observable triggered when the camera view matrix has changed.
  93522. */
  93523. onViewMatrixChangedObservable: Observable<Camera>;
  93524. /**
  93525. * Observable triggered when the camera Projection matrix has changed.
  93526. */
  93527. onProjectionMatrixChangedObservable: Observable<Camera>;
  93528. /**
  93529. * Observable triggered when the inputs have been processed.
  93530. */
  93531. onAfterCheckInputsObservable: Observable<Camera>;
  93532. /**
  93533. * Observable triggered when reset has been called and applied to the camera.
  93534. */
  93535. onRestoreStateObservable: Observable<Camera>;
  93536. /** @hidden */
  93537. _cameraRigParams: any;
  93538. /** @hidden */
  93539. _rigCameras: Camera[];
  93540. /** @hidden */
  93541. _rigPostProcess: Nullable<PostProcess>;
  93542. protected _webvrViewMatrix: Matrix;
  93543. /** @hidden */
  93544. _skipRendering: boolean;
  93545. /** @hidden */
  93546. _projectionMatrix: Matrix;
  93547. /** @hidden */
  93548. _postProcesses: Nullable<PostProcess>[];
  93549. /** @hidden */
  93550. _activeMeshes: SmartArray<AbstractMesh>;
  93551. protected _globalPosition: Vector3;
  93552. /** @hidden */
  93553. _computedViewMatrix: Matrix;
  93554. private _doNotComputeProjectionMatrix;
  93555. private _transformMatrix;
  93556. private _frustumPlanes;
  93557. private _refreshFrustumPlanes;
  93558. private _storedFov;
  93559. private _stateStored;
  93560. /**
  93561. * Instantiates a new camera object.
  93562. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93563. * @see http://doc.babylonjs.com/features/cameras
  93564. * @param name Defines the name of the camera in the scene
  93565. * @param position Defines the position of the camera
  93566. * @param scene Defines the scene the camera belongs too
  93567. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93568. */
  93569. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93570. /**
  93571. * Store current camera state (fov, position, etc..)
  93572. * @returns the camera
  93573. */
  93574. storeState(): Camera;
  93575. /**
  93576. * Restores the camera state values if it has been stored. You must call storeState() first
  93577. */
  93578. protected _restoreStateValues(): boolean;
  93579. /**
  93580. * Restored camera state. You must call storeState() first.
  93581. * @returns true if restored and false otherwise
  93582. */
  93583. restoreState(): boolean;
  93584. /**
  93585. * Gets the class name of the camera.
  93586. * @returns the class name
  93587. */
  93588. getClassName(): string;
  93589. /** @hidden */
  93590. readonly _isCamera: boolean;
  93591. /**
  93592. * Gets a string representation of the camera useful for debug purpose.
  93593. * @param fullDetails Defines that a more verboe level of logging is required
  93594. * @returns the string representation
  93595. */
  93596. toString(fullDetails?: boolean): string;
  93597. /**
  93598. * Gets the current world space position of the camera.
  93599. */
  93600. readonly globalPosition: Vector3;
  93601. /**
  93602. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93603. * @returns the active meshe list
  93604. */
  93605. getActiveMeshes(): SmartArray<AbstractMesh>;
  93606. /**
  93607. * Check wether a mesh is part of the current active mesh list of the camera
  93608. * @param mesh Defines the mesh to check
  93609. * @returns true if active, false otherwise
  93610. */
  93611. isActiveMesh(mesh: Mesh): boolean;
  93612. /**
  93613. * Is this camera ready to be used/rendered
  93614. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93615. * @return true if the camera is ready
  93616. */
  93617. isReady(completeCheck?: boolean): boolean;
  93618. /** @hidden */
  93619. _initCache(): void;
  93620. /** @hidden */
  93621. _updateCache(ignoreParentClass?: boolean): void;
  93622. /** @hidden */
  93623. _isSynchronized(): boolean;
  93624. /** @hidden */
  93625. _isSynchronizedViewMatrix(): boolean;
  93626. /** @hidden */
  93627. _isSynchronizedProjectionMatrix(): boolean;
  93628. /**
  93629. * Attach the input controls to a specific dom element to get the input from.
  93630. * @param element Defines the element the controls should be listened from
  93631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93632. */
  93633. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93634. /**
  93635. * Detach the current controls from the specified dom element.
  93636. * @param element Defines the element to stop listening the inputs from
  93637. */
  93638. detachControl(element: HTMLElement): void;
  93639. /**
  93640. * Update the camera state according to the different inputs gathered during the frame.
  93641. */
  93642. update(): void;
  93643. /** @hidden */
  93644. _checkInputs(): void;
  93645. /** @hidden */
  93646. readonly rigCameras: Camera[];
  93647. /**
  93648. * Gets the post process used by the rig cameras
  93649. */
  93650. readonly rigPostProcess: Nullable<PostProcess>;
  93651. /**
  93652. * Internal, gets the first post proces.
  93653. * @returns the first post process to be run on this camera.
  93654. */
  93655. _getFirstPostProcess(): Nullable<PostProcess>;
  93656. private _cascadePostProcessesToRigCams;
  93657. /**
  93658. * Attach a post process to the camera.
  93659. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93660. * @param postProcess The post process to attach to the camera
  93661. * @param insertAt The position of the post process in case several of them are in use in the scene
  93662. * @returns the position the post process has been inserted at
  93663. */
  93664. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93665. /**
  93666. * Detach a post process to the camera.
  93667. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93668. * @param postProcess The post process to detach from the camera
  93669. */
  93670. detachPostProcess(postProcess: PostProcess): void;
  93671. /**
  93672. * Gets the current world matrix of the camera
  93673. */
  93674. getWorldMatrix(): Matrix;
  93675. /** @hidden */
  93676. _getViewMatrix(): Matrix;
  93677. /**
  93678. * Gets the current view matrix of the camera.
  93679. * @param force forces the camera to recompute the matrix without looking at the cached state
  93680. * @returns the view matrix
  93681. */
  93682. getViewMatrix(force?: boolean): Matrix;
  93683. /**
  93684. * Freeze the projection matrix.
  93685. * It will prevent the cache check of the camera projection compute and can speed up perf
  93686. * if no parameter of the camera are meant to change
  93687. * @param projection Defines manually a projection if necessary
  93688. */
  93689. freezeProjectionMatrix(projection?: Matrix): void;
  93690. /**
  93691. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93692. */
  93693. unfreezeProjectionMatrix(): void;
  93694. /**
  93695. * Gets the current projection matrix of the camera.
  93696. * @param force forces the camera to recompute the matrix without looking at the cached state
  93697. * @returns the projection matrix
  93698. */
  93699. getProjectionMatrix(force?: boolean): Matrix;
  93700. /**
  93701. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93702. * @returns a Matrix
  93703. */
  93704. getTransformationMatrix(): Matrix;
  93705. private _updateFrustumPlanes;
  93706. /**
  93707. * Checks if a cullable object (mesh...) is in the camera frustum
  93708. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93709. * @param target The object to check
  93710. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93711. * @returns true if the object is in frustum otherwise false
  93712. */
  93713. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93714. /**
  93715. * Checks if a cullable object (mesh...) is in the camera frustum
  93716. * Unlike isInFrustum this cheks the full bounding box
  93717. * @param target The object to check
  93718. * @returns true if the object is in frustum otherwise false
  93719. */
  93720. isCompletelyInFrustum(target: ICullable): boolean;
  93721. /**
  93722. * Gets a ray in the forward direction from the camera.
  93723. * @param length Defines the length of the ray to create
  93724. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93725. * @param origin Defines the start point of the ray which defaults to the camera position
  93726. * @returns the forward ray
  93727. */
  93728. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93729. /**
  93730. * Releases resources associated with this node.
  93731. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93732. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93733. */
  93734. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93735. /** @hidden */
  93736. _isLeftCamera: boolean;
  93737. /**
  93738. * Gets the left camera of a rig setup in case of Rigged Camera
  93739. */
  93740. readonly isLeftCamera: boolean;
  93741. /** @hidden */
  93742. _isRightCamera: boolean;
  93743. /**
  93744. * Gets the right camera of a rig setup in case of Rigged Camera
  93745. */
  93746. readonly isRightCamera: boolean;
  93747. /**
  93748. * Gets the left camera of a rig setup in case of Rigged Camera
  93749. */
  93750. readonly leftCamera: Nullable<FreeCamera>;
  93751. /**
  93752. * Gets the right camera of a rig setup in case of Rigged Camera
  93753. */
  93754. readonly rightCamera: Nullable<FreeCamera>;
  93755. /**
  93756. * Gets the left camera target of a rig setup in case of Rigged Camera
  93757. * @returns the target position
  93758. */
  93759. getLeftTarget(): Nullable<Vector3>;
  93760. /**
  93761. * Gets the right camera target of a rig setup in case of Rigged Camera
  93762. * @returns the target position
  93763. */
  93764. getRightTarget(): Nullable<Vector3>;
  93765. /**
  93766. * @hidden
  93767. */
  93768. setCameraRigMode(mode: number, rigParams: any): void;
  93769. /** @hidden */
  93770. static _setStereoscopicRigMode(camera: Camera): void;
  93771. /** @hidden */
  93772. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93773. /** @hidden */
  93774. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93775. /** @hidden */
  93776. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93777. /** @hidden */
  93778. _getVRProjectionMatrix(): Matrix;
  93779. protected _updateCameraRotationMatrix(): void;
  93780. protected _updateWebVRCameraRotationMatrix(): void;
  93781. /**
  93782. * This function MUST be overwritten by the different WebVR cameras available.
  93783. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93784. * @hidden
  93785. */
  93786. _getWebVRProjectionMatrix(): Matrix;
  93787. /**
  93788. * This function MUST be overwritten by the different WebVR cameras available.
  93789. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93790. * @hidden
  93791. */
  93792. _getWebVRViewMatrix(): Matrix;
  93793. /** @hidden */
  93794. setCameraRigParameter(name: string, value: any): void;
  93795. /**
  93796. * needs to be overridden by children so sub has required properties to be copied
  93797. * @hidden
  93798. */
  93799. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93800. /**
  93801. * May need to be overridden by children
  93802. * @hidden
  93803. */
  93804. _updateRigCameras(): void;
  93805. /** @hidden */
  93806. _setupInputs(): void;
  93807. /**
  93808. * Serialiaze the camera setup to a json represention
  93809. * @returns the JSON representation
  93810. */
  93811. serialize(): any;
  93812. /**
  93813. * Clones the current camera.
  93814. * @param name The cloned camera name
  93815. * @returns the cloned camera
  93816. */
  93817. clone(name: string): Camera;
  93818. /**
  93819. * Gets the direction of the camera relative to a given local axis.
  93820. * @param localAxis Defines the reference axis to provide a relative direction.
  93821. * @return the direction
  93822. */
  93823. getDirection(localAxis: Vector3): Vector3;
  93824. /**
  93825. * Returns the current camera absolute rotation
  93826. */
  93827. readonly absoluteRotation: Quaternion;
  93828. /**
  93829. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93830. * @param localAxis Defines the reference axis to provide a relative direction.
  93831. * @param result Defines the vector to store the result in
  93832. */
  93833. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93834. /**
  93835. * Gets a camera constructor for a given camera type
  93836. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93837. * @param name The name of the camera the result will be able to instantiate
  93838. * @param scene The scene the result will construct the camera in
  93839. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93840. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93841. * @returns a factory method to construc the camera
  93842. */
  93843. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93844. /**
  93845. * Compute the world matrix of the camera.
  93846. * @returns the camera world matrix
  93847. */
  93848. computeWorldMatrix(): Matrix;
  93849. /**
  93850. * Parse a JSON and creates the camera from the parsed information
  93851. * @param parsedCamera The JSON to parse
  93852. * @param scene The scene to instantiate the camera in
  93853. * @returns the newly constructed camera
  93854. */
  93855. static Parse(parsedCamera: any, scene: Scene): Camera;
  93856. }
  93857. }
  93858. declare module BABYLON {
  93859. /**
  93860. * Class containing static functions to help procedurally build meshes
  93861. */
  93862. export class DiscBuilder {
  93863. /**
  93864. * Creates a plane polygonal mesh. By default, this is a disc
  93865. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  93866. * * 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
  93867. * * 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
  93868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93871. * @param name defines the name of the mesh
  93872. * @param options defines the options used to create the mesh
  93873. * @param scene defines the hosting scene
  93874. * @returns the plane polygonal mesh
  93875. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  93876. */
  93877. static CreateDisc(name: string, options: {
  93878. radius?: number;
  93879. tessellation?: number;
  93880. arc?: number;
  93881. updatable?: boolean;
  93882. sideOrientation?: number;
  93883. frontUVs?: Vector4;
  93884. backUVs?: Vector4;
  93885. }, scene?: Nullable<Scene>): Mesh;
  93886. }
  93887. }
  93888. declare module BABYLON {
  93889. /**
  93890. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  93891. *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.
  93892. * The SPS is also a particle system. It provides some methods to manage the particles.
  93893. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  93894. *
  93895. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  93896. */
  93897. export class SolidParticleSystem implements IDisposable {
  93898. /**
  93899. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  93900. * Example : var p = SPS.particles[i];
  93901. */
  93902. particles: SolidParticle[];
  93903. /**
  93904. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  93905. */
  93906. nbParticles: number;
  93907. /**
  93908. * If the particles must ever face the camera (default false). Useful for planar particles.
  93909. */
  93910. billboard: boolean;
  93911. /**
  93912. * Recompute normals when adding a shape
  93913. */
  93914. recomputeNormals: boolean;
  93915. /**
  93916. * This a counter ofr your own usage. It's not set by any SPS functions.
  93917. */
  93918. counter: number;
  93919. /**
  93920. * The SPS name. This name is also given to the underlying mesh.
  93921. */
  93922. name: string;
  93923. /**
  93924. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  93925. */
  93926. mesh: Mesh;
  93927. /**
  93928. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  93929. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  93930. */
  93931. vars: any;
  93932. /**
  93933. * This array is populated when the SPS is set as 'pickable'.
  93934. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  93935. * Each element of this array is an object `{idx: int, faceId: int}`.
  93936. * `idx` is the picked particle index in the `SPS.particles` array
  93937. * `faceId` is the picked face index counted within this particle.
  93938. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  93939. */
  93940. pickedParticles: {
  93941. idx: number;
  93942. faceId: number;
  93943. }[];
  93944. /**
  93945. * This array is populated when `enableDepthSort` is set to true.
  93946. * Each element of this array is an instance of the class DepthSortedParticle.
  93947. */
  93948. depthSortedParticles: DepthSortedParticle[];
  93949. /**
  93950. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  93951. * @hidden
  93952. */
  93953. _bSphereOnly: boolean;
  93954. /**
  93955. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  93956. * @hidden
  93957. */
  93958. _bSphereRadiusFactor: number;
  93959. private _scene;
  93960. private _positions;
  93961. private _indices;
  93962. private _normals;
  93963. private _colors;
  93964. private _uvs;
  93965. private _indices32;
  93966. private _positions32;
  93967. private _normals32;
  93968. private _fixedNormal32;
  93969. private _colors32;
  93970. private _uvs32;
  93971. private _index;
  93972. private _updatable;
  93973. private _pickable;
  93974. private _isVisibilityBoxLocked;
  93975. private _alwaysVisible;
  93976. private _depthSort;
  93977. private _expandable;
  93978. private _shapeCounter;
  93979. private _copy;
  93980. private _color;
  93981. private _computeParticleColor;
  93982. private _computeParticleTexture;
  93983. private _computeParticleRotation;
  93984. private _computeParticleVertex;
  93985. private _computeBoundingBox;
  93986. private _depthSortParticles;
  93987. private _camera;
  93988. private _mustUnrotateFixedNormals;
  93989. private _particlesIntersect;
  93990. private _needs32Bits;
  93991. private _isNotBuilt;
  93992. private _lastParticleId;
  93993. private _idxOfId;
  93994. /**
  93995. * Creates a SPS (Solid Particle System) object.
  93996. * @param name (String) is the SPS name, this will be the underlying mesh name.
  93997. * @param scene (Scene) is the scene in which the SPS is added.
  93998. * @param options defines the options of the sps e.g.
  93999. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  94000. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  94001. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  94002. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  94003. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  94004. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  94005. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  94006. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  94007. */
  94008. constructor(name: string, scene: Scene, options?: {
  94009. updatable?: boolean;
  94010. isPickable?: boolean;
  94011. enableDepthSort?: boolean;
  94012. particleIntersection?: boolean;
  94013. boundingSphereOnly?: boolean;
  94014. bSphereRadiusFactor?: number;
  94015. expandable?: boolean;
  94016. });
  94017. /**
  94018. * Builds the SPS underlying mesh. Returns a standard Mesh.
  94019. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  94020. * @returns the created mesh
  94021. */
  94022. buildMesh(): Mesh;
  94023. /**
  94024. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  94025. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  94026. * Thus the particles generated from `digest()` have their property `position` set yet.
  94027. * @param mesh ( Mesh ) is the mesh to be digested
  94028. * @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
  94029. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  94030. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  94031. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  94032. * @returns the current SPS
  94033. */
  94034. digest(mesh: Mesh, options?: {
  94035. facetNb?: number;
  94036. number?: number;
  94037. delta?: number;
  94038. storage?: [];
  94039. }): SolidParticleSystem;
  94040. /**
  94041. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  94042. * @hidden
  94043. */
  94044. private _unrotateFixedNormals;
  94045. /**
  94046. * Resets the temporary working copy particle
  94047. * @hidden
  94048. */
  94049. private _resetCopy;
  94050. /**
  94051. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  94052. * @param p the current index in the positions array to be updated
  94053. * @param shape a Vector3 array, the shape geometry
  94054. * @param positions the positions array to be updated
  94055. * @param meshInd the shape indices array
  94056. * @param indices the indices array to be updated
  94057. * @param meshUV the shape uv array
  94058. * @param uvs the uv array to be updated
  94059. * @param meshCol the shape color array
  94060. * @param colors the color array to be updated
  94061. * @param meshNor the shape normals array
  94062. * @param normals the normals array to be updated
  94063. * @param idx the particle index
  94064. * @param idxInShape the particle index in its shape
  94065. * @param options the addShape() method passed options
  94066. * @hidden
  94067. */
  94068. private _meshBuilder;
  94069. /**
  94070. * Returns a shape Vector3 array from positions float array
  94071. * @param positions float array
  94072. * @returns a vector3 array
  94073. * @hidden
  94074. */
  94075. private _posToShape;
  94076. /**
  94077. * Returns a shapeUV array from a float uvs (array deep copy)
  94078. * @param uvs as a float array
  94079. * @returns a shapeUV array
  94080. * @hidden
  94081. */
  94082. private _uvsToShapeUV;
  94083. /**
  94084. * Adds a new particle object in the particles array
  94085. * @param idx particle index in particles array
  94086. * @param id particle id
  94087. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  94088. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  94089. * @param model particle ModelShape object
  94090. * @param shapeId model shape identifier
  94091. * @param idxInShape index of the particle in the current model
  94092. * @param bInfo model bounding info object
  94093. * @param storage target storage array, if any
  94094. * @hidden
  94095. */
  94096. private _addParticle;
  94097. /**
  94098. * Adds some particles to the SPS from the model shape. Returns the shape id.
  94099. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  94100. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  94101. * @param nb (positive integer) the number of particles to be created from this model
  94102. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  94103. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  94104. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  94105. * @returns the number of shapes in the system
  94106. */
  94107. addShape(mesh: Mesh, nb: number, options?: {
  94108. positionFunction?: any;
  94109. vertexFunction?: any;
  94110. storage?: [];
  94111. }): number;
  94112. /**
  94113. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  94114. * @hidden
  94115. */
  94116. private _rebuildParticle;
  94117. /**
  94118. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  94119. * @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.
  94120. * @returns the SPS.
  94121. */
  94122. rebuildMesh(reset?: boolean): SolidParticleSystem;
  94123. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  94124. * Returns an array with the removed particles.
  94125. * 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.
  94126. * The SPS can't be empty so at least one particle needs to remain in place.
  94127. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  94128. * @param start index of the first particle to remove
  94129. * @param end index of the last particle to remove (included)
  94130. * @returns an array populated with the removed particles
  94131. */
  94132. removeParticles(start: number, end: number): SolidParticle[];
  94133. /**
  94134. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  94135. * @param solidParticleArray an array populated with Solid Particles objects
  94136. * @returns the SPS
  94137. */
  94138. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  94139. /**
  94140. * Creates a new particle and modifies the SPS mesh geometry :
  94141. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  94142. * - calls _addParticle() to populate the particle array
  94143. * factorized code from addShape() and insertParticlesFromArray()
  94144. * @param idx particle index in the particles array
  94145. * @param i particle index in its shape
  94146. * @param modelShape particle ModelShape object
  94147. * @param shape shape vertex array
  94148. * @param meshInd shape indices array
  94149. * @param meshUV shape uv array
  94150. * @param meshCol shape color array
  94151. * @param meshNor shape normals array
  94152. * @param bbInfo shape bounding info
  94153. * @param storage target particle storage
  94154. * @options addShape() passed options
  94155. * @hidden
  94156. */
  94157. private _insertNewParticle;
  94158. /**
  94159. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  94160. * This method calls `updateParticle()` for each particle of the SPS.
  94161. * For an animated SPS, it is usually called within the render loop.
  94162. * 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.
  94163. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  94164. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  94165. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  94166. * @returns the SPS.
  94167. */
  94168. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  94169. /**
  94170. * Disposes the SPS.
  94171. */
  94172. dispose(): void;
  94173. /**
  94174. * Returns a SolidParticle object from its identifier : particle.id
  94175. * @param id (integer) the particle Id
  94176. * @returns the searched particle or null if not found in the SPS.
  94177. */
  94178. getParticleById(id: number): Nullable<SolidParticle>;
  94179. /**
  94180. * Returns a new array populated with the particles having the passed shapeId.
  94181. * @param shapeId (integer) the shape identifier
  94182. * @returns a new solid particle array
  94183. */
  94184. getParticlesByShapeId(shapeId: number): SolidParticle[];
  94185. /**
  94186. * Populates the passed array "ref" with the particles having the passed shapeId.
  94187. * @param shapeId the shape identifier
  94188. * @returns the SPS
  94189. * @param ref
  94190. */
  94191. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  94192. /**
  94193. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  94194. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94195. * @returns the SPS.
  94196. */
  94197. refreshVisibleSize(): SolidParticleSystem;
  94198. /**
  94199. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  94200. * @param size the size (float) of the visibility box
  94201. * note : this doesn't lock the SPS mesh bounding box.
  94202. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94203. */
  94204. setVisibilityBox(size: number): void;
  94205. /**
  94206. * Gets whether the SPS as always visible or not
  94207. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94208. */
  94209. /**
  94210. * Sets the SPS as always visible or not
  94211. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94212. */
  94213. isAlwaysVisible: boolean;
  94214. /**
  94215. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  94216. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94217. */
  94218. /**
  94219. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  94220. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  94221. */
  94222. isVisibilityBoxLocked: boolean;
  94223. /**
  94224. * Tells to `setParticles()` to compute the particle rotations or not.
  94225. * Default value : true. The SPS is faster when it's set to false.
  94226. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  94227. */
  94228. /**
  94229. * Gets if `setParticles()` computes the particle rotations or not.
  94230. * Default value : true. The SPS is faster when it's set to false.
  94231. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  94232. */
  94233. computeParticleRotation: boolean;
  94234. /**
  94235. * Tells to `setParticles()` to compute the particle colors or not.
  94236. * Default value : true. The SPS is faster when it's set to false.
  94237. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  94238. */
  94239. /**
  94240. * Gets if `setParticles()` computes the particle colors or not.
  94241. * Default value : true. The SPS is faster when it's set to false.
  94242. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  94243. */
  94244. computeParticleColor: boolean;
  94245. /**
  94246. * Gets if `setParticles()` computes the particle textures or not.
  94247. * Default value : true. The SPS is faster when it's set to false.
  94248. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  94249. */
  94250. computeParticleTexture: boolean;
  94251. /**
  94252. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  94253. * Default value : false. The SPS is faster when it's set to false.
  94254. * Note : the particle custom vertex positions aren't stored values.
  94255. */
  94256. /**
  94257. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  94258. * Default value : false. The SPS is faster when it's set to false.
  94259. * Note : the particle custom vertex positions aren't stored values.
  94260. */
  94261. computeParticleVertex: boolean;
  94262. /**
  94263. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  94264. */
  94265. /**
  94266. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  94267. */
  94268. computeBoundingBox: boolean;
  94269. /**
  94270. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  94271. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94272. * Default : `true`
  94273. */
  94274. /**
  94275. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  94276. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  94277. * Default : `true`
  94278. */
  94279. depthSortParticles: boolean;
  94280. /**
  94281. * Gets if the SPS is created as expandable at construction time.
  94282. * Default : `false`
  94283. */
  94284. readonly expandable: boolean;
  94285. /**
  94286. * This function does nothing. It may be overwritten to set all the particle first values.
  94287. * The SPS doesn't call this function, you may have to call it by your own.
  94288. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94289. */
  94290. initParticles(): void;
  94291. /**
  94292. * This function does nothing. It may be overwritten to recycle a particle.
  94293. * The SPS doesn't call this function, you may have to call it by your own.
  94294. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94295. * @param particle The particle to recycle
  94296. * @returns the recycled particle
  94297. */
  94298. recycleParticle(particle: SolidParticle): SolidParticle;
  94299. /**
  94300. * Updates a particle : this function should be overwritten by the user.
  94301. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  94302. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  94303. * @example : just set a particle position or velocity and recycle conditions
  94304. * @param particle The particle to update
  94305. * @returns the updated particle
  94306. */
  94307. updateParticle(particle: SolidParticle): SolidParticle;
  94308. /**
  94309. * Updates a vertex of a particle : it can be overwritten by the user.
  94310. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  94311. * @param particle the current particle
  94312. * @param vertex the current index of the current particle
  94313. * @param pt the index of the current vertex in the particle shape
  94314. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  94315. * @example : just set a vertex particle position
  94316. * @returns the updated vertex
  94317. */
  94318. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  94319. /**
  94320. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  94321. * This does nothing and may be overwritten by the user.
  94322. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94323. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94324. * @param update the boolean update value actually passed to setParticles()
  94325. */
  94326. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94327. /**
  94328. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  94329. * This will be passed three parameters.
  94330. * This does nothing and may be overwritten by the user.
  94331. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94332. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  94333. * @param update the boolean update value actually passed to setParticles()
  94334. */
  94335. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  94336. }
  94337. }
  94338. declare module BABYLON {
  94339. /**
  94340. * Represents one particle of a solid particle system.
  94341. */
  94342. export class SolidParticle {
  94343. /**
  94344. * particle global index
  94345. */
  94346. idx: number;
  94347. /**
  94348. * particle identifier
  94349. */
  94350. id: number;
  94351. /**
  94352. * The color of the particle
  94353. */
  94354. color: Nullable<Color4>;
  94355. /**
  94356. * The world space position of the particle.
  94357. */
  94358. position: Vector3;
  94359. /**
  94360. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  94361. */
  94362. rotation: Vector3;
  94363. /**
  94364. * The world space rotation quaternion of the particle.
  94365. */
  94366. rotationQuaternion: Nullable<Quaternion>;
  94367. /**
  94368. * The scaling of the particle.
  94369. */
  94370. scaling: Vector3;
  94371. /**
  94372. * The uvs of the particle.
  94373. */
  94374. uvs: Vector4;
  94375. /**
  94376. * The current speed of the particle.
  94377. */
  94378. velocity: Vector3;
  94379. /**
  94380. * The pivot point in the particle local space.
  94381. */
  94382. pivot: Vector3;
  94383. /**
  94384. * Must the particle be translated from its pivot point in its local space ?
  94385. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  94386. * Default : false
  94387. */
  94388. translateFromPivot: boolean;
  94389. /**
  94390. * Is the particle active or not ?
  94391. */
  94392. alive: boolean;
  94393. /**
  94394. * Is the particle visible or not ?
  94395. */
  94396. isVisible: boolean;
  94397. /**
  94398. * Index of this particle in the global "positions" array (Internal use)
  94399. * @hidden
  94400. */
  94401. _pos: number;
  94402. /**
  94403. * @hidden Index of this particle in the global "indices" array (Internal use)
  94404. */
  94405. _ind: number;
  94406. /**
  94407. * @hidden ModelShape of this particle (Internal use)
  94408. */
  94409. _model: ModelShape;
  94410. /**
  94411. * ModelShape id of this particle
  94412. */
  94413. shapeId: number;
  94414. /**
  94415. * Index of the particle in its shape id
  94416. */
  94417. idxInShape: number;
  94418. /**
  94419. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  94420. */
  94421. _modelBoundingInfo: BoundingInfo;
  94422. /**
  94423. * @hidden Particle BoundingInfo object (Internal use)
  94424. */
  94425. _boundingInfo: BoundingInfo;
  94426. /**
  94427. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  94428. */
  94429. _sps: SolidParticleSystem;
  94430. /**
  94431. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  94432. */
  94433. _stillInvisible: boolean;
  94434. /**
  94435. * @hidden Last computed particle rotation matrix
  94436. */
  94437. _rotationMatrix: number[];
  94438. /**
  94439. * Parent particle Id, if any.
  94440. * Default null.
  94441. */
  94442. parentId: Nullable<number>;
  94443. /**
  94444. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  94445. * The possible values are :
  94446. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94447. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94448. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94449. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94450. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94451. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  94452. * */
  94453. cullingStrategy: number;
  94454. /**
  94455. * @hidden Internal global position in the SPS.
  94456. */
  94457. _globalPosition: Vector3;
  94458. /**
  94459. * Creates a Solid Particle object.
  94460. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  94461. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  94462. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  94463. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  94464. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  94465. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  94466. * @param shapeId (integer) is the model shape identifier in the SPS.
  94467. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  94468. * @param sps defines the sps it is associated to
  94469. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  94470. */
  94471. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  94472. /**
  94473. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  94474. * @param target the particle target
  94475. * @returns the current particle
  94476. */
  94477. copyToRef(target: SolidParticle): SolidParticle;
  94478. /**
  94479. * Legacy support, changed scale to scaling
  94480. */
  94481. /**
  94482. * Legacy support, changed scale to scaling
  94483. */
  94484. scale: Vector3;
  94485. /**
  94486. * Legacy support, changed quaternion to rotationQuaternion
  94487. */
  94488. /**
  94489. * Legacy support, changed quaternion to rotationQuaternion
  94490. */
  94491. quaternion: Nullable<Quaternion>;
  94492. /**
  94493. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  94494. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  94495. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  94496. * @returns true if it intersects
  94497. */
  94498. intersectsMesh(target: Mesh | SolidParticle): boolean;
  94499. /**
  94500. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  94501. * A particle is in the frustum if its bounding box intersects the frustum
  94502. * @param frustumPlanes defines the frustum to test
  94503. * @returns true if the particle is in the frustum planes
  94504. */
  94505. isInFrustum(frustumPlanes: Plane[]): boolean;
  94506. /**
  94507. * get the rotation matrix of the particle
  94508. * @hidden
  94509. */
  94510. getRotationMatrix(m: Matrix): void;
  94511. }
  94512. /**
  94513. * Represents the shape of the model used by one particle of a solid particle system.
  94514. * SPS internal tool, don't use it manually.
  94515. */
  94516. export class ModelShape {
  94517. /**
  94518. * The shape id
  94519. * @hidden
  94520. */
  94521. shapeID: number;
  94522. /**
  94523. * flat array of model positions (internal use)
  94524. * @hidden
  94525. */
  94526. _shape: Vector3[];
  94527. /**
  94528. * flat array of model UVs (internal use)
  94529. * @hidden
  94530. */
  94531. _shapeUV: number[];
  94532. /**
  94533. * color array of the model
  94534. * @hidden
  94535. */
  94536. _shapeColors: number[];
  94537. /**
  94538. * indices array of the model
  94539. * @hidden
  94540. */
  94541. _indices: number[];
  94542. /**
  94543. * normals array of the model
  94544. * @hidden
  94545. */
  94546. _normals: number[];
  94547. /**
  94548. * length of the shape in the model indices array (internal use)
  94549. * @hidden
  94550. */
  94551. _indicesLength: number;
  94552. /**
  94553. * Custom position function (internal use)
  94554. * @hidden
  94555. */
  94556. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  94557. /**
  94558. * Custom vertex function (internal use)
  94559. * @hidden
  94560. */
  94561. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  94562. /**
  94563. * 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.
  94564. * SPS internal tool, don't use it manually.
  94565. * @hidden
  94566. */
  94567. 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>);
  94568. }
  94569. /**
  94570. * Represents a Depth Sorted Particle in the solid particle system.
  94571. */
  94572. export class DepthSortedParticle {
  94573. /**
  94574. * Index of the particle in the "indices" array
  94575. */
  94576. ind: number;
  94577. /**
  94578. * Length of the particle shape in the "indices" array
  94579. */
  94580. indicesLength: number;
  94581. /**
  94582. * Squared distance from the particle to the camera
  94583. */
  94584. sqDistance: number;
  94585. }
  94586. }
  94587. declare module BABYLON {
  94588. /**
  94589. * @hidden
  94590. */
  94591. export class _MeshCollisionData {
  94592. _checkCollisions: boolean;
  94593. _collisionMask: number;
  94594. _collisionGroup: number;
  94595. _collider: Nullable<Collider>;
  94596. _oldPositionForCollisions: Vector3;
  94597. _diffPositionForCollisions: Vector3;
  94598. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  94599. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  94600. }
  94601. }
  94602. declare module BABYLON {
  94603. /** @hidden */
  94604. class _FacetDataStorage {
  94605. facetPositions: Vector3[];
  94606. facetNormals: Vector3[];
  94607. facetPartitioning: number[][];
  94608. facetNb: number;
  94609. partitioningSubdivisions: number;
  94610. partitioningBBoxRatio: number;
  94611. facetDataEnabled: boolean;
  94612. facetParameters: any;
  94613. bbSize: Vector3;
  94614. subDiv: {
  94615. max: number;
  94616. X: number;
  94617. Y: number;
  94618. Z: number;
  94619. };
  94620. facetDepthSort: boolean;
  94621. facetDepthSortEnabled: boolean;
  94622. depthSortedIndices: IndicesArray;
  94623. depthSortedFacets: {
  94624. ind: number;
  94625. sqDistance: number;
  94626. }[];
  94627. facetDepthSortFunction: (f1: {
  94628. ind: number;
  94629. sqDistance: number;
  94630. }, f2: {
  94631. ind: number;
  94632. sqDistance: number;
  94633. }) => number;
  94634. facetDepthSortFrom: Vector3;
  94635. facetDepthSortOrigin: Vector3;
  94636. invertedMatrix: Matrix;
  94637. }
  94638. /**
  94639. * @hidden
  94640. **/
  94641. class _InternalAbstractMeshDataInfo {
  94642. _hasVertexAlpha: boolean;
  94643. _useVertexColors: boolean;
  94644. _numBoneInfluencers: number;
  94645. _applyFog: boolean;
  94646. _receiveShadows: boolean;
  94647. _facetData: _FacetDataStorage;
  94648. _visibility: number;
  94649. _skeleton: Nullable<Skeleton>;
  94650. _layerMask: number;
  94651. _computeBonesUsingShaders: boolean;
  94652. _isActive: boolean;
  94653. _onlyForInstances: boolean;
  94654. _isActiveIntermediate: boolean;
  94655. _onlyForInstancesIntermediate: boolean;
  94656. _actAsRegularMesh: boolean;
  94657. }
  94658. /**
  94659. * Class used to store all common mesh properties
  94660. */
  94661. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  94662. /** No occlusion */
  94663. static OCCLUSION_TYPE_NONE: number;
  94664. /** Occlusion set to optimisitic */
  94665. static OCCLUSION_TYPE_OPTIMISTIC: number;
  94666. /** Occlusion set to strict */
  94667. static OCCLUSION_TYPE_STRICT: number;
  94668. /** Use an accurante occlusion algorithm */
  94669. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  94670. /** Use a conservative occlusion algorithm */
  94671. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  94672. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  94673. * Test order :
  94674. * Is the bounding sphere outside the frustum ?
  94675. * If not, are the bounding box vertices outside the frustum ?
  94676. * It not, then the cullable object is in the frustum.
  94677. */
  94678. static readonly CULLINGSTRATEGY_STANDARD: number;
  94679. /** Culling strategy : Bounding Sphere Only.
  94680. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  94681. * It's also less accurate than the standard because some not visible objects can still be selected.
  94682. * Test : is the bounding sphere outside the frustum ?
  94683. * If not, then the cullable object is in the frustum.
  94684. */
  94685. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  94686. /** Culling strategy : Optimistic Inclusion.
  94687. * This in an inclusion test first, then the standard exclusion test.
  94688. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  94689. * 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.
  94690. * Anyway, it's as accurate as the standard strategy.
  94691. * Test :
  94692. * Is the cullable object bounding sphere center in the frustum ?
  94693. * If not, apply the default culling strategy.
  94694. */
  94695. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  94696. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  94697. * This in an inclusion test first, then the bounding sphere only exclusion test.
  94698. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  94699. * 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.
  94700. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  94701. * Test :
  94702. * Is the cullable object bounding sphere center in the frustum ?
  94703. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  94704. */
  94705. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  94706. /**
  94707. * No billboard
  94708. */
  94709. static readonly BILLBOARDMODE_NONE: number;
  94710. /** Billboard on X axis */
  94711. static readonly BILLBOARDMODE_X: number;
  94712. /** Billboard on Y axis */
  94713. static readonly BILLBOARDMODE_Y: number;
  94714. /** Billboard on Z axis */
  94715. static readonly BILLBOARDMODE_Z: number;
  94716. /** Billboard on all axes */
  94717. static readonly BILLBOARDMODE_ALL: number;
  94718. /** Billboard on using position instead of orientation */
  94719. static readonly BILLBOARDMODE_USE_POSITION: number;
  94720. /** @hidden */
  94721. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  94722. /**
  94723. * The culling strategy to use to check whether the mesh must be rendered or not.
  94724. * This value can be changed at any time and will be used on the next render mesh selection.
  94725. * The possible values are :
  94726. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  94727. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  94728. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  94729. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  94730. * Please read each static variable documentation to get details about the culling process.
  94731. * */
  94732. cullingStrategy: number;
  94733. /**
  94734. * Gets the number of facets in the mesh
  94735. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94736. */
  94737. readonly facetNb: number;
  94738. /**
  94739. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  94740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94741. */
  94742. partitioningSubdivisions: number;
  94743. /**
  94744. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  94745. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  94746. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  94747. */
  94748. partitioningBBoxRatio: number;
  94749. /**
  94750. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  94751. * Works only for updatable meshes.
  94752. * Doesn't work with multi-materials
  94753. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94754. */
  94755. mustDepthSortFacets: boolean;
  94756. /**
  94757. * The location (Vector3) where the facet depth sort must be computed from.
  94758. * By default, the active camera position.
  94759. * Used only when facet depth sort is enabled
  94760. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  94761. */
  94762. facetDepthSortFrom: Vector3;
  94763. /**
  94764. * gets a boolean indicating if facetData is enabled
  94765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  94766. */
  94767. readonly isFacetDataEnabled: boolean;
  94768. /** @hidden */
  94769. _updateNonUniformScalingState(value: boolean): boolean;
  94770. /**
  94771. * An event triggered when this mesh collides with another one
  94772. */
  94773. onCollideObservable: Observable<AbstractMesh>;
  94774. /** Set a function to call when this mesh collides with another one */
  94775. onCollide: () => void;
  94776. /**
  94777. * An event triggered when the collision's position changes
  94778. */
  94779. onCollisionPositionChangeObservable: Observable<Vector3>;
  94780. /** Set a function to call when the collision's position changes */
  94781. onCollisionPositionChange: () => void;
  94782. /**
  94783. * An event triggered when material is changed
  94784. */
  94785. onMaterialChangedObservable: Observable<AbstractMesh>;
  94786. /**
  94787. * Gets or sets the orientation for POV movement & rotation
  94788. */
  94789. definedFacingForward: boolean;
  94790. /** @hidden */
  94791. _occlusionQuery: Nullable<WebGLQuery>;
  94792. /** @hidden */
  94793. _renderingGroup: Nullable<RenderingGroup>;
  94794. /**
  94795. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94796. */
  94797. /**
  94798. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  94799. */
  94800. visibility: number;
  94801. /** Gets or sets the alpha index used to sort transparent meshes
  94802. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  94803. */
  94804. alphaIndex: number;
  94805. /**
  94806. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  94807. */
  94808. isVisible: boolean;
  94809. /**
  94810. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  94811. */
  94812. isPickable: boolean;
  94813. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  94814. showSubMeshesBoundingBox: boolean;
  94815. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  94816. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  94817. */
  94818. isBlocker: boolean;
  94819. /**
  94820. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  94821. */
  94822. enablePointerMoveEvents: boolean;
  94823. /**
  94824. * Specifies the rendering group id for this mesh (0 by default)
  94825. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  94826. */
  94827. renderingGroupId: number;
  94828. private _material;
  94829. /** Gets or sets current material */
  94830. material: Nullable<Material>;
  94831. /**
  94832. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  94833. * @see http://doc.babylonjs.com/babylon101/shadows
  94834. */
  94835. receiveShadows: boolean;
  94836. /** Defines color to use when rendering outline */
  94837. outlineColor: Color3;
  94838. /** Define width to use when rendering outline */
  94839. outlineWidth: number;
  94840. /** Defines color to use when rendering overlay */
  94841. overlayColor: Color3;
  94842. /** Defines alpha to use when rendering overlay */
  94843. overlayAlpha: number;
  94844. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  94845. hasVertexAlpha: boolean;
  94846. /** 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) */
  94847. useVertexColors: boolean;
  94848. /**
  94849. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  94850. */
  94851. computeBonesUsingShaders: boolean;
  94852. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  94853. numBoneInfluencers: number;
  94854. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  94855. applyFog: boolean;
  94856. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  94857. useOctreeForRenderingSelection: boolean;
  94858. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  94859. useOctreeForPicking: boolean;
  94860. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  94861. useOctreeForCollisions: boolean;
  94862. /**
  94863. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  94864. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  94865. */
  94866. layerMask: number;
  94867. /**
  94868. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  94869. */
  94870. alwaysSelectAsActiveMesh: boolean;
  94871. /**
  94872. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  94873. */
  94874. doNotSyncBoundingInfo: boolean;
  94875. /**
  94876. * Gets or sets the current action manager
  94877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94878. */
  94879. actionManager: Nullable<AbstractActionManager>;
  94880. private _meshCollisionData;
  94881. /**
  94882. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  94883. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94884. */
  94885. ellipsoid: Vector3;
  94886. /**
  94887. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  94888. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94889. */
  94890. ellipsoidOffset: Vector3;
  94891. /**
  94892. * Gets or sets a collision mask used to mask collisions (default is -1).
  94893. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94894. */
  94895. collisionMask: number;
  94896. /**
  94897. * Gets or sets the current collision group mask (-1 by default).
  94898. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  94899. */
  94900. collisionGroup: number;
  94901. /**
  94902. * Defines edge width used when edgesRenderer is enabled
  94903. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94904. */
  94905. edgesWidth: number;
  94906. /**
  94907. * Defines edge color used when edgesRenderer is enabled
  94908. * @see https://www.babylonjs-playground.com/#10OJSG#13
  94909. */
  94910. edgesColor: Color4;
  94911. /** @hidden */
  94912. _edgesRenderer: Nullable<IEdgesRenderer>;
  94913. /** @hidden */
  94914. _masterMesh: Nullable<AbstractMesh>;
  94915. /** @hidden */
  94916. _boundingInfo: Nullable<BoundingInfo>;
  94917. /** @hidden */
  94918. _renderId: number;
  94919. /**
  94920. * Gets or sets the list of subMeshes
  94921. * @see http://doc.babylonjs.com/how_to/multi_materials
  94922. */
  94923. subMeshes: SubMesh[];
  94924. /** @hidden */
  94925. _intersectionsInProgress: AbstractMesh[];
  94926. /** @hidden */
  94927. _unIndexed: boolean;
  94928. /** @hidden */
  94929. _lightSources: Light[];
  94930. /** Gets the list of lights affecting that mesh */
  94931. readonly lightSources: Light[];
  94932. /** @hidden */
  94933. readonly _positions: Nullable<Vector3[]>;
  94934. /** @hidden */
  94935. _waitingData: {
  94936. lods: Nullable<any>;
  94937. actions: Nullable<any>;
  94938. freezeWorldMatrix: Nullable<boolean>;
  94939. };
  94940. /** @hidden */
  94941. _bonesTransformMatrices: Nullable<Float32Array>;
  94942. /** @hidden */
  94943. _transformMatrixTexture: Nullable<RawTexture>;
  94944. /**
  94945. * Gets or sets a skeleton to apply skining transformations
  94946. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94947. */
  94948. skeleton: Nullable<Skeleton>;
  94949. /**
  94950. * An event triggered when the mesh is rebuilt.
  94951. */
  94952. onRebuildObservable: Observable<AbstractMesh>;
  94953. /**
  94954. * Creates a new AbstractMesh
  94955. * @param name defines the name of the mesh
  94956. * @param scene defines the hosting scene
  94957. */
  94958. constructor(name: string, scene?: Nullable<Scene>);
  94959. /**
  94960. * Returns the string "AbstractMesh"
  94961. * @returns "AbstractMesh"
  94962. */
  94963. getClassName(): string;
  94964. /**
  94965. * Gets a string representation of the current mesh
  94966. * @param fullDetails defines a boolean indicating if full details must be included
  94967. * @returns a string representation of the current mesh
  94968. */
  94969. toString(fullDetails?: boolean): string;
  94970. /**
  94971. * @hidden
  94972. */
  94973. protected _getEffectiveParent(): Nullable<Node>;
  94974. /** @hidden */
  94975. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  94976. /** @hidden */
  94977. _rebuild(): void;
  94978. /** @hidden */
  94979. _resyncLightSources(): void;
  94980. /** @hidden */
  94981. _resyncLighSource(light: Light): void;
  94982. /** @hidden */
  94983. _unBindEffect(): void;
  94984. /** @hidden */
  94985. _removeLightSource(light: Light, dispose: boolean): void;
  94986. private _markSubMeshesAsDirty;
  94987. /** @hidden */
  94988. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  94989. /** @hidden */
  94990. _markSubMeshesAsAttributesDirty(): void;
  94991. /** @hidden */
  94992. _markSubMeshesAsMiscDirty(): void;
  94993. /**
  94994. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  94995. */
  94996. scaling: Vector3;
  94997. /**
  94998. * Returns true if the mesh is blocked. Implemented by child classes
  94999. */
  95000. readonly isBlocked: boolean;
  95001. /**
  95002. * Returns the mesh itself by default. Implemented by child classes
  95003. * @param camera defines the camera to use to pick the right LOD level
  95004. * @returns the currentAbstractMesh
  95005. */
  95006. getLOD(camera: Camera): Nullable<AbstractMesh>;
  95007. /**
  95008. * Returns 0 by default. Implemented by child classes
  95009. * @returns an integer
  95010. */
  95011. getTotalVertices(): number;
  95012. /**
  95013. * Returns a positive integer : the total number of indices in this mesh geometry.
  95014. * @returns the numner of indices or zero if the mesh has no geometry.
  95015. */
  95016. getTotalIndices(): number;
  95017. /**
  95018. * Returns null by default. Implemented by child classes
  95019. * @returns null
  95020. */
  95021. getIndices(): Nullable<IndicesArray>;
  95022. /**
  95023. * Returns the array of the requested vertex data kind. Implemented by child classes
  95024. * @param kind defines the vertex data kind to use
  95025. * @returns null
  95026. */
  95027. getVerticesData(kind: string): Nullable<FloatArray>;
  95028. /**
  95029. * Sets the vertex data of the mesh geometry for the requested `kind`.
  95030. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  95031. * Note that a new underlying VertexBuffer object is created each call.
  95032. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  95033. * @param kind defines vertex data kind:
  95034. * * VertexBuffer.PositionKind
  95035. * * VertexBuffer.UVKind
  95036. * * VertexBuffer.UV2Kind
  95037. * * VertexBuffer.UV3Kind
  95038. * * VertexBuffer.UV4Kind
  95039. * * VertexBuffer.UV5Kind
  95040. * * VertexBuffer.UV6Kind
  95041. * * VertexBuffer.ColorKind
  95042. * * VertexBuffer.MatricesIndicesKind
  95043. * * VertexBuffer.MatricesIndicesExtraKind
  95044. * * VertexBuffer.MatricesWeightsKind
  95045. * * VertexBuffer.MatricesWeightsExtraKind
  95046. * @param data defines the data source
  95047. * @param updatable defines if the data must be flagged as updatable (or static)
  95048. * @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
  95049. * @returns the current mesh
  95050. */
  95051. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95052. /**
  95053. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  95054. * If the mesh has no geometry, it is simply returned as it is.
  95055. * @param kind defines vertex data kind:
  95056. * * VertexBuffer.PositionKind
  95057. * * VertexBuffer.UVKind
  95058. * * VertexBuffer.UV2Kind
  95059. * * VertexBuffer.UV3Kind
  95060. * * VertexBuffer.UV4Kind
  95061. * * VertexBuffer.UV5Kind
  95062. * * VertexBuffer.UV6Kind
  95063. * * VertexBuffer.ColorKind
  95064. * * VertexBuffer.MatricesIndicesKind
  95065. * * VertexBuffer.MatricesIndicesExtraKind
  95066. * * VertexBuffer.MatricesWeightsKind
  95067. * * VertexBuffer.MatricesWeightsExtraKind
  95068. * @param data defines the data source
  95069. * @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
  95070. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  95071. * @returns the current mesh
  95072. */
  95073. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95074. /**
  95075. * Sets the mesh indices,
  95076. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  95077. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  95078. * @param totalVertices Defines the total number of vertices
  95079. * @returns the current mesh
  95080. */
  95081. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  95082. /**
  95083. * Gets a boolean indicating if specific vertex data is present
  95084. * @param kind defines the vertex data kind to use
  95085. * @returns true is data kind is present
  95086. */
  95087. isVerticesDataPresent(kind: string): boolean;
  95088. /**
  95089. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  95090. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  95091. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  95092. * @returns a BoundingInfo
  95093. */
  95094. getBoundingInfo(): BoundingInfo;
  95095. /**
  95096. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95097. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95098. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95099. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95100. * @returns the current mesh
  95101. */
  95102. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  95103. /**
  95104. * Overwrite the current bounding info
  95105. * @param boundingInfo defines the new bounding info
  95106. * @returns the current mesh
  95107. */
  95108. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  95109. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  95110. readonly useBones: boolean;
  95111. /** @hidden */
  95112. _preActivate(): void;
  95113. /** @hidden */
  95114. _preActivateForIntermediateRendering(renderId: number): void;
  95115. /** @hidden */
  95116. _activate(renderId: number, intermediateRendering: boolean): boolean;
  95117. /** @hidden */
  95118. _postActivate(): void;
  95119. /** @hidden */
  95120. _freeze(): void;
  95121. /** @hidden */
  95122. _unFreeze(): void;
  95123. /**
  95124. * Gets the current world matrix
  95125. * @returns a Matrix
  95126. */
  95127. getWorldMatrix(): Matrix;
  95128. /** @hidden */
  95129. _getWorldMatrixDeterminant(): number;
  95130. /**
  95131. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  95132. */
  95133. readonly isAnInstance: boolean;
  95134. /**
  95135. * Gets a boolean indicating if this mesh has instances
  95136. */
  95137. readonly hasInstances: boolean;
  95138. /**
  95139. * Perform relative position change from the point of view of behind the front of the mesh.
  95140. * This is performed taking into account the meshes current rotation, so you do not have to care.
  95141. * Supports definition of mesh facing forward or backward
  95142. * @param amountRight defines the distance on the right axis
  95143. * @param amountUp defines the distance on the up axis
  95144. * @param amountForward defines the distance on the forward axis
  95145. * @returns the current mesh
  95146. */
  95147. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  95148. /**
  95149. * Calculate relative position change from the point of view of behind the front of the mesh.
  95150. * This is performed taking into account the meshes current rotation, so you do not have to care.
  95151. * Supports definition of mesh facing forward or backward
  95152. * @param amountRight defines the distance on the right axis
  95153. * @param amountUp defines the distance on the up axis
  95154. * @param amountForward defines the distance on the forward axis
  95155. * @returns the new displacement vector
  95156. */
  95157. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  95158. /**
  95159. * Perform relative rotation change from the point of view of behind the front of the mesh.
  95160. * Supports definition of mesh facing forward or backward
  95161. * @param flipBack defines the flip
  95162. * @param twirlClockwise defines the twirl
  95163. * @param tiltRight defines the tilt
  95164. * @returns the current mesh
  95165. */
  95166. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  95167. /**
  95168. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  95169. * Supports definition of mesh facing forward or backward.
  95170. * @param flipBack defines the flip
  95171. * @param twirlClockwise defines the twirl
  95172. * @param tiltRight defines the tilt
  95173. * @returns the new rotation vector
  95174. */
  95175. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  95176. /**
  95177. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95178. * This means the mesh underlying bounding box and sphere are recomputed.
  95179. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95180. * @returns the current mesh
  95181. */
  95182. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  95183. /** @hidden */
  95184. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  95185. /** @hidden */
  95186. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  95187. /** @hidden */
  95188. _updateBoundingInfo(): AbstractMesh;
  95189. /** @hidden */
  95190. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  95191. /** @hidden */
  95192. protected _afterComputeWorldMatrix(): void;
  95193. /** @hidden */
  95194. readonly _effectiveMesh: AbstractMesh;
  95195. /**
  95196. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  95197. * A mesh is in the frustum if its bounding box intersects the frustum
  95198. * @param frustumPlanes defines the frustum to test
  95199. * @returns true if the mesh is in the frustum planes
  95200. */
  95201. isInFrustum(frustumPlanes: Plane[]): boolean;
  95202. /**
  95203. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  95204. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  95205. * @param frustumPlanes defines the frustum to test
  95206. * @returns true if the mesh is completely in the frustum planes
  95207. */
  95208. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  95209. /**
  95210. * True if the mesh intersects another mesh or a SolidParticle object
  95211. * @param mesh defines a target mesh or SolidParticle to test
  95212. * @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)
  95213. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  95214. * @returns true if there is an intersection
  95215. */
  95216. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  95217. /**
  95218. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  95219. * @param point defines the point to test
  95220. * @returns true if there is an intersection
  95221. */
  95222. intersectsPoint(point: Vector3): boolean;
  95223. /**
  95224. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  95225. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95226. */
  95227. checkCollisions: boolean;
  95228. /**
  95229. * Gets Collider object used to compute collisions (not physics)
  95230. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95231. */
  95232. readonly collider: Nullable<Collider>;
  95233. /**
  95234. * Move the mesh using collision engine
  95235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95236. * @param displacement defines the requested displacement vector
  95237. * @returns the current mesh
  95238. */
  95239. moveWithCollisions(displacement: Vector3): AbstractMesh;
  95240. private _onCollisionPositionChange;
  95241. /** @hidden */
  95242. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  95243. /** @hidden */
  95244. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  95245. /** @hidden */
  95246. _checkCollision(collider: Collider): AbstractMesh;
  95247. /** @hidden */
  95248. _generatePointsArray(): boolean;
  95249. /**
  95250. * Checks if the passed Ray intersects with the mesh
  95251. * @param ray defines the ray to use
  95252. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  95253. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95254. * @returns the picking info
  95255. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  95256. */
  95257. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  95258. /**
  95259. * Clones the current mesh
  95260. * @param name defines the mesh name
  95261. * @param newParent defines the new mesh parent
  95262. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  95263. * @returns the new mesh
  95264. */
  95265. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  95266. /**
  95267. * Disposes all the submeshes of the current meshnp
  95268. * @returns the current mesh
  95269. */
  95270. releaseSubMeshes(): AbstractMesh;
  95271. /**
  95272. * Releases resources associated with this abstract mesh.
  95273. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95274. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95275. */
  95276. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95277. /**
  95278. * Adds the passed mesh as a child to the current mesh
  95279. * @param mesh defines the child mesh
  95280. * @returns the current mesh
  95281. */
  95282. addChild(mesh: AbstractMesh): AbstractMesh;
  95283. /**
  95284. * Removes the passed mesh from the current mesh children list
  95285. * @param mesh defines the child mesh
  95286. * @returns the current mesh
  95287. */
  95288. removeChild(mesh: AbstractMesh): AbstractMesh;
  95289. /** @hidden */
  95290. private _initFacetData;
  95291. /**
  95292. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  95293. * This method can be called within the render loop.
  95294. * 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
  95295. * @returns the current mesh
  95296. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95297. */
  95298. updateFacetData(): AbstractMesh;
  95299. /**
  95300. * Returns the facetLocalNormals array.
  95301. * The normals are expressed in the mesh local spac
  95302. * @returns an array of Vector3
  95303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95304. */
  95305. getFacetLocalNormals(): Vector3[];
  95306. /**
  95307. * Returns the facetLocalPositions array.
  95308. * The facet positions are expressed in the mesh local space
  95309. * @returns an array of Vector3
  95310. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95311. */
  95312. getFacetLocalPositions(): Vector3[];
  95313. /**
  95314. * Returns the facetLocalPartioning array
  95315. * @returns an array of array of numbers
  95316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95317. */
  95318. getFacetLocalPartitioning(): number[][];
  95319. /**
  95320. * Returns the i-th facet position in the world system.
  95321. * This method allocates a new Vector3 per call
  95322. * @param i defines the facet index
  95323. * @returns a new Vector3
  95324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95325. */
  95326. getFacetPosition(i: number): Vector3;
  95327. /**
  95328. * Sets the reference Vector3 with the i-th facet position in the world system
  95329. * @param i defines the facet index
  95330. * @param ref defines the target vector
  95331. * @returns the current mesh
  95332. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95333. */
  95334. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  95335. /**
  95336. * Returns the i-th facet normal in the world system.
  95337. * This method allocates a new Vector3 per call
  95338. * @param i defines the facet index
  95339. * @returns a new Vector3
  95340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95341. */
  95342. getFacetNormal(i: number): Vector3;
  95343. /**
  95344. * Sets the reference Vector3 with the i-th facet normal in the world system
  95345. * @param i defines the facet index
  95346. * @param ref defines the target vector
  95347. * @returns the current mesh
  95348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95349. */
  95350. getFacetNormalToRef(i: number, ref: Vector3): this;
  95351. /**
  95352. * 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)
  95353. * @param x defines x coordinate
  95354. * @param y defines y coordinate
  95355. * @param z defines z coordinate
  95356. * @returns the array of facet indexes
  95357. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95358. */
  95359. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  95360. /**
  95361. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  95362. * @param projected sets as the (x,y,z) world projection on the facet
  95363. * @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
  95364. * @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
  95365. * @param x defines x coordinate
  95366. * @param y defines y coordinate
  95367. * @param z defines z coordinate
  95368. * @returns the face index if found (or null instead)
  95369. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95370. */
  95371. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95372. /**
  95373. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  95374. * @param projected sets as the (x,y,z) local projection on the facet
  95375. * @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
  95376. * @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
  95377. * @param x defines x coordinate
  95378. * @param y defines y coordinate
  95379. * @param z defines z coordinate
  95380. * @returns the face index if found (or null instead)
  95381. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95382. */
  95383. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  95384. /**
  95385. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  95386. * @returns the parameters
  95387. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95388. */
  95389. getFacetDataParameters(): any;
  95390. /**
  95391. * Disables the feature FacetData and frees the related memory
  95392. * @returns the current mesh
  95393. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  95394. */
  95395. disableFacetData(): AbstractMesh;
  95396. /**
  95397. * Updates the AbstractMesh indices array
  95398. * @param indices defines the data source
  95399. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95400. * @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)
  95401. * @returns the current mesh
  95402. */
  95403. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95404. /**
  95405. * Creates new normals data for the mesh
  95406. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  95407. * @returns the current mesh
  95408. */
  95409. createNormals(updatable: boolean): AbstractMesh;
  95410. /**
  95411. * Align the mesh with a normal
  95412. * @param normal defines the normal to use
  95413. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  95414. * @returns the current mesh
  95415. */
  95416. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  95417. /** @hidden */
  95418. _checkOcclusionQuery(): boolean;
  95419. /**
  95420. * Disables the mesh edge rendering mode
  95421. * @returns the currentAbstractMesh
  95422. */
  95423. disableEdgesRendering(): AbstractMesh;
  95424. /**
  95425. * Enables the edge rendering mode on the mesh.
  95426. * This mode makes the mesh edges visible
  95427. * @param epsilon defines the maximal distance between two angles to detect a face
  95428. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95429. * @returns the currentAbstractMesh
  95430. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95431. */
  95432. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95433. }
  95434. }
  95435. declare module BABYLON {
  95436. /**
  95437. * Interface used to define ActionEvent
  95438. */
  95439. export interface IActionEvent {
  95440. /** The mesh or sprite that triggered the action */
  95441. source: any;
  95442. /** The X mouse cursor position at the time of the event */
  95443. pointerX: number;
  95444. /** The Y mouse cursor position at the time of the event */
  95445. pointerY: number;
  95446. /** The mesh that is currently pointed at (can be null) */
  95447. meshUnderPointer: Nullable<AbstractMesh>;
  95448. /** the original (browser) event that triggered the ActionEvent */
  95449. sourceEvent?: any;
  95450. /** additional data for the event */
  95451. additionalData?: any;
  95452. }
  95453. /**
  95454. * ActionEvent is the event being sent when an action is triggered.
  95455. */
  95456. export class ActionEvent implements IActionEvent {
  95457. /** The mesh or sprite that triggered the action */
  95458. source: any;
  95459. /** The X mouse cursor position at the time of the event */
  95460. pointerX: number;
  95461. /** The Y mouse cursor position at the time of the event */
  95462. pointerY: number;
  95463. /** The mesh that is currently pointed at (can be null) */
  95464. meshUnderPointer: Nullable<AbstractMesh>;
  95465. /** the original (browser) event that triggered the ActionEvent */
  95466. sourceEvent?: any;
  95467. /** additional data for the event */
  95468. additionalData?: any;
  95469. /**
  95470. * Creates a new ActionEvent
  95471. * @param source The mesh or sprite that triggered the action
  95472. * @param pointerX The X mouse cursor position at the time of the event
  95473. * @param pointerY The Y mouse cursor position at the time of the event
  95474. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  95475. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  95476. * @param additionalData additional data for the event
  95477. */
  95478. constructor(
  95479. /** The mesh or sprite that triggered the action */
  95480. source: any,
  95481. /** The X mouse cursor position at the time of the event */
  95482. pointerX: number,
  95483. /** The Y mouse cursor position at the time of the event */
  95484. pointerY: number,
  95485. /** The mesh that is currently pointed at (can be null) */
  95486. meshUnderPointer: Nullable<AbstractMesh>,
  95487. /** the original (browser) event that triggered the ActionEvent */
  95488. sourceEvent?: any,
  95489. /** additional data for the event */
  95490. additionalData?: any);
  95491. /**
  95492. * Helper function to auto-create an ActionEvent from a source mesh.
  95493. * @param source The source mesh that triggered the event
  95494. * @param evt The original (browser) event
  95495. * @param additionalData additional data for the event
  95496. * @returns the new ActionEvent
  95497. */
  95498. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  95499. /**
  95500. * Helper function to auto-create an ActionEvent from a source sprite
  95501. * @param source The source sprite that triggered the event
  95502. * @param scene Scene associated with the sprite
  95503. * @param evt The original (browser) event
  95504. * @param additionalData additional data for the event
  95505. * @returns the new ActionEvent
  95506. */
  95507. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  95508. /**
  95509. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  95510. * @param scene the scene where the event occurred
  95511. * @param evt The original (browser) event
  95512. * @returns the new ActionEvent
  95513. */
  95514. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  95515. /**
  95516. * Helper function to auto-create an ActionEvent from a primitive
  95517. * @param prim defines the target primitive
  95518. * @param pointerPos defines the pointer position
  95519. * @param evt The original (browser) event
  95520. * @param additionalData additional data for the event
  95521. * @returns the new ActionEvent
  95522. */
  95523. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  95524. }
  95525. }
  95526. declare module BABYLON {
  95527. /**
  95528. * Abstract class used to decouple action Manager from scene and meshes.
  95529. * Do not instantiate.
  95530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95531. */
  95532. export abstract class AbstractActionManager implements IDisposable {
  95533. /** Gets the list of active triggers */
  95534. static Triggers: {
  95535. [key: string]: number;
  95536. };
  95537. /** Gets the cursor to use when hovering items */
  95538. hoverCursor: string;
  95539. /** Gets the list of actions */
  95540. actions: IAction[];
  95541. /**
  95542. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  95543. */
  95544. isRecursive: boolean;
  95545. /**
  95546. * Releases all associated resources
  95547. */
  95548. abstract dispose(): void;
  95549. /**
  95550. * Does this action manager has pointer triggers
  95551. */
  95552. abstract readonly hasPointerTriggers: boolean;
  95553. /**
  95554. * Does this action manager has pick triggers
  95555. */
  95556. abstract readonly hasPickTriggers: boolean;
  95557. /**
  95558. * Process a specific trigger
  95559. * @param trigger defines the trigger to process
  95560. * @param evt defines the event details to be processed
  95561. */
  95562. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  95563. /**
  95564. * Does this action manager handles actions of any of the given triggers
  95565. * @param triggers defines the triggers to be tested
  95566. * @return a boolean indicating whether one (or more) of the triggers is handled
  95567. */
  95568. abstract hasSpecificTriggers(triggers: number[]): boolean;
  95569. /**
  95570. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  95571. * speed.
  95572. * @param triggerA defines the trigger to be tested
  95573. * @param triggerB defines the trigger to be tested
  95574. * @return a boolean indicating whether one (or more) of the triggers is handled
  95575. */
  95576. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  95577. /**
  95578. * Does this action manager handles actions of a given trigger
  95579. * @param trigger defines the trigger to be tested
  95580. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  95581. * @return whether the trigger is handled
  95582. */
  95583. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  95584. /**
  95585. * Serialize this manager to a JSON object
  95586. * @param name defines the property name to store this manager
  95587. * @returns a JSON representation of this manager
  95588. */
  95589. abstract serialize(name: string): any;
  95590. /**
  95591. * Registers an action to this action manager
  95592. * @param action defines the action to be registered
  95593. * @return the action amended (prepared) after registration
  95594. */
  95595. abstract registerAction(action: IAction): Nullable<IAction>;
  95596. /**
  95597. * Unregisters an action to this action manager
  95598. * @param action defines the action to be unregistered
  95599. * @return a boolean indicating whether the action has been unregistered
  95600. */
  95601. abstract unregisterAction(action: IAction): Boolean;
  95602. /**
  95603. * Does exist one action manager with at least one trigger
  95604. **/
  95605. static readonly HasTriggers: boolean;
  95606. /**
  95607. * Does exist one action manager with at least one pick trigger
  95608. **/
  95609. static readonly HasPickTriggers: boolean;
  95610. /**
  95611. * Does exist one action manager that handles actions of a given trigger
  95612. * @param trigger defines the trigger to be tested
  95613. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  95614. **/
  95615. static HasSpecificTrigger(trigger: number): boolean;
  95616. }
  95617. }
  95618. declare module BABYLON {
  95619. /**
  95620. * Defines how a node can be built from a string name.
  95621. */
  95622. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  95623. /**
  95624. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  95625. */
  95626. export class Node implements IBehaviorAware<Node> {
  95627. /** @hidden */
  95628. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  95629. private static _NodeConstructors;
  95630. /**
  95631. * Add a new node constructor
  95632. * @param type defines the type name of the node to construct
  95633. * @param constructorFunc defines the constructor function
  95634. */
  95635. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  95636. /**
  95637. * Returns a node constructor based on type name
  95638. * @param type defines the type name
  95639. * @param name defines the new node name
  95640. * @param scene defines the hosting scene
  95641. * @param options defines optional options to transmit to constructors
  95642. * @returns the new constructor or null
  95643. */
  95644. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  95645. /**
  95646. * Gets or sets the name of the node
  95647. */
  95648. name: string;
  95649. /**
  95650. * Gets or sets the id of the node
  95651. */
  95652. id: string;
  95653. /**
  95654. * Gets or sets the unique id of the node
  95655. */
  95656. uniqueId: number;
  95657. /**
  95658. * Gets or sets a string used to store user defined state for the node
  95659. */
  95660. state: string;
  95661. /**
  95662. * Gets or sets an object used to store user defined information for the node
  95663. */
  95664. metadata: any;
  95665. /**
  95666. * For internal use only. Please do not use.
  95667. */
  95668. reservedDataStore: any;
  95669. /**
  95670. * List of inspectable custom properties (used by the Inspector)
  95671. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95672. */
  95673. inspectableCustomProperties: IInspectable[];
  95674. private _doNotSerialize;
  95675. /**
  95676. * Gets or sets a boolean used to define if the node must be serialized
  95677. */
  95678. doNotSerialize: boolean;
  95679. /** @hidden */
  95680. _isDisposed: boolean;
  95681. /**
  95682. * Gets a list of Animations associated with the node
  95683. */
  95684. animations: Animation[];
  95685. protected _ranges: {
  95686. [name: string]: Nullable<AnimationRange>;
  95687. };
  95688. /**
  95689. * Callback raised when the node is ready to be used
  95690. */
  95691. onReady: Nullable<(node: Node) => void>;
  95692. private _isEnabled;
  95693. private _isParentEnabled;
  95694. private _isReady;
  95695. /** @hidden */
  95696. _currentRenderId: number;
  95697. private _parentUpdateId;
  95698. /** @hidden */
  95699. _childUpdateId: number;
  95700. /** @hidden */
  95701. _waitingParentId: Nullable<string>;
  95702. /** @hidden */
  95703. _scene: Scene;
  95704. /** @hidden */
  95705. _cache: any;
  95706. private _parentNode;
  95707. private _children;
  95708. /** @hidden */
  95709. _worldMatrix: Matrix;
  95710. /** @hidden */
  95711. _worldMatrixDeterminant: number;
  95712. /** @hidden */
  95713. _worldMatrixDeterminantIsDirty: boolean;
  95714. /** @hidden */
  95715. private _sceneRootNodesIndex;
  95716. /**
  95717. * Gets a boolean indicating if the node has been disposed
  95718. * @returns true if the node was disposed
  95719. */
  95720. isDisposed(): boolean;
  95721. /**
  95722. * Gets or sets the parent of the node (without keeping the current position in the scene)
  95723. * @see https://doc.babylonjs.com/how_to/parenting
  95724. */
  95725. parent: Nullable<Node>;
  95726. /** @hidden */
  95727. _addToSceneRootNodes(): void;
  95728. /** @hidden */
  95729. _removeFromSceneRootNodes(): void;
  95730. private _animationPropertiesOverride;
  95731. /**
  95732. * Gets or sets the animation properties override
  95733. */
  95734. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  95735. /**
  95736. * Gets a string idenfifying the name of the class
  95737. * @returns "Node" string
  95738. */
  95739. getClassName(): string;
  95740. /** @hidden */
  95741. readonly _isNode: boolean;
  95742. /**
  95743. * An event triggered when the mesh is disposed
  95744. */
  95745. onDisposeObservable: Observable<Node>;
  95746. private _onDisposeObserver;
  95747. /**
  95748. * Sets a callback that will be raised when the node will be disposed
  95749. */
  95750. onDispose: () => void;
  95751. /**
  95752. * Creates a new Node
  95753. * @param name the name and id to be given to this node
  95754. * @param scene the scene this node will be added to
  95755. */
  95756. constructor(name: string, scene?: Nullable<Scene>);
  95757. /**
  95758. * Gets the scene of the node
  95759. * @returns a scene
  95760. */
  95761. getScene(): Scene;
  95762. /**
  95763. * Gets the engine of the node
  95764. * @returns a Engine
  95765. */
  95766. getEngine(): Engine;
  95767. private _behaviors;
  95768. /**
  95769. * Attach a behavior to the node
  95770. * @see http://doc.babylonjs.com/features/behaviour
  95771. * @param behavior defines the behavior to attach
  95772. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  95773. * @returns the current Node
  95774. */
  95775. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  95776. /**
  95777. * Remove an attached behavior
  95778. * @see http://doc.babylonjs.com/features/behaviour
  95779. * @param behavior defines the behavior to attach
  95780. * @returns the current Node
  95781. */
  95782. removeBehavior(behavior: Behavior<Node>): Node;
  95783. /**
  95784. * Gets the list of attached behaviors
  95785. * @see http://doc.babylonjs.com/features/behaviour
  95786. */
  95787. readonly behaviors: Behavior<Node>[];
  95788. /**
  95789. * Gets an attached behavior by name
  95790. * @param name defines the name of the behavior to look for
  95791. * @see http://doc.babylonjs.com/features/behaviour
  95792. * @returns null if behavior was not found else the requested behavior
  95793. */
  95794. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  95795. /**
  95796. * Returns the latest update of the World matrix
  95797. * @returns a Matrix
  95798. */
  95799. getWorldMatrix(): Matrix;
  95800. /** @hidden */
  95801. _getWorldMatrixDeterminant(): number;
  95802. /**
  95803. * Returns directly the latest state of the mesh World matrix.
  95804. * A Matrix is returned.
  95805. */
  95806. readonly worldMatrixFromCache: Matrix;
  95807. /** @hidden */
  95808. _initCache(): void;
  95809. /** @hidden */
  95810. updateCache(force?: boolean): void;
  95811. /** @hidden */
  95812. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  95813. /** @hidden */
  95814. _updateCache(ignoreParentClass?: boolean): void;
  95815. /** @hidden */
  95816. _isSynchronized(): boolean;
  95817. /** @hidden */
  95818. _markSyncedWithParent(): void;
  95819. /** @hidden */
  95820. isSynchronizedWithParent(): boolean;
  95821. /** @hidden */
  95822. isSynchronized(): boolean;
  95823. /**
  95824. * Is this node ready to be used/rendered
  95825. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95826. * @return true if the node is ready
  95827. */
  95828. isReady(completeCheck?: boolean): boolean;
  95829. /**
  95830. * Is this node enabled?
  95831. * 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
  95832. * @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
  95833. * @return whether this node (and its parent) is enabled
  95834. */
  95835. isEnabled(checkAncestors?: boolean): boolean;
  95836. /** @hidden */
  95837. protected _syncParentEnabledState(): void;
  95838. /**
  95839. * Set the enabled state of this node
  95840. * @param value defines the new enabled state
  95841. */
  95842. setEnabled(value: boolean): void;
  95843. /**
  95844. * Is this node a descendant of the given node?
  95845. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  95846. * @param ancestor defines the parent node to inspect
  95847. * @returns a boolean indicating if this node is a descendant of the given node
  95848. */
  95849. isDescendantOf(ancestor: Node): boolean;
  95850. /** @hidden */
  95851. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  95852. /**
  95853. * Will return all nodes that have this node as ascendant
  95854. * @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
  95855. * @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
  95856. * @return all children nodes of all types
  95857. */
  95858. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  95859. /**
  95860. * Get all child-meshes of this node
  95861. * @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)
  95862. * @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
  95863. * @returns an array of AbstractMesh
  95864. */
  95865. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  95866. /**
  95867. * Get all direct children of this node
  95868. * @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
  95869. * @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)
  95870. * @returns an array of Node
  95871. */
  95872. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  95873. /** @hidden */
  95874. _setReady(state: boolean): void;
  95875. /**
  95876. * Get an animation by name
  95877. * @param name defines the name of the animation to look for
  95878. * @returns null if not found else the requested animation
  95879. */
  95880. getAnimationByName(name: string): Nullable<Animation>;
  95881. /**
  95882. * Creates an animation range for this node
  95883. * @param name defines the name of the range
  95884. * @param from defines the starting key
  95885. * @param to defines the end key
  95886. */
  95887. createAnimationRange(name: string, from: number, to: number): void;
  95888. /**
  95889. * Delete a specific animation range
  95890. * @param name defines the name of the range to delete
  95891. * @param deleteFrames defines if animation frames from the range must be deleted as well
  95892. */
  95893. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  95894. /**
  95895. * Get an animation range by name
  95896. * @param name defines the name of the animation range to look for
  95897. * @returns null if not found else the requested animation range
  95898. */
  95899. getAnimationRange(name: string): Nullable<AnimationRange>;
  95900. /**
  95901. * Gets the list of all animation ranges defined on this node
  95902. * @returns an array
  95903. */
  95904. getAnimationRanges(): Nullable<AnimationRange>[];
  95905. /**
  95906. * Will start the animation sequence
  95907. * @param name defines the range frames for animation sequence
  95908. * @param loop defines if the animation should loop (false by default)
  95909. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  95910. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  95911. * @returns the object created for this animation. If range does not exist, it will return null
  95912. */
  95913. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  95914. /**
  95915. * Serialize animation ranges into a JSON compatible object
  95916. * @returns serialization object
  95917. */
  95918. serializeAnimationRanges(): any;
  95919. /**
  95920. * Computes the world matrix of the node
  95921. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95922. * @returns the world matrix
  95923. */
  95924. computeWorldMatrix(force?: boolean): Matrix;
  95925. /**
  95926. * Releases resources associated with this node.
  95927. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95928. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95929. */
  95930. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95931. /**
  95932. * Parse animation range data from a serialization object and store them into a given node
  95933. * @param node defines where to store the animation ranges
  95934. * @param parsedNode defines the serialization object to read data from
  95935. * @param scene defines the hosting scene
  95936. */
  95937. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  95938. /**
  95939. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  95940. * @param includeDescendants Include bounding info from descendants as well (true by default)
  95941. * @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
  95942. * @returns the new bounding vectors
  95943. */
  95944. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  95945. min: Vector3;
  95946. max: Vector3;
  95947. };
  95948. }
  95949. }
  95950. declare module BABYLON {
  95951. /**
  95952. * @hidden
  95953. */
  95954. export class _IAnimationState {
  95955. key: number;
  95956. repeatCount: number;
  95957. workValue?: any;
  95958. loopMode?: number;
  95959. offsetValue?: any;
  95960. highLimitValue?: any;
  95961. }
  95962. /**
  95963. * Class used to store any kind of animation
  95964. */
  95965. export class Animation {
  95966. /**Name of the animation */
  95967. name: string;
  95968. /**Property to animate */
  95969. targetProperty: string;
  95970. /**The frames per second of the animation */
  95971. framePerSecond: number;
  95972. /**The data type of the animation */
  95973. dataType: number;
  95974. /**The loop mode of the animation */
  95975. loopMode?: number | undefined;
  95976. /**Specifies if blending should be enabled */
  95977. enableBlending?: boolean | undefined;
  95978. /**
  95979. * Use matrix interpolation instead of using direct key value when animating matrices
  95980. */
  95981. static AllowMatricesInterpolation: boolean;
  95982. /**
  95983. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  95984. */
  95985. static AllowMatrixDecomposeForInterpolation: boolean;
  95986. /**
  95987. * Stores the key frames of the animation
  95988. */
  95989. private _keys;
  95990. /**
  95991. * Stores the easing function of the animation
  95992. */
  95993. private _easingFunction;
  95994. /**
  95995. * @hidden Internal use only
  95996. */
  95997. _runtimeAnimations: RuntimeAnimation[];
  95998. /**
  95999. * The set of event that will be linked to this animation
  96000. */
  96001. private _events;
  96002. /**
  96003. * Stores an array of target property paths
  96004. */
  96005. targetPropertyPath: string[];
  96006. /**
  96007. * Stores the blending speed of the animation
  96008. */
  96009. blendingSpeed: number;
  96010. /**
  96011. * Stores the animation ranges for the animation
  96012. */
  96013. private _ranges;
  96014. /**
  96015. * @hidden Internal use
  96016. */
  96017. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  96018. /**
  96019. * Sets up an animation
  96020. * @param property The property to animate
  96021. * @param animationType The animation type to apply
  96022. * @param framePerSecond The frames per second of the animation
  96023. * @param easingFunction The easing function used in the animation
  96024. * @returns The created animation
  96025. */
  96026. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  96027. /**
  96028. * Create and start an animation on a node
  96029. * @param name defines the name of the global animation that will be run on all nodes
  96030. * @param node defines the root node where the animation will take place
  96031. * @param targetProperty defines property to animate
  96032. * @param framePerSecond defines the number of frame per second yo use
  96033. * @param totalFrame defines the number of frames in total
  96034. * @param from defines the initial value
  96035. * @param to defines the final value
  96036. * @param loopMode defines which loop mode you want to use (off by default)
  96037. * @param easingFunction defines the easing function to use (linear by default)
  96038. * @param onAnimationEnd defines the callback to call when animation end
  96039. * @returns the animatable created for this animation
  96040. */
  96041. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  96042. /**
  96043. * Create and start an animation on a node and its descendants
  96044. * @param name defines the name of the global animation that will be run on all nodes
  96045. * @param node defines the root node where the animation will take place
  96046. * @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
  96047. * @param targetProperty defines property to animate
  96048. * @param framePerSecond defines the number of frame per second to use
  96049. * @param totalFrame defines the number of frames in total
  96050. * @param from defines the initial value
  96051. * @param to defines the final value
  96052. * @param loopMode defines which loop mode you want to use (off by default)
  96053. * @param easingFunction defines the easing function to use (linear by default)
  96054. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96055. * @returns the list of animatables created for all nodes
  96056. * @example https://www.babylonjs-playground.com/#MH0VLI
  96057. */
  96058. 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[]>;
  96059. /**
  96060. * Creates a new animation, merges it with the existing animations and starts it
  96061. * @param name Name of the animation
  96062. * @param node Node which contains the scene that begins the animations
  96063. * @param targetProperty Specifies which property to animate
  96064. * @param framePerSecond The frames per second of the animation
  96065. * @param totalFrame The total number of frames
  96066. * @param from The frame at the beginning of the animation
  96067. * @param to The frame at the end of the animation
  96068. * @param loopMode Specifies the loop mode of the animation
  96069. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  96070. * @param onAnimationEnd Callback to run once the animation is complete
  96071. * @returns Nullable animation
  96072. */
  96073. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  96074. /**
  96075. * Transition property of an host to the target Value
  96076. * @param property The property to transition
  96077. * @param targetValue The target Value of the property
  96078. * @param host The object where the property to animate belongs
  96079. * @param scene Scene used to run the animation
  96080. * @param frameRate Framerate (in frame/s) to use
  96081. * @param transition The transition type we want to use
  96082. * @param duration The duration of the animation, in milliseconds
  96083. * @param onAnimationEnd Callback trigger at the end of the animation
  96084. * @returns Nullable animation
  96085. */
  96086. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  96087. /**
  96088. * Return the array of runtime animations currently using this animation
  96089. */
  96090. readonly runtimeAnimations: RuntimeAnimation[];
  96091. /**
  96092. * Specifies if any of the runtime animations are currently running
  96093. */
  96094. readonly hasRunningRuntimeAnimations: boolean;
  96095. /**
  96096. * Initializes the animation
  96097. * @param name Name of the animation
  96098. * @param targetProperty Property to animate
  96099. * @param framePerSecond The frames per second of the animation
  96100. * @param dataType The data type of the animation
  96101. * @param loopMode The loop mode of the animation
  96102. * @param enableBlending Specifies if blending should be enabled
  96103. */
  96104. constructor(
  96105. /**Name of the animation */
  96106. name: string,
  96107. /**Property to animate */
  96108. targetProperty: string,
  96109. /**The frames per second of the animation */
  96110. framePerSecond: number,
  96111. /**The data type of the animation */
  96112. dataType: number,
  96113. /**The loop mode of the animation */
  96114. loopMode?: number | undefined,
  96115. /**Specifies if blending should be enabled */
  96116. enableBlending?: boolean | undefined);
  96117. /**
  96118. * Converts the animation to a string
  96119. * @param fullDetails support for multiple levels of logging within scene loading
  96120. * @returns String form of the animation
  96121. */
  96122. toString(fullDetails?: boolean): string;
  96123. /**
  96124. * Add an event to this animation
  96125. * @param event Event to add
  96126. */
  96127. addEvent(event: AnimationEvent): void;
  96128. /**
  96129. * Remove all events found at the given frame
  96130. * @param frame The frame to remove events from
  96131. */
  96132. removeEvents(frame: number): void;
  96133. /**
  96134. * Retrieves all the events from the animation
  96135. * @returns Events from the animation
  96136. */
  96137. getEvents(): AnimationEvent[];
  96138. /**
  96139. * Creates an animation range
  96140. * @param name Name of the animation range
  96141. * @param from Starting frame of the animation range
  96142. * @param to Ending frame of the animation
  96143. */
  96144. createRange(name: string, from: number, to: number): void;
  96145. /**
  96146. * Deletes an animation range by name
  96147. * @param name Name of the animation range to delete
  96148. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  96149. */
  96150. deleteRange(name: string, deleteFrames?: boolean): void;
  96151. /**
  96152. * Gets the animation range by name, or null if not defined
  96153. * @param name Name of the animation range
  96154. * @returns Nullable animation range
  96155. */
  96156. getRange(name: string): Nullable<AnimationRange>;
  96157. /**
  96158. * Gets the key frames from the animation
  96159. * @returns The key frames of the animation
  96160. */
  96161. getKeys(): Array<IAnimationKey>;
  96162. /**
  96163. * Gets the highest frame rate of the animation
  96164. * @returns Highest frame rate of the animation
  96165. */
  96166. getHighestFrame(): number;
  96167. /**
  96168. * Gets the easing function of the animation
  96169. * @returns Easing function of the animation
  96170. */
  96171. getEasingFunction(): IEasingFunction;
  96172. /**
  96173. * Sets the easing function of the animation
  96174. * @param easingFunction A custom mathematical formula for animation
  96175. */
  96176. setEasingFunction(easingFunction: EasingFunction): void;
  96177. /**
  96178. * Interpolates a scalar linearly
  96179. * @param startValue Start value of the animation curve
  96180. * @param endValue End value of the animation curve
  96181. * @param gradient Scalar amount to interpolate
  96182. * @returns Interpolated scalar value
  96183. */
  96184. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  96185. /**
  96186. * Interpolates a scalar cubically
  96187. * @param startValue Start value of the animation curve
  96188. * @param outTangent End tangent of the animation
  96189. * @param endValue End value of the animation curve
  96190. * @param inTangent Start tangent of the animation curve
  96191. * @param gradient Scalar amount to interpolate
  96192. * @returns Interpolated scalar value
  96193. */
  96194. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  96195. /**
  96196. * Interpolates a quaternion using a spherical linear interpolation
  96197. * @param startValue Start value of the animation curve
  96198. * @param endValue End value of the animation curve
  96199. * @param gradient Scalar amount to interpolate
  96200. * @returns Interpolated quaternion value
  96201. */
  96202. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  96203. /**
  96204. * Interpolates a quaternion cubically
  96205. * @param startValue Start value of the animation curve
  96206. * @param outTangent End tangent of the animation curve
  96207. * @param endValue End value of the animation curve
  96208. * @param inTangent Start tangent of the animation curve
  96209. * @param gradient Scalar amount to interpolate
  96210. * @returns Interpolated quaternion value
  96211. */
  96212. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  96213. /**
  96214. * Interpolates a Vector3 linearl
  96215. * @param startValue Start value of the animation curve
  96216. * @param endValue End value of the animation curve
  96217. * @param gradient Scalar amount to interpolate
  96218. * @returns Interpolated scalar value
  96219. */
  96220. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  96221. /**
  96222. * Interpolates a Vector3 cubically
  96223. * @param startValue Start value of the animation curve
  96224. * @param outTangent End tangent of the animation
  96225. * @param endValue End value of the animation curve
  96226. * @param inTangent Start tangent of the animation curve
  96227. * @param gradient Scalar amount to interpolate
  96228. * @returns InterpolatedVector3 value
  96229. */
  96230. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  96231. /**
  96232. * Interpolates a Vector2 linearly
  96233. * @param startValue Start value of the animation curve
  96234. * @param endValue End value of the animation curve
  96235. * @param gradient Scalar amount to interpolate
  96236. * @returns Interpolated Vector2 value
  96237. */
  96238. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  96239. /**
  96240. * Interpolates a Vector2 cubically
  96241. * @param startValue Start value of the animation curve
  96242. * @param outTangent End tangent of the animation
  96243. * @param endValue End value of the animation curve
  96244. * @param inTangent Start tangent of the animation curve
  96245. * @param gradient Scalar amount to interpolate
  96246. * @returns Interpolated Vector2 value
  96247. */
  96248. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  96249. /**
  96250. * Interpolates a size linearly
  96251. * @param startValue Start value of the animation curve
  96252. * @param endValue End value of the animation curve
  96253. * @param gradient Scalar amount to interpolate
  96254. * @returns Interpolated Size value
  96255. */
  96256. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  96257. /**
  96258. * Interpolates a Color3 linearly
  96259. * @param startValue Start value of the animation curve
  96260. * @param endValue End value of the animation curve
  96261. * @param gradient Scalar amount to interpolate
  96262. * @returns Interpolated Color3 value
  96263. */
  96264. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  96265. /**
  96266. * Interpolates a Color4 linearly
  96267. * @param startValue Start value of the animation curve
  96268. * @param endValue End value of the animation curve
  96269. * @param gradient Scalar amount to interpolate
  96270. * @returns Interpolated Color3 value
  96271. */
  96272. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  96273. /**
  96274. * @hidden Internal use only
  96275. */
  96276. _getKeyValue(value: any): any;
  96277. /**
  96278. * @hidden Internal use only
  96279. */
  96280. _interpolate(currentFrame: number, state: _IAnimationState): any;
  96281. /**
  96282. * Defines the function to use to interpolate matrices
  96283. * @param startValue defines the start matrix
  96284. * @param endValue defines the end matrix
  96285. * @param gradient defines the gradient between both matrices
  96286. * @param result defines an optional target matrix where to store the interpolation
  96287. * @returns the interpolated matrix
  96288. */
  96289. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  96290. /**
  96291. * Makes a copy of the animation
  96292. * @returns Cloned animation
  96293. */
  96294. clone(): Animation;
  96295. /**
  96296. * Sets the key frames of the animation
  96297. * @param values The animation key frames to set
  96298. */
  96299. setKeys(values: Array<IAnimationKey>): void;
  96300. /**
  96301. * Serializes the animation to an object
  96302. * @returns Serialized object
  96303. */
  96304. serialize(): any;
  96305. /**
  96306. * Float animation type
  96307. */
  96308. static readonly ANIMATIONTYPE_FLOAT: number;
  96309. /**
  96310. * Vector3 animation type
  96311. */
  96312. static readonly ANIMATIONTYPE_VECTOR3: number;
  96313. /**
  96314. * Quaternion animation type
  96315. */
  96316. static readonly ANIMATIONTYPE_QUATERNION: number;
  96317. /**
  96318. * Matrix animation type
  96319. */
  96320. static readonly ANIMATIONTYPE_MATRIX: number;
  96321. /**
  96322. * Color3 animation type
  96323. */
  96324. static readonly ANIMATIONTYPE_COLOR3: number;
  96325. /**
  96326. * Color3 animation type
  96327. */
  96328. static readonly ANIMATIONTYPE_COLOR4: number;
  96329. /**
  96330. * Vector2 animation type
  96331. */
  96332. static readonly ANIMATIONTYPE_VECTOR2: number;
  96333. /**
  96334. * Size animation type
  96335. */
  96336. static readonly ANIMATIONTYPE_SIZE: number;
  96337. /**
  96338. * Relative Loop Mode
  96339. */
  96340. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  96341. /**
  96342. * Cycle Loop Mode
  96343. */
  96344. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  96345. /**
  96346. * Constant Loop Mode
  96347. */
  96348. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  96349. /** @hidden */
  96350. static _UniversalLerp(left: any, right: any, amount: number): any;
  96351. /**
  96352. * Parses an animation object and creates an animation
  96353. * @param parsedAnimation Parsed animation object
  96354. * @returns Animation object
  96355. */
  96356. static Parse(parsedAnimation: any): Animation;
  96357. /**
  96358. * Appends the serialized animations from the source animations
  96359. * @param source Source containing the animations
  96360. * @param destination Target to store the animations
  96361. */
  96362. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96363. }
  96364. }
  96365. declare module BABYLON {
  96366. /**
  96367. * Interface containing an array of animations
  96368. */
  96369. export interface IAnimatable {
  96370. /**
  96371. * Array of animations
  96372. */
  96373. animations: Nullable<Array<Animation>>;
  96374. }
  96375. }
  96376. declare module BABYLON {
  96377. /**
  96378. * This represents all the required information to add a fresnel effect on a material:
  96379. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96380. */
  96381. export class FresnelParameters {
  96382. private _isEnabled;
  96383. /**
  96384. * Define if the fresnel effect is enable or not.
  96385. */
  96386. isEnabled: boolean;
  96387. /**
  96388. * Define the color used on edges (grazing angle)
  96389. */
  96390. leftColor: Color3;
  96391. /**
  96392. * Define the color used on center
  96393. */
  96394. rightColor: Color3;
  96395. /**
  96396. * Define bias applied to computed fresnel term
  96397. */
  96398. bias: number;
  96399. /**
  96400. * Defined the power exponent applied to fresnel term
  96401. */
  96402. power: number;
  96403. /**
  96404. * Clones the current fresnel and its valuues
  96405. * @returns a clone fresnel configuration
  96406. */
  96407. clone(): FresnelParameters;
  96408. /**
  96409. * Serializes the current fresnel parameters to a JSON representation.
  96410. * @return the JSON serialization
  96411. */
  96412. serialize(): any;
  96413. /**
  96414. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  96415. * @param parsedFresnelParameters Define the JSON representation
  96416. * @returns the parsed parameters
  96417. */
  96418. static Parse(parsedFresnelParameters: any): FresnelParameters;
  96419. }
  96420. }
  96421. declare module BABYLON {
  96422. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  96423. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96424. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96425. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96426. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96427. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96428. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96429. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96430. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96431. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96432. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96433. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96434. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96435. /**
  96436. * Decorator used to define property that can be serialized as reference to a camera
  96437. * @param sourceName defines the name of the property to decorate
  96438. */
  96439. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  96440. /**
  96441. * Class used to help serialization objects
  96442. */
  96443. export class SerializationHelper {
  96444. /** @hidden */
  96445. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  96446. /** @hidden */
  96447. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  96448. /** @hidden */
  96449. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  96450. /** @hidden */
  96451. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  96452. /**
  96453. * Appends the serialized animations from the source animations
  96454. * @param source Source containing the animations
  96455. * @param destination Target to store the animations
  96456. */
  96457. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  96458. /**
  96459. * Static function used to serialized a specific entity
  96460. * @param entity defines the entity to serialize
  96461. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  96462. * @returns a JSON compatible object representing the serialization of the entity
  96463. */
  96464. static Serialize<T>(entity: T, serializationObject?: any): any;
  96465. /**
  96466. * Creates a new entity from a serialization data object
  96467. * @param creationFunction defines a function used to instanciated the new entity
  96468. * @param source defines the source serialization data
  96469. * @param scene defines the hosting scene
  96470. * @param rootUrl defines the root url for resources
  96471. * @returns a new entity
  96472. */
  96473. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  96474. /**
  96475. * Clones an object
  96476. * @param creationFunction defines the function used to instanciate the new object
  96477. * @param source defines the source object
  96478. * @returns the cloned object
  96479. */
  96480. static Clone<T>(creationFunction: () => T, source: T): T;
  96481. /**
  96482. * Instanciates a new object based on a source one (some data will be shared between both object)
  96483. * @param creationFunction defines the function used to instanciate the new object
  96484. * @param source defines the source object
  96485. * @returns the new object
  96486. */
  96487. static Instanciate<T>(creationFunction: () => T, source: T): T;
  96488. }
  96489. }
  96490. declare module BABYLON {
  96491. /**
  96492. * Class used to manipulate GUIDs
  96493. */
  96494. export class GUID {
  96495. /**
  96496. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96497. * Be aware Math.random() could cause collisions, but:
  96498. * "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"
  96499. * @returns a pseudo random id
  96500. */
  96501. static RandomId(): string;
  96502. }
  96503. }
  96504. declare module BABYLON {
  96505. /**
  96506. * Base class of all the textures in babylon.
  96507. * It groups all the common properties the materials, post process, lights... might need
  96508. * in order to make a correct use of the texture.
  96509. */
  96510. export class BaseTexture implements IAnimatable {
  96511. /**
  96512. * Default anisotropic filtering level for the application.
  96513. * It is set to 4 as a good tradeoff between perf and quality.
  96514. */
  96515. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  96516. /**
  96517. * Gets or sets the unique id of the texture
  96518. */
  96519. uniqueId: number;
  96520. /**
  96521. * Define the name of the texture.
  96522. */
  96523. name: string;
  96524. /**
  96525. * Gets or sets an object used to store user defined information.
  96526. */
  96527. metadata: any;
  96528. /**
  96529. * For internal use only. Please do not use.
  96530. */
  96531. reservedDataStore: any;
  96532. private _hasAlpha;
  96533. /**
  96534. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  96535. */
  96536. hasAlpha: boolean;
  96537. /**
  96538. * Defines if the alpha value should be determined via the rgb values.
  96539. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  96540. */
  96541. getAlphaFromRGB: boolean;
  96542. /**
  96543. * Intensity or strength of the texture.
  96544. * It is commonly used by materials to fine tune the intensity of the texture
  96545. */
  96546. level: number;
  96547. /**
  96548. * Define the UV chanel to use starting from 0 and defaulting to 0.
  96549. * This is part of the texture as textures usually maps to one uv set.
  96550. */
  96551. coordinatesIndex: number;
  96552. private _coordinatesMode;
  96553. /**
  96554. * How a texture is mapped.
  96555. *
  96556. * | Value | Type | Description |
  96557. * | ----- | ----------------------------------- | ----------- |
  96558. * | 0 | EXPLICIT_MODE | |
  96559. * | 1 | SPHERICAL_MODE | |
  96560. * | 2 | PLANAR_MODE | |
  96561. * | 3 | CUBIC_MODE | |
  96562. * | 4 | PROJECTION_MODE | |
  96563. * | 5 | SKYBOX_MODE | |
  96564. * | 6 | INVCUBIC_MODE | |
  96565. * | 7 | EQUIRECTANGULAR_MODE | |
  96566. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  96567. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  96568. */
  96569. coordinatesMode: number;
  96570. /**
  96571. * | Value | Type | Description |
  96572. * | ----- | ------------------ | ----------- |
  96573. * | 0 | CLAMP_ADDRESSMODE | |
  96574. * | 1 | WRAP_ADDRESSMODE | |
  96575. * | 2 | MIRROR_ADDRESSMODE | |
  96576. */
  96577. wrapU: number;
  96578. /**
  96579. * | Value | Type | Description |
  96580. * | ----- | ------------------ | ----------- |
  96581. * | 0 | CLAMP_ADDRESSMODE | |
  96582. * | 1 | WRAP_ADDRESSMODE | |
  96583. * | 2 | MIRROR_ADDRESSMODE | |
  96584. */
  96585. wrapV: number;
  96586. /**
  96587. * | Value | Type | Description |
  96588. * | ----- | ------------------ | ----------- |
  96589. * | 0 | CLAMP_ADDRESSMODE | |
  96590. * | 1 | WRAP_ADDRESSMODE | |
  96591. * | 2 | MIRROR_ADDRESSMODE | |
  96592. */
  96593. wrapR: number;
  96594. /**
  96595. * With compliant hardware and browser (supporting anisotropic filtering)
  96596. * this defines the level of anisotropic filtering in the texture.
  96597. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  96598. */
  96599. anisotropicFilteringLevel: number;
  96600. /**
  96601. * Define if the texture is a cube texture or if false a 2d texture.
  96602. */
  96603. isCube: boolean;
  96604. /**
  96605. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  96606. */
  96607. is3D: boolean;
  96608. /**
  96609. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  96610. */
  96611. is2DArray: boolean;
  96612. /**
  96613. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  96614. * HDR texture are usually stored in linear space.
  96615. * This only impacts the PBR and Background materials
  96616. */
  96617. gammaSpace: boolean;
  96618. /**
  96619. * Gets or sets whether or not the texture contains RGBD data.
  96620. */
  96621. isRGBD: boolean;
  96622. /**
  96623. * Is Z inverted in the texture (useful in a cube texture).
  96624. */
  96625. invertZ: boolean;
  96626. /**
  96627. * Are mip maps generated for this texture or not.
  96628. */
  96629. readonly noMipmap: boolean;
  96630. /**
  96631. * @hidden
  96632. */
  96633. lodLevelInAlpha: boolean;
  96634. /**
  96635. * With prefiltered texture, defined the offset used during the prefiltering steps.
  96636. */
  96637. lodGenerationOffset: number;
  96638. /**
  96639. * With prefiltered texture, defined the scale used during the prefiltering steps.
  96640. */
  96641. lodGenerationScale: number;
  96642. /**
  96643. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  96644. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  96645. * average roughness values.
  96646. */
  96647. linearSpecularLOD: boolean;
  96648. /**
  96649. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  96650. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  96651. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  96652. */
  96653. irradianceTexture: Nullable<BaseTexture>;
  96654. /**
  96655. * Define if the texture is a render target.
  96656. */
  96657. isRenderTarget: boolean;
  96658. /**
  96659. * Define the unique id of the texture in the scene.
  96660. */
  96661. readonly uid: string;
  96662. /**
  96663. * Return a string representation of the texture.
  96664. * @returns the texture as a string
  96665. */
  96666. toString(): string;
  96667. /**
  96668. * Get the class name of the texture.
  96669. * @returns "BaseTexture"
  96670. */
  96671. getClassName(): string;
  96672. /**
  96673. * Define the list of animation attached to the texture.
  96674. */
  96675. animations: Animation[];
  96676. /**
  96677. * An event triggered when the texture is disposed.
  96678. */
  96679. onDisposeObservable: Observable<BaseTexture>;
  96680. private _onDisposeObserver;
  96681. /**
  96682. * Callback triggered when the texture has been disposed.
  96683. * Kept for back compatibility, you can use the onDisposeObservable instead.
  96684. */
  96685. onDispose: () => void;
  96686. /**
  96687. * Define the current state of the loading sequence when in delayed load mode.
  96688. */
  96689. delayLoadState: number;
  96690. private _scene;
  96691. /** @hidden */
  96692. _texture: Nullable<InternalTexture>;
  96693. private _uid;
  96694. /**
  96695. * Define if the texture is preventinga material to render or not.
  96696. * If not and the texture is not ready, the engine will use a default black texture instead.
  96697. */
  96698. readonly isBlocking: boolean;
  96699. /**
  96700. * Instantiates a new BaseTexture.
  96701. * Base class of all the textures in babylon.
  96702. * It groups all the common properties the materials, post process, lights... might need
  96703. * in order to make a correct use of the texture.
  96704. * @param scene Define the scene the texture blongs to
  96705. */
  96706. constructor(scene: Nullable<Scene>);
  96707. /**
  96708. * Get the scene the texture belongs to.
  96709. * @returns the scene or null if undefined
  96710. */
  96711. getScene(): Nullable<Scene>;
  96712. /**
  96713. * Get the texture transform matrix used to offset tile the texture for istance.
  96714. * @returns the transformation matrix
  96715. */
  96716. getTextureMatrix(): Matrix;
  96717. /**
  96718. * Get the texture reflection matrix used to rotate/transform the reflection.
  96719. * @returns the reflection matrix
  96720. */
  96721. getReflectionTextureMatrix(): Matrix;
  96722. /**
  96723. * Get the underlying lower level texture from Babylon.
  96724. * @returns the insternal texture
  96725. */
  96726. getInternalTexture(): Nullable<InternalTexture>;
  96727. /**
  96728. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  96729. * @returns true if ready or not blocking
  96730. */
  96731. isReadyOrNotBlocking(): boolean;
  96732. /**
  96733. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  96734. * @returns true if fully ready
  96735. */
  96736. isReady(): boolean;
  96737. private _cachedSize;
  96738. /**
  96739. * Get the size of the texture.
  96740. * @returns the texture size.
  96741. */
  96742. getSize(): ISize;
  96743. /**
  96744. * Get the base size of the texture.
  96745. * It can be different from the size if the texture has been resized for POT for instance
  96746. * @returns the base size
  96747. */
  96748. getBaseSize(): ISize;
  96749. /**
  96750. * Update the sampling mode of the texture.
  96751. * Default is Trilinear mode.
  96752. *
  96753. * | Value | Type | Description |
  96754. * | ----- | ------------------ | ----------- |
  96755. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  96756. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  96757. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  96758. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  96759. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  96760. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  96761. * | 7 | NEAREST_LINEAR | |
  96762. * | 8 | NEAREST_NEAREST | |
  96763. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  96764. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  96765. * | 11 | LINEAR_LINEAR | |
  96766. * | 12 | LINEAR_NEAREST | |
  96767. *
  96768. * > _mag_: magnification filter (close to the viewer)
  96769. * > _min_: minification filter (far from the viewer)
  96770. * > _mip_: filter used between mip map levels
  96771. *@param samplingMode Define the new sampling mode of the texture
  96772. */
  96773. updateSamplingMode(samplingMode: number): void;
  96774. /**
  96775. * Scales the texture if is `canRescale()`
  96776. * @param ratio the resize factor we want to use to rescale
  96777. */
  96778. scale(ratio: number): void;
  96779. /**
  96780. * Get if the texture can rescale.
  96781. */
  96782. readonly canRescale: boolean;
  96783. /** @hidden */
  96784. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  96785. /** @hidden */
  96786. _rebuild(): void;
  96787. /**
  96788. * Triggers the load sequence in delayed load mode.
  96789. */
  96790. delayLoad(): void;
  96791. /**
  96792. * Clones the texture.
  96793. * @returns the cloned texture
  96794. */
  96795. clone(): Nullable<BaseTexture>;
  96796. /**
  96797. * Get the texture underlying type (INT, FLOAT...)
  96798. */
  96799. readonly textureType: number;
  96800. /**
  96801. * Get the texture underlying format (RGB, RGBA...)
  96802. */
  96803. readonly textureFormat: number;
  96804. /**
  96805. * Indicates that textures need to be re-calculated for all materials
  96806. */
  96807. protected _markAllSubMeshesAsTexturesDirty(): void;
  96808. /**
  96809. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  96810. * This will returns an RGBA array buffer containing either in values (0-255) or
  96811. * float values (0-1) depending of the underlying buffer type.
  96812. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  96813. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  96814. * @param buffer defines a user defined buffer to fill with data (can be null)
  96815. * @returns The Array buffer containing the pixels data.
  96816. */
  96817. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  96818. /**
  96819. * Release and destroy the underlying lower level texture aka internalTexture.
  96820. */
  96821. releaseInternalTexture(): void;
  96822. /** @hidden */
  96823. readonly _lodTextureHigh: Nullable<BaseTexture>;
  96824. /** @hidden */
  96825. readonly _lodTextureMid: Nullable<BaseTexture>;
  96826. /** @hidden */
  96827. readonly _lodTextureLow: Nullable<BaseTexture>;
  96828. /**
  96829. * Dispose the texture and release its associated resources.
  96830. */
  96831. dispose(): void;
  96832. /**
  96833. * Serialize the texture into a JSON representation that can be parsed later on.
  96834. * @returns the JSON representation of the texture
  96835. */
  96836. serialize(): any;
  96837. /**
  96838. * Helper function to be called back once a list of texture contains only ready textures.
  96839. * @param textures Define the list of textures to wait for
  96840. * @param callback Define the callback triggered once the entire list will be ready
  96841. */
  96842. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  96843. }
  96844. }
  96845. declare module BABYLON {
  96846. /**
  96847. * Options to be used when creating an effect.
  96848. */
  96849. export interface IEffectCreationOptions {
  96850. /**
  96851. * Atrributes that will be used in the shader.
  96852. */
  96853. attributes: string[];
  96854. /**
  96855. * Uniform varible names that will be set in the shader.
  96856. */
  96857. uniformsNames: string[];
  96858. /**
  96859. * Uniform buffer variable names that will be set in the shader.
  96860. */
  96861. uniformBuffersNames: string[];
  96862. /**
  96863. * Sampler texture variable names that will be set in the shader.
  96864. */
  96865. samplers: string[];
  96866. /**
  96867. * Define statements that will be set in the shader.
  96868. */
  96869. defines: any;
  96870. /**
  96871. * Possible fallbacks for this effect to improve performance when needed.
  96872. */
  96873. fallbacks: Nullable<IEffectFallbacks>;
  96874. /**
  96875. * Callback that will be called when the shader is compiled.
  96876. */
  96877. onCompiled: Nullable<(effect: Effect) => void>;
  96878. /**
  96879. * Callback that will be called if an error occurs during shader compilation.
  96880. */
  96881. onError: Nullable<(effect: Effect, errors: string) => void>;
  96882. /**
  96883. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96884. */
  96885. indexParameters?: any;
  96886. /**
  96887. * Max number of lights that can be used in the shader.
  96888. */
  96889. maxSimultaneousLights?: number;
  96890. /**
  96891. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  96892. */
  96893. transformFeedbackVaryings?: Nullable<string[]>;
  96894. }
  96895. /**
  96896. * Effect containing vertex and fragment shader that can be executed on an object.
  96897. */
  96898. export class Effect implements IDisposable {
  96899. /**
  96900. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96901. */
  96902. static ShadersRepository: string;
  96903. /**
  96904. * Name of the effect.
  96905. */
  96906. name: any;
  96907. /**
  96908. * String container all the define statements that should be set on the shader.
  96909. */
  96910. defines: string;
  96911. /**
  96912. * Callback that will be called when the shader is compiled.
  96913. */
  96914. onCompiled: Nullable<(effect: Effect) => void>;
  96915. /**
  96916. * Callback that will be called if an error occurs during shader compilation.
  96917. */
  96918. onError: Nullable<(effect: Effect, errors: string) => void>;
  96919. /**
  96920. * Callback that will be called when effect is bound.
  96921. */
  96922. onBind: Nullable<(effect: Effect) => void>;
  96923. /**
  96924. * Unique ID of the effect.
  96925. */
  96926. uniqueId: number;
  96927. /**
  96928. * Observable that will be called when the shader is compiled.
  96929. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  96930. */
  96931. onCompileObservable: Observable<Effect>;
  96932. /**
  96933. * Observable that will be called if an error occurs during shader compilation.
  96934. */
  96935. onErrorObservable: Observable<Effect>;
  96936. /** @hidden */
  96937. _onBindObservable: Nullable<Observable<Effect>>;
  96938. /**
  96939. * Observable that will be called when effect is bound.
  96940. */
  96941. readonly onBindObservable: Observable<Effect>;
  96942. /** @hidden */
  96943. _bonesComputationForcedToCPU: boolean;
  96944. private static _uniqueIdSeed;
  96945. private _engine;
  96946. private _uniformBuffersNames;
  96947. private _uniformsNames;
  96948. private _samplerList;
  96949. private _samplers;
  96950. private _isReady;
  96951. private _compilationError;
  96952. private _allFallbacksProcessed;
  96953. private _attributesNames;
  96954. private _attributes;
  96955. private _uniforms;
  96956. /**
  96957. * Key for the effect.
  96958. * @hidden
  96959. */
  96960. _key: string;
  96961. private _indexParameters;
  96962. private _fallbacks;
  96963. private _vertexSourceCode;
  96964. private _fragmentSourceCode;
  96965. private _vertexSourceCodeOverride;
  96966. private _fragmentSourceCodeOverride;
  96967. private _transformFeedbackVaryings;
  96968. /**
  96969. * Compiled shader to webGL program.
  96970. * @hidden
  96971. */
  96972. _pipelineContext: Nullable<IPipelineContext>;
  96973. private _valueCache;
  96974. private static _baseCache;
  96975. /**
  96976. * Instantiates an effect.
  96977. * An effect can be used to create/manage/execute vertex and fragment shaders.
  96978. * @param baseName Name of the effect.
  96979. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  96980. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  96981. * @param samplers List of sampler variables that will be passed to the shader.
  96982. * @param engine Engine to be used to render the effect
  96983. * @param defines Define statements to be added to the shader.
  96984. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  96985. * @param onCompiled Callback that will be called when the shader is compiled.
  96986. * @param onError Callback that will be called if an error occurs during shader compilation.
  96987. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  96988. */
  96989. 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);
  96990. private _useFinalCode;
  96991. /**
  96992. * Unique key for this effect
  96993. */
  96994. readonly key: string;
  96995. /**
  96996. * If the effect has been compiled and prepared.
  96997. * @returns if the effect is compiled and prepared.
  96998. */
  96999. isReady(): boolean;
  97000. private _isReadyInternal;
  97001. /**
  97002. * The engine the effect was initialized with.
  97003. * @returns the engine.
  97004. */
  97005. getEngine(): Engine;
  97006. /**
  97007. * The pipeline context for this effect
  97008. * @returns the associated pipeline context
  97009. */
  97010. getPipelineContext(): Nullable<IPipelineContext>;
  97011. /**
  97012. * The set of names of attribute variables for the shader.
  97013. * @returns An array of attribute names.
  97014. */
  97015. getAttributesNames(): string[];
  97016. /**
  97017. * Returns the attribute at the given index.
  97018. * @param index The index of the attribute.
  97019. * @returns The location of the attribute.
  97020. */
  97021. getAttributeLocation(index: number): number;
  97022. /**
  97023. * Returns the attribute based on the name of the variable.
  97024. * @param name of the attribute to look up.
  97025. * @returns the attribute location.
  97026. */
  97027. getAttributeLocationByName(name: string): number;
  97028. /**
  97029. * The number of attributes.
  97030. * @returns the numnber of attributes.
  97031. */
  97032. getAttributesCount(): number;
  97033. /**
  97034. * Gets the index of a uniform variable.
  97035. * @param uniformName of the uniform to look up.
  97036. * @returns the index.
  97037. */
  97038. getUniformIndex(uniformName: string): number;
  97039. /**
  97040. * Returns the attribute based on the name of the variable.
  97041. * @param uniformName of the uniform to look up.
  97042. * @returns the location of the uniform.
  97043. */
  97044. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  97045. /**
  97046. * Returns an array of sampler variable names
  97047. * @returns The array of sampler variable neames.
  97048. */
  97049. getSamplers(): string[];
  97050. /**
  97051. * The error from the last compilation.
  97052. * @returns the error string.
  97053. */
  97054. getCompilationError(): string;
  97055. /**
  97056. * Gets a boolean indicating that all fallbacks were used during compilation
  97057. * @returns true if all fallbacks were used
  97058. */
  97059. allFallbacksProcessed(): boolean;
  97060. /**
  97061. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  97062. * @param func The callback to be used.
  97063. */
  97064. executeWhenCompiled(func: (effect: Effect) => void): void;
  97065. private _checkIsReady;
  97066. private _loadShader;
  97067. /**
  97068. * Recompiles the webGL program
  97069. * @param vertexSourceCode The source code for the vertex shader.
  97070. * @param fragmentSourceCode The source code for the fragment shader.
  97071. * @param onCompiled Callback called when completed.
  97072. * @param onError Callback called on error.
  97073. * @hidden
  97074. */
  97075. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  97076. /**
  97077. * Prepares the effect
  97078. * @hidden
  97079. */
  97080. _prepareEffect(): void;
  97081. private _processCompilationErrors;
  97082. /**
  97083. * Checks if the effect is supported. (Must be called after compilation)
  97084. */
  97085. readonly isSupported: boolean;
  97086. /**
  97087. * Binds a texture to the engine to be used as output of the shader.
  97088. * @param channel Name of the output variable.
  97089. * @param texture Texture to bind.
  97090. * @hidden
  97091. */
  97092. _bindTexture(channel: string, texture: InternalTexture): void;
  97093. /**
  97094. * Sets a texture on the engine to be used in the shader.
  97095. * @param channel Name of the sampler variable.
  97096. * @param texture Texture to set.
  97097. */
  97098. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  97099. /**
  97100. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  97101. * @param channel Name of the sampler variable.
  97102. * @param texture Texture to set.
  97103. */
  97104. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  97105. /**
  97106. * Sets an array of textures on the engine to be used in the shader.
  97107. * @param channel Name of the variable.
  97108. * @param textures Textures to set.
  97109. */
  97110. setTextureArray(channel: string, textures: BaseTexture[]): void;
  97111. /**
  97112. * 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)
  97113. * @param channel Name of the sampler variable.
  97114. * @param postProcess Post process to get the input texture from.
  97115. */
  97116. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  97117. /**
  97118. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  97119. * 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)
  97120. * @param channel Name of the sampler variable.
  97121. * @param postProcess Post process to get the output texture from.
  97122. */
  97123. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  97124. /** @hidden */
  97125. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  97126. /** @hidden */
  97127. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  97128. /** @hidden */
  97129. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  97130. /** @hidden */
  97131. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  97132. /**
  97133. * Binds a buffer to a uniform.
  97134. * @param buffer Buffer to bind.
  97135. * @param name Name of the uniform variable to bind to.
  97136. */
  97137. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  97138. /**
  97139. * Binds block to a uniform.
  97140. * @param blockName Name of the block to bind.
  97141. * @param index Index to bind.
  97142. */
  97143. bindUniformBlock(blockName: string, index: number): void;
  97144. /**
  97145. * Sets an interger value on a uniform variable.
  97146. * @param uniformName Name of the variable.
  97147. * @param value Value to be set.
  97148. * @returns this effect.
  97149. */
  97150. setInt(uniformName: string, value: number): Effect;
  97151. /**
  97152. * Sets an int array on a uniform variable.
  97153. * @param uniformName Name of the variable.
  97154. * @param array array to be set.
  97155. * @returns this effect.
  97156. */
  97157. setIntArray(uniformName: string, array: Int32Array): Effect;
  97158. /**
  97159. * 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)
  97160. * @param uniformName Name of the variable.
  97161. * @param array array to be set.
  97162. * @returns this effect.
  97163. */
  97164. setIntArray2(uniformName: string, array: Int32Array): Effect;
  97165. /**
  97166. * 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)
  97167. * @param uniformName Name of the variable.
  97168. * @param array array to be set.
  97169. * @returns this effect.
  97170. */
  97171. setIntArray3(uniformName: string, array: Int32Array): Effect;
  97172. /**
  97173. * 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)
  97174. * @param uniformName Name of the variable.
  97175. * @param array array to be set.
  97176. * @returns this effect.
  97177. */
  97178. setIntArray4(uniformName: string, array: Int32Array): Effect;
  97179. /**
  97180. * Sets an float array on a uniform variable.
  97181. * @param uniformName Name of the variable.
  97182. * @param array array to be set.
  97183. * @returns this effect.
  97184. */
  97185. setFloatArray(uniformName: string, array: Float32Array): Effect;
  97186. /**
  97187. * 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)
  97188. * @param uniformName Name of the variable.
  97189. * @param array array to be set.
  97190. * @returns this effect.
  97191. */
  97192. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  97193. /**
  97194. * 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)
  97195. * @param uniformName Name of the variable.
  97196. * @param array array to be set.
  97197. * @returns this effect.
  97198. */
  97199. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  97200. /**
  97201. * 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)
  97202. * @param uniformName Name of the variable.
  97203. * @param array array to be set.
  97204. * @returns this effect.
  97205. */
  97206. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  97207. /**
  97208. * Sets an array on a uniform variable.
  97209. * @param uniformName Name of the variable.
  97210. * @param array array to be set.
  97211. * @returns this effect.
  97212. */
  97213. setArray(uniformName: string, array: number[]): Effect;
  97214. /**
  97215. * 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)
  97216. * @param uniformName Name of the variable.
  97217. * @param array array to be set.
  97218. * @returns this effect.
  97219. */
  97220. setArray2(uniformName: string, array: number[]): Effect;
  97221. /**
  97222. * 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)
  97223. * @param uniformName Name of the variable.
  97224. * @param array array to be set.
  97225. * @returns this effect.
  97226. */
  97227. setArray3(uniformName: string, array: number[]): Effect;
  97228. /**
  97229. * 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)
  97230. * @param uniformName Name of the variable.
  97231. * @param array array to be set.
  97232. * @returns this effect.
  97233. */
  97234. setArray4(uniformName: string, array: number[]): Effect;
  97235. /**
  97236. * Sets matrices on a uniform variable.
  97237. * @param uniformName Name of the variable.
  97238. * @param matrices matrices to be set.
  97239. * @returns this effect.
  97240. */
  97241. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  97242. /**
  97243. * Sets matrix on a uniform variable.
  97244. * @param uniformName Name of the variable.
  97245. * @param matrix matrix to be set.
  97246. * @returns this effect.
  97247. */
  97248. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  97249. /**
  97250. * 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)
  97251. * @param uniformName Name of the variable.
  97252. * @param matrix matrix to be set.
  97253. * @returns this effect.
  97254. */
  97255. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  97256. /**
  97257. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  97258. * @param uniformName Name of the variable.
  97259. * @param matrix matrix to be set.
  97260. * @returns this effect.
  97261. */
  97262. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  97263. /**
  97264. * Sets a float on a uniform variable.
  97265. * @param uniformName Name of the variable.
  97266. * @param value value to be set.
  97267. * @returns this effect.
  97268. */
  97269. setFloat(uniformName: string, value: number): Effect;
  97270. /**
  97271. * Sets a boolean on a uniform variable.
  97272. * @param uniformName Name of the variable.
  97273. * @param bool value to be set.
  97274. * @returns this effect.
  97275. */
  97276. setBool(uniformName: string, bool: boolean): Effect;
  97277. /**
  97278. * Sets a Vector2 on a uniform variable.
  97279. * @param uniformName Name of the variable.
  97280. * @param vector2 vector2 to be set.
  97281. * @returns this effect.
  97282. */
  97283. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  97284. /**
  97285. * Sets a float2 on a uniform variable.
  97286. * @param uniformName Name of the variable.
  97287. * @param x First float in float2.
  97288. * @param y Second float in float2.
  97289. * @returns this effect.
  97290. */
  97291. setFloat2(uniformName: string, x: number, y: number): Effect;
  97292. /**
  97293. * Sets a Vector3 on a uniform variable.
  97294. * @param uniformName Name of the variable.
  97295. * @param vector3 Value to be set.
  97296. * @returns this effect.
  97297. */
  97298. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  97299. /**
  97300. * Sets a float3 on a uniform variable.
  97301. * @param uniformName Name of the variable.
  97302. * @param x First float in float3.
  97303. * @param y Second float in float3.
  97304. * @param z Third float in float3.
  97305. * @returns this effect.
  97306. */
  97307. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  97308. /**
  97309. * Sets a Vector4 on a uniform variable.
  97310. * @param uniformName Name of the variable.
  97311. * @param vector4 Value to be set.
  97312. * @returns this effect.
  97313. */
  97314. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  97315. /**
  97316. * Sets a float4 on a uniform variable.
  97317. * @param uniformName Name of the variable.
  97318. * @param x First float in float4.
  97319. * @param y Second float in float4.
  97320. * @param z Third float in float4.
  97321. * @param w Fourth float in float4.
  97322. * @returns this effect.
  97323. */
  97324. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  97325. /**
  97326. * Sets a Color3 on a uniform variable.
  97327. * @param uniformName Name of the variable.
  97328. * @param color3 Value to be set.
  97329. * @returns this effect.
  97330. */
  97331. setColor3(uniformName: string, color3: IColor3Like): Effect;
  97332. /**
  97333. * Sets a Color4 on a uniform variable.
  97334. * @param uniformName Name of the variable.
  97335. * @param color3 Value to be set.
  97336. * @param alpha Alpha value to be set.
  97337. * @returns this effect.
  97338. */
  97339. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  97340. /**
  97341. * Sets a Color4 on a uniform variable
  97342. * @param uniformName defines the name of the variable
  97343. * @param color4 defines the value to be set
  97344. * @returns this effect.
  97345. */
  97346. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  97347. /** Release all associated resources */
  97348. dispose(): void;
  97349. /**
  97350. * This function will add a new shader to the shader store
  97351. * @param name the name of the shader
  97352. * @param pixelShader optional pixel shader content
  97353. * @param vertexShader optional vertex shader content
  97354. */
  97355. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  97356. /**
  97357. * Store of each shader (The can be looked up using effect.key)
  97358. */
  97359. static ShadersStore: {
  97360. [key: string]: string;
  97361. };
  97362. /**
  97363. * Store of each included file for a shader (The can be looked up using effect.key)
  97364. */
  97365. static IncludesShadersStore: {
  97366. [key: string]: string;
  97367. };
  97368. /**
  97369. * Resets the cache of effects.
  97370. */
  97371. static ResetCache(): void;
  97372. }
  97373. }
  97374. declare module BABYLON {
  97375. /**
  97376. * Interface used to describe the capabilities of the engine relatively to the current browser
  97377. */
  97378. export interface EngineCapabilities {
  97379. /** Maximum textures units per fragment shader */
  97380. maxTexturesImageUnits: number;
  97381. /** Maximum texture units per vertex shader */
  97382. maxVertexTextureImageUnits: number;
  97383. /** Maximum textures units in the entire pipeline */
  97384. maxCombinedTexturesImageUnits: number;
  97385. /** Maximum texture size */
  97386. maxTextureSize: number;
  97387. /** Maximum texture samples */
  97388. maxSamples?: number;
  97389. /** Maximum cube texture size */
  97390. maxCubemapTextureSize: number;
  97391. /** Maximum render texture size */
  97392. maxRenderTextureSize: number;
  97393. /** Maximum number of vertex attributes */
  97394. maxVertexAttribs: number;
  97395. /** Maximum number of varyings */
  97396. maxVaryingVectors: number;
  97397. /** Maximum number of uniforms per vertex shader */
  97398. maxVertexUniformVectors: number;
  97399. /** Maximum number of uniforms per fragment shader */
  97400. maxFragmentUniformVectors: number;
  97401. /** Defines if standard derivates (dx/dy) are supported */
  97402. standardDerivatives: boolean;
  97403. /** Defines if s3tc texture compression is supported */
  97404. s3tc?: WEBGL_compressed_texture_s3tc;
  97405. /** Defines if pvrtc texture compression is supported */
  97406. pvrtc: any;
  97407. /** Defines if etc1 texture compression is supported */
  97408. etc1: any;
  97409. /** Defines if etc2 texture compression is supported */
  97410. etc2: any;
  97411. /** Defines if astc texture compression is supported */
  97412. astc: any;
  97413. /** Defines if float textures are supported */
  97414. textureFloat: boolean;
  97415. /** Defines if vertex array objects are supported */
  97416. vertexArrayObject: boolean;
  97417. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  97418. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  97419. /** Gets the maximum level of anisotropy supported */
  97420. maxAnisotropy: number;
  97421. /** Defines if instancing is supported */
  97422. instancedArrays: boolean;
  97423. /** Defines if 32 bits indices are supported */
  97424. uintIndices: boolean;
  97425. /** Defines if high precision shaders are supported */
  97426. highPrecisionShaderSupported: boolean;
  97427. /** Defines if depth reading in the fragment shader is supported */
  97428. fragmentDepthSupported: boolean;
  97429. /** Defines if float texture linear filtering is supported*/
  97430. textureFloatLinearFiltering: boolean;
  97431. /** Defines if rendering to float textures is supported */
  97432. textureFloatRender: boolean;
  97433. /** Defines if half float textures are supported*/
  97434. textureHalfFloat: boolean;
  97435. /** Defines if half float texture linear filtering is supported*/
  97436. textureHalfFloatLinearFiltering: boolean;
  97437. /** Defines if rendering to half float textures is supported */
  97438. textureHalfFloatRender: boolean;
  97439. /** Defines if textureLOD shader command is supported */
  97440. textureLOD: boolean;
  97441. /** Defines if draw buffers extension is supported */
  97442. drawBuffersExtension: boolean;
  97443. /** Defines if depth textures are supported */
  97444. depthTextureExtension: boolean;
  97445. /** Defines if float color buffer are supported */
  97446. colorBufferFloat: boolean;
  97447. /** Gets disjoint timer query extension (null if not supported) */
  97448. timerQuery?: EXT_disjoint_timer_query;
  97449. /** Defines if timestamp can be used with timer query */
  97450. canUseTimestampForTimerQuery: boolean;
  97451. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  97452. multiview?: any;
  97453. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  97454. oculusMultiview?: any;
  97455. /** Function used to let the system compiles shaders in background */
  97456. parallelShaderCompile?: {
  97457. COMPLETION_STATUS_KHR: number;
  97458. };
  97459. /** Max number of texture samples for MSAA */
  97460. maxMSAASamples: number;
  97461. /** Defines if the blend min max extension is supported */
  97462. blendMinMax: boolean;
  97463. }
  97464. }
  97465. declare module BABYLON {
  97466. /**
  97467. * @hidden
  97468. **/
  97469. export class DepthCullingState {
  97470. private _isDepthTestDirty;
  97471. private _isDepthMaskDirty;
  97472. private _isDepthFuncDirty;
  97473. private _isCullFaceDirty;
  97474. private _isCullDirty;
  97475. private _isZOffsetDirty;
  97476. private _isFrontFaceDirty;
  97477. private _depthTest;
  97478. private _depthMask;
  97479. private _depthFunc;
  97480. private _cull;
  97481. private _cullFace;
  97482. private _zOffset;
  97483. private _frontFace;
  97484. /**
  97485. * Initializes the state.
  97486. */
  97487. constructor();
  97488. readonly isDirty: boolean;
  97489. zOffset: number;
  97490. cullFace: Nullable<number>;
  97491. cull: Nullable<boolean>;
  97492. depthFunc: Nullable<number>;
  97493. depthMask: boolean;
  97494. depthTest: boolean;
  97495. frontFace: Nullable<number>;
  97496. reset(): void;
  97497. apply(gl: WebGLRenderingContext): void;
  97498. }
  97499. }
  97500. declare module BABYLON {
  97501. /**
  97502. * @hidden
  97503. **/
  97504. export class StencilState {
  97505. /** 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 */
  97506. static readonly ALWAYS: number;
  97507. /** Passed to stencilOperation to specify that stencil value must be kept */
  97508. static readonly KEEP: number;
  97509. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97510. static readonly REPLACE: number;
  97511. private _isStencilTestDirty;
  97512. private _isStencilMaskDirty;
  97513. private _isStencilFuncDirty;
  97514. private _isStencilOpDirty;
  97515. private _stencilTest;
  97516. private _stencilMask;
  97517. private _stencilFunc;
  97518. private _stencilFuncRef;
  97519. private _stencilFuncMask;
  97520. private _stencilOpStencilFail;
  97521. private _stencilOpDepthFail;
  97522. private _stencilOpStencilDepthPass;
  97523. readonly isDirty: boolean;
  97524. stencilFunc: number;
  97525. stencilFuncRef: number;
  97526. stencilFuncMask: number;
  97527. stencilOpStencilFail: number;
  97528. stencilOpDepthFail: number;
  97529. stencilOpStencilDepthPass: number;
  97530. stencilMask: number;
  97531. stencilTest: boolean;
  97532. constructor();
  97533. reset(): void;
  97534. apply(gl: WebGLRenderingContext): void;
  97535. }
  97536. }
  97537. declare module BABYLON {
  97538. /**
  97539. * @hidden
  97540. **/
  97541. export class AlphaState {
  97542. private _isAlphaBlendDirty;
  97543. private _isBlendFunctionParametersDirty;
  97544. private _isBlendEquationParametersDirty;
  97545. private _isBlendConstantsDirty;
  97546. private _alphaBlend;
  97547. private _blendFunctionParameters;
  97548. private _blendEquationParameters;
  97549. private _blendConstants;
  97550. /**
  97551. * Initializes the state.
  97552. */
  97553. constructor();
  97554. readonly isDirty: boolean;
  97555. alphaBlend: boolean;
  97556. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  97557. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  97558. setAlphaEquationParameters(rgb: number, alpha: number): void;
  97559. reset(): void;
  97560. apply(gl: WebGLRenderingContext): void;
  97561. }
  97562. }
  97563. declare module BABYLON {
  97564. /** @hidden */
  97565. export class WebGL2ShaderProcessor implements IShaderProcessor {
  97566. attributeProcessor(attribute: string): string;
  97567. varyingProcessor(varying: string, isFragment: boolean): string;
  97568. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  97569. }
  97570. }
  97571. declare module BABYLON {
  97572. /**
  97573. * Interface for attribute information associated with buffer instanciation
  97574. */
  97575. export interface InstancingAttributeInfo {
  97576. /**
  97577. * Index/offset of the attribute in the vertex shader
  97578. */
  97579. index: number;
  97580. /**
  97581. * size of the attribute, 1, 2, 3 or 4
  97582. */
  97583. attributeSize: number;
  97584. /**
  97585. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  97586. * default is FLOAT
  97587. */
  97588. attributeType: number;
  97589. /**
  97590. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  97591. */
  97592. normalized: boolean;
  97593. /**
  97594. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  97595. */
  97596. offset: number;
  97597. /**
  97598. * Name of the GLSL attribute, for debugging purpose only
  97599. */
  97600. attributeName: string;
  97601. }
  97602. }
  97603. declare module BABYLON {
  97604. interface ThinEngine {
  97605. /**
  97606. * Update a video texture
  97607. * @param texture defines the texture to update
  97608. * @param video defines the video element to use
  97609. * @param invertY defines if data must be stored with Y axis inverted
  97610. */
  97611. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97612. }
  97613. }
  97614. declare module BABYLON {
  97615. /**
  97616. * Settings for finer control over video usage
  97617. */
  97618. export interface VideoTextureSettings {
  97619. /**
  97620. * Applies `autoplay` to video, if specified
  97621. */
  97622. autoPlay?: boolean;
  97623. /**
  97624. * Applies `loop` to video, if specified
  97625. */
  97626. loop?: boolean;
  97627. /**
  97628. * Automatically updates internal texture from video at every frame in the render loop
  97629. */
  97630. autoUpdateTexture: boolean;
  97631. /**
  97632. * Image src displayed during the video loading or until the user interacts with the video.
  97633. */
  97634. poster?: string;
  97635. }
  97636. /**
  97637. * If you want to display a video in your scene, this is the special texture for that.
  97638. * This special texture works similar to other textures, with the exception of a few parameters.
  97639. * @see https://doc.babylonjs.com/how_to/video_texture
  97640. */
  97641. export class VideoTexture extends Texture {
  97642. /**
  97643. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  97644. */
  97645. readonly autoUpdateTexture: boolean;
  97646. /**
  97647. * The video instance used by the texture internally
  97648. */
  97649. readonly video: HTMLVideoElement;
  97650. private _onUserActionRequestedObservable;
  97651. /**
  97652. * Event triggerd when a dom action is required by the user to play the video.
  97653. * This happens due to recent changes in browser policies preventing video to auto start.
  97654. */
  97655. readonly onUserActionRequestedObservable: Observable<Texture>;
  97656. private _generateMipMaps;
  97657. private _engine;
  97658. private _stillImageCaptured;
  97659. private _displayingPosterTexture;
  97660. private _settings;
  97661. private _createInternalTextureOnEvent;
  97662. private _frameId;
  97663. /**
  97664. * Creates a video texture.
  97665. * If you want to display a video in your scene, this is the special texture for that.
  97666. * This special texture works similar to other textures, with the exception of a few parameters.
  97667. * @see https://doc.babylonjs.com/how_to/video_texture
  97668. * @param name optional name, will detect from video source, if not defined
  97669. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  97670. * @param scene is obviously the current scene.
  97671. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  97672. * @param invertY is false by default but can be used to invert video on Y axis
  97673. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  97674. * @param settings allows finer control over video usage
  97675. */
  97676. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  97677. private _getName;
  97678. private _getVideo;
  97679. private _createInternalTexture;
  97680. private reset;
  97681. /**
  97682. * @hidden Internal method to initiate `update`.
  97683. */
  97684. _rebuild(): void;
  97685. /**
  97686. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  97687. */
  97688. update(): void;
  97689. /**
  97690. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  97691. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  97692. */
  97693. updateTexture(isVisible: boolean): void;
  97694. protected _updateInternalTexture: () => void;
  97695. /**
  97696. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  97697. * @param url New url.
  97698. */
  97699. updateURL(url: string): void;
  97700. /**
  97701. * Dispose the texture and release its associated resources.
  97702. */
  97703. dispose(): void;
  97704. /**
  97705. * Creates a video texture straight from a stream.
  97706. * @param scene Define the scene the texture should be created in
  97707. * @param stream Define the stream the texture should be created from
  97708. * @returns The created video texture as a promise
  97709. */
  97710. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  97711. /**
  97712. * Creates a video texture straight from your WebCam video feed.
  97713. * @param scene Define the scene the texture should be created in
  97714. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97715. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97716. * @returns The created video texture as a promise
  97717. */
  97718. static CreateFromWebCamAsync(scene: Scene, constraints: {
  97719. minWidth: number;
  97720. maxWidth: number;
  97721. minHeight: number;
  97722. maxHeight: number;
  97723. deviceId: string;
  97724. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  97725. /**
  97726. * Creates a video texture straight from your WebCam video feed.
  97727. * @param scene Define the scene the texture should be created in
  97728. * @param onReady Define a callback to triggered once the texture will be ready
  97729. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  97730. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  97731. */
  97732. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  97733. minWidth: number;
  97734. maxWidth: number;
  97735. minHeight: number;
  97736. maxHeight: number;
  97737. deviceId: string;
  97738. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  97739. }
  97740. }
  97741. declare module BABYLON {
  97742. /**
  97743. * Defines the interface used by objects working like Scene
  97744. * @hidden
  97745. */
  97746. interface ISceneLike {
  97747. _addPendingData(data: any): void;
  97748. _removePendingData(data: any): void;
  97749. offlineProvider: IOfflineProvider;
  97750. }
  97751. /** Interface defining initialization parameters for Engine class */
  97752. export interface EngineOptions extends WebGLContextAttributes {
  97753. /**
  97754. * Defines if the engine should no exceed a specified device ratio
  97755. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  97756. */
  97757. limitDeviceRatio?: number;
  97758. /**
  97759. * Defines if webvr should be enabled automatically
  97760. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97761. */
  97762. autoEnableWebVR?: boolean;
  97763. /**
  97764. * Defines if webgl2 should be turned off even if supported
  97765. * @see http://doc.babylonjs.com/features/webgl2
  97766. */
  97767. disableWebGL2Support?: boolean;
  97768. /**
  97769. * Defines if webaudio should be initialized as well
  97770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97771. */
  97772. audioEngine?: boolean;
  97773. /**
  97774. * Defines if animations should run using a deterministic lock step
  97775. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97776. */
  97777. deterministicLockstep?: boolean;
  97778. /** Defines the maximum steps to use with deterministic lock step mode */
  97779. lockstepMaxSteps?: number;
  97780. /**
  97781. * Defines that engine should ignore context lost events
  97782. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  97783. */
  97784. doNotHandleContextLost?: boolean;
  97785. /**
  97786. * Defines that engine should ignore modifying touch action attribute and style
  97787. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  97788. */
  97789. doNotHandleTouchAction?: boolean;
  97790. /**
  97791. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  97792. */
  97793. useHighPrecisionFloats?: boolean;
  97794. }
  97795. /**
  97796. * The base engine class (root of all engines)
  97797. */
  97798. export class ThinEngine {
  97799. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  97800. static ExceptionList: ({
  97801. key: string;
  97802. capture: string;
  97803. captureConstraint: number;
  97804. targets: string[];
  97805. } | {
  97806. key: string;
  97807. capture: null;
  97808. captureConstraint: null;
  97809. targets: string[];
  97810. })[];
  97811. /** @hidden */
  97812. static _TextureLoaders: IInternalTextureLoader[];
  97813. /**
  97814. * Returns the current npm package of the sdk
  97815. */
  97816. static readonly NpmPackage: string;
  97817. /**
  97818. * Returns the current version of the framework
  97819. */
  97820. static readonly Version: string;
  97821. /**
  97822. * Returns a string describing the current engine
  97823. */
  97824. readonly description: string;
  97825. /**
  97826. * Gets or sets the epsilon value used by collision engine
  97827. */
  97828. static CollisionsEpsilon: number;
  97829. /**
  97830. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  97831. */
  97832. static ShadersRepository: string;
  97833. /** @hidden */
  97834. _shaderProcessor: IShaderProcessor;
  97835. /**
  97836. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  97837. */
  97838. forcePOTTextures: boolean;
  97839. /**
  97840. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  97841. */
  97842. isFullscreen: boolean;
  97843. /**
  97844. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  97845. */
  97846. cullBackFaces: boolean;
  97847. /**
  97848. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  97849. */
  97850. renderEvenInBackground: boolean;
  97851. /**
  97852. * Gets or sets a boolean indicating that cache can be kept between frames
  97853. */
  97854. preventCacheWipeBetweenFrames: boolean;
  97855. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  97856. validateShaderPrograms: boolean;
  97857. /**
  97858. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  97859. * This can provide greater z depth for distant objects.
  97860. */
  97861. useReverseDepthBuffer: boolean;
  97862. /**
  97863. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  97864. */
  97865. disableUniformBuffers: boolean;
  97866. /** @hidden */
  97867. _uniformBuffers: UniformBuffer[];
  97868. /**
  97869. * Gets a boolean indicating that the engine supports uniform buffers
  97870. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  97871. */
  97872. readonly supportsUniformBuffers: boolean;
  97873. /** @hidden */
  97874. _gl: WebGLRenderingContext;
  97875. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  97876. protected _windowIsBackground: boolean;
  97877. protected _webGLVersion: number;
  97878. protected _creationOptions: EngineOptions;
  97879. protected _highPrecisionShadersAllowed: boolean;
  97880. /** @hidden */
  97881. readonly _shouldUseHighPrecisionShader: boolean;
  97882. /**
  97883. * Gets a boolean indicating that only power of 2 textures are supported
  97884. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  97885. */
  97886. readonly needPOTTextures: boolean;
  97887. /** @hidden */
  97888. _badOS: boolean;
  97889. /** @hidden */
  97890. _badDesktopOS: boolean;
  97891. private _hardwareScalingLevel;
  97892. /** @hidden */
  97893. _caps: EngineCapabilities;
  97894. private _isStencilEnable;
  97895. protected _colorWrite: boolean;
  97896. private _glVersion;
  97897. private _glRenderer;
  97898. private _glVendor;
  97899. /** @hidden */
  97900. _videoTextureSupported: boolean;
  97901. protected _renderingQueueLaunched: boolean;
  97902. protected _activeRenderLoops: (() => void)[];
  97903. /**
  97904. * Observable signaled when a context lost event is raised
  97905. */
  97906. onContextLostObservable: Observable<ThinEngine>;
  97907. /**
  97908. * Observable signaled when a context restored event is raised
  97909. */
  97910. onContextRestoredObservable: Observable<ThinEngine>;
  97911. private _onContextLost;
  97912. private _onContextRestored;
  97913. protected _contextWasLost: boolean;
  97914. /** @hidden */
  97915. _doNotHandleContextLost: boolean;
  97916. /**
  97917. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  97918. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  97919. */
  97920. doNotHandleContextLost: boolean;
  97921. /**
  97922. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  97923. */
  97924. disableVertexArrayObjects: boolean;
  97925. /** @hidden */
  97926. protected _depthCullingState: DepthCullingState;
  97927. /** @hidden */
  97928. protected _stencilState: StencilState;
  97929. /** @hidden */
  97930. protected _alphaState: AlphaState;
  97931. /** @hidden */
  97932. _internalTexturesCache: InternalTexture[];
  97933. /** @hidden */
  97934. protected _activeChannel: number;
  97935. private _currentTextureChannel;
  97936. /** @hidden */
  97937. protected _boundTexturesCache: {
  97938. [key: string]: Nullable<InternalTexture>;
  97939. };
  97940. /** @hidden */
  97941. protected _currentEffect: Nullable<Effect>;
  97942. /** @hidden */
  97943. protected _currentProgram: Nullable<WebGLProgram>;
  97944. private _compiledEffects;
  97945. private _vertexAttribArraysEnabled;
  97946. /** @hidden */
  97947. protected _cachedViewport: Nullable<IViewportLike>;
  97948. private _cachedVertexArrayObject;
  97949. /** @hidden */
  97950. protected _cachedVertexBuffers: any;
  97951. /** @hidden */
  97952. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  97953. /** @hidden */
  97954. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  97955. /** @hidden */
  97956. _currentRenderTarget: Nullable<InternalTexture>;
  97957. private _uintIndicesCurrentlySet;
  97958. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  97959. /** @hidden */
  97960. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  97961. private _currentBufferPointers;
  97962. private _currentInstanceLocations;
  97963. private _currentInstanceBuffers;
  97964. private _textureUnits;
  97965. /** @hidden */
  97966. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  97967. /** @hidden */
  97968. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  97969. /** @hidden */
  97970. _boundRenderFunction: any;
  97971. private _vaoRecordInProgress;
  97972. private _mustWipeVertexAttributes;
  97973. private _emptyTexture;
  97974. private _emptyCubeTexture;
  97975. private _emptyTexture3D;
  97976. private _emptyTexture2DArray;
  97977. /** @hidden */
  97978. _frameHandler: number;
  97979. private _nextFreeTextureSlots;
  97980. private _maxSimultaneousTextures;
  97981. private _activeRequests;
  97982. protected _texturesSupported: string[];
  97983. /** @hidden */
  97984. _textureFormatInUse: Nullable<string>;
  97985. protected readonly _supportsHardwareTextureRescaling: boolean;
  97986. /**
  97987. * Gets the list of texture formats supported
  97988. */
  97989. readonly texturesSupported: Array<string>;
  97990. /**
  97991. * Gets the list of texture formats in use
  97992. */
  97993. readonly textureFormatInUse: Nullable<string>;
  97994. /**
  97995. * Gets the current viewport
  97996. */
  97997. readonly currentViewport: Nullable<IViewportLike>;
  97998. /**
  97999. * Gets the default empty texture
  98000. */
  98001. readonly emptyTexture: InternalTexture;
  98002. /**
  98003. * Gets the default empty 3D texture
  98004. */
  98005. readonly emptyTexture3D: InternalTexture;
  98006. /**
  98007. * Gets the default empty 2D array texture
  98008. */
  98009. readonly emptyTexture2DArray: InternalTexture;
  98010. /**
  98011. * Gets the default empty cube texture
  98012. */
  98013. readonly emptyCubeTexture: InternalTexture;
  98014. /**
  98015. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  98016. */
  98017. readonly premultipliedAlpha: boolean;
  98018. /**
  98019. * Observable event triggered before each texture is initialized
  98020. */
  98021. onBeforeTextureInitObservable: Observable<Texture>;
  98022. /**
  98023. * Creates a new engine
  98024. * @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
  98025. * @param antialias defines enable antialiasing (default: false)
  98026. * @param options defines further options to be sent to the getContext() function
  98027. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98028. */
  98029. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98030. private _rebuildInternalTextures;
  98031. private _rebuildEffects;
  98032. /**
  98033. * Gets a boolean indicating if all created effects are ready
  98034. * @returns true if all effects are ready
  98035. */
  98036. areAllEffectsReady(): boolean;
  98037. protected _rebuildBuffers(): void;
  98038. private _initGLContext;
  98039. /**
  98040. * Gets version of the current webGL context
  98041. */
  98042. readonly webGLVersion: number;
  98043. /**
  98044. * Gets a string idenfifying the name of the class
  98045. * @returns "Engine" string
  98046. */
  98047. getClassName(): string;
  98048. /**
  98049. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  98050. */
  98051. readonly isStencilEnable: boolean;
  98052. /** @hidden */
  98053. _prepareWorkingCanvas(): void;
  98054. /**
  98055. * Reset the texture cache to empty state
  98056. */
  98057. resetTextureCache(): void;
  98058. /**
  98059. * Gets an object containing information about the current webGL context
  98060. * @returns an object containing the vender, the renderer and the version of the current webGL context
  98061. */
  98062. getGlInfo(): {
  98063. vendor: string;
  98064. renderer: string;
  98065. version: string;
  98066. };
  98067. /**
  98068. * Defines the hardware scaling level.
  98069. * By default the hardware scaling level is computed from the window device ratio.
  98070. * 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.
  98071. * @param level defines the level to use
  98072. */
  98073. setHardwareScalingLevel(level: number): void;
  98074. /**
  98075. * Gets the current hardware scaling level.
  98076. * By default the hardware scaling level is computed from the window device ratio.
  98077. * 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.
  98078. * @returns a number indicating the current hardware scaling level
  98079. */
  98080. getHardwareScalingLevel(): number;
  98081. /**
  98082. * Gets the list of loaded textures
  98083. * @returns an array containing all loaded textures
  98084. */
  98085. getLoadedTexturesCache(): InternalTexture[];
  98086. /**
  98087. * Gets the object containing all engine capabilities
  98088. * @returns the EngineCapabilities object
  98089. */
  98090. getCaps(): EngineCapabilities;
  98091. /**
  98092. * stop executing a render loop function and remove it from the execution array
  98093. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  98094. */
  98095. stopRenderLoop(renderFunction?: () => void): void;
  98096. /** @hidden */
  98097. _renderLoop(): void;
  98098. /**
  98099. * Gets the HTML canvas attached with the current webGL context
  98100. * @returns a HTML canvas
  98101. */
  98102. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  98103. /**
  98104. * Gets host window
  98105. * @returns the host window object
  98106. */
  98107. getHostWindow(): Nullable<Window>;
  98108. /**
  98109. * Gets the current render width
  98110. * @param useScreen defines if screen size must be used (or the current render target if any)
  98111. * @returns a number defining the current render width
  98112. */
  98113. getRenderWidth(useScreen?: boolean): number;
  98114. /**
  98115. * Gets the current render height
  98116. * @param useScreen defines if screen size must be used (or the current render target if any)
  98117. * @returns a number defining the current render height
  98118. */
  98119. getRenderHeight(useScreen?: boolean): number;
  98120. /**
  98121. * Can be used to override the current requestAnimationFrame requester.
  98122. * @hidden
  98123. */
  98124. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  98125. /**
  98126. * Register and execute a render loop. The engine can have more than one render function
  98127. * @param renderFunction defines the function to continuously execute
  98128. */
  98129. runRenderLoop(renderFunction: () => void): void;
  98130. /**
  98131. * Clear the current render buffer or the current render target (if any is set up)
  98132. * @param color defines the color to use
  98133. * @param backBuffer defines if the back buffer must be cleared
  98134. * @param depth defines if the depth buffer must be cleared
  98135. * @param stencil defines if the stencil buffer must be cleared
  98136. */
  98137. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  98138. private _viewportCached;
  98139. /** @hidden */
  98140. _viewport(x: number, y: number, width: number, height: number): void;
  98141. /**
  98142. * Set the WebGL's viewport
  98143. * @param viewport defines the viewport element to be used
  98144. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  98145. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  98146. */
  98147. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  98148. /**
  98149. * Begin a new frame
  98150. */
  98151. beginFrame(): void;
  98152. /**
  98153. * Enf the current frame
  98154. */
  98155. endFrame(): void;
  98156. /**
  98157. * Resize the view according to the canvas' size
  98158. */
  98159. resize(): void;
  98160. /**
  98161. * Force a specific size of the canvas
  98162. * @param width defines the new canvas' width
  98163. * @param height defines the new canvas' height
  98164. */
  98165. setSize(width: number, height: number): void;
  98166. /**
  98167. * Binds the frame buffer to the specified texture.
  98168. * @param texture The texture to render to or null for the default canvas
  98169. * @param faceIndex The face of the texture to render to in case of cube texture
  98170. * @param requiredWidth The width of the target to render to
  98171. * @param requiredHeight The height of the target to render to
  98172. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  98173. * @param depthStencilTexture The depth stencil texture to use to render
  98174. * @param lodLevel defines le lod level to bind to the frame buffer
  98175. */
  98176. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  98177. /** @hidden */
  98178. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  98179. /**
  98180. * Unbind the current render target texture from the webGL context
  98181. * @param texture defines the render target texture to unbind
  98182. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  98183. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  98184. */
  98185. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  98186. /**
  98187. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  98188. */
  98189. flushFramebuffer(): void;
  98190. /**
  98191. * Unbind the current render target and bind the default framebuffer
  98192. */
  98193. restoreDefaultFramebuffer(): void;
  98194. /** @hidden */
  98195. protected _resetVertexBufferBinding(): void;
  98196. /**
  98197. * Creates a vertex buffer
  98198. * @param data the data for the vertex buffer
  98199. * @returns the new WebGL static buffer
  98200. */
  98201. createVertexBuffer(data: DataArray): DataBuffer;
  98202. private _createVertexBuffer;
  98203. /**
  98204. * Creates a dynamic vertex buffer
  98205. * @param data the data for the dynamic vertex buffer
  98206. * @returns the new WebGL dynamic buffer
  98207. */
  98208. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  98209. protected _resetIndexBufferBinding(): void;
  98210. /**
  98211. * Creates a new index buffer
  98212. * @param indices defines the content of the index buffer
  98213. * @param updatable defines if the index buffer must be updatable
  98214. * @returns a new webGL buffer
  98215. */
  98216. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  98217. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  98218. /**
  98219. * Bind a webGL buffer to the webGL context
  98220. * @param buffer defines the buffer to bind
  98221. */
  98222. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  98223. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  98224. private bindBuffer;
  98225. /**
  98226. * update the bound buffer with the given data
  98227. * @param data defines the data to update
  98228. */
  98229. updateArrayBuffer(data: Float32Array): void;
  98230. private _vertexAttribPointer;
  98231. private _bindIndexBufferWithCache;
  98232. private _bindVertexBuffersAttributes;
  98233. /**
  98234. * Records a vertex array object
  98235. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  98236. * @param vertexBuffers defines the list of vertex buffers to store
  98237. * @param indexBuffer defines the index buffer to store
  98238. * @param effect defines the effect to store
  98239. * @returns the new vertex array object
  98240. */
  98241. recordVertexArrayObject(vertexBuffers: {
  98242. [key: string]: VertexBuffer;
  98243. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  98244. /**
  98245. * Bind a specific vertex array object
  98246. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  98247. * @param vertexArrayObject defines the vertex array object to bind
  98248. * @param indexBuffer defines the index buffer to bind
  98249. */
  98250. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  98251. /**
  98252. * Bind webGl buffers directly to the webGL context
  98253. * @param vertexBuffer defines the vertex buffer to bind
  98254. * @param indexBuffer defines the index buffer to bind
  98255. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  98256. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  98257. * @param effect defines the effect associated with the vertex buffer
  98258. */
  98259. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  98260. private _unbindVertexArrayObject;
  98261. /**
  98262. * Bind a list of vertex buffers to the webGL context
  98263. * @param vertexBuffers defines the list of vertex buffers to bind
  98264. * @param indexBuffer defines the index buffer to bind
  98265. * @param effect defines the effect associated with the vertex buffers
  98266. */
  98267. bindBuffers(vertexBuffers: {
  98268. [key: string]: Nullable<VertexBuffer>;
  98269. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  98270. /**
  98271. * Unbind all instance attributes
  98272. */
  98273. unbindInstanceAttributes(): void;
  98274. /**
  98275. * Release and free the memory of a vertex array object
  98276. * @param vao defines the vertex array object to delete
  98277. */
  98278. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  98279. /** @hidden */
  98280. _releaseBuffer(buffer: DataBuffer): boolean;
  98281. protected _deleteBuffer(buffer: DataBuffer): void;
  98282. /**
  98283. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  98284. * @param instancesBuffer defines the webGL buffer to update and bind
  98285. * @param data defines the data to store in the buffer
  98286. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  98287. */
  98288. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  98289. /**
  98290. * Apply all cached states (depth, culling, stencil and alpha)
  98291. */
  98292. applyStates(): void;
  98293. /**
  98294. * Send a draw order
  98295. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98296. * @param indexStart defines the starting index
  98297. * @param indexCount defines the number of index to draw
  98298. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98299. */
  98300. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  98301. /**
  98302. * Draw a list of points
  98303. * @param verticesStart defines the index of first vertex to draw
  98304. * @param verticesCount defines the count of vertices to draw
  98305. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98306. */
  98307. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98308. /**
  98309. * Draw a list of unindexed primitives
  98310. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  98311. * @param verticesStart defines the index of first vertex to draw
  98312. * @param verticesCount defines the count of vertices to draw
  98313. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98314. */
  98315. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98316. /**
  98317. * Draw a list of indexed primitives
  98318. * @param fillMode defines the primitive to use
  98319. * @param indexStart defines the starting index
  98320. * @param indexCount defines the number of index to draw
  98321. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98322. */
  98323. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  98324. /**
  98325. * Draw a list of unindexed primitives
  98326. * @param fillMode defines the primitive to use
  98327. * @param verticesStart defines the index of first vertex to draw
  98328. * @param verticesCount defines the count of vertices to draw
  98329. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  98330. */
  98331. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  98332. private _drawMode;
  98333. /** @hidden */
  98334. protected _reportDrawCall(): void;
  98335. /** @hidden */
  98336. _releaseEffect(effect: Effect): void;
  98337. /** @hidden */
  98338. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98339. /**
  98340. * Create a new effect (used to store vertex/fragment shaders)
  98341. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  98342. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  98343. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  98344. * @param samplers defines an array of string used to represent textures
  98345. * @param defines defines the string containing the defines to use to compile the shaders
  98346. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  98347. * @param onCompiled defines a function to call when the effect creation is successful
  98348. * @param onError defines a function to call when the effect creation has failed
  98349. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  98350. * @returns the new Effect
  98351. */
  98352. 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;
  98353. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  98354. private _compileShader;
  98355. private _compileRawShader;
  98356. /**
  98357. * Directly creates a webGL program
  98358. * @param pipelineContext defines the pipeline context to attach to
  98359. * @param vertexCode defines the vertex shader code to use
  98360. * @param fragmentCode defines the fragment shader code to use
  98361. * @param context defines the webGL context to use (if not set, the current one will be used)
  98362. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98363. * @returns the new webGL program
  98364. */
  98365. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98366. /**
  98367. * Creates a webGL program
  98368. * @param pipelineContext defines the pipeline context to attach to
  98369. * @param vertexCode defines the vertex shader code to use
  98370. * @param fragmentCode defines the fragment shader code to use
  98371. * @param defines defines the string containing the defines to use to compile the shaders
  98372. * @param context defines the webGL context to use (if not set, the current one will be used)
  98373. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  98374. * @returns the new webGL program
  98375. */
  98376. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98377. /**
  98378. * Creates a new pipeline context
  98379. * @returns the new pipeline
  98380. */
  98381. createPipelineContext(): IPipelineContext;
  98382. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98383. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  98384. /** @hidden */
  98385. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  98386. /** @hidden */
  98387. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  98388. /** @hidden */
  98389. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  98390. /**
  98391. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  98392. * @param pipelineContext defines the pipeline context to use
  98393. * @param uniformsNames defines the list of uniform names
  98394. * @returns an array of webGL uniform locations
  98395. */
  98396. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  98397. /**
  98398. * Gets the lsit of active attributes for a given webGL program
  98399. * @param pipelineContext defines the pipeline context to use
  98400. * @param attributesNames defines the list of attribute names to get
  98401. * @returns an array of indices indicating the offset of each attribute
  98402. */
  98403. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  98404. /**
  98405. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  98406. * @param effect defines the effect to activate
  98407. */
  98408. enableEffect(effect: Nullable<Effect>): void;
  98409. /**
  98410. * Set the value of an uniform to a number (int)
  98411. * @param uniform defines the webGL uniform location where to store the value
  98412. * @param value defines the int number to store
  98413. */
  98414. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98415. /**
  98416. * Set the value of an uniform to an array of int32
  98417. * @param uniform defines the webGL uniform location where to store the value
  98418. * @param array defines the array of int32 to store
  98419. */
  98420. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98421. /**
  98422. * Set the value of an uniform to an array of int32 (stored as vec2)
  98423. * @param uniform defines the webGL uniform location where to store the value
  98424. * @param array defines the array of int32 to store
  98425. */
  98426. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98427. /**
  98428. * Set the value of an uniform to an array of int32 (stored as vec3)
  98429. * @param uniform defines the webGL uniform location where to store the value
  98430. * @param array defines the array of int32 to store
  98431. */
  98432. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98433. /**
  98434. * Set the value of an uniform to an array of int32 (stored as vec4)
  98435. * @param uniform defines the webGL uniform location where to store the value
  98436. * @param array defines the array of int32 to store
  98437. */
  98438. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  98439. /**
  98440. * Set the value of an uniform to an array of number
  98441. * @param uniform defines the webGL uniform location where to store the value
  98442. * @param array defines the array of number to store
  98443. */
  98444. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98445. /**
  98446. * Set the value of an uniform to an array of number (stored as vec2)
  98447. * @param uniform defines the webGL uniform location where to store the value
  98448. * @param array defines the array of number to store
  98449. */
  98450. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98451. /**
  98452. * Set the value of an uniform to an array of number (stored as vec3)
  98453. * @param uniform defines the webGL uniform location where to store the value
  98454. * @param array defines the array of number to store
  98455. */
  98456. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98457. /**
  98458. * Set the value of an uniform to an array of number (stored as vec4)
  98459. * @param uniform defines the webGL uniform location where to store the value
  98460. * @param array defines the array of number to store
  98461. */
  98462. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  98463. /**
  98464. * Set the value of an uniform to an array of float32 (stored as matrices)
  98465. * @param uniform defines the webGL uniform location where to store the value
  98466. * @param matrices defines the array of float32 to store
  98467. */
  98468. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  98469. /**
  98470. * Set the value of an uniform to a matrix (3x3)
  98471. * @param uniform defines the webGL uniform location where to store the value
  98472. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  98473. */
  98474. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98475. /**
  98476. * Set the value of an uniform to a matrix (2x2)
  98477. * @param uniform defines the webGL uniform location where to store the value
  98478. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  98479. */
  98480. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  98481. /**
  98482. * Set the value of an uniform to a number (float)
  98483. * @param uniform defines the webGL uniform location where to store the value
  98484. * @param value defines the float number to store
  98485. */
  98486. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  98487. /**
  98488. * Set the value of an uniform to a vec2
  98489. * @param uniform defines the webGL uniform location where to store the value
  98490. * @param x defines the 1st component of the value
  98491. * @param y defines the 2nd component of the value
  98492. */
  98493. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  98494. /**
  98495. * Set the value of an uniform to a vec3
  98496. * @param uniform defines the webGL uniform location where to store the value
  98497. * @param x defines the 1st component of the value
  98498. * @param y defines the 2nd component of the value
  98499. * @param z defines the 3rd component of the value
  98500. */
  98501. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  98502. /**
  98503. * Set the value of an uniform to a vec4
  98504. * @param uniform defines the webGL uniform location where to store the value
  98505. * @param x defines the 1st component of the value
  98506. * @param y defines the 2nd component of the value
  98507. * @param z defines the 3rd component of the value
  98508. * @param w defines the 4th component of the value
  98509. */
  98510. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  98511. /**
  98512. * Gets the depth culling state manager
  98513. */
  98514. readonly depthCullingState: DepthCullingState;
  98515. /**
  98516. * Gets the alpha state manager
  98517. */
  98518. readonly alphaState: AlphaState;
  98519. /**
  98520. * Gets the stencil state manager
  98521. */
  98522. readonly stencilState: StencilState;
  98523. /**
  98524. * Clears the list of texture accessible through engine.
  98525. * This can help preventing texture load conflict due to name collision.
  98526. */
  98527. clearInternalTexturesCache(): void;
  98528. /**
  98529. * Force the entire cache to be cleared
  98530. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  98531. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  98532. */
  98533. wipeCaches(bruteForce?: boolean): void;
  98534. /** @hidden */
  98535. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  98536. min: number;
  98537. mag: number;
  98538. };
  98539. /** @hidden */
  98540. _createTexture(): WebGLTexture;
  98541. /**
  98542. * Usually called from Texture.ts.
  98543. * Passed information to create a WebGLTexture
  98544. * @param urlArg defines a value which contains one of the following:
  98545. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  98546. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  98547. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  98548. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  98549. * @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)
  98550. * @param scene needed for loading to the correct scene
  98551. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  98552. * @param onLoad optional callback to be called upon successful completion
  98553. * @param onError optional callback to be called upon failure
  98554. * @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
  98555. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  98556. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  98557. * @param forcedExtension defines the extension to use to pick the right loader
  98558. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  98559. * @param mimeType defines an optional mime type
  98560. * @returns a InternalTexture for assignment back into BABYLON.Texture
  98561. */
  98562. 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;
  98563. /**
  98564. * @hidden
  98565. */
  98566. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98567. /**
  98568. * Creates a raw texture
  98569. * @param data defines the data to store in the texture
  98570. * @param width defines the width of the texture
  98571. * @param height defines the height of the texture
  98572. * @param format defines the format of the data
  98573. * @param generateMipMaps defines if the engine should generate the mip levels
  98574. * @param invertY defines if data must be stored with Y axis inverted
  98575. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  98576. * @param compression defines the compression used (null by default)
  98577. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  98578. * @returns the raw texture inside an InternalTexture
  98579. */
  98580. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  98581. /**
  98582. * Creates a new raw cube texture
  98583. * @param data defines the array of data to use to create each face
  98584. * @param size defines the size of the textures
  98585. * @param format defines the format of the data
  98586. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  98587. * @param generateMipMaps defines if the engine should generate the mip levels
  98588. * @param invertY defines if data must be stored with Y axis inverted
  98589. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98590. * @param compression defines the compression used (null by default)
  98591. * @returns the cube texture as an InternalTexture
  98592. */
  98593. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  98594. /**
  98595. * Creates a new raw 3D texture
  98596. * @param data defines the data used to create the texture
  98597. * @param width defines the width of the texture
  98598. * @param height defines the height of the texture
  98599. * @param depth defines the depth of the texture
  98600. * @param format defines the format of the texture
  98601. * @param generateMipMaps defines if the engine must generate mip levels
  98602. * @param invertY defines if data must be stored with Y axis inverted
  98603. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98604. * @param compression defines the compressed used (can be null)
  98605. * @param textureType defines the compressed used (can be null)
  98606. * @returns a new raw 3D texture (stored in an InternalTexture)
  98607. */
  98608. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98609. /**
  98610. * Creates a new raw 2D array texture
  98611. * @param data defines the data used to create the texture
  98612. * @param width defines the width of the texture
  98613. * @param height defines the height of the texture
  98614. * @param depth defines the number of layers of the texture
  98615. * @param format defines the format of the texture
  98616. * @param generateMipMaps defines if the engine must generate mip levels
  98617. * @param invertY defines if data must be stored with Y axis inverted
  98618. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  98619. * @param compression defines the compressed used (can be null)
  98620. * @param textureType defines the compressed used (can be null)
  98621. * @returns a new raw 2D array texture (stored in an InternalTexture)
  98622. */
  98623. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  98624. private _unpackFlipYCached;
  98625. /**
  98626. * In case you are sharing the context with other applications, it might
  98627. * be interested to not cache the unpack flip y state to ensure a consistent
  98628. * value would be set.
  98629. */
  98630. enableUnpackFlipYCached: boolean;
  98631. /** @hidden */
  98632. _unpackFlipY(value: boolean): void;
  98633. /** @hidden */
  98634. _getUnpackAlignement(): number;
  98635. /**
  98636. * Update the sampling mode of a given texture
  98637. * @param samplingMode defines the required sampling mode
  98638. * @param texture defines the texture to update
  98639. */
  98640. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  98641. /** @hidden */
  98642. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  98643. width: number;
  98644. height: number;
  98645. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  98646. /** @hidden */
  98647. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98648. /** @hidden */
  98649. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  98650. /** @hidden */
  98651. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  98652. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  98653. private _prepareWebGLTexture;
  98654. /** @hidden */
  98655. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  98656. /** @hidden */
  98657. _releaseFramebufferObjects(texture: InternalTexture): void;
  98658. /** @hidden */
  98659. _releaseTexture(texture: InternalTexture): void;
  98660. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  98661. protected _setProgram(program: WebGLProgram): void;
  98662. protected _boundUniforms: {
  98663. [key: number]: WebGLUniformLocation;
  98664. };
  98665. /**
  98666. * Binds an effect to the webGL context
  98667. * @param effect defines the effect to bind
  98668. */
  98669. bindSamplers(effect: Effect): void;
  98670. private _activateCurrentTexture;
  98671. /** @hidden */
  98672. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  98673. /** @hidden */
  98674. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  98675. /**
  98676. * Unbind all textures from the webGL context
  98677. */
  98678. unbindAllTextures(): void;
  98679. /**
  98680. * Sets a texture to the according uniform.
  98681. * @param channel The texture channel
  98682. * @param uniform The uniform to set
  98683. * @param texture The texture to apply
  98684. */
  98685. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  98686. private _bindSamplerUniformToChannel;
  98687. private _getTextureWrapMode;
  98688. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  98689. /**
  98690. * Sets an array of texture to the webGL context
  98691. * @param channel defines the channel where the texture array must be set
  98692. * @param uniform defines the associated uniform location
  98693. * @param textures defines the array of textures to bind
  98694. */
  98695. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  98696. /** @hidden */
  98697. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  98698. private _setTextureParameterFloat;
  98699. private _setTextureParameterInteger;
  98700. /**
  98701. * Unbind all vertex attributes from the webGL context
  98702. */
  98703. unbindAllAttributes(): void;
  98704. /**
  98705. * 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
  98706. */
  98707. releaseEffects(): void;
  98708. /**
  98709. * Dispose and release all associated resources
  98710. */
  98711. dispose(): void;
  98712. /**
  98713. * Attach a new callback raised when context lost event is fired
  98714. * @param callback defines the callback to call
  98715. */
  98716. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98717. /**
  98718. * Attach a new callback raised when context restored event is fired
  98719. * @param callback defines the callback to call
  98720. */
  98721. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  98722. /**
  98723. * Get the current error code of the webGL context
  98724. * @returns the error code
  98725. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  98726. */
  98727. getError(): number;
  98728. private _canRenderToFloatFramebuffer;
  98729. private _canRenderToHalfFloatFramebuffer;
  98730. private _canRenderToFramebuffer;
  98731. /** @hidden */
  98732. _getWebGLTextureType(type: number): number;
  98733. /** @hidden */
  98734. _getInternalFormat(format: number): number;
  98735. /** @hidden */
  98736. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  98737. /** @hidden */
  98738. _getRGBAMultiSampleBufferFormat(type: number): number;
  98739. /** @hidden */
  98740. _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;
  98741. /**
  98742. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  98743. * @returns true if the engine can be created
  98744. * @ignorenaming
  98745. */
  98746. static isSupported(): boolean;
  98747. /**
  98748. * Find the next highest power of two.
  98749. * @param x Number to start search from.
  98750. * @return Next highest power of two.
  98751. */
  98752. static CeilingPOT(x: number): number;
  98753. /**
  98754. * Find the next lowest power of two.
  98755. * @param x Number to start search from.
  98756. * @return Next lowest power of two.
  98757. */
  98758. static FloorPOT(x: number): number;
  98759. /**
  98760. * Find the nearest power of two.
  98761. * @param x Number to start search from.
  98762. * @return Next nearest power of two.
  98763. */
  98764. static NearestPOT(x: number): number;
  98765. /**
  98766. * Get the closest exponent of two
  98767. * @param value defines the value to approximate
  98768. * @param max defines the maximum value to return
  98769. * @param mode defines how to define the closest value
  98770. * @returns closest exponent of two of the given value
  98771. */
  98772. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  98773. /**
  98774. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  98775. * @param func - the function to be called
  98776. * @param requester - the object that will request the next frame. Falls back to window.
  98777. * @returns frame number
  98778. */
  98779. static QueueNewFrame(func: () => void, requester?: any): number;
  98780. }
  98781. }
  98782. declare module BABYLON {
  98783. /**
  98784. * Class representing spherical harmonics coefficients to the 3rd degree
  98785. */
  98786. export class SphericalHarmonics {
  98787. /**
  98788. * Defines whether or not the harmonics have been prescaled for rendering.
  98789. */
  98790. preScaled: boolean;
  98791. /**
  98792. * The l0,0 coefficients of the spherical harmonics
  98793. */
  98794. l00: Vector3;
  98795. /**
  98796. * The l1,-1 coefficients of the spherical harmonics
  98797. */
  98798. l1_1: Vector3;
  98799. /**
  98800. * The l1,0 coefficients of the spherical harmonics
  98801. */
  98802. l10: Vector3;
  98803. /**
  98804. * The l1,1 coefficients of the spherical harmonics
  98805. */
  98806. l11: Vector3;
  98807. /**
  98808. * The l2,-2 coefficients of the spherical harmonics
  98809. */
  98810. l2_2: Vector3;
  98811. /**
  98812. * The l2,-1 coefficients of the spherical harmonics
  98813. */
  98814. l2_1: Vector3;
  98815. /**
  98816. * The l2,0 coefficients of the spherical harmonics
  98817. */
  98818. l20: Vector3;
  98819. /**
  98820. * The l2,1 coefficients of the spherical harmonics
  98821. */
  98822. l21: Vector3;
  98823. /**
  98824. * The l2,2 coefficients of the spherical harmonics
  98825. */
  98826. l22: Vector3;
  98827. /**
  98828. * Adds a light to the spherical harmonics
  98829. * @param direction the direction of the light
  98830. * @param color the color of the light
  98831. * @param deltaSolidAngle the delta solid angle of the light
  98832. */
  98833. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  98834. /**
  98835. * Scales the spherical harmonics by the given amount
  98836. * @param scale the amount to scale
  98837. */
  98838. scaleInPlace(scale: number): void;
  98839. /**
  98840. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  98841. *
  98842. * ```
  98843. * E_lm = A_l * L_lm
  98844. * ```
  98845. *
  98846. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  98847. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  98848. * the scaling factors are given in equation 9.
  98849. */
  98850. convertIncidentRadianceToIrradiance(): void;
  98851. /**
  98852. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  98853. *
  98854. * ```
  98855. * L = (1/pi) * E * rho
  98856. * ```
  98857. *
  98858. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  98859. */
  98860. convertIrradianceToLambertianRadiance(): void;
  98861. /**
  98862. * Integrates the reconstruction coefficients directly in to the SH preventing further
  98863. * required operations at run time.
  98864. *
  98865. * This is simply done by scaling back the SH with Ylm constants parameter.
  98866. * The trigonometric part being applied by the shader at run time.
  98867. */
  98868. preScaleForRendering(): void;
  98869. /**
  98870. * Constructs a spherical harmonics from an array.
  98871. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  98872. * @returns the spherical harmonics
  98873. */
  98874. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  98875. /**
  98876. * Gets the spherical harmonics from polynomial
  98877. * @param polynomial the spherical polynomial
  98878. * @returns the spherical harmonics
  98879. */
  98880. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  98881. }
  98882. /**
  98883. * Class representing spherical polynomial coefficients to the 3rd degree
  98884. */
  98885. export class SphericalPolynomial {
  98886. private _harmonics;
  98887. /**
  98888. * The spherical harmonics used to create the polynomials.
  98889. */
  98890. readonly preScaledHarmonics: SphericalHarmonics;
  98891. /**
  98892. * The x coefficients of the spherical polynomial
  98893. */
  98894. x: Vector3;
  98895. /**
  98896. * The y coefficients of the spherical polynomial
  98897. */
  98898. y: Vector3;
  98899. /**
  98900. * The z coefficients of the spherical polynomial
  98901. */
  98902. z: Vector3;
  98903. /**
  98904. * The xx coefficients of the spherical polynomial
  98905. */
  98906. xx: Vector3;
  98907. /**
  98908. * The yy coefficients of the spherical polynomial
  98909. */
  98910. yy: Vector3;
  98911. /**
  98912. * The zz coefficients of the spherical polynomial
  98913. */
  98914. zz: Vector3;
  98915. /**
  98916. * The xy coefficients of the spherical polynomial
  98917. */
  98918. xy: Vector3;
  98919. /**
  98920. * The yz coefficients of the spherical polynomial
  98921. */
  98922. yz: Vector3;
  98923. /**
  98924. * The zx coefficients of the spherical polynomial
  98925. */
  98926. zx: Vector3;
  98927. /**
  98928. * Adds an ambient color to the spherical polynomial
  98929. * @param color the color to add
  98930. */
  98931. addAmbient(color: Color3): void;
  98932. /**
  98933. * Scales the spherical polynomial by the given amount
  98934. * @param scale the amount to scale
  98935. */
  98936. scaleInPlace(scale: number): void;
  98937. /**
  98938. * Gets the spherical polynomial from harmonics
  98939. * @param harmonics the spherical harmonics
  98940. * @returns the spherical polynomial
  98941. */
  98942. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  98943. /**
  98944. * Constructs a spherical polynomial from an array.
  98945. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  98946. * @returns the spherical polynomial
  98947. */
  98948. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  98949. }
  98950. }
  98951. declare module BABYLON {
  98952. /**
  98953. * Defines the source of the internal texture
  98954. */
  98955. export enum InternalTextureSource {
  98956. /**
  98957. * The source of the texture data is unknown
  98958. */
  98959. Unknown = 0,
  98960. /**
  98961. * Texture data comes from an URL
  98962. */
  98963. Url = 1,
  98964. /**
  98965. * Texture data is only used for temporary storage
  98966. */
  98967. Temp = 2,
  98968. /**
  98969. * Texture data comes from raw data (ArrayBuffer)
  98970. */
  98971. Raw = 3,
  98972. /**
  98973. * Texture content is dynamic (video or dynamic texture)
  98974. */
  98975. Dynamic = 4,
  98976. /**
  98977. * Texture content is generated by rendering to it
  98978. */
  98979. RenderTarget = 5,
  98980. /**
  98981. * Texture content is part of a multi render target process
  98982. */
  98983. MultiRenderTarget = 6,
  98984. /**
  98985. * Texture data comes from a cube data file
  98986. */
  98987. Cube = 7,
  98988. /**
  98989. * Texture data comes from a raw cube data
  98990. */
  98991. CubeRaw = 8,
  98992. /**
  98993. * Texture data come from a prefiltered cube data file
  98994. */
  98995. CubePrefiltered = 9,
  98996. /**
  98997. * Texture content is raw 3D data
  98998. */
  98999. Raw3D = 10,
  99000. /**
  99001. * Texture content is raw 2D array data
  99002. */
  99003. Raw2DArray = 11,
  99004. /**
  99005. * Texture content is a depth texture
  99006. */
  99007. Depth = 12,
  99008. /**
  99009. * Texture data comes from a raw cube data encoded with RGBD
  99010. */
  99011. CubeRawRGBD = 13
  99012. }
  99013. /**
  99014. * Class used to store data associated with WebGL texture data for the engine
  99015. * This class should not be used directly
  99016. */
  99017. export class InternalTexture {
  99018. /** @hidden */
  99019. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  99020. /**
  99021. * Defines if the texture is ready
  99022. */
  99023. isReady: boolean;
  99024. /**
  99025. * Defines if the texture is a cube texture
  99026. */
  99027. isCube: boolean;
  99028. /**
  99029. * Defines if the texture contains 3D data
  99030. */
  99031. is3D: boolean;
  99032. /**
  99033. * Defines if the texture contains 2D array data
  99034. */
  99035. is2DArray: boolean;
  99036. /**
  99037. * Defines if the texture contains multiview data
  99038. */
  99039. isMultiview: boolean;
  99040. /**
  99041. * Gets the URL used to load this texture
  99042. */
  99043. url: string;
  99044. /**
  99045. * Gets the sampling mode of the texture
  99046. */
  99047. samplingMode: number;
  99048. /**
  99049. * Gets a boolean indicating if the texture needs mipmaps generation
  99050. */
  99051. generateMipMaps: boolean;
  99052. /**
  99053. * Gets the number of samples used by the texture (WebGL2+ only)
  99054. */
  99055. samples: number;
  99056. /**
  99057. * Gets the type of the texture (int, float...)
  99058. */
  99059. type: number;
  99060. /**
  99061. * Gets the format of the texture (RGB, RGBA...)
  99062. */
  99063. format: number;
  99064. /**
  99065. * Observable called when the texture is loaded
  99066. */
  99067. onLoadedObservable: Observable<InternalTexture>;
  99068. /**
  99069. * Gets the width of the texture
  99070. */
  99071. width: number;
  99072. /**
  99073. * Gets the height of the texture
  99074. */
  99075. height: number;
  99076. /**
  99077. * Gets the depth of the texture
  99078. */
  99079. depth: number;
  99080. /**
  99081. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  99082. */
  99083. baseWidth: number;
  99084. /**
  99085. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  99086. */
  99087. baseHeight: number;
  99088. /**
  99089. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  99090. */
  99091. baseDepth: number;
  99092. /**
  99093. * Gets a boolean indicating if the texture is inverted on Y axis
  99094. */
  99095. invertY: boolean;
  99096. /** @hidden */
  99097. _invertVScale: boolean;
  99098. /** @hidden */
  99099. _associatedChannel: number;
  99100. /** @hidden */
  99101. _source: InternalTextureSource;
  99102. /** @hidden */
  99103. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  99104. /** @hidden */
  99105. _bufferView: Nullable<ArrayBufferView>;
  99106. /** @hidden */
  99107. _bufferViewArray: Nullable<ArrayBufferView[]>;
  99108. /** @hidden */
  99109. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  99110. /** @hidden */
  99111. _size: number;
  99112. /** @hidden */
  99113. _extension: string;
  99114. /** @hidden */
  99115. _files: Nullable<string[]>;
  99116. /** @hidden */
  99117. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  99118. /** @hidden */
  99119. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  99120. /** @hidden */
  99121. _framebuffer: Nullable<WebGLFramebuffer>;
  99122. /** @hidden */
  99123. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  99124. /** @hidden */
  99125. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  99126. /** @hidden */
  99127. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  99128. /** @hidden */
  99129. _attachments: Nullable<number[]>;
  99130. /** @hidden */
  99131. _cachedCoordinatesMode: Nullable<number>;
  99132. /** @hidden */
  99133. _cachedWrapU: Nullable<number>;
  99134. /** @hidden */
  99135. _cachedWrapV: Nullable<number>;
  99136. /** @hidden */
  99137. _cachedWrapR: Nullable<number>;
  99138. /** @hidden */
  99139. _cachedAnisotropicFilteringLevel: Nullable<number>;
  99140. /** @hidden */
  99141. _isDisabled: boolean;
  99142. /** @hidden */
  99143. _compression: Nullable<string>;
  99144. /** @hidden */
  99145. _generateStencilBuffer: boolean;
  99146. /** @hidden */
  99147. _generateDepthBuffer: boolean;
  99148. /** @hidden */
  99149. _comparisonFunction: number;
  99150. /** @hidden */
  99151. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  99152. /** @hidden */
  99153. _lodGenerationScale: number;
  99154. /** @hidden */
  99155. _lodGenerationOffset: number;
  99156. /** @hidden */
  99157. _colorTextureArray: Nullable<WebGLTexture>;
  99158. /** @hidden */
  99159. _depthStencilTextureArray: Nullable<WebGLTexture>;
  99160. /** @hidden */
  99161. _lodTextureHigh: Nullable<BaseTexture>;
  99162. /** @hidden */
  99163. _lodTextureMid: Nullable<BaseTexture>;
  99164. /** @hidden */
  99165. _lodTextureLow: Nullable<BaseTexture>;
  99166. /** @hidden */
  99167. _isRGBD: boolean;
  99168. /** @hidden */
  99169. _linearSpecularLOD: boolean;
  99170. /** @hidden */
  99171. _irradianceTexture: Nullable<BaseTexture>;
  99172. /** @hidden */
  99173. _webGLTexture: Nullable<WebGLTexture>;
  99174. /** @hidden */
  99175. _references: number;
  99176. private _engine;
  99177. /**
  99178. * Gets the Engine the texture belongs to.
  99179. * @returns The babylon engine
  99180. */
  99181. getEngine(): ThinEngine;
  99182. /**
  99183. * Gets the data source type of the texture
  99184. */
  99185. readonly source: InternalTextureSource;
  99186. /**
  99187. * Creates a new InternalTexture
  99188. * @param engine defines the engine to use
  99189. * @param source defines the type of data that will be used
  99190. * @param delayAllocation if the texture allocation should be delayed (default: false)
  99191. */
  99192. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  99193. /**
  99194. * Increments the number of references (ie. the number of Texture that point to it)
  99195. */
  99196. incrementReferences(): void;
  99197. /**
  99198. * Change the size of the texture (not the size of the content)
  99199. * @param width defines the new width
  99200. * @param height defines the new height
  99201. * @param depth defines the new depth (1 by default)
  99202. */
  99203. updateSize(width: int, height: int, depth?: int): void;
  99204. /** @hidden */
  99205. _rebuild(): void;
  99206. /** @hidden */
  99207. _swapAndDie(target: InternalTexture): void;
  99208. /**
  99209. * Dispose the current allocated resources
  99210. */
  99211. dispose(): void;
  99212. }
  99213. }
  99214. declare module BABYLON {
  99215. /**
  99216. * Class used to work with sound analyzer using fast fourier transform (FFT)
  99217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99218. */
  99219. export class Analyser {
  99220. /**
  99221. * Gets or sets the smoothing
  99222. * @ignorenaming
  99223. */
  99224. SMOOTHING: number;
  99225. /**
  99226. * Gets or sets the FFT table size
  99227. * @ignorenaming
  99228. */
  99229. FFT_SIZE: number;
  99230. /**
  99231. * Gets or sets the bar graph amplitude
  99232. * @ignorenaming
  99233. */
  99234. BARGRAPHAMPLITUDE: number;
  99235. /**
  99236. * Gets or sets the position of the debug canvas
  99237. * @ignorenaming
  99238. */
  99239. DEBUGCANVASPOS: {
  99240. x: number;
  99241. y: number;
  99242. };
  99243. /**
  99244. * Gets or sets the debug canvas size
  99245. * @ignorenaming
  99246. */
  99247. DEBUGCANVASSIZE: {
  99248. width: number;
  99249. height: number;
  99250. };
  99251. private _byteFreqs;
  99252. private _byteTime;
  99253. private _floatFreqs;
  99254. private _webAudioAnalyser;
  99255. private _debugCanvas;
  99256. private _debugCanvasContext;
  99257. private _scene;
  99258. private _registerFunc;
  99259. private _audioEngine;
  99260. /**
  99261. * Creates a new analyser
  99262. * @param scene defines hosting scene
  99263. */
  99264. constructor(scene: Scene);
  99265. /**
  99266. * Get the number of data values you will have to play with for the visualization
  99267. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  99268. * @returns a number
  99269. */
  99270. getFrequencyBinCount(): number;
  99271. /**
  99272. * Gets the current frequency data as a byte array
  99273. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  99274. * @returns a Uint8Array
  99275. */
  99276. getByteFrequencyData(): Uint8Array;
  99277. /**
  99278. * Gets the current waveform as a byte array
  99279. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  99280. * @returns a Uint8Array
  99281. */
  99282. getByteTimeDomainData(): Uint8Array;
  99283. /**
  99284. * Gets the current frequency data as a float array
  99285. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  99286. * @returns a Float32Array
  99287. */
  99288. getFloatFrequencyData(): Float32Array;
  99289. /**
  99290. * Renders the debug canvas
  99291. */
  99292. drawDebugCanvas(): void;
  99293. /**
  99294. * Stops rendering the debug canvas and removes it
  99295. */
  99296. stopDebugCanvas(): void;
  99297. /**
  99298. * Connects two audio nodes
  99299. * @param inputAudioNode defines first node to connect
  99300. * @param outputAudioNode defines second node to connect
  99301. */
  99302. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  99303. /**
  99304. * Releases all associated resources
  99305. */
  99306. dispose(): void;
  99307. }
  99308. }
  99309. declare module BABYLON {
  99310. /**
  99311. * This represents an audio engine and it is responsible
  99312. * to play, synchronize and analyse sounds throughout the application.
  99313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99314. */
  99315. export interface IAudioEngine extends IDisposable {
  99316. /**
  99317. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99318. */
  99319. readonly canUseWebAudio: boolean;
  99320. /**
  99321. * Gets the current AudioContext if available.
  99322. */
  99323. readonly audioContext: Nullable<AudioContext>;
  99324. /**
  99325. * The master gain node defines the global audio volume of your audio engine.
  99326. */
  99327. readonly masterGain: GainNode;
  99328. /**
  99329. * Gets whether or not mp3 are supported by your browser.
  99330. */
  99331. readonly isMP3supported: boolean;
  99332. /**
  99333. * Gets whether or not ogg are supported by your browser.
  99334. */
  99335. readonly isOGGsupported: boolean;
  99336. /**
  99337. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99338. * @ignoreNaming
  99339. */
  99340. WarnedWebAudioUnsupported: boolean;
  99341. /**
  99342. * Defines if the audio engine relies on a custom unlocked button.
  99343. * In this case, the embedded button will not be displayed.
  99344. */
  99345. useCustomUnlockedButton: boolean;
  99346. /**
  99347. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  99348. */
  99349. readonly unlocked: boolean;
  99350. /**
  99351. * Event raised when audio has been unlocked on the browser.
  99352. */
  99353. onAudioUnlockedObservable: Observable<AudioEngine>;
  99354. /**
  99355. * Event raised when audio has been locked on the browser.
  99356. */
  99357. onAudioLockedObservable: Observable<AudioEngine>;
  99358. /**
  99359. * Flags the audio engine in Locked state.
  99360. * This happens due to new browser policies preventing audio to autoplay.
  99361. */
  99362. lock(): void;
  99363. /**
  99364. * Unlocks the audio engine once a user action has been done on the dom.
  99365. * This is helpful to resume play once browser policies have been satisfied.
  99366. */
  99367. unlock(): void;
  99368. }
  99369. /**
  99370. * This represents the default audio engine used in babylon.
  99371. * It is responsible to play, synchronize and analyse sounds throughout the application.
  99372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99373. */
  99374. export class AudioEngine implements IAudioEngine {
  99375. private _audioContext;
  99376. private _audioContextInitialized;
  99377. private _muteButton;
  99378. private _hostElement;
  99379. /**
  99380. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  99381. */
  99382. canUseWebAudio: boolean;
  99383. /**
  99384. * The master gain node defines the global audio volume of your audio engine.
  99385. */
  99386. masterGain: GainNode;
  99387. /**
  99388. * Defines if Babylon should emit a warning if WebAudio is not supported.
  99389. * @ignoreNaming
  99390. */
  99391. WarnedWebAudioUnsupported: boolean;
  99392. /**
  99393. * Gets whether or not mp3 are supported by your browser.
  99394. */
  99395. isMP3supported: boolean;
  99396. /**
  99397. * Gets whether or not ogg are supported by your browser.
  99398. */
  99399. isOGGsupported: boolean;
  99400. /**
  99401. * Gets whether audio has been unlocked on the device.
  99402. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  99403. * a user interaction has happened.
  99404. */
  99405. unlocked: boolean;
  99406. /**
  99407. * Defines if the audio engine relies on a custom unlocked button.
  99408. * In this case, the embedded button will not be displayed.
  99409. */
  99410. useCustomUnlockedButton: boolean;
  99411. /**
  99412. * Event raised when audio has been unlocked on the browser.
  99413. */
  99414. onAudioUnlockedObservable: Observable<AudioEngine>;
  99415. /**
  99416. * Event raised when audio has been locked on the browser.
  99417. */
  99418. onAudioLockedObservable: Observable<AudioEngine>;
  99419. /**
  99420. * Gets the current AudioContext if available.
  99421. */
  99422. readonly audioContext: Nullable<AudioContext>;
  99423. private _connectedAnalyser;
  99424. /**
  99425. * Instantiates a new audio engine.
  99426. *
  99427. * There should be only one per page as some browsers restrict the number
  99428. * of audio contexts you can create.
  99429. * @param hostElement defines the host element where to display the mute icon if necessary
  99430. */
  99431. constructor(hostElement?: Nullable<HTMLElement>);
  99432. /**
  99433. * Flags the audio engine in Locked state.
  99434. * This happens due to new browser policies preventing audio to autoplay.
  99435. */
  99436. lock(): void;
  99437. /**
  99438. * Unlocks the audio engine once a user action has been done on the dom.
  99439. * This is helpful to resume play once browser policies have been satisfied.
  99440. */
  99441. unlock(): void;
  99442. private _resumeAudioContext;
  99443. private _initializeAudioContext;
  99444. private _tryToRun;
  99445. private _triggerRunningState;
  99446. private _triggerSuspendedState;
  99447. private _displayMuteButton;
  99448. private _moveButtonToTopLeft;
  99449. private _onResize;
  99450. private _hideMuteButton;
  99451. /**
  99452. * Destroy and release the resources associated with the audio ccontext.
  99453. */
  99454. dispose(): void;
  99455. /**
  99456. * Gets the global volume sets on the master gain.
  99457. * @returns the global volume if set or -1 otherwise
  99458. */
  99459. getGlobalVolume(): number;
  99460. /**
  99461. * Sets the global volume of your experience (sets on the master gain).
  99462. * @param newVolume Defines the new global volume of the application
  99463. */
  99464. setGlobalVolume(newVolume: number): void;
  99465. /**
  99466. * Connect the audio engine to an audio analyser allowing some amazing
  99467. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  99468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  99469. * @param analyser The analyser to connect to the engine
  99470. */
  99471. connectToAnalyser(analyser: Analyser): void;
  99472. }
  99473. }
  99474. declare module BABYLON {
  99475. /**
  99476. * Interface used to present a loading screen while loading a scene
  99477. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99478. */
  99479. export interface ILoadingScreen {
  99480. /**
  99481. * Function called to display the loading screen
  99482. */
  99483. displayLoadingUI: () => void;
  99484. /**
  99485. * Function called to hide the loading screen
  99486. */
  99487. hideLoadingUI: () => void;
  99488. /**
  99489. * Gets or sets the color to use for the background
  99490. */
  99491. loadingUIBackgroundColor: string;
  99492. /**
  99493. * Gets or sets the text to display while loading
  99494. */
  99495. loadingUIText: string;
  99496. }
  99497. /**
  99498. * Class used for the default loading screen
  99499. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  99500. */
  99501. export class DefaultLoadingScreen implements ILoadingScreen {
  99502. private _renderingCanvas;
  99503. private _loadingText;
  99504. private _loadingDivBackgroundColor;
  99505. private _loadingDiv;
  99506. private _loadingTextDiv;
  99507. /** Gets or sets the logo url to use for the default loading screen */
  99508. static DefaultLogoUrl: string;
  99509. /** Gets or sets the spinner url to use for the default loading screen */
  99510. static DefaultSpinnerUrl: string;
  99511. /**
  99512. * Creates a new default loading screen
  99513. * @param _renderingCanvas defines the canvas used to render the scene
  99514. * @param _loadingText defines the default text to display
  99515. * @param _loadingDivBackgroundColor defines the default background color
  99516. */
  99517. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  99518. /**
  99519. * Function called to display the loading screen
  99520. */
  99521. displayLoadingUI(): void;
  99522. /**
  99523. * Function called to hide the loading screen
  99524. */
  99525. hideLoadingUI(): void;
  99526. /**
  99527. * Gets or sets the text to display while loading
  99528. */
  99529. loadingUIText: string;
  99530. /**
  99531. * Gets or sets the color to use for the background
  99532. */
  99533. loadingUIBackgroundColor: string;
  99534. private _resizeLoadingUI;
  99535. }
  99536. }
  99537. declare module BABYLON {
  99538. /**
  99539. * Interface for any object that can request an animation frame
  99540. */
  99541. export interface ICustomAnimationFrameRequester {
  99542. /**
  99543. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  99544. */
  99545. renderFunction?: Function;
  99546. /**
  99547. * Called to request the next frame to render to
  99548. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  99549. */
  99550. requestAnimationFrame: Function;
  99551. /**
  99552. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  99553. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  99554. */
  99555. requestID?: number;
  99556. }
  99557. }
  99558. declare module BABYLON {
  99559. /**
  99560. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99561. */
  99562. export class PerformanceMonitor {
  99563. private _enabled;
  99564. private _rollingFrameTime;
  99565. private _lastFrameTimeMs;
  99566. /**
  99567. * constructor
  99568. * @param frameSampleSize The number of samples required to saturate the sliding window
  99569. */
  99570. constructor(frameSampleSize?: number);
  99571. /**
  99572. * Samples current frame
  99573. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99574. */
  99575. sampleFrame(timeMs?: number): void;
  99576. /**
  99577. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99578. */
  99579. readonly averageFrameTime: number;
  99580. /**
  99581. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99582. */
  99583. readonly averageFrameTimeVariance: number;
  99584. /**
  99585. * Returns the frame time of the most recent frame
  99586. */
  99587. readonly instantaneousFrameTime: number;
  99588. /**
  99589. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  99590. */
  99591. readonly averageFPS: number;
  99592. /**
  99593. * Returns the average framerate in frames per second using the most recent frame time
  99594. */
  99595. readonly instantaneousFPS: number;
  99596. /**
  99597. * Returns true if enough samples have been taken to completely fill the sliding window
  99598. */
  99599. readonly isSaturated: boolean;
  99600. /**
  99601. * Enables contributions to the sliding window sample set
  99602. */
  99603. enable(): void;
  99604. /**
  99605. * Disables contributions to the sliding window sample set
  99606. * Samples will not be interpolated over the disabled period
  99607. */
  99608. disable(): void;
  99609. /**
  99610. * Returns true if sampling is enabled
  99611. */
  99612. readonly isEnabled: boolean;
  99613. /**
  99614. * Resets performance monitor
  99615. */
  99616. reset(): void;
  99617. }
  99618. /**
  99619. * RollingAverage
  99620. *
  99621. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  99622. */
  99623. export class RollingAverage {
  99624. /**
  99625. * Current average
  99626. */
  99627. average: number;
  99628. /**
  99629. * Current variance
  99630. */
  99631. variance: number;
  99632. protected _samples: Array<number>;
  99633. protected _sampleCount: number;
  99634. protected _pos: number;
  99635. protected _m2: number;
  99636. /**
  99637. * constructor
  99638. * @param length The number of samples required to saturate the sliding window
  99639. */
  99640. constructor(length: number);
  99641. /**
  99642. * Adds a sample to the sample set
  99643. * @param v The sample value
  99644. */
  99645. add(v: number): void;
  99646. /**
  99647. * Returns previously added values or null if outside of history or outside the sliding window domain
  99648. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  99649. * @return Value previously recorded with add() or null if outside of range
  99650. */
  99651. history(i: number): number;
  99652. /**
  99653. * Returns true if enough samples have been taken to completely fill the sliding window
  99654. * @return true if sample-set saturated
  99655. */
  99656. isSaturated(): boolean;
  99657. /**
  99658. * Resets the rolling average (equivalent to 0 samples taken so far)
  99659. */
  99660. reset(): void;
  99661. /**
  99662. * Wraps a value around the sample range boundaries
  99663. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  99664. * @return Wrapped position in sample range
  99665. */
  99666. protected _wrapPosition(i: number): number;
  99667. }
  99668. }
  99669. declare module BABYLON {
  99670. /**
  99671. * This class is used to track a performance counter which is number based.
  99672. * The user has access to many properties which give statistics of different nature.
  99673. *
  99674. * The implementer can track two kinds of Performance Counter: time and count.
  99675. * 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.
  99676. * 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.
  99677. */
  99678. export class PerfCounter {
  99679. /**
  99680. * Gets or sets a global boolean to turn on and off all the counters
  99681. */
  99682. static Enabled: boolean;
  99683. /**
  99684. * Returns the smallest value ever
  99685. */
  99686. readonly min: number;
  99687. /**
  99688. * Returns the biggest value ever
  99689. */
  99690. readonly max: number;
  99691. /**
  99692. * Returns the average value since the performance counter is running
  99693. */
  99694. readonly average: number;
  99695. /**
  99696. * Returns the average value of the last second the counter was monitored
  99697. */
  99698. readonly lastSecAverage: number;
  99699. /**
  99700. * Returns the current value
  99701. */
  99702. readonly current: number;
  99703. /**
  99704. * Gets the accumulated total
  99705. */
  99706. readonly total: number;
  99707. /**
  99708. * Gets the total value count
  99709. */
  99710. readonly count: number;
  99711. /**
  99712. * Creates a new counter
  99713. */
  99714. constructor();
  99715. /**
  99716. * Call this method to start monitoring a new frame.
  99717. * 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.
  99718. */
  99719. fetchNewFrame(): void;
  99720. /**
  99721. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  99722. * @param newCount the count value to add to the monitored count
  99723. * @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.
  99724. */
  99725. addCount(newCount: number, fetchResult: boolean): void;
  99726. /**
  99727. * Start monitoring this performance counter
  99728. */
  99729. beginMonitoring(): void;
  99730. /**
  99731. * Compute the time lapsed since the previous beginMonitoring() call.
  99732. * @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
  99733. */
  99734. endMonitoring(newFrame?: boolean): void;
  99735. private _fetchResult;
  99736. private _startMonitoringTime;
  99737. private _min;
  99738. private _max;
  99739. private _average;
  99740. private _current;
  99741. private _totalValueCount;
  99742. private _totalAccumulated;
  99743. private _lastSecAverage;
  99744. private _lastSecAccumulated;
  99745. private _lastSecTime;
  99746. private _lastSecValueCount;
  99747. }
  99748. }
  99749. declare module BABYLON {
  99750. /**
  99751. * Defines the interface used by display changed events
  99752. */
  99753. export interface IDisplayChangedEventArgs {
  99754. /** Gets the vrDisplay object (if any) */
  99755. vrDisplay: Nullable<any>;
  99756. /** Gets a boolean indicating if webVR is supported */
  99757. vrSupported: boolean;
  99758. }
  99759. /**
  99760. * Defines the interface used by objects containing a viewport (like a camera)
  99761. */
  99762. interface IViewportOwnerLike {
  99763. /**
  99764. * Gets or sets the viewport
  99765. */
  99766. viewport: IViewportLike;
  99767. }
  99768. /**
  99769. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  99770. */
  99771. export class Engine extends ThinEngine {
  99772. /** Defines that alpha blending is disabled */
  99773. static readonly ALPHA_DISABLE: number;
  99774. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  99775. static readonly ALPHA_ADD: number;
  99776. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  99777. static readonly ALPHA_COMBINE: number;
  99778. /** Defines that alpha blending to DEST - SRC * DEST */
  99779. static readonly ALPHA_SUBTRACT: number;
  99780. /** Defines that alpha blending to SRC * DEST */
  99781. static readonly ALPHA_MULTIPLY: number;
  99782. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  99783. static readonly ALPHA_MAXIMIZED: number;
  99784. /** Defines that alpha blending to SRC + DEST */
  99785. static readonly ALPHA_ONEONE: number;
  99786. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  99787. static readonly ALPHA_PREMULTIPLIED: number;
  99788. /**
  99789. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  99790. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  99791. */
  99792. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  99793. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  99794. static readonly ALPHA_INTERPOLATE: number;
  99795. /**
  99796. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  99797. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  99798. */
  99799. static readonly ALPHA_SCREENMODE: number;
  99800. /** Defines that the ressource is not delayed*/
  99801. static readonly DELAYLOADSTATE_NONE: number;
  99802. /** Defines that the ressource was successfully delay loaded */
  99803. static readonly DELAYLOADSTATE_LOADED: number;
  99804. /** Defines that the ressource is currently delay loading */
  99805. static readonly DELAYLOADSTATE_LOADING: number;
  99806. /** Defines that the ressource is delayed and has not started loading */
  99807. static readonly DELAYLOADSTATE_NOTLOADED: number;
  99808. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  99809. static readonly NEVER: number;
  99810. /** 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 */
  99811. static readonly ALWAYS: number;
  99812. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  99813. static readonly LESS: number;
  99814. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  99815. static readonly EQUAL: number;
  99816. /** 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 */
  99817. static readonly LEQUAL: number;
  99818. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  99819. static readonly GREATER: number;
  99820. /** 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 */
  99821. static readonly GEQUAL: number;
  99822. /** 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 */
  99823. static readonly NOTEQUAL: number;
  99824. /** Passed to stencilOperation to specify that stencil value must be kept */
  99825. static readonly KEEP: number;
  99826. /** Passed to stencilOperation to specify that stencil value must be replaced */
  99827. static readonly REPLACE: number;
  99828. /** Passed to stencilOperation to specify that stencil value must be incremented */
  99829. static readonly INCR: number;
  99830. /** Passed to stencilOperation to specify that stencil value must be decremented */
  99831. static readonly DECR: number;
  99832. /** Passed to stencilOperation to specify that stencil value must be inverted */
  99833. static readonly INVERT: number;
  99834. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  99835. static readonly INCR_WRAP: number;
  99836. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  99837. static readonly DECR_WRAP: number;
  99838. /** Texture is not repeating outside of 0..1 UVs */
  99839. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  99840. /** Texture is repeating outside of 0..1 UVs */
  99841. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  99842. /** Texture is repeating and mirrored */
  99843. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  99844. /** ALPHA */
  99845. static readonly TEXTUREFORMAT_ALPHA: number;
  99846. /** LUMINANCE */
  99847. static readonly TEXTUREFORMAT_LUMINANCE: number;
  99848. /** LUMINANCE_ALPHA */
  99849. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  99850. /** RGB */
  99851. static readonly TEXTUREFORMAT_RGB: number;
  99852. /** RGBA */
  99853. static readonly TEXTUREFORMAT_RGBA: number;
  99854. /** RED */
  99855. static readonly TEXTUREFORMAT_RED: number;
  99856. /** RED (2nd reference) */
  99857. static readonly TEXTUREFORMAT_R: number;
  99858. /** RG */
  99859. static readonly TEXTUREFORMAT_RG: number;
  99860. /** RED_INTEGER */
  99861. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  99862. /** RED_INTEGER (2nd reference) */
  99863. static readonly TEXTUREFORMAT_R_INTEGER: number;
  99864. /** RG_INTEGER */
  99865. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  99866. /** RGB_INTEGER */
  99867. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  99868. /** RGBA_INTEGER */
  99869. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  99870. /** UNSIGNED_BYTE */
  99871. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  99872. /** UNSIGNED_BYTE (2nd reference) */
  99873. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  99874. /** FLOAT */
  99875. static readonly TEXTURETYPE_FLOAT: number;
  99876. /** HALF_FLOAT */
  99877. static readonly TEXTURETYPE_HALF_FLOAT: number;
  99878. /** BYTE */
  99879. static readonly TEXTURETYPE_BYTE: number;
  99880. /** SHORT */
  99881. static readonly TEXTURETYPE_SHORT: number;
  99882. /** UNSIGNED_SHORT */
  99883. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  99884. /** INT */
  99885. static readonly TEXTURETYPE_INT: number;
  99886. /** UNSIGNED_INT */
  99887. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  99888. /** UNSIGNED_SHORT_4_4_4_4 */
  99889. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  99890. /** UNSIGNED_SHORT_5_5_5_1 */
  99891. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  99892. /** UNSIGNED_SHORT_5_6_5 */
  99893. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  99894. /** UNSIGNED_INT_2_10_10_10_REV */
  99895. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  99896. /** UNSIGNED_INT_24_8 */
  99897. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  99898. /** UNSIGNED_INT_10F_11F_11F_REV */
  99899. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  99900. /** UNSIGNED_INT_5_9_9_9_REV */
  99901. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  99902. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  99903. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  99904. /** nearest is mag = nearest and min = nearest and mip = linear */
  99905. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  99906. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99907. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  99908. /** Trilinear is mag = linear and min = linear and mip = linear */
  99909. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  99910. /** nearest is mag = nearest and min = nearest and mip = linear */
  99911. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  99912. /** Bilinear is mag = linear and min = linear and mip = nearest */
  99913. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  99914. /** Trilinear is mag = linear and min = linear and mip = linear */
  99915. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  99916. /** mag = nearest and min = nearest and mip = nearest */
  99917. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  99918. /** mag = nearest and min = linear and mip = nearest */
  99919. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  99920. /** mag = nearest and min = linear and mip = linear */
  99921. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  99922. /** mag = nearest and min = linear and mip = none */
  99923. static readonly TEXTURE_NEAREST_LINEAR: number;
  99924. /** mag = nearest and min = nearest and mip = none */
  99925. static readonly TEXTURE_NEAREST_NEAREST: number;
  99926. /** mag = linear and min = nearest and mip = nearest */
  99927. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  99928. /** mag = linear and min = nearest and mip = linear */
  99929. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  99930. /** mag = linear and min = linear and mip = none */
  99931. static readonly TEXTURE_LINEAR_LINEAR: number;
  99932. /** mag = linear and min = nearest and mip = none */
  99933. static readonly TEXTURE_LINEAR_NEAREST: number;
  99934. /** Explicit coordinates mode */
  99935. static readonly TEXTURE_EXPLICIT_MODE: number;
  99936. /** Spherical coordinates mode */
  99937. static readonly TEXTURE_SPHERICAL_MODE: number;
  99938. /** Planar coordinates mode */
  99939. static readonly TEXTURE_PLANAR_MODE: number;
  99940. /** Cubic coordinates mode */
  99941. static readonly TEXTURE_CUBIC_MODE: number;
  99942. /** Projection coordinates mode */
  99943. static readonly TEXTURE_PROJECTION_MODE: number;
  99944. /** Skybox coordinates mode */
  99945. static readonly TEXTURE_SKYBOX_MODE: number;
  99946. /** Inverse Cubic coordinates mode */
  99947. static readonly TEXTURE_INVCUBIC_MODE: number;
  99948. /** Equirectangular coordinates mode */
  99949. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  99950. /** Equirectangular Fixed coordinates mode */
  99951. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  99952. /** Equirectangular Fixed Mirrored coordinates mode */
  99953. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  99954. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  99955. static readonly SCALEMODE_FLOOR: number;
  99956. /** Defines that texture rescaling will look for the nearest power of 2 size */
  99957. static readonly SCALEMODE_NEAREST: number;
  99958. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  99959. static readonly SCALEMODE_CEILING: number;
  99960. /**
  99961. * Returns the current npm package of the sdk
  99962. */
  99963. static readonly NpmPackage: string;
  99964. /**
  99965. * Returns the current version of the framework
  99966. */
  99967. static readonly Version: string;
  99968. /** Gets the list of created engines */
  99969. static readonly Instances: Engine[];
  99970. /**
  99971. * Gets the latest created engine
  99972. */
  99973. static readonly LastCreatedEngine: Nullable<Engine>;
  99974. /**
  99975. * Gets the latest created scene
  99976. */
  99977. static readonly LastCreatedScene: Nullable<Scene>;
  99978. /**
  99979. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  99980. * @param flag defines which part of the materials must be marked as dirty
  99981. * @param predicate defines a predicate used to filter which materials should be affected
  99982. */
  99983. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  99984. /**
  99985. * Method called to create the default loading screen.
  99986. * This can be overriden in your own app.
  99987. * @param canvas The rendering canvas element
  99988. * @returns The loading screen
  99989. */
  99990. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  99991. /**
  99992. * Method called to create the default rescale post process on each engine.
  99993. */
  99994. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  99995. /**
  99996. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  99997. **/
  99998. enableOfflineSupport: boolean;
  99999. /**
  100000. * 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)
  100001. **/
  100002. disableManifestCheck: boolean;
  100003. /**
  100004. * Gets the list of created scenes
  100005. */
  100006. scenes: Scene[];
  100007. /**
  100008. * Event raised when a new scene is created
  100009. */
  100010. onNewSceneAddedObservable: Observable<Scene>;
  100011. /**
  100012. * Gets the list of created postprocesses
  100013. */
  100014. postProcesses: PostProcess[];
  100015. /**
  100016. * Gets a boolean indicating if the pointer is currently locked
  100017. */
  100018. isPointerLock: boolean;
  100019. /**
  100020. * Observable event triggered each time the rendering canvas is resized
  100021. */
  100022. onResizeObservable: Observable<Engine>;
  100023. /**
  100024. * Observable event triggered each time the canvas loses focus
  100025. */
  100026. onCanvasBlurObservable: Observable<Engine>;
  100027. /**
  100028. * Observable event triggered each time the canvas gains focus
  100029. */
  100030. onCanvasFocusObservable: Observable<Engine>;
  100031. /**
  100032. * Observable event triggered each time the canvas receives pointerout event
  100033. */
  100034. onCanvasPointerOutObservable: Observable<PointerEvent>;
  100035. /**
  100036. * Observable raised when the engine begins a new frame
  100037. */
  100038. onBeginFrameObservable: Observable<Engine>;
  100039. /**
  100040. * If set, will be used to request the next animation frame for the render loop
  100041. */
  100042. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  100043. /**
  100044. * Observable raised when the engine ends the current frame
  100045. */
  100046. onEndFrameObservable: Observable<Engine>;
  100047. /**
  100048. * Observable raised when the engine is about to compile a shader
  100049. */
  100050. onBeforeShaderCompilationObservable: Observable<Engine>;
  100051. /**
  100052. * Observable raised when the engine has jsut compiled a shader
  100053. */
  100054. onAfterShaderCompilationObservable: Observable<Engine>;
  100055. /**
  100056. * Gets the audio engine
  100057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100058. * @ignorenaming
  100059. */
  100060. static audioEngine: IAudioEngine;
  100061. /**
  100062. * Default AudioEngine factory responsible of creating the Audio Engine.
  100063. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  100064. */
  100065. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  100066. /**
  100067. * Default offline support factory responsible of creating a tool used to store data locally.
  100068. * By default, this will create a Database object if the workload has been embedded.
  100069. */
  100070. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  100071. private _loadingScreen;
  100072. private _pointerLockRequested;
  100073. private _dummyFramebuffer;
  100074. private _rescalePostProcess;
  100075. /** @hidden */
  100076. protected _alphaMode: number;
  100077. /** @hidden */
  100078. protected _alphaEquation: number;
  100079. private _deterministicLockstep;
  100080. private _lockstepMaxSteps;
  100081. protected readonly _supportsHardwareTextureRescaling: boolean;
  100082. private _fps;
  100083. private _deltaTime;
  100084. /** @hidden */
  100085. _drawCalls: PerfCounter;
  100086. /**
  100087. * Turn this value on if you want to pause FPS computation when in background
  100088. */
  100089. disablePerformanceMonitorInBackground: boolean;
  100090. private _performanceMonitor;
  100091. /**
  100092. * Gets the performance monitor attached to this engine
  100093. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  100094. */
  100095. readonly performanceMonitor: PerformanceMonitor;
  100096. private _onFocus;
  100097. private _onBlur;
  100098. private _onCanvasPointerOut;
  100099. private _onCanvasBlur;
  100100. private _onCanvasFocus;
  100101. private _onFullscreenChange;
  100102. private _onPointerLockChange;
  100103. /**
  100104. * Gets the HTML element used to attach event listeners
  100105. * @returns a HTML element
  100106. */
  100107. getInputElement(): Nullable<HTMLElement>;
  100108. /**
  100109. * Creates a new engine
  100110. * @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
  100111. * @param antialias defines enable antialiasing (default: false)
  100112. * @param options defines further options to be sent to the getContext() function
  100113. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  100114. */
  100115. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  100116. /**
  100117. * Gets current aspect ratio
  100118. * @param viewportOwner defines the camera to use to get the aspect ratio
  100119. * @param useScreen defines if screen size must be used (or the current render target if any)
  100120. * @returns a number defining the aspect ratio
  100121. */
  100122. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  100123. /**
  100124. * Gets current screen aspect ratio
  100125. * @returns a number defining the aspect ratio
  100126. */
  100127. getScreenAspectRatio(): number;
  100128. /**
  100129. * Gets host document
  100130. * @returns the host document object
  100131. */
  100132. getHostDocument(): Document;
  100133. /**
  100134. * Gets the client rect of the HTML canvas attached with the current webGL context
  100135. * @returns a client rectanglee
  100136. */
  100137. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  100138. /**
  100139. * Gets the client rect of the HTML element used for events
  100140. * @returns a client rectanglee
  100141. */
  100142. getInputElementClientRect(): Nullable<ClientRect>;
  100143. /**
  100144. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  100145. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100146. * @returns true if engine is in deterministic lock step mode
  100147. */
  100148. isDeterministicLockStep(): boolean;
  100149. /**
  100150. * Gets the max steps when engine is running in deterministic lock step
  100151. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100152. * @returns the max steps
  100153. */
  100154. getLockstepMaxSteps(): number;
  100155. /**
  100156. * Force the mipmap generation for the given render target texture
  100157. * @param texture defines the render target texture to use
  100158. */
  100159. generateMipMapsForCubemap(texture: InternalTexture): void;
  100160. /** States */
  100161. /**
  100162. * Set various states to the webGL context
  100163. * @param culling defines backface culling state
  100164. * @param zOffset defines the value to apply to zOffset (0 by default)
  100165. * @param force defines if states must be applied even if cache is up to date
  100166. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  100167. */
  100168. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100169. /**
  100170. * Set the z offset to apply to current rendering
  100171. * @param value defines the offset to apply
  100172. */
  100173. setZOffset(value: number): void;
  100174. /**
  100175. * Gets the current value of the zOffset
  100176. * @returns the current zOffset state
  100177. */
  100178. getZOffset(): number;
  100179. /**
  100180. * Enable or disable depth buffering
  100181. * @param enable defines the state to set
  100182. */
  100183. setDepthBuffer(enable: boolean): void;
  100184. /**
  100185. * Gets a boolean indicating if depth writing is enabled
  100186. * @returns the current depth writing state
  100187. */
  100188. getDepthWrite(): boolean;
  100189. /**
  100190. * Enable or disable depth writing
  100191. * @param enable defines the state to set
  100192. */
  100193. setDepthWrite(enable: boolean): void;
  100194. /**
  100195. * Enable or disable color writing
  100196. * @param enable defines the state to set
  100197. */
  100198. setColorWrite(enable: boolean): void;
  100199. /**
  100200. * Gets a boolean indicating if color writing is enabled
  100201. * @returns the current color writing state
  100202. */
  100203. getColorWrite(): boolean;
  100204. /**
  100205. * Sets alpha constants used by some alpha blending modes
  100206. * @param r defines the red component
  100207. * @param g defines the green component
  100208. * @param b defines the blue component
  100209. * @param a defines the alpha component
  100210. */
  100211. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  100212. /**
  100213. * Sets the current alpha mode
  100214. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  100215. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  100216. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100217. */
  100218. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100219. /**
  100220. * Gets the current alpha mode
  100221. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  100222. * @returns the current alpha mode
  100223. */
  100224. getAlphaMode(): number;
  100225. /**
  100226. * Sets the current alpha equation
  100227. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  100228. */
  100229. setAlphaEquation(equation: number): void;
  100230. /**
  100231. * Gets the current alpha equation.
  100232. * @returns the current alpha equation
  100233. */
  100234. getAlphaEquation(): number;
  100235. /**
  100236. * Gets a boolean indicating if stencil buffer is enabled
  100237. * @returns the current stencil buffer state
  100238. */
  100239. getStencilBuffer(): boolean;
  100240. /**
  100241. * Enable or disable the stencil buffer
  100242. * @param enable defines if the stencil buffer must be enabled or disabled
  100243. */
  100244. setStencilBuffer(enable: boolean): void;
  100245. /**
  100246. * Gets the current stencil mask
  100247. * @returns a number defining the new stencil mask to use
  100248. */
  100249. getStencilMask(): number;
  100250. /**
  100251. * Sets the current stencil mask
  100252. * @param mask defines the new stencil mask to use
  100253. */
  100254. setStencilMask(mask: number): void;
  100255. /**
  100256. * Gets the current stencil function
  100257. * @returns a number defining the stencil function to use
  100258. */
  100259. getStencilFunction(): number;
  100260. /**
  100261. * Gets the current stencil reference value
  100262. * @returns a number defining the stencil reference value to use
  100263. */
  100264. getStencilFunctionReference(): number;
  100265. /**
  100266. * Gets the current stencil mask
  100267. * @returns a number defining the stencil mask to use
  100268. */
  100269. getStencilFunctionMask(): number;
  100270. /**
  100271. * Sets the current stencil function
  100272. * @param stencilFunc defines the new stencil function to use
  100273. */
  100274. setStencilFunction(stencilFunc: number): void;
  100275. /**
  100276. * Sets the current stencil reference
  100277. * @param reference defines the new stencil reference to use
  100278. */
  100279. setStencilFunctionReference(reference: number): void;
  100280. /**
  100281. * Sets the current stencil mask
  100282. * @param mask defines the new stencil mask to use
  100283. */
  100284. setStencilFunctionMask(mask: number): void;
  100285. /**
  100286. * Gets the current stencil operation when stencil fails
  100287. * @returns a number defining stencil operation to use when stencil fails
  100288. */
  100289. getStencilOperationFail(): number;
  100290. /**
  100291. * Gets the current stencil operation when depth fails
  100292. * @returns a number defining stencil operation to use when depth fails
  100293. */
  100294. getStencilOperationDepthFail(): number;
  100295. /**
  100296. * Gets the current stencil operation when stencil passes
  100297. * @returns a number defining stencil operation to use when stencil passes
  100298. */
  100299. getStencilOperationPass(): number;
  100300. /**
  100301. * Sets the stencil operation to use when stencil fails
  100302. * @param operation defines the stencil operation to use when stencil fails
  100303. */
  100304. setStencilOperationFail(operation: number): void;
  100305. /**
  100306. * Sets the stencil operation to use when depth fails
  100307. * @param operation defines the stencil operation to use when depth fails
  100308. */
  100309. setStencilOperationDepthFail(operation: number): void;
  100310. /**
  100311. * Sets the stencil operation to use when stencil passes
  100312. * @param operation defines the stencil operation to use when stencil passes
  100313. */
  100314. setStencilOperationPass(operation: number): void;
  100315. /**
  100316. * Sets a boolean indicating if the dithering state is enabled or disabled
  100317. * @param value defines the dithering state
  100318. */
  100319. setDitheringState(value: boolean): void;
  100320. /**
  100321. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  100322. * @param value defines the rasterizer state
  100323. */
  100324. setRasterizerState(value: boolean): void;
  100325. /**
  100326. * Gets the current depth function
  100327. * @returns a number defining the depth function
  100328. */
  100329. getDepthFunction(): Nullable<number>;
  100330. /**
  100331. * Sets the current depth function
  100332. * @param depthFunc defines the function to use
  100333. */
  100334. setDepthFunction(depthFunc: number): void;
  100335. /**
  100336. * Sets the current depth function to GREATER
  100337. */
  100338. setDepthFunctionToGreater(): void;
  100339. /**
  100340. * Sets the current depth function to GEQUAL
  100341. */
  100342. setDepthFunctionToGreaterOrEqual(): void;
  100343. /**
  100344. * Sets the current depth function to LESS
  100345. */
  100346. setDepthFunctionToLess(): void;
  100347. /**
  100348. * Sets the current depth function to LEQUAL
  100349. */
  100350. setDepthFunctionToLessOrEqual(): void;
  100351. private _cachedStencilBuffer;
  100352. private _cachedStencilFunction;
  100353. private _cachedStencilMask;
  100354. private _cachedStencilOperationPass;
  100355. private _cachedStencilOperationFail;
  100356. private _cachedStencilOperationDepthFail;
  100357. private _cachedStencilReference;
  100358. /**
  100359. * Caches the the state of the stencil buffer
  100360. */
  100361. cacheStencilState(): void;
  100362. /**
  100363. * Restores the state of the stencil buffer
  100364. */
  100365. restoreStencilState(): void;
  100366. /**
  100367. * Directly set the WebGL Viewport
  100368. * @param x defines the x coordinate of the viewport (in screen space)
  100369. * @param y defines the y coordinate of the viewport (in screen space)
  100370. * @param width defines the width of the viewport (in screen space)
  100371. * @param height defines the height of the viewport (in screen space)
  100372. * @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
  100373. */
  100374. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  100375. /**
  100376. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  100377. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100378. * @param y defines the y-coordinate of the corner of the clear rectangle
  100379. * @param width defines the width of the clear rectangle
  100380. * @param height defines the height of the clear rectangle
  100381. * @param clearColor defines the clear color
  100382. */
  100383. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  100384. /**
  100385. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  100386. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  100387. * @param y defines the y-coordinate of the corner of the clear rectangle
  100388. * @param width defines the width of the clear rectangle
  100389. * @param height defines the height of the clear rectangle
  100390. */
  100391. enableScissor(x: number, y: number, width: number, height: number): void;
  100392. /**
  100393. * Disable previously set scissor test rectangle
  100394. */
  100395. disableScissor(): void;
  100396. protected _reportDrawCall(): void;
  100397. /**
  100398. * Initializes a webVR display and starts listening to display change events
  100399. * The onVRDisplayChangedObservable will be notified upon these changes
  100400. * @returns The onVRDisplayChangedObservable
  100401. */
  100402. initWebVR(): Observable<IDisplayChangedEventArgs>;
  100403. /** @hidden */
  100404. _prepareVRComponent(): void;
  100405. /** @hidden */
  100406. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  100407. /** @hidden */
  100408. _submitVRFrame(): void;
  100409. /**
  100410. * Call this function to leave webVR mode
  100411. * Will do nothing if webVR is not supported or if there is no webVR device
  100412. * @see http://doc.babylonjs.com/how_to/webvr_camera
  100413. */
  100414. disableVR(): void;
  100415. /**
  100416. * Gets a boolean indicating that the system is in VR mode and is presenting
  100417. * @returns true if VR mode is engaged
  100418. */
  100419. isVRPresenting(): boolean;
  100420. /** @hidden */
  100421. _requestVRFrame(): void;
  100422. /** @hidden */
  100423. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100424. /**
  100425. * Gets the source code of the vertex shader associated with a specific webGL program
  100426. * @param program defines the program to use
  100427. * @returns a string containing the source code of the vertex shader associated with the program
  100428. */
  100429. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  100430. /**
  100431. * Gets the source code of the fragment shader associated with a specific webGL program
  100432. * @param program defines the program to use
  100433. * @returns a string containing the source code of the fragment shader associated with the program
  100434. */
  100435. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  100436. /**
  100437. * Reads pixels from the current frame buffer. Please note that this function can be slow
  100438. * @param x defines the x coordinate of the rectangle where pixels must be read
  100439. * @param y defines the y coordinate of the rectangle where pixels must be read
  100440. * @param width defines the width of the rectangle where pixels must be read
  100441. * @param height defines the height of the rectangle where pixels must be read
  100442. * @returns a Uint8Array containing RGBA colors
  100443. */
  100444. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  100445. /**
  100446. * Sets a depth stencil texture from a render target to the according uniform.
  100447. * @param channel The texture channel
  100448. * @param uniform The uniform to set
  100449. * @param texture The render target texture containing the depth stencil texture to apply
  100450. */
  100451. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  100452. /**
  100453. * Sets a texture to the webGL context from a postprocess
  100454. * @param channel defines the channel to use
  100455. * @param postProcess defines the source postprocess
  100456. */
  100457. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  100458. /**
  100459. * Binds the output of the passed in post process to the texture channel specified
  100460. * @param channel The channel the texture should be bound to
  100461. * @param postProcess The post process which's output should be bound
  100462. */
  100463. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  100464. /** @hidden */
  100465. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  100466. protected _rebuildBuffers(): void;
  100467. /** @hidden */
  100468. _renderFrame(): void;
  100469. _renderLoop(): void;
  100470. /** @hidden */
  100471. _renderViews(): boolean;
  100472. /**
  100473. * Toggle full screen mode
  100474. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100475. */
  100476. switchFullscreen(requestPointerLock: boolean): void;
  100477. /**
  100478. * Enters full screen mode
  100479. * @param requestPointerLock defines if a pointer lock should be requested from the user
  100480. */
  100481. enterFullscreen(requestPointerLock: boolean): void;
  100482. /**
  100483. * Exits full screen mode
  100484. */
  100485. exitFullscreen(): void;
  100486. /**
  100487. * Enters Pointerlock mode
  100488. */
  100489. enterPointerlock(): void;
  100490. /**
  100491. * Exits Pointerlock mode
  100492. */
  100493. exitPointerlock(): void;
  100494. /**
  100495. * Begin a new frame
  100496. */
  100497. beginFrame(): void;
  100498. /**
  100499. * Enf the current frame
  100500. */
  100501. endFrame(): void;
  100502. resize(): void;
  100503. /**
  100504. * Set the compressed texture format to use, based on the formats you have, and the formats
  100505. * supported by the hardware / browser.
  100506. *
  100507. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  100508. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  100509. * to API arguments needed to compressed textures. This puts the burden on the container
  100510. * generator to house the arcane code for determining these for current & future formats.
  100511. *
  100512. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  100513. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  100514. *
  100515. * Note: The result of this call is not taken into account when a texture is base64.
  100516. *
  100517. * @param formatsAvailable defines the list of those format families you have created
  100518. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  100519. *
  100520. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  100521. * @returns The extension selected.
  100522. */
  100523. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  100524. /**
  100525. * Force a specific size of the canvas
  100526. * @param width defines the new canvas' width
  100527. * @param height defines the new canvas' height
  100528. */
  100529. setSize(width: number, height: number): void;
  100530. /**
  100531. * Updates a dynamic vertex buffer.
  100532. * @param vertexBuffer the vertex buffer to update
  100533. * @param data the data used to update the vertex buffer
  100534. * @param byteOffset the byte offset of the data
  100535. * @param byteLength the byte length of the data
  100536. */
  100537. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  100538. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  100539. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100540. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  100541. _releaseTexture(texture: InternalTexture): void;
  100542. /**
  100543. * @hidden
  100544. * Rescales a texture
  100545. * @param source input texutre
  100546. * @param destination destination texture
  100547. * @param scene scene to use to render the resize
  100548. * @param internalFormat format to use when resizing
  100549. * @param onComplete callback to be called when resize has completed
  100550. */
  100551. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  100552. /**
  100553. * Gets the current framerate
  100554. * @returns a number representing the framerate
  100555. */
  100556. getFps(): number;
  100557. /**
  100558. * Gets the time spent between current and previous frame
  100559. * @returns a number representing the delta time in ms
  100560. */
  100561. getDeltaTime(): number;
  100562. private _measureFps;
  100563. /** @hidden */
  100564. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  100565. /**
  100566. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  100567. * @param renderTarget The render target to set the frame buffer for
  100568. */
  100569. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  100570. /**
  100571. * Update a dynamic index buffer
  100572. * @param indexBuffer defines the target index buffer
  100573. * @param indices defines the data to update
  100574. * @param offset defines the offset in the target index buffer where update should start
  100575. */
  100576. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  100577. /**
  100578. * Updates the sample count of a render target texture
  100579. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  100580. * @param texture defines the texture to update
  100581. * @param samples defines the sample count to set
  100582. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  100583. */
  100584. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  100585. /**
  100586. * Updates a depth texture Comparison Mode and Function.
  100587. * If the comparison Function is equal to 0, the mode will be set to none.
  100588. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  100589. * @param texture The texture to set the comparison function for
  100590. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  100591. */
  100592. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  100593. /**
  100594. * Creates a webGL buffer to use with instanciation
  100595. * @param capacity defines the size of the buffer
  100596. * @returns the webGL buffer
  100597. */
  100598. createInstancesBuffer(capacity: number): DataBuffer;
  100599. /**
  100600. * Delete a webGL buffer used with instanciation
  100601. * @param buffer defines the webGL buffer to delete
  100602. */
  100603. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  100604. /** @hidden */
  100605. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  100606. dispose(): void;
  100607. private _disableTouchAction;
  100608. /**
  100609. * Display the loading screen
  100610. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100611. */
  100612. displayLoadingUI(): void;
  100613. /**
  100614. * Hide the loading screen
  100615. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100616. */
  100617. hideLoadingUI(): void;
  100618. /**
  100619. * Gets the current loading screen object
  100620. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100621. */
  100622. /**
  100623. * Sets the current loading screen object
  100624. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100625. */
  100626. loadingScreen: ILoadingScreen;
  100627. /**
  100628. * Sets the current loading screen text
  100629. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100630. */
  100631. loadingUIText: string;
  100632. /**
  100633. * Sets the current loading screen background color
  100634. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  100635. */
  100636. loadingUIBackgroundColor: string;
  100637. /** Pointerlock and fullscreen */
  100638. /**
  100639. * Ask the browser to promote the current element to pointerlock mode
  100640. * @param element defines the DOM element to promote
  100641. */
  100642. static _RequestPointerlock(element: HTMLElement): void;
  100643. /**
  100644. * Asks the browser to exit pointerlock mode
  100645. */
  100646. static _ExitPointerlock(): void;
  100647. /**
  100648. * Ask the browser to promote the current element to fullscreen rendering mode
  100649. * @param element defines the DOM element to promote
  100650. */
  100651. static _RequestFullscreen(element: HTMLElement): void;
  100652. /**
  100653. * Asks the browser to exit fullscreen mode
  100654. */
  100655. static _ExitFullscreen(): void;
  100656. }
  100657. }
  100658. declare module BABYLON {
  100659. /**
  100660. * The engine store class is responsible to hold all the instances of Engine and Scene created
  100661. * during the life time of the application.
  100662. */
  100663. export class EngineStore {
  100664. /** Gets the list of created engines */
  100665. static Instances: Engine[];
  100666. /** @hidden */
  100667. static _LastCreatedScene: Nullable<Scene>;
  100668. /**
  100669. * Gets the latest created engine
  100670. */
  100671. static readonly LastCreatedEngine: Nullable<Engine>;
  100672. /**
  100673. * Gets the latest created scene
  100674. */
  100675. static readonly LastCreatedScene: Nullable<Scene>;
  100676. /**
  100677. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100678. * @ignorenaming
  100679. */
  100680. static UseFallbackTexture: boolean;
  100681. /**
  100682. * Texture content used if a texture cannot loaded
  100683. * @ignorenaming
  100684. */
  100685. static FallbackTexture: string;
  100686. }
  100687. }
  100688. declare module BABYLON {
  100689. /**
  100690. * Helper class that provides a small promise polyfill
  100691. */
  100692. export class PromisePolyfill {
  100693. /**
  100694. * Static function used to check if the polyfill is required
  100695. * If this is the case then the function will inject the polyfill to window.Promise
  100696. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100697. */
  100698. static Apply(force?: boolean): void;
  100699. }
  100700. }
  100701. declare module BABYLON {
  100702. /**
  100703. * Interface for screenshot methods with describe argument called `size` as object with options
  100704. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  100705. */
  100706. export interface IScreenshotSize {
  100707. /**
  100708. * number in pixels for canvas height
  100709. */
  100710. height?: number;
  100711. /**
  100712. * multiplier allowing render at a higher or lower resolution
  100713. * If value is defined then height and width will be ignored and taken from camera
  100714. */
  100715. precision?: number;
  100716. /**
  100717. * number in pixels for canvas width
  100718. */
  100719. width?: number;
  100720. }
  100721. }
  100722. declare module BABYLON {
  100723. interface IColor4Like {
  100724. r: float;
  100725. g: float;
  100726. b: float;
  100727. a: float;
  100728. }
  100729. /**
  100730. * Class containing a set of static utilities functions
  100731. */
  100732. export class Tools {
  100733. /**
  100734. * Gets or sets the base URL to use to load assets
  100735. */
  100736. static BaseUrl: string;
  100737. /**
  100738. * Enable/Disable Custom HTTP Request Headers globally.
  100739. * default = false
  100740. * @see CustomRequestHeaders
  100741. */
  100742. static UseCustomRequestHeaders: boolean;
  100743. /**
  100744. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  100745. * i.e. when loading files, where the server/service expects an Authorization header
  100746. */
  100747. static CustomRequestHeaders: {
  100748. [key: string]: string;
  100749. };
  100750. /**
  100751. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  100752. */
  100753. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  100754. /**
  100755. * Default behaviour for cors in the application.
  100756. * It can be a string if the expected behavior is identical in the entire app.
  100757. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  100758. */
  100759. static CorsBehavior: string | ((url: string | string[]) => string);
  100760. /**
  100761. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100762. * @ignorenaming
  100763. */
  100764. static UseFallbackTexture: boolean;
  100765. /**
  100766. * Use this object to register external classes like custom textures or material
  100767. * to allow the laoders to instantiate them
  100768. */
  100769. static RegisteredExternalClasses: {
  100770. [key: string]: Object;
  100771. };
  100772. /**
  100773. * Texture content used if a texture cannot loaded
  100774. * @ignorenaming
  100775. */
  100776. static fallbackTexture: string;
  100777. /**
  100778. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  100779. * @param u defines the coordinate on X axis
  100780. * @param v defines the coordinate on Y axis
  100781. * @param width defines the width of the source data
  100782. * @param height defines the height of the source data
  100783. * @param pixels defines the source byte array
  100784. * @param color defines the output color
  100785. */
  100786. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  100787. /**
  100788. * Interpolates between a and b via alpha
  100789. * @param a The lower value (returned when alpha = 0)
  100790. * @param b The upper value (returned when alpha = 1)
  100791. * @param alpha The interpolation-factor
  100792. * @return The mixed value
  100793. */
  100794. static Mix(a: number, b: number, alpha: number): number;
  100795. /**
  100796. * Tries to instantiate a new object from a given class name
  100797. * @param className defines the class name to instantiate
  100798. * @returns the new object or null if the system was not able to do the instantiation
  100799. */
  100800. static Instantiate(className: string): any;
  100801. /**
  100802. * Provides a slice function that will work even on IE
  100803. * @param data defines the array to slice
  100804. * @param start defines the start of the data (optional)
  100805. * @param end defines the end of the data (optional)
  100806. * @returns the new sliced array
  100807. */
  100808. static Slice<T>(data: T, start?: number, end?: number): T;
  100809. /**
  100810. * Polyfill for setImmediate
  100811. * @param action defines the action to execute after the current execution block
  100812. */
  100813. static SetImmediate(action: () => void): void;
  100814. /**
  100815. * Function indicating if a number is an exponent of 2
  100816. * @param value defines the value to test
  100817. * @returns true if the value is an exponent of 2
  100818. */
  100819. static IsExponentOfTwo(value: number): boolean;
  100820. private static _tmpFloatArray;
  100821. /**
  100822. * Returns the nearest 32-bit single precision float representation of a Number
  100823. * @param value A Number. If the parameter is of a different type, it will get converted
  100824. * to a number or to NaN if it cannot be converted
  100825. * @returns number
  100826. */
  100827. static FloatRound(value: number): number;
  100828. /**
  100829. * Extracts the filename from a path
  100830. * @param path defines the path to use
  100831. * @returns the filename
  100832. */
  100833. static GetFilename(path: string): string;
  100834. /**
  100835. * Extracts the "folder" part of a path (everything before the filename).
  100836. * @param uri The URI to extract the info from
  100837. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  100838. * @returns The "folder" part of the path
  100839. */
  100840. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  100841. /**
  100842. * Extracts text content from a DOM element hierarchy
  100843. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  100844. */
  100845. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  100846. /**
  100847. * Convert an angle in radians to degrees
  100848. * @param angle defines the angle to convert
  100849. * @returns the angle in degrees
  100850. */
  100851. static ToDegrees(angle: number): number;
  100852. /**
  100853. * Convert an angle in degrees to radians
  100854. * @param angle defines the angle to convert
  100855. * @returns the angle in radians
  100856. */
  100857. static ToRadians(angle: number): number;
  100858. /**
  100859. * Returns an array if obj is not an array
  100860. * @param obj defines the object to evaluate as an array
  100861. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  100862. * @returns either obj directly if obj is an array or a new array containing obj
  100863. */
  100864. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  100865. /**
  100866. * Gets the pointer prefix to use
  100867. * @returns "pointer" if touch is enabled. Else returns "mouse"
  100868. */
  100869. static GetPointerPrefix(): string;
  100870. /**
  100871. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  100872. * @param url define the url we are trying
  100873. * @param element define the dom element where to configure the cors policy
  100874. */
  100875. static SetCorsBehavior(url: string | string[], element: {
  100876. crossOrigin: string | null;
  100877. }): void;
  100878. /**
  100879. * Removes unwanted characters from an url
  100880. * @param url defines the url to clean
  100881. * @returns the cleaned url
  100882. */
  100883. static CleanUrl(url: string): string;
  100884. /**
  100885. * Gets or sets a function used to pre-process url before using them to load assets
  100886. */
  100887. static PreprocessUrl: (url: string) => string;
  100888. /**
  100889. * Loads an image as an HTMLImageElement.
  100890. * @param input url string, ArrayBuffer, or Blob to load
  100891. * @param onLoad callback called when the image successfully loads
  100892. * @param onError callback called when the image fails to load
  100893. * @param offlineProvider offline provider for caching
  100894. * @param mimeType optional mime type
  100895. * @returns the HTMLImageElement of the loaded image
  100896. */
  100897. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  100898. /**
  100899. * Loads a file from a url
  100900. * @param url url string, ArrayBuffer, or Blob to load
  100901. * @param onSuccess callback called when the file successfully loads
  100902. * @param onProgress callback called while file is loading (if the server supports this mode)
  100903. * @param offlineProvider defines the offline provider for caching
  100904. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  100905. * @param onError callback called when the file fails to load
  100906. * @returns a file request object
  100907. */
  100908. 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;
  100909. /**
  100910. * Loads a file from a url
  100911. * @param url the file url to load
  100912. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  100913. */
  100914. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  100915. /**
  100916. * Load a script (identified by an url). When the url returns, the
  100917. * content of this file is added into a new script element, attached to the DOM (body element)
  100918. * @param scriptUrl defines the url of the script to laod
  100919. * @param onSuccess defines the callback called when the script is loaded
  100920. * @param onError defines the callback to call if an error occurs
  100921. * @param scriptId defines the id of the script element
  100922. */
  100923. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  100924. /**
  100925. * Load an asynchronous script (identified by an url). When the url returns, the
  100926. * content of this file is added into a new script element, attached to the DOM (body element)
  100927. * @param scriptUrl defines the url of the script to laod
  100928. * @param scriptId defines the id of the script element
  100929. * @returns a promise request object
  100930. */
  100931. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  100932. /**
  100933. * Loads a file from a blob
  100934. * @param fileToLoad defines the blob to use
  100935. * @param callback defines the callback to call when data is loaded
  100936. * @param progressCallback defines the callback to call during loading process
  100937. * @returns a file request object
  100938. */
  100939. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  100940. /**
  100941. * Reads a file from a File object
  100942. * @param file defines the file to load
  100943. * @param onSuccess defines the callback to call when data is loaded
  100944. * @param onProgress defines the callback to call during loading process
  100945. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  100946. * @param onError defines the callback to call when an error occurs
  100947. * @returns a file request object
  100948. */
  100949. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  100950. /**
  100951. * Creates a data url from a given string content
  100952. * @param content defines the content to convert
  100953. * @returns the new data url link
  100954. */
  100955. static FileAsURL(content: string): string;
  100956. /**
  100957. * Format the given number to a specific decimal format
  100958. * @param value defines the number to format
  100959. * @param decimals defines the number of decimals to use
  100960. * @returns the formatted string
  100961. */
  100962. static Format(value: number, decimals?: number): string;
  100963. /**
  100964. * Tries to copy an object by duplicating every property
  100965. * @param source defines the source object
  100966. * @param destination defines the target object
  100967. * @param doNotCopyList defines a list of properties to avoid
  100968. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  100969. */
  100970. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  100971. /**
  100972. * Gets a boolean indicating if the given object has no own property
  100973. * @param obj defines the object to test
  100974. * @returns true if object has no own property
  100975. */
  100976. static IsEmpty(obj: any): boolean;
  100977. /**
  100978. * Function used to register events at window level
  100979. * @param windowElement defines the Window object to use
  100980. * @param events defines the events to register
  100981. */
  100982. static RegisterTopRootEvents(windowElement: Window, events: {
  100983. name: string;
  100984. handler: Nullable<(e: FocusEvent) => any>;
  100985. }[]): void;
  100986. /**
  100987. * Function used to unregister events from window level
  100988. * @param windowElement defines the Window object to use
  100989. * @param events defines the events to unregister
  100990. */
  100991. static UnregisterTopRootEvents(windowElement: Window, events: {
  100992. name: string;
  100993. handler: Nullable<(e: FocusEvent) => any>;
  100994. }[]): void;
  100995. /**
  100996. * @ignore
  100997. */
  100998. static _ScreenshotCanvas: HTMLCanvasElement;
  100999. /**
  101000. * Dumps the current bound framebuffer
  101001. * @param width defines the rendering width
  101002. * @param height defines the rendering height
  101003. * @param engine defines the hosting engine
  101004. * @param successCallback defines the callback triggered once the data are available
  101005. * @param mimeType defines the mime type of the result
  101006. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  101007. */
  101008. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  101009. /**
  101010. * Converts the canvas data to blob.
  101011. * This acts as a polyfill for browsers not supporting the to blob function.
  101012. * @param canvas Defines the canvas to extract the data from
  101013. * @param successCallback Defines the callback triggered once the data are available
  101014. * @param mimeType Defines the mime type of the result
  101015. */
  101016. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  101017. /**
  101018. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  101019. * @param successCallback defines the callback triggered once the data are available
  101020. * @param mimeType defines the mime type of the result
  101021. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  101022. */
  101023. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  101024. /**
  101025. * Downloads a blob in the browser
  101026. * @param blob defines the blob to download
  101027. * @param fileName defines the name of the downloaded file
  101028. */
  101029. static Download(blob: Blob, fileName: string): void;
  101030. /**
  101031. * Captures a screenshot of the current rendering
  101032. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101033. * @param engine defines the rendering engine
  101034. * @param camera defines the source camera
  101035. * @param size This parameter can be set to a single number or to an object with the
  101036. * following (optional) properties: precision, width, height. If a single number is passed,
  101037. * it will be used for both width and height. If an object is passed, the screenshot size
  101038. * will be derived from the parameters. The precision property is a multiplier allowing
  101039. * rendering at a higher or lower resolution
  101040. * @param successCallback defines the callback receives a single parameter which contains the
  101041. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  101042. * src parameter of an <img> to display it
  101043. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  101044. * Check your browser for supported MIME types
  101045. */
  101046. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  101047. /**
  101048. * Captures a screenshot of the current rendering
  101049. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101050. * @param engine defines the rendering engine
  101051. * @param camera defines the source camera
  101052. * @param size This parameter can be set to a single number or to an object with the
  101053. * following (optional) properties: precision, width, height. If a single number is passed,
  101054. * it will be used for both width and height. If an object is passed, the screenshot size
  101055. * will be derived from the parameters. The precision property is a multiplier allowing
  101056. * rendering at a higher or lower resolution
  101057. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  101058. * Check your browser for supported MIME types
  101059. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  101060. * to the src parameter of an <img> to display it
  101061. */
  101062. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  101063. /**
  101064. * Generates an image screenshot from the specified camera.
  101065. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101066. * @param engine The engine to use for rendering
  101067. * @param camera The camera to use for rendering
  101068. * @param size This parameter can be set to a single number or to an object with the
  101069. * following (optional) properties: precision, width, height. If a single number is passed,
  101070. * it will be used for both width and height. If an object is passed, the screenshot size
  101071. * will be derived from the parameters. The precision property is a multiplier allowing
  101072. * rendering at a higher or lower resolution
  101073. * @param successCallback The callback receives a single parameter which contains the
  101074. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  101075. * src parameter of an <img> to display it
  101076. * @param mimeType The MIME type of the screenshot image (default: image/png).
  101077. * Check your browser for supported MIME types
  101078. * @param samples Texture samples (default: 1)
  101079. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  101080. * @param fileName A name for for the downloaded file.
  101081. */
  101082. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  101083. /**
  101084. * Generates an image screenshot from the specified camera.
  101085. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101086. * @param engine The engine to use for rendering
  101087. * @param camera The camera to use for rendering
  101088. * @param size This parameter can be set to a single number or to an object with the
  101089. * following (optional) properties: precision, width, height. If a single number is passed,
  101090. * it will be used for both width and height. If an object is passed, the screenshot size
  101091. * will be derived from the parameters. The precision property is a multiplier allowing
  101092. * rendering at a higher or lower resolution
  101093. * @param mimeType The MIME type of the screenshot image (default: image/png).
  101094. * Check your browser for supported MIME types
  101095. * @param samples Texture samples (default: 1)
  101096. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  101097. * @param fileName A name for for the downloaded file.
  101098. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  101099. * to the src parameter of an <img> to display it
  101100. */
  101101. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  101102. /**
  101103. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101104. * Be aware Math.random() could cause collisions, but:
  101105. * "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"
  101106. * @returns a pseudo random id
  101107. */
  101108. static RandomId(): string;
  101109. /**
  101110. * Test if the given uri is a base64 string
  101111. * @param uri The uri to test
  101112. * @return True if the uri is a base64 string or false otherwise
  101113. */
  101114. static IsBase64(uri: string): boolean;
  101115. /**
  101116. * Decode the given base64 uri.
  101117. * @param uri The uri to decode
  101118. * @return The decoded base64 data.
  101119. */
  101120. static DecodeBase64(uri: string): ArrayBuffer;
  101121. /**
  101122. * Gets the absolute url.
  101123. * @param url the input url
  101124. * @return the absolute url
  101125. */
  101126. static GetAbsoluteUrl(url: string): string;
  101127. /**
  101128. * No log
  101129. */
  101130. static readonly NoneLogLevel: number;
  101131. /**
  101132. * Only message logs
  101133. */
  101134. static readonly MessageLogLevel: number;
  101135. /**
  101136. * Only warning logs
  101137. */
  101138. static readonly WarningLogLevel: number;
  101139. /**
  101140. * Only error logs
  101141. */
  101142. static readonly ErrorLogLevel: number;
  101143. /**
  101144. * All logs
  101145. */
  101146. static readonly AllLogLevel: number;
  101147. /**
  101148. * Gets a value indicating the number of loading errors
  101149. * @ignorenaming
  101150. */
  101151. static readonly errorsCount: number;
  101152. /**
  101153. * Callback called when a new log is added
  101154. */
  101155. static OnNewCacheEntry: (entry: string) => void;
  101156. /**
  101157. * Log a message to the console
  101158. * @param message defines the message to log
  101159. */
  101160. static Log(message: string): void;
  101161. /**
  101162. * Write a warning message to the console
  101163. * @param message defines the message to log
  101164. */
  101165. static Warn(message: string): void;
  101166. /**
  101167. * Write an error message to the console
  101168. * @param message defines the message to log
  101169. */
  101170. static Error(message: string): void;
  101171. /**
  101172. * Gets current log cache (list of logs)
  101173. */
  101174. static readonly LogCache: string;
  101175. /**
  101176. * Clears the log cache
  101177. */
  101178. static ClearLogCache(): void;
  101179. /**
  101180. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  101181. */
  101182. static LogLevels: number;
  101183. /**
  101184. * Checks if the window object exists
  101185. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  101186. */
  101187. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  101188. /**
  101189. * No performance log
  101190. */
  101191. static readonly PerformanceNoneLogLevel: number;
  101192. /**
  101193. * Use user marks to log performance
  101194. */
  101195. static readonly PerformanceUserMarkLogLevel: number;
  101196. /**
  101197. * Log performance to the console
  101198. */
  101199. static readonly PerformanceConsoleLogLevel: number;
  101200. private static _performance;
  101201. /**
  101202. * Sets the current performance log level
  101203. */
  101204. static PerformanceLogLevel: number;
  101205. private static _StartPerformanceCounterDisabled;
  101206. private static _EndPerformanceCounterDisabled;
  101207. private static _StartUserMark;
  101208. private static _EndUserMark;
  101209. private static _StartPerformanceConsole;
  101210. private static _EndPerformanceConsole;
  101211. /**
  101212. * Starts a performance counter
  101213. */
  101214. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  101215. /**
  101216. * Ends a specific performance coutner
  101217. */
  101218. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  101219. /**
  101220. * Gets either window.performance.now() if supported or Date.now() else
  101221. */
  101222. static readonly Now: number;
  101223. /**
  101224. * This method will return the name of the class used to create the instance of the given object.
  101225. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  101226. * @param object the object to get the class name from
  101227. * @param isType defines if the object is actually a type
  101228. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  101229. */
  101230. static GetClassName(object: any, isType?: boolean): string;
  101231. /**
  101232. * Gets the first element of an array satisfying a given predicate
  101233. * @param array defines the array to browse
  101234. * @param predicate defines the predicate to use
  101235. * @returns null if not found or the element
  101236. */
  101237. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  101238. /**
  101239. * This method will return the name of the full name of the class, including its owning module (if any).
  101240. * 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).
  101241. * @param object the object to get the class name from
  101242. * @param isType defines if the object is actually a type
  101243. * @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.
  101244. * @ignorenaming
  101245. */
  101246. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  101247. /**
  101248. * Returns a promise that resolves after the given amount of time.
  101249. * @param delay Number of milliseconds to delay
  101250. * @returns Promise that resolves after the given amount of time
  101251. */
  101252. static DelayAsync(delay: number): Promise<void>;
  101253. }
  101254. /**
  101255. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  101256. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  101257. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  101258. * @param name The name of the class, case should be preserved
  101259. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  101260. */
  101261. export function className(name: string, module?: string): (target: Object) => void;
  101262. /**
  101263. * An implementation of a loop for asynchronous functions.
  101264. */
  101265. export class AsyncLoop {
  101266. /**
  101267. * Defines the number of iterations for the loop
  101268. */
  101269. iterations: number;
  101270. /**
  101271. * Defines the current index of the loop.
  101272. */
  101273. index: number;
  101274. private _done;
  101275. private _fn;
  101276. private _successCallback;
  101277. /**
  101278. * Constructor.
  101279. * @param iterations the number of iterations.
  101280. * @param func the function to run each iteration
  101281. * @param successCallback the callback that will be called upon succesful execution
  101282. * @param offset starting offset.
  101283. */
  101284. constructor(
  101285. /**
  101286. * Defines the number of iterations for the loop
  101287. */
  101288. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  101289. /**
  101290. * Execute the next iteration. Must be called after the last iteration was finished.
  101291. */
  101292. executeNext(): void;
  101293. /**
  101294. * Break the loop and run the success callback.
  101295. */
  101296. breakLoop(): void;
  101297. /**
  101298. * Create and run an async loop.
  101299. * @param iterations the number of iterations.
  101300. * @param fn the function to run each iteration
  101301. * @param successCallback the callback that will be called upon succesful execution
  101302. * @param offset starting offset.
  101303. * @returns the created async loop object
  101304. */
  101305. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  101306. /**
  101307. * A for-loop that will run a given number of iterations synchronous and the rest async.
  101308. * @param iterations total number of iterations
  101309. * @param syncedIterations number of synchronous iterations in each async iteration.
  101310. * @param fn the function to call each iteration.
  101311. * @param callback a success call back that will be called when iterating stops.
  101312. * @param breakFunction a break condition (optional)
  101313. * @param timeout timeout settings for the setTimeout function. default - 0.
  101314. * @returns the created async loop object
  101315. */
  101316. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  101317. }
  101318. }
  101319. declare module BABYLON {
  101320. /**
  101321. * This class implement a typical dictionary using a string as key and the generic type T as value.
  101322. * The underlying implementation relies on an associative array to ensure the best performances.
  101323. * The value can be anything including 'null' but except 'undefined'
  101324. */
  101325. export class StringDictionary<T> {
  101326. /**
  101327. * This will clear this dictionary and copy the content from the 'source' one.
  101328. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  101329. * @param source the dictionary to take the content from and copy to this dictionary
  101330. */
  101331. copyFrom(source: StringDictionary<T>): void;
  101332. /**
  101333. * Get a value based from its key
  101334. * @param key the given key to get the matching value from
  101335. * @return the value if found, otherwise undefined is returned
  101336. */
  101337. get(key: string): T | undefined;
  101338. /**
  101339. * Get a value from its key or add it if it doesn't exist.
  101340. * This method will ensure you that a given key/data will be present in the dictionary.
  101341. * @param key the given key to get the matching value from
  101342. * @param factory the factory that will create the value if the key is not present in the dictionary.
  101343. * The factory will only be invoked if there's no data for the given key.
  101344. * @return the value corresponding to the key.
  101345. */
  101346. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  101347. /**
  101348. * Get a value from its key if present in the dictionary otherwise add it
  101349. * @param key the key to get the value from
  101350. * @param val if there's no such key/value pair in the dictionary add it with this value
  101351. * @return the value corresponding to the key
  101352. */
  101353. getOrAdd(key: string, val: T): T;
  101354. /**
  101355. * Check if there's a given key in the dictionary
  101356. * @param key the key to check for
  101357. * @return true if the key is present, false otherwise
  101358. */
  101359. contains(key: string): boolean;
  101360. /**
  101361. * Add a new key and its corresponding value
  101362. * @param key the key to add
  101363. * @param value the value corresponding to the key
  101364. * @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
  101365. */
  101366. add(key: string, value: T): boolean;
  101367. /**
  101368. * Update a specific value associated to a key
  101369. * @param key defines the key to use
  101370. * @param value defines the value to store
  101371. * @returns true if the value was updated (or false if the key was not found)
  101372. */
  101373. set(key: string, value: T): boolean;
  101374. /**
  101375. * Get the element of the given key and remove it from the dictionary
  101376. * @param key defines the key to search
  101377. * @returns the value associated with the key or null if not found
  101378. */
  101379. getAndRemove(key: string): Nullable<T>;
  101380. /**
  101381. * Remove a key/value from the dictionary.
  101382. * @param key the key to remove
  101383. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  101384. */
  101385. remove(key: string): boolean;
  101386. /**
  101387. * Clear the whole content of the dictionary
  101388. */
  101389. clear(): void;
  101390. /**
  101391. * Gets the current count
  101392. */
  101393. readonly count: number;
  101394. /**
  101395. * Execute a callback on each key/val of the dictionary.
  101396. * Note that you can remove any element in this dictionary in the callback implementation
  101397. * @param callback the callback to execute on a given key/value pair
  101398. */
  101399. forEach(callback: (key: string, val: T) => void): void;
  101400. /**
  101401. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  101402. * If the callback returns null or undefined the method will iterate to the next key/value pair
  101403. * Note that you can remove any element in this dictionary in the callback implementation
  101404. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  101405. * @returns the first item
  101406. */
  101407. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  101408. private _count;
  101409. private _data;
  101410. }
  101411. }
  101412. declare module BABYLON {
  101413. /** @hidden */
  101414. export interface ICollisionCoordinator {
  101415. createCollider(): Collider;
  101416. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101417. init(scene: Scene): void;
  101418. }
  101419. /** @hidden */
  101420. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  101421. private _scene;
  101422. private _scaledPosition;
  101423. private _scaledVelocity;
  101424. private _finalPosition;
  101425. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  101426. createCollider(): Collider;
  101427. init(scene: Scene): void;
  101428. private _collideWithWorld;
  101429. }
  101430. }
  101431. declare module BABYLON {
  101432. /**
  101433. * Class used to manage all inputs for the scene.
  101434. */
  101435. export class InputManager {
  101436. /** The distance in pixel that you have to move to prevent some events */
  101437. static DragMovementThreshold: number;
  101438. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  101439. static LongPressDelay: number;
  101440. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  101441. static DoubleClickDelay: number;
  101442. /** If you need to check double click without raising a single click at first click, enable this flag */
  101443. static ExclusiveDoubleClickMode: boolean;
  101444. private _wheelEventName;
  101445. private _onPointerMove;
  101446. private _onPointerDown;
  101447. private _onPointerUp;
  101448. private _initClickEvent;
  101449. private _initActionManager;
  101450. private _delayedSimpleClick;
  101451. private _delayedSimpleClickTimeout;
  101452. private _previousDelayedSimpleClickTimeout;
  101453. private _meshPickProceed;
  101454. private _previousButtonPressed;
  101455. private _currentPickResult;
  101456. private _previousPickResult;
  101457. private _totalPointersPressed;
  101458. private _doubleClickOccured;
  101459. private _pointerOverMesh;
  101460. private _pickedDownMesh;
  101461. private _pickedUpMesh;
  101462. private _pointerX;
  101463. private _pointerY;
  101464. private _unTranslatedPointerX;
  101465. private _unTranslatedPointerY;
  101466. private _startingPointerPosition;
  101467. private _previousStartingPointerPosition;
  101468. private _startingPointerTime;
  101469. private _previousStartingPointerTime;
  101470. private _pointerCaptures;
  101471. private _onKeyDown;
  101472. private _onKeyUp;
  101473. private _onCanvasFocusObserver;
  101474. private _onCanvasBlurObserver;
  101475. private _scene;
  101476. /**
  101477. * Creates a new InputManager
  101478. * @param scene defines the hosting scene
  101479. */
  101480. constructor(scene: Scene);
  101481. /**
  101482. * Gets the mesh that is currently under the pointer
  101483. */
  101484. readonly meshUnderPointer: Nullable<AbstractMesh>;
  101485. /**
  101486. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  101487. */
  101488. readonly unTranslatedPointer: Vector2;
  101489. /**
  101490. * Gets or sets the current on-screen X position of the pointer
  101491. */
  101492. pointerX: number;
  101493. /**
  101494. * Gets or sets the current on-screen Y position of the pointer
  101495. */
  101496. pointerY: number;
  101497. private _updatePointerPosition;
  101498. private _processPointerMove;
  101499. private _setRayOnPointerInfo;
  101500. private _checkPrePointerObservable;
  101501. /**
  101502. * Use this method to simulate a pointer move on a mesh
  101503. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101504. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101505. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101506. */
  101507. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101508. /**
  101509. * Use this method to simulate a pointer down on a mesh
  101510. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101511. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101512. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101513. */
  101514. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  101515. private _processPointerDown;
  101516. /** @hidden */
  101517. _isPointerSwiping(): boolean;
  101518. /**
  101519. * Use this method to simulate a pointer up on a mesh
  101520. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  101521. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  101522. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  101523. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  101524. */
  101525. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  101526. private _processPointerUp;
  101527. /**
  101528. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  101529. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  101530. * @returns true if the pointer was captured
  101531. */
  101532. isPointerCaptured(pointerId?: number): boolean;
  101533. /**
  101534. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  101535. * @param attachUp defines if you want to attach events to pointerup
  101536. * @param attachDown defines if you want to attach events to pointerdown
  101537. * @param attachMove defines if you want to attach events to pointermove
  101538. */
  101539. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  101540. /**
  101541. * Detaches all event handlers
  101542. */
  101543. detachControl(): void;
  101544. /**
  101545. * Force the value of meshUnderPointer
  101546. * @param mesh defines the mesh to use
  101547. */
  101548. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101549. /**
  101550. * Gets the mesh under the pointer
  101551. * @returns a Mesh or null if no mesh is under the pointer
  101552. */
  101553. getPointerOverMesh(): Nullable<AbstractMesh>;
  101554. }
  101555. }
  101556. declare module BABYLON {
  101557. /**
  101558. * Helper class used to generate session unique ID
  101559. */
  101560. export class UniqueIdGenerator {
  101561. private static _UniqueIdCounter;
  101562. /**
  101563. * Gets an unique (relatively to the current scene) Id
  101564. */
  101565. static readonly UniqueId: number;
  101566. }
  101567. }
  101568. declare module BABYLON {
  101569. /**
  101570. * This class defines the direct association between an animation and a target
  101571. */
  101572. export class TargetedAnimation {
  101573. /**
  101574. * Animation to perform
  101575. */
  101576. animation: Animation;
  101577. /**
  101578. * Target to animate
  101579. */
  101580. target: any;
  101581. /**
  101582. * Serialize the object
  101583. * @returns the JSON object representing the current entity
  101584. */
  101585. serialize(): any;
  101586. }
  101587. /**
  101588. * Use this class to create coordinated animations on multiple targets
  101589. */
  101590. export class AnimationGroup implements IDisposable {
  101591. /** The name of the animation group */
  101592. name: string;
  101593. private _scene;
  101594. private _targetedAnimations;
  101595. private _animatables;
  101596. private _from;
  101597. private _to;
  101598. private _isStarted;
  101599. private _isPaused;
  101600. private _speedRatio;
  101601. private _loopAnimation;
  101602. /**
  101603. * Gets or sets the unique id of the node
  101604. */
  101605. uniqueId: number;
  101606. /**
  101607. * This observable will notify when one animation have ended
  101608. */
  101609. onAnimationEndObservable: Observable<TargetedAnimation>;
  101610. /**
  101611. * Observer raised when one animation loops
  101612. */
  101613. onAnimationLoopObservable: Observable<TargetedAnimation>;
  101614. /**
  101615. * Observer raised when all animations have looped
  101616. */
  101617. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  101618. /**
  101619. * This observable will notify when all animations have ended.
  101620. */
  101621. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  101622. /**
  101623. * This observable will notify when all animations have paused.
  101624. */
  101625. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  101626. /**
  101627. * This observable will notify when all animations are playing.
  101628. */
  101629. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  101630. /**
  101631. * Gets the first frame
  101632. */
  101633. readonly from: number;
  101634. /**
  101635. * Gets the last frame
  101636. */
  101637. readonly to: number;
  101638. /**
  101639. * Define if the animations are started
  101640. */
  101641. readonly isStarted: boolean;
  101642. /**
  101643. * Gets a value indicating that the current group is playing
  101644. */
  101645. readonly isPlaying: boolean;
  101646. /**
  101647. * Gets or sets the speed ratio to use for all animations
  101648. */
  101649. /**
  101650. * Gets or sets the speed ratio to use for all animations
  101651. */
  101652. speedRatio: number;
  101653. /**
  101654. * Gets or sets if all animations should loop or not
  101655. */
  101656. loopAnimation: boolean;
  101657. /**
  101658. * Gets the targeted animations for this animation group
  101659. */
  101660. readonly targetedAnimations: Array<TargetedAnimation>;
  101661. /**
  101662. * returning the list of animatables controlled by this animation group.
  101663. */
  101664. readonly animatables: Array<Animatable>;
  101665. /**
  101666. * Instantiates a new Animation Group.
  101667. * This helps managing several animations at once.
  101668. * @see http://doc.babylonjs.com/how_to/group
  101669. * @param name Defines the name of the group
  101670. * @param scene Defines the scene the group belongs to
  101671. */
  101672. constructor(
  101673. /** The name of the animation group */
  101674. name: string, scene?: Nullable<Scene>);
  101675. /**
  101676. * Add an animation (with its target) in the group
  101677. * @param animation defines the animation we want to add
  101678. * @param target defines the target of the animation
  101679. * @returns the TargetedAnimation object
  101680. */
  101681. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  101682. /**
  101683. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  101684. * It can add constant keys at begin or end
  101685. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  101686. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  101687. * @returns the animation group
  101688. */
  101689. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  101690. private _animationLoopCount;
  101691. private _animationLoopFlags;
  101692. private _processLoop;
  101693. /**
  101694. * Start all animations on given targets
  101695. * @param loop defines if animations must loop
  101696. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  101697. * @param from defines the from key (optional)
  101698. * @param to defines the to key (optional)
  101699. * @returns the current animation group
  101700. */
  101701. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  101702. /**
  101703. * Pause all animations
  101704. * @returns the animation group
  101705. */
  101706. pause(): AnimationGroup;
  101707. /**
  101708. * Play all animations to initial state
  101709. * This function will start() the animations if they were not started or will restart() them if they were paused
  101710. * @param loop defines if animations must loop
  101711. * @returns the animation group
  101712. */
  101713. play(loop?: boolean): AnimationGroup;
  101714. /**
  101715. * Reset all animations to initial state
  101716. * @returns the animation group
  101717. */
  101718. reset(): AnimationGroup;
  101719. /**
  101720. * Restart animations from key 0
  101721. * @returns the animation group
  101722. */
  101723. restart(): AnimationGroup;
  101724. /**
  101725. * Stop all animations
  101726. * @returns the animation group
  101727. */
  101728. stop(): AnimationGroup;
  101729. /**
  101730. * Set animation weight for all animatables
  101731. * @param weight defines the weight to use
  101732. * @return the animationGroup
  101733. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101734. */
  101735. setWeightForAllAnimatables(weight: number): AnimationGroup;
  101736. /**
  101737. * Synchronize and normalize all animatables with a source animatable
  101738. * @param root defines the root animatable to synchronize with
  101739. * @return the animationGroup
  101740. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  101741. */
  101742. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  101743. /**
  101744. * Goes to a specific frame in this animation group
  101745. * @param frame the frame number to go to
  101746. * @return the animationGroup
  101747. */
  101748. goToFrame(frame: number): AnimationGroup;
  101749. /**
  101750. * Dispose all associated resources
  101751. */
  101752. dispose(): void;
  101753. private _checkAnimationGroupEnded;
  101754. /**
  101755. * Clone the current animation group and returns a copy
  101756. * @param newName defines the name of the new group
  101757. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  101758. * @returns the new aniamtion group
  101759. */
  101760. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  101761. /**
  101762. * Serializes the animationGroup to an object
  101763. * @returns Serialized object
  101764. */
  101765. serialize(): any;
  101766. /**
  101767. * Returns a new AnimationGroup object parsed from the source provided.
  101768. * @param parsedAnimationGroup defines the source
  101769. * @param scene defines the scene that will receive the animationGroup
  101770. * @returns a new AnimationGroup
  101771. */
  101772. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  101773. /**
  101774. * Returns the string "AnimationGroup"
  101775. * @returns "AnimationGroup"
  101776. */
  101777. getClassName(): string;
  101778. /**
  101779. * Creates a detailled string about the object
  101780. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  101781. * @returns a string representing the object
  101782. */
  101783. toString(fullDetails?: boolean): string;
  101784. }
  101785. }
  101786. declare module BABYLON {
  101787. /**
  101788. * Define an interface for all classes that will hold resources
  101789. */
  101790. export interface IDisposable {
  101791. /**
  101792. * Releases all held resources
  101793. */
  101794. dispose(): void;
  101795. }
  101796. /** Interface defining initialization parameters for Scene class */
  101797. export interface SceneOptions {
  101798. /**
  101799. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  101800. * It will improve performance when the number of geometries becomes important.
  101801. */
  101802. useGeometryUniqueIdsMap?: boolean;
  101803. /**
  101804. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  101805. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101806. */
  101807. useMaterialMeshMap?: boolean;
  101808. /**
  101809. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  101810. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  101811. */
  101812. useClonedMeshhMap?: boolean;
  101813. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  101814. virtual?: boolean;
  101815. }
  101816. /**
  101817. * Represents a scene to be rendered by the engine.
  101818. * @see http://doc.babylonjs.com/features/scene
  101819. */
  101820. export class Scene extends AbstractScene implements IAnimatable {
  101821. /** The fog is deactivated */
  101822. static readonly FOGMODE_NONE: number;
  101823. /** The fog density is following an exponential function */
  101824. static readonly FOGMODE_EXP: number;
  101825. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  101826. static readonly FOGMODE_EXP2: number;
  101827. /** The fog density is following a linear function. */
  101828. static readonly FOGMODE_LINEAR: number;
  101829. /**
  101830. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  101831. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101832. */
  101833. static MinDeltaTime: number;
  101834. /**
  101835. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  101836. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  101837. */
  101838. static MaxDeltaTime: number;
  101839. /**
  101840. * Factory used to create the default material.
  101841. * @param name The name of the material to create
  101842. * @param scene The scene to create the material for
  101843. * @returns The default material
  101844. */
  101845. static DefaultMaterialFactory(scene: Scene): Material;
  101846. /**
  101847. * Factory used to create the a collision coordinator.
  101848. * @returns The collision coordinator
  101849. */
  101850. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  101851. /** @hidden */
  101852. _inputManager: InputManager;
  101853. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  101854. cameraToUseForPointers: Nullable<Camera>;
  101855. /** @hidden */
  101856. readonly _isScene: boolean;
  101857. /**
  101858. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  101859. */
  101860. autoClear: boolean;
  101861. /**
  101862. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  101863. */
  101864. autoClearDepthAndStencil: boolean;
  101865. /**
  101866. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  101867. */
  101868. clearColor: Color4;
  101869. /**
  101870. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  101871. */
  101872. ambientColor: Color3;
  101873. /**
  101874. * This is use to store the default BRDF lookup for PBR materials in your scene.
  101875. * It should only be one of the following (if not the default embedded one):
  101876. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  101877. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  101878. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  101879. * The material properties need to be setup according to the type of texture in use.
  101880. */
  101881. environmentBRDFTexture: BaseTexture;
  101882. /** @hidden */
  101883. protected _environmentTexture: Nullable<BaseTexture>;
  101884. /**
  101885. * Texture used in all pbr material as the reflection texture.
  101886. * As in the majority of the scene they are the same (exception for multi room and so on),
  101887. * this is easier to reference from here than from all the materials.
  101888. */
  101889. /**
  101890. * Texture used in all pbr material as the reflection texture.
  101891. * As in the majority of the scene they are the same (exception for multi room and so on),
  101892. * this is easier to set here than in all the materials.
  101893. */
  101894. environmentTexture: Nullable<BaseTexture>;
  101895. /** @hidden */
  101896. protected _environmentIntensity: number;
  101897. /**
  101898. * Intensity of the environment in all pbr material.
  101899. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101900. * As in the majority of the scene they are the same (exception for multi room and so on),
  101901. * this is easier to reference from here than from all the materials.
  101902. */
  101903. /**
  101904. * Intensity of the environment in all pbr material.
  101905. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  101906. * As in the majority of the scene they are the same (exception for multi room and so on),
  101907. * this is easier to set here than in all the materials.
  101908. */
  101909. environmentIntensity: number;
  101910. /** @hidden */
  101911. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101912. /**
  101913. * Default image processing configuration used either in the rendering
  101914. * Forward main pass or through the imageProcessingPostProcess if present.
  101915. * As in the majority of the scene they are the same (exception for multi camera),
  101916. * this is easier to reference from here than from all the materials and post process.
  101917. *
  101918. * No setter as we it is a shared configuration, you can set the values instead.
  101919. */
  101920. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  101921. private _forceWireframe;
  101922. /**
  101923. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  101924. */
  101925. forceWireframe: boolean;
  101926. private _forcePointsCloud;
  101927. /**
  101928. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  101929. */
  101930. forcePointsCloud: boolean;
  101931. /**
  101932. * Gets or sets the active clipplane 1
  101933. */
  101934. clipPlane: Nullable<Plane>;
  101935. /**
  101936. * Gets or sets the active clipplane 2
  101937. */
  101938. clipPlane2: Nullable<Plane>;
  101939. /**
  101940. * Gets or sets the active clipplane 3
  101941. */
  101942. clipPlane3: Nullable<Plane>;
  101943. /**
  101944. * Gets or sets the active clipplane 4
  101945. */
  101946. clipPlane4: Nullable<Plane>;
  101947. /**
  101948. * Gets or sets a boolean indicating if animations are enabled
  101949. */
  101950. animationsEnabled: boolean;
  101951. private _animationPropertiesOverride;
  101952. /**
  101953. * Gets or sets the animation properties override
  101954. */
  101955. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  101956. /**
  101957. * Gets or sets a boolean indicating if a constant deltatime has to be used
  101958. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  101959. */
  101960. useConstantAnimationDeltaTime: boolean;
  101961. /**
  101962. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  101963. * Please note that it requires to run a ray cast through the scene on every frame
  101964. */
  101965. constantlyUpdateMeshUnderPointer: boolean;
  101966. /**
  101967. * Defines the HTML cursor to use when hovering over interactive elements
  101968. */
  101969. hoverCursor: string;
  101970. /**
  101971. * Defines the HTML default cursor to use (empty by default)
  101972. */
  101973. defaultCursor: string;
  101974. /**
  101975. * Defines wether cursors are handled by the scene.
  101976. */
  101977. doNotHandleCursors: boolean;
  101978. /**
  101979. * This is used to call preventDefault() on pointer down
  101980. * in order to block unwanted artifacts like system double clicks
  101981. */
  101982. preventDefaultOnPointerDown: boolean;
  101983. /**
  101984. * This is used to call preventDefault() on pointer up
  101985. * in order to block unwanted artifacts like system double clicks
  101986. */
  101987. preventDefaultOnPointerUp: boolean;
  101988. /**
  101989. * Gets or sets user defined metadata
  101990. */
  101991. metadata: any;
  101992. /**
  101993. * For internal use only. Please do not use.
  101994. */
  101995. reservedDataStore: any;
  101996. /**
  101997. * Gets the name of the plugin used to load this scene (null by default)
  101998. */
  101999. loadingPluginName: string;
  102000. /**
  102001. * Use this array to add regular expressions used to disable offline support for specific urls
  102002. */
  102003. disableOfflineSupportExceptionRules: RegExp[];
  102004. /**
  102005. * An event triggered when the scene is disposed.
  102006. */
  102007. onDisposeObservable: Observable<Scene>;
  102008. private _onDisposeObserver;
  102009. /** Sets a function to be executed when this scene is disposed. */
  102010. onDispose: () => void;
  102011. /**
  102012. * An event triggered before rendering the scene (right after animations and physics)
  102013. */
  102014. onBeforeRenderObservable: Observable<Scene>;
  102015. private _onBeforeRenderObserver;
  102016. /** Sets a function to be executed before rendering this scene */
  102017. beforeRender: Nullable<() => void>;
  102018. /**
  102019. * An event triggered after rendering the scene
  102020. */
  102021. onAfterRenderObservable: Observable<Scene>;
  102022. /**
  102023. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  102024. */
  102025. onAfterRenderCameraObservable: Observable<Camera>;
  102026. private _onAfterRenderObserver;
  102027. /** Sets a function to be executed after rendering this scene */
  102028. afterRender: Nullable<() => void>;
  102029. /**
  102030. * An event triggered before animating the scene
  102031. */
  102032. onBeforeAnimationsObservable: Observable<Scene>;
  102033. /**
  102034. * An event triggered after animations processing
  102035. */
  102036. onAfterAnimationsObservable: Observable<Scene>;
  102037. /**
  102038. * An event triggered before draw calls are ready to be sent
  102039. */
  102040. onBeforeDrawPhaseObservable: Observable<Scene>;
  102041. /**
  102042. * An event triggered after draw calls have been sent
  102043. */
  102044. onAfterDrawPhaseObservable: Observable<Scene>;
  102045. /**
  102046. * An event triggered when the scene is ready
  102047. */
  102048. onReadyObservable: Observable<Scene>;
  102049. /**
  102050. * An event triggered before rendering a camera
  102051. */
  102052. onBeforeCameraRenderObservable: Observable<Camera>;
  102053. private _onBeforeCameraRenderObserver;
  102054. /** Sets a function to be executed before rendering a camera*/
  102055. beforeCameraRender: () => void;
  102056. /**
  102057. * An event triggered after rendering a camera
  102058. */
  102059. onAfterCameraRenderObservable: Observable<Camera>;
  102060. private _onAfterCameraRenderObserver;
  102061. /** Sets a function to be executed after rendering a camera*/
  102062. afterCameraRender: () => void;
  102063. /**
  102064. * An event triggered when active meshes evaluation is about to start
  102065. */
  102066. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  102067. /**
  102068. * An event triggered when active meshes evaluation is done
  102069. */
  102070. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  102071. /**
  102072. * An event triggered when particles rendering is about to start
  102073. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  102074. */
  102075. onBeforeParticlesRenderingObservable: Observable<Scene>;
  102076. /**
  102077. * An event triggered when particles rendering is done
  102078. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  102079. */
  102080. onAfterParticlesRenderingObservable: Observable<Scene>;
  102081. /**
  102082. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  102083. */
  102084. onDataLoadedObservable: Observable<Scene>;
  102085. /**
  102086. * An event triggered when a camera is created
  102087. */
  102088. onNewCameraAddedObservable: Observable<Camera>;
  102089. /**
  102090. * An event triggered when a camera is removed
  102091. */
  102092. onCameraRemovedObservable: Observable<Camera>;
  102093. /**
  102094. * An event triggered when a light is created
  102095. */
  102096. onNewLightAddedObservable: Observable<Light>;
  102097. /**
  102098. * An event triggered when a light is removed
  102099. */
  102100. onLightRemovedObservable: Observable<Light>;
  102101. /**
  102102. * An event triggered when a geometry is created
  102103. */
  102104. onNewGeometryAddedObservable: Observable<Geometry>;
  102105. /**
  102106. * An event triggered when a geometry is removed
  102107. */
  102108. onGeometryRemovedObservable: Observable<Geometry>;
  102109. /**
  102110. * An event triggered when a transform node is created
  102111. */
  102112. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  102113. /**
  102114. * An event triggered when a transform node is removed
  102115. */
  102116. onTransformNodeRemovedObservable: Observable<TransformNode>;
  102117. /**
  102118. * An event triggered when a mesh is created
  102119. */
  102120. onNewMeshAddedObservable: Observable<AbstractMesh>;
  102121. /**
  102122. * An event triggered when a mesh is removed
  102123. */
  102124. onMeshRemovedObservable: Observable<AbstractMesh>;
  102125. /**
  102126. * An event triggered when a skeleton is created
  102127. */
  102128. onNewSkeletonAddedObservable: Observable<Skeleton>;
  102129. /**
  102130. * An event triggered when a skeleton is removed
  102131. */
  102132. onSkeletonRemovedObservable: Observable<Skeleton>;
  102133. /**
  102134. * An event triggered when a material is created
  102135. */
  102136. onNewMaterialAddedObservable: Observable<Material>;
  102137. /**
  102138. * An event triggered when a material is removed
  102139. */
  102140. onMaterialRemovedObservable: Observable<Material>;
  102141. /**
  102142. * An event triggered when a texture is created
  102143. */
  102144. onNewTextureAddedObservable: Observable<BaseTexture>;
  102145. /**
  102146. * An event triggered when a texture is removed
  102147. */
  102148. onTextureRemovedObservable: Observable<BaseTexture>;
  102149. /**
  102150. * An event triggered when render targets are about to be rendered
  102151. * Can happen multiple times per frame.
  102152. */
  102153. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  102154. /**
  102155. * An event triggered when render targets were rendered.
  102156. * Can happen multiple times per frame.
  102157. */
  102158. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  102159. /**
  102160. * An event triggered before calculating deterministic simulation step
  102161. */
  102162. onBeforeStepObservable: Observable<Scene>;
  102163. /**
  102164. * An event triggered after calculating deterministic simulation step
  102165. */
  102166. onAfterStepObservable: Observable<Scene>;
  102167. /**
  102168. * An event triggered when the activeCamera property is updated
  102169. */
  102170. onActiveCameraChanged: Observable<Scene>;
  102171. /**
  102172. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  102173. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  102174. * 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)
  102175. */
  102176. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  102177. /**
  102178. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  102179. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  102180. * 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)
  102181. */
  102182. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  102183. /**
  102184. * This Observable will when a mesh has been imported into the scene.
  102185. */
  102186. onMeshImportedObservable: Observable<AbstractMesh>;
  102187. /**
  102188. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  102189. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  102190. */
  102191. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  102192. /** @hidden */
  102193. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  102194. /**
  102195. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  102196. */
  102197. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  102198. /**
  102199. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  102200. */
  102201. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  102202. /**
  102203. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  102204. */
  102205. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  102206. /** Callback called when a pointer move is detected */
  102207. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  102208. /** Callback called when a pointer down is detected */
  102209. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  102210. /** Callback called when a pointer up is detected */
  102211. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  102212. /** Callback called when a pointer pick is detected */
  102213. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  102214. /**
  102215. * 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).
  102216. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  102217. */
  102218. onPrePointerObservable: Observable<PointerInfoPre>;
  102219. /**
  102220. * Observable event triggered each time an input event is received from the rendering canvas
  102221. */
  102222. onPointerObservable: Observable<PointerInfo>;
  102223. /**
  102224. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  102225. */
  102226. readonly unTranslatedPointer: Vector2;
  102227. /**
  102228. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  102229. */
  102230. static DragMovementThreshold: number;
  102231. /**
  102232. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  102233. */
  102234. static LongPressDelay: number;
  102235. /**
  102236. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  102237. */
  102238. static DoubleClickDelay: number;
  102239. /** If you need to check double click without raising a single click at first click, enable this flag */
  102240. static ExclusiveDoubleClickMode: boolean;
  102241. /** @hidden */
  102242. _mirroredCameraPosition: Nullable<Vector3>;
  102243. /**
  102244. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  102245. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  102246. */
  102247. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  102248. /**
  102249. * Observable event triggered each time an keyboard event is received from the hosting window
  102250. */
  102251. onKeyboardObservable: Observable<KeyboardInfo>;
  102252. private _useRightHandedSystem;
  102253. /**
  102254. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  102255. */
  102256. useRightHandedSystem: boolean;
  102257. private _timeAccumulator;
  102258. private _currentStepId;
  102259. private _currentInternalStep;
  102260. /**
  102261. * Sets the step Id used by deterministic lock step
  102262. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102263. * @param newStepId defines the step Id
  102264. */
  102265. setStepId(newStepId: number): void;
  102266. /**
  102267. * Gets the step Id used by deterministic lock step
  102268. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102269. * @returns the step Id
  102270. */
  102271. getStepId(): number;
  102272. /**
  102273. * Gets the internal step used by deterministic lock step
  102274. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102275. * @returns the internal step
  102276. */
  102277. getInternalStep(): number;
  102278. private _fogEnabled;
  102279. /**
  102280. * Gets or sets a boolean indicating if fog is enabled on this scene
  102281. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102282. * (Default is true)
  102283. */
  102284. fogEnabled: boolean;
  102285. private _fogMode;
  102286. /**
  102287. * Gets or sets the fog mode to use
  102288. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102289. * | mode | value |
  102290. * | --- | --- |
  102291. * | FOGMODE_NONE | 0 |
  102292. * | FOGMODE_EXP | 1 |
  102293. * | FOGMODE_EXP2 | 2 |
  102294. * | FOGMODE_LINEAR | 3 |
  102295. */
  102296. fogMode: number;
  102297. /**
  102298. * Gets or sets the fog color to use
  102299. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102300. * (Default is Color3(0.2, 0.2, 0.3))
  102301. */
  102302. fogColor: Color3;
  102303. /**
  102304. * Gets or sets the fog density to use
  102305. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102306. * (Default is 0.1)
  102307. */
  102308. fogDensity: number;
  102309. /**
  102310. * Gets or sets the fog start distance to use
  102311. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102312. * (Default is 0)
  102313. */
  102314. fogStart: number;
  102315. /**
  102316. * Gets or sets the fog end distance to use
  102317. * @see http://doc.babylonjs.com/babylon101/environment#fog
  102318. * (Default is 1000)
  102319. */
  102320. fogEnd: number;
  102321. private _shadowsEnabled;
  102322. /**
  102323. * Gets or sets a boolean indicating if shadows are enabled on this scene
  102324. */
  102325. shadowsEnabled: boolean;
  102326. private _lightsEnabled;
  102327. /**
  102328. * Gets or sets a boolean indicating if lights are enabled on this scene
  102329. */
  102330. lightsEnabled: boolean;
  102331. /** All of the active cameras added to this scene. */
  102332. activeCameras: Camera[];
  102333. /** @hidden */
  102334. _activeCamera: Nullable<Camera>;
  102335. /** Gets or sets the current active camera */
  102336. activeCamera: Nullable<Camera>;
  102337. private _defaultMaterial;
  102338. /** The default material used on meshes when no material is affected */
  102339. /** The default material used on meshes when no material is affected */
  102340. defaultMaterial: Material;
  102341. private _texturesEnabled;
  102342. /**
  102343. * Gets or sets a boolean indicating if textures are enabled on this scene
  102344. */
  102345. texturesEnabled: boolean;
  102346. /**
  102347. * Gets or sets a boolean indicating if particles are enabled on this scene
  102348. */
  102349. particlesEnabled: boolean;
  102350. /**
  102351. * Gets or sets a boolean indicating if sprites are enabled on this scene
  102352. */
  102353. spritesEnabled: boolean;
  102354. private _skeletonsEnabled;
  102355. /**
  102356. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  102357. */
  102358. skeletonsEnabled: boolean;
  102359. /**
  102360. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  102361. */
  102362. lensFlaresEnabled: boolean;
  102363. /**
  102364. * Gets or sets a boolean indicating if collisions are enabled on this scene
  102365. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102366. */
  102367. collisionsEnabled: boolean;
  102368. private _collisionCoordinator;
  102369. /** @hidden */
  102370. readonly collisionCoordinator: ICollisionCoordinator;
  102371. /**
  102372. * Defines the gravity applied to this scene (used only for collisions)
  102373. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102374. */
  102375. gravity: Vector3;
  102376. /**
  102377. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  102378. */
  102379. postProcessesEnabled: boolean;
  102380. /**
  102381. * The list of postprocesses added to the scene
  102382. */
  102383. postProcesses: PostProcess[];
  102384. /**
  102385. * Gets the current postprocess manager
  102386. */
  102387. postProcessManager: PostProcessManager;
  102388. /**
  102389. * Gets or sets a boolean indicating if render targets are enabled on this scene
  102390. */
  102391. renderTargetsEnabled: boolean;
  102392. /**
  102393. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  102394. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  102395. */
  102396. dumpNextRenderTargets: boolean;
  102397. /**
  102398. * The list of user defined render targets added to the scene
  102399. */
  102400. customRenderTargets: RenderTargetTexture[];
  102401. /**
  102402. * Defines if texture loading must be delayed
  102403. * If true, textures will only be loaded when they need to be rendered
  102404. */
  102405. useDelayedTextureLoading: boolean;
  102406. /**
  102407. * Gets the list of meshes imported to the scene through SceneLoader
  102408. */
  102409. importedMeshesFiles: String[];
  102410. /**
  102411. * Gets or sets a boolean indicating if probes are enabled on this scene
  102412. */
  102413. probesEnabled: boolean;
  102414. /**
  102415. * Gets or sets the current offline provider to use to store scene data
  102416. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  102417. */
  102418. offlineProvider: IOfflineProvider;
  102419. /**
  102420. * Gets or sets the action manager associated with the scene
  102421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102422. */
  102423. actionManager: AbstractActionManager;
  102424. private _meshesForIntersections;
  102425. /**
  102426. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  102427. */
  102428. proceduralTexturesEnabled: boolean;
  102429. private _engine;
  102430. private _totalVertices;
  102431. /** @hidden */
  102432. _activeIndices: PerfCounter;
  102433. /** @hidden */
  102434. _activeParticles: PerfCounter;
  102435. /** @hidden */
  102436. _activeBones: PerfCounter;
  102437. private _animationRatio;
  102438. /** @hidden */
  102439. _animationTimeLast: number;
  102440. /** @hidden */
  102441. _animationTime: number;
  102442. /**
  102443. * Gets or sets a general scale for animation speed
  102444. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  102445. */
  102446. animationTimeScale: number;
  102447. /** @hidden */
  102448. _cachedMaterial: Nullable<Material>;
  102449. /** @hidden */
  102450. _cachedEffect: Nullable<Effect>;
  102451. /** @hidden */
  102452. _cachedVisibility: Nullable<number>;
  102453. private _renderId;
  102454. private _frameId;
  102455. private _executeWhenReadyTimeoutId;
  102456. private _intermediateRendering;
  102457. private _viewUpdateFlag;
  102458. private _projectionUpdateFlag;
  102459. /** @hidden */
  102460. _toBeDisposed: Nullable<IDisposable>[];
  102461. private _activeRequests;
  102462. /** @hidden */
  102463. _pendingData: any[];
  102464. private _isDisposed;
  102465. /**
  102466. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  102467. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  102468. */
  102469. dispatchAllSubMeshesOfActiveMeshes: boolean;
  102470. private _activeMeshes;
  102471. private _processedMaterials;
  102472. private _renderTargets;
  102473. /** @hidden */
  102474. _activeParticleSystems: SmartArray<IParticleSystem>;
  102475. private _activeSkeletons;
  102476. private _softwareSkinnedMeshes;
  102477. private _renderingManager;
  102478. /** @hidden */
  102479. _activeAnimatables: Animatable[];
  102480. private _transformMatrix;
  102481. private _sceneUbo;
  102482. /** @hidden */
  102483. _viewMatrix: Matrix;
  102484. private _projectionMatrix;
  102485. /** @hidden */
  102486. _forcedViewPosition: Nullable<Vector3>;
  102487. /** @hidden */
  102488. _frustumPlanes: Plane[];
  102489. /**
  102490. * Gets the list of frustum planes (built from the active camera)
  102491. */
  102492. readonly frustumPlanes: Plane[];
  102493. /**
  102494. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  102495. * This is useful if there are more lights that the maximum simulteanous authorized
  102496. */
  102497. requireLightSorting: boolean;
  102498. /** @hidden */
  102499. readonly useMaterialMeshMap: boolean;
  102500. /** @hidden */
  102501. readonly useClonedMeshhMap: boolean;
  102502. private _externalData;
  102503. private _uid;
  102504. /**
  102505. * @hidden
  102506. * Backing store of defined scene components.
  102507. */
  102508. _components: ISceneComponent[];
  102509. /**
  102510. * @hidden
  102511. * Backing store of defined scene components.
  102512. */
  102513. _serializableComponents: ISceneSerializableComponent[];
  102514. /**
  102515. * List of components to register on the next registration step.
  102516. */
  102517. private _transientComponents;
  102518. /**
  102519. * Registers the transient components if needed.
  102520. */
  102521. private _registerTransientComponents;
  102522. /**
  102523. * @hidden
  102524. * Add a component to the scene.
  102525. * Note that the ccomponent could be registered on th next frame if this is called after
  102526. * the register component stage.
  102527. * @param component Defines the component to add to the scene
  102528. */
  102529. _addComponent(component: ISceneComponent): void;
  102530. /**
  102531. * @hidden
  102532. * Gets a component from the scene.
  102533. * @param name defines the name of the component to retrieve
  102534. * @returns the component or null if not present
  102535. */
  102536. _getComponent(name: string): Nullable<ISceneComponent>;
  102537. /**
  102538. * @hidden
  102539. * Defines the actions happening before camera updates.
  102540. */
  102541. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  102542. /**
  102543. * @hidden
  102544. * Defines the actions happening before clear the canvas.
  102545. */
  102546. _beforeClearStage: Stage<SimpleStageAction>;
  102547. /**
  102548. * @hidden
  102549. * Defines the actions when collecting render targets for the frame.
  102550. */
  102551. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102552. /**
  102553. * @hidden
  102554. * Defines the actions happening for one camera in the frame.
  102555. */
  102556. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  102557. /**
  102558. * @hidden
  102559. * Defines the actions happening during the per mesh ready checks.
  102560. */
  102561. _isReadyForMeshStage: Stage<MeshStageAction>;
  102562. /**
  102563. * @hidden
  102564. * Defines the actions happening before evaluate active mesh checks.
  102565. */
  102566. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  102567. /**
  102568. * @hidden
  102569. * Defines the actions happening during the evaluate sub mesh checks.
  102570. */
  102571. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  102572. /**
  102573. * @hidden
  102574. * Defines the actions happening during the active mesh stage.
  102575. */
  102576. _activeMeshStage: Stage<ActiveMeshStageAction>;
  102577. /**
  102578. * @hidden
  102579. * Defines the actions happening during the per camera render target step.
  102580. */
  102581. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  102582. /**
  102583. * @hidden
  102584. * Defines the actions happening just before the active camera is drawing.
  102585. */
  102586. _beforeCameraDrawStage: Stage<CameraStageAction>;
  102587. /**
  102588. * @hidden
  102589. * Defines the actions happening just before a render target is drawing.
  102590. */
  102591. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102592. /**
  102593. * @hidden
  102594. * Defines the actions happening just before a rendering group is drawing.
  102595. */
  102596. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102597. /**
  102598. * @hidden
  102599. * Defines the actions happening just before a mesh is drawing.
  102600. */
  102601. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102602. /**
  102603. * @hidden
  102604. * Defines the actions happening just after a mesh has been drawn.
  102605. */
  102606. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  102607. /**
  102608. * @hidden
  102609. * Defines the actions happening just after a rendering group has been drawn.
  102610. */
  102611. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  102612. /**
  102613. * @hidden
  102614. * Defines the actions happening just after the active camera has been drawn.
  102615. */
  102616. _afterCameraDrawStage: Stage<CameraStageAction>;
  102617. /**
  102618. * @hidden
  102619. * Defines the actions happening just after a render target has been drawn.
  102620. */
  102621. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  102622. /**
  102623. * @hidden
  102624. * Defines the actions happening just after rendering all cameras and computing intersections.
  102625. */
  102626. _afterRenderStage: Stage<SimpleStageAction>;
  102627. /**
  102628. * @hidden
  102629. * Defines the actions happening when a pointer move event happens.
  102630. */
  102631. _pointerMoveStage: Stage<PointerMoveStageAction>;
  102632. /**
  102633. * @hidden
  102634. * Defines the actions happening when a pointer down event happens.
  102635. */
  102636. _pointerDownStage: Stage<PointerUpDownStageAction>;
  102637. /**
  102638. * @hidden
  102639. * Defines the actions happening when a pointer up event happens.
  102640. */
  102641. _pointerUpStage: Stage<PointerUpDownStageAction>;
  102642. /**
  102643. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  102644. */
  102645. private geometriesByUniqueId;
  102646. /**
  102647. * Creates a new Scene
  102648. * @param engine defines the engine to use to render this scene
  102649. * @param options defines the scene options
  102650. */
  102651. constructor(engine: Engine, options?: SceneOptions);
  102652. /**
  102653. * Gets a string idenfifying the name of the class
  102654. * @returns "Scene" string
  102655. */
  102656. getClassName(): string;
  102657. private _defaultMeshCandidates;
  102658. /**
  102659. * @hidden
  102660. */
  102661. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102662. private _defaultSubMeshCandidates;
  102663. /**
  102664. * @hidden
  102665. */
  102666. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102667. /**
  102668. * Sets the default candidate providers for the scene.
  102669. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  102670. * and getCollidingSubMeshCandidates to their default function
  102671. */
  102672. setDefaultCandidateProviders(): void;
  102673. /**
  102674. * Gets the mesh that is currently under the pointer
  102675. */
  102676. readonly meshUnderPointer: Nullable<AbstractMesh>;
  102677. /**
  102678. * Gets or sets the current on-screen X position of the pointer
  102679. */
  102680. pointerX: number;
  102681. /**
  102682. * Gets or sets the current on-screen Y position of the pointer
  102683. */
  102684. pointerY: number;
  102685. /**
  102686. * Gets the cached material (ie. the latest rendered one)
  102687. * @returns the cached material
  102688. */
  102689. getCachedMaterial(): Nullable<Material>;
  102690. /**
  102691. * Gets the cached effect (ie. the latest rendered one)
  102692. * @returns the cached effect
  102693. */
  102694. getCachedEffect(): Nullable<Effect>;
  102695. /**
  102696. * Gets the cached visibility state (ie. the latest rendered one)
  102697. * @returns the cached visibility state
  102698. */
  102699. getCachedVisibility(): Nullable<number>;
  102700. /**
  102701. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  102702. * @param material defines the current material
  102703. * @param effect defines the current effect
  102704. * @param visibility defines the current visibility state
  102705. * @returns true if one parameter is not cached
  102706. */
  102707. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  102708. /**
  102709. * Gets the engine associated with the scene
  102710. * @returns an Engine
  102711. */
  102712. getEngine(): Engine;
  102713. /**
  102714. * Gets the total number of vertices rendered per frame
  102715. * @returns the total number of vertices rendered per frame
  102716. */
  102717. getTotalVertices(): number;
  102718. /**
  102719. * Gets the performance counter for total vertices
  102720. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102721. */
  102722. readonly totalVerticesPerfCounter: PerfCounter;
  102723. /**
  102724. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  102725. * @returns the total number of active indices rendered per frame
  102726. */
  102727. getActiveIndices(): number;
  102728. /**
  102729. * Gets the performance counter for active indices
  102730. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102731. */
  102732. readonly totalActiveIndicesPerfCounter: PerfCounter;
  102733. /**
  102734. * Gets the total number of active particles rendered per frame
  102735. * @returns the total number of active particles rendered per frame
  102736. */
  102737. getActiveParticles(): number;
  102738. /**
  102739. * Gets the performance counter for active particles
  102740. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102741. */
  102742. readonly activeParticlesPerfCounter: PerfCounter;
  102743. /**
  102744. * Gets the total number of active bones rendered per frame
  102745. * @returns the total number of active bones rendered per frame
  102746. */
  102747. getActiveBones(): number;
  102748. /**
  102749. * Gets the performance counter for active bones
  102750. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  102751. */
  102752. readonly activeBonesPerfCounter: PerfCounter;
  102753. /**
  102754. * Gets the array of active meshes
  102755. * @returns an array of AbstractMesh
  102756. */
  102757. getActiveMeshes(): SmartArray<AbstractMesh>;
  102758. /**
  102759. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  102760. * @returns a number
  102761. */
  102762. getAnimationRatio(): number;
  102763. /**
  102764. * Gets an unique Id for the current render phase
  102765. * @returns a number
  102766. */
  102767. getRenderId(): number;
  102768. /**
  102769. * Gets an unique Id for the current frame
  102770. * @returns a number
  102771. */
  102772. getFrameId(): number;
  102773. /** Call this function if you want to manually increment the render Id*/
  102774. incrementRenderId(): void;
  102775. private _createUbo;
  102776. /**
  102777. * Use this method to simulate a pointer move on a mesh
  102778. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102779. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102780. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102781. * @returns the current scene
  102782. */
  102783. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102784. /**
  102785. * Use this method to simulate a pointer down on a mesh
  102786. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102787. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102788. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102789. * @returns the current scene
  102790. */
  102791. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  102792. /**
  102793. * Use this method to simulate a pointer up on a mesh
  102794. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  102795. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  102796. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  102797. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  102798. * @returns the current scene
  102799. */
  102800. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  102801. /**
  102802. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  102803. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  102804. * @returns true if the pointer was captured
  102805. */
  102806. isPointerCaptured(pointerId?: number): boolean;
  102807. /**
  102808. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  102809. * @param attachUp defines if you want to attach events to pointerup
  102810. * @param attachDown defines if you want to attach events to pointerdown
  102811. * @param attachMove defines if you want to attach events to pointermove
  102812. */
  102813. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  102814. /** Detaches all event handlers*/
  102815. detachControl(): void;
  102816. /**
  102817. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  102818. * Delay loaded resources are not taking in account
  102819. * @return true if all required resources are ready
  102820. */
  102821. isReady(): boolean;
  102822. /** Resets all cached information relative to material (including effect and visibility) */
  102823. resetCachedMaterial(): void;
  102824. /**
  102825. * Registers a function to be called before every frame render
  102826. * @param func defines the function to register
  102827. */
  102828. registerBeforeRender(func: () => void): void;
  102829. /**
  102830. * Unregisters a function called before every frame render
  102831. * @param func defines the function to unregister
  102832. */
  102833. unregisterBeforeRender(func: () => void): void;
  102834. /**
  102835. * Registers a function to be called after every frame render
  102836. * @param func defines the function to register
  102837. */
  102838. registerAfterRender(func: () => void): void;
  102839. /**
  102840. * Unregisters a function called after every frame render
  102841. * @param func defines the function to unregister
  102842. */
  102843. unregisterAfterRender(func: () => void): void;
  102844. private _executeOnceBeforeRender;
  102845. /**
  102846. * The provided function will run before render once and will be disposed afterwards.
  102847. * A timeout delay can be provided so that the function will be executed in N ms.
  102848. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  102849. * @param func The function to be executed.
  102850. * @param timeout optional delay in ms
  102851. */
  102852. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  102853. /** @hidden */
  102854. _addPendingData(data: any): void;
  102855. /** @hidden */
  102856. _removePendingData(data: any): void;
  102857. /**
  102858. * Returns the number of items waiting to be loaded
  102859. * @returns the number of items waiting to be loaded
  102860. */
  102861. getWaitingItemsCount(): number;
  102862. /**
  102863. * Returns a boolean indicating if the scene is still loading data
  102864. */
  102865. readonly isLoading: boolean;
  102866. /**
  102867. * Registers a function to be executed when the scene is ready
  102868. * @param {Function} func - the function to be executed
  102869. */
  102870. executeWhenReady(func: () => void): void;
  102871. /**
  102872. * Returns a promise that resolves when the scene is ready
  102873. * @returns A promise that resolves when the scene is ready
  102874. */
  102875. whenReadyAsync(): Promise<void>;
  102876. /** @hidden */
  102877. _checkIsReady(): void;
  102878. /**
  102879. * Gets all animatable attached to the scene
  102880. */
  102881. readonly animatables: Animatable[];
  102882. /**
  102883. * Resets the last animation time frame.
  102884. * Useful to override when animations start running when loading a scene for the first time.
  102885. */
  102886. resetLastAnimationTimeFrame(): void;
  102887. /**
  102888. * Gets the current view matrix
  102889. * @returns a Matrix
  102890. */
  102891. getViewMatrix(): Matrix;
  102892. /**
  102893. * Gets the current projection matrix
  102894. * @returns a Matrix
  102895. */
  102896. getProjectionMatrix(): Matrix;
  102897. /**
  102898. * Gets the current transform matrix
  102899. * @returns a Matrix made of View * Projection
  102900. */
  102901. getTransformMatrix(): Matrix;
  102902. /**
  102903. * Sets the current transform matrix
  102904. * @param viewL defines the View matrix to use
  102905. * @param projectionL defines the Projection matrix to use
  102906. * @param viewR defines the right View matrix to use (if provided)
  102907. * @param projectionR defines the right Projection matrix to use (if provided)
  102908. */
  102909. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  102910. /**
  102911. * Gets the uniform buffer used to store scene data
  102912. * @returns a UniformBuffer
  102913. */
  102914. getSceneUniformBuffer(): UniformBuffer;
  102915. /**
  102916. * Gets an unique (relatively to the current scene) Id
  102917. * @returns an unique number for the scene
  102918. */
  102919. getUniqueId(): number;
  102920. /**
  102921. * Add a mesh to the list of scene's meshes
  102922. * @param newMesh defines the mesh to add
  102923. * @param recursive if all child meshes should also be added to the scene
  102924. */
  102925. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  102926. /**
  102927. * Remove a mesh for the list of scene's meshes
  102928. * @param toRemove defines the mesh to remove
  102929. * @param recursive if all child meshes should also be removed from the scene
  102930. * @returns the index where the mesh was in the mesh list
  102931. */
  102932. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  102933. /**
  102934. * Add a transform node to the list of scene's transform nodes
  102935. * @param newTransformNode defines the transform node to add
  102936. */
  102937. addTransformNode(newTransformNode: TransformNode): void;
  102938. /**
  102939. * Remove a transform node for the list of scene's transform nodes
  102940. * @param toRemove defines the transform node to remove
  102941. * @returns the index where the transform node was in the transform node list
  102942. */
  102943. removeTransformNode(toRemove: TransformNode): number;
  102944. /**
  102945. * Remove a skeleton for the list of scene's skeletons
  102946. * @param toRemove defines the skeleton to remove
  102947. * @returns the index where the skeleton was in the skeleton list
  102948. */
  102949. removeSkeleton(toRemove: Skeleton): number;
  102950. /**
  102951. * Remove a morph target for the list of scene's morph targets
  102952. * @param toRemove defines the morph target to remove
  102953. * @returns the index where the morph target was in the morph target list
  102954. */
  102955. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  102956. /**
  102957. * Remove a light for the list of scene's lights
  102958. * @param toRemove defines the light to remove
  102959. * @returns the index where the light was in the light list
  102960. */
  102961. removeLight(toRemove: Light): number;
  102962. /**
  102963. * Remove a camera for the list of scene's cameras
  102964. * @param toRemove defines the camera to remove
  102965. * @returns the index where the camera was in the camera list
  102966. */
  102967. removeCamera(toRemove: Camera): number;
  102968. /**
  102969. * Remove a particle system for the list of scene's particle systems
  102970. * @param toRemove defines the particle system to remove
  102971. * @returns the index where the particle system was in the particle system list
  102972. */
  102973. removeParticleSystem(toRemove: IParticleSystem): number;
  102974. /**
  102975. * Remove a animation for the list of scene's animations
  102976. * @param toRemove defines the animation to remove
  102977. * @returns the index where the animation was in the animation list
  102978. */
  102979. removeAnimation(toRemove: Animation): number;
  102980. /**
  102981. * Will stop the animation of the given target
  102982. * @param target - the target
  102983. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  102984. * @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)
  102985. */
  102986. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  102987. /**
  102988. * Removes the given animation group from this scene.
  102989. * @param toRemove The animation group to remove
  102990. * @returns The index of the removed animation group
  102991. */
  102992. removeAnimationGroup(toRemove: AnimationGroup): number;
  102993. /**
  102994. * Removes the given multi-material from this scene.
  102995. * @param toRemove The multi-material to remove
  102996. * @returns The index of the removed multi-material
  102997. */
  102998. removeMultiMaterial(toRemove: MultiMaterial): number;
  102999. /**
  103000. * Removes the given material from this scene.
  103001. * @param toRemove The material to remove
  103002. * @returns The index of the removed material
  103003. */
  103004. removeMaterial(toRemove: Material): number;
  103005. /**
  103006. * Removes the given action manager from this scene.
  103007. * @param toRemove The action manager to remove
  103008. * @returns The index of the removed action manager
  103009. */
  103010. removeActionManager(toRemove: AbstractActionManager): number;
  103011. /**
  103012. * Removes the given texture from this scene.
  103013. * @param toRemove The texture to remove
  103014. * @returns The index of the removed texture
  103015. */
  103016. removeTexture(toRemove: BaseTexture): number;
  103017. /**
  103018. * Adds the given light to this scene
  103019. * @param newLight The light to add
  103020. */
  103021. addLight(newLight: Light): void;
  103022. /**
  103023. * Sorts the list list based on light priorities
  103024. */
  103025. sortLightsByPriority(): void;
  103026. /**
  103027. * Adds the given camera to this scene
  103028. * @param newCamera The camera to add
  103029. */
  103030. addCamera(newCamera: Camera): void;
  103031. /**
  103032. * Adds the given skeleton to this scene
  103033. * @param newSkeleton The skeleton to add
  103034. */
  103035. addSkeleton(newSkeleton: Skeleton): void;
  103036. /**
  103037. * Adds the given particle system to this scene
  103038. * @param newParticleSystem The particle system to add
  103039. */
  103040. addParticleSystem(newParticleSystem: IParticleSystem): void;
  103041. /**
  103042. * Adds the given animation to this scene
  103043. * @param newAnimation The animation to add
  103044. */
  103045. addAnimation(newAnimation: Animation): void;
  103046. /**
  103047. * Adds the given animation group to this scene.
  103048. * @param newAnimationGroup The animation group to add
  103049. */
  103050. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  103051. /**
  103052. * Adds the given multi-material to this scene
  103053. * @param newMultiMaterial The multi-material to add
  103054. */
  103055. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  103056. /**
  103057. * Adds the given material to this scene
  103058. * @param newMaterial The material to add
  103059. */
  103060. addMaterial(newMaterial: Material): void;
  103061. /**
  103062. * Adds the given morph target to this scene
  103063. * @param newMorphTargetManager The morph target to add
  103064. */
  103065. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  103066. /**
  103067. * Adds the given geometry to this scene
  103068. * @param newGeometry The geometry to add
  103069. */
  103070. addGeometry(newGeometry: Geometry): void;
  103071. /**
  103072. * Adds the given action manager to this scene
  103073. * @param newActionManager The action manager to add
  103074. */
  103075. addActionManager(newActionManager: AbstractActionManager): void;
  103076. /**
  103077. * Adds the given texture to this scene.
  103078. * @param newTexture The texture to add
  103079. */
  103080. addTexture(newTexture: BaseTexture): void;
  103081. /**
  103082. * Switch active camera
  103083. * @param newCamera defines the new active camera
  103084. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  103085. */
  103086. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  103087. /**
  103088. * sets the active camera of the scene using its ID
  103089. * @param id defines the camera's ID
  103090. * @return the new active camera or null if none found.
  103091. */
  103092. setActiveCameraByID(id: string): Nullable<Camera>;
  103093. /**
  103094. * sets the active camera of the scene using its name
  103095. * @param name defines the camera's name
  103096. * @returns the new active camera or null if none found.
  103097. */
  103098. setActiveCameraByName(name: string): Nullable<Camera>;
  103099. /**
  103100. * get an animation group using its name
  103101. * @param name defines the material's name
  103102. * @return the animation group or null if none found.
  103103. */
  103104. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  103105. /**
  103106. * Get a material using its unique id
  103107. * @param uniqueId defines the material's unique id
  103108. * @return the material or null if none found.
  103109. */
  103110. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  103111. /**
  103112. * get a material using its id
  103113. * @param id defines the material's ID
  103114. * @return the material or null if none found.
  103115. */
  103116. getMaterialByID(id: string): Nullable<Material>;
  103117. /**
  103118. * Gets a the last added material using a given id
  103119. * @param id defines the material's ID
  103120. * @return the last material with the given id or null if none found.
  103121. */
  103122. getLastMaterialByID(id: string): Nullable<Material>;
  103123. /**
  103124. * Gets a material using its name
  103125. * @param name defines the material's name
  103126. * @return the material or null if none found.
  103127. */
  103128. getMaterialByName(name: string): Nullable<Material>;
  103129. /**
  103130. * Get a texture using its unique id
  103131. * @param uniqueId defines the texture's unique id
  103132. * @return the texture or null if none found.
  103133. */
  103134. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  103135. /**
  103136. * Gets a camera using its id
  103137. * @param id defines the id to look for
  103138. * @returns the camera or null if not found
  103139. */
  103140. getCameraByID(id: string): Nullable<Camera>;
  103141. /**
  103142. * Gets a camera using its unique id
  103143. * @param uniqueId defines the unique id to look for
  103144. * @returns the camera or null if not found
  103145. */
  103146. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  103147. /**
  103148. * Gets a camera using its name
  103149. * @param name defines the camera's name
  103150. * @return the camera or null if none found.
  103151. */
  103152. getCameraByName(name: string): Nullable<Camera>;
  103153. /**
  103154. * Gets a bone using its id
  103155. * @param id defines the bone's id
  103156. * @return the bone or null if not found
  103157. */
  103158. getBoneByID(id: string): Nullable<Bone>;
  103159. /**
  103160. * Gets a bone using its id
  103161. * @param name defines the bone's name
  103162. * @return the bone or null if not found
  103163. */
  103164. getBoneByName(name: string): Nullable<Bone>;
  103165. /**
  103166. * Gets a light node using its name
  103167. * @param name defines the the light's name
  103168. * @return the light or null if none found.
  103169. */
  103170. getLightByName(name: string): Nullable<Light>;
  103171. /**
  103172. * Gets a light node using its id
  103173. * @param id defines the light's id
  103174. * @return the light or null if none found.
  103175. */
  103176. getLightByID(id: string): Nullable<Light>;
  103177. /**
  103178. * Gets a light node using its scene-generated unique ID
  103179. * @param uniqueId defines the light's unique id
  103180. * @return the light or null if none found.
  103181. */
  103182. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  103183. /**
  103184. * Gets a particle system by id
  103185. * @param id defines the particle system id
  103186. * @return the corresponding system or null if none found
  103187. */
  103188. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  103189. /**
  103190. * Gets a geometry using its ID
  103191. * @param id defines the geometry's id
  103192. * @return the geometry or null if none found.
  103193. */
  103194. getGeometryByID(id: string): Nullable<Geometry>;
  103195. private _getGeometryByUniqueID;
  103196. /**
  103197. * Add a new geometry to this scene
  103198. * @param geometry defines the geometry to be added to the scene.
  103199. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  103200. * @return a boolean defining if the geometry was added or not
  103201. */
  103202. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  103203. /**
  103204. * Removes an existing geometry
  103205. * @param geometry defines the geometry to be removed from the scene
  103206. * @return a boolean defining if the geometry was removed or not
  103207. */
  103208. removeGeometry(geometry: Geometry): boolean;
  103209. /**
  103210. * Gets the list of geometries attached to the scene
  103211. * @returns an array of Geometry
  103212. */
  103213. getGeometries(): Geometry[];
  103214. /**
  103215. * Gets the first added mesh found of a given ID
  103216. * @param id defines the id to search for
  103217. * @return the mesh found or null if not found at all
  103218. */
  103219. getMeshByID(id: string): Nullable<AbstractMesh>;
  103220. /**
  103221. * Gets a list of meshes using their id
  103222. * @param id defines the id to search for
  103223. * @returns a list of meshes
  103224. */
  103225. getMeshesByID(id: string): Array<AbstractMesh>;
  103226. /**
  103227. * Gets the first added transform node found of a given ID
  103228. * @param id defines the id to search for
  103229. * @return the found transform node or null if not found at all.
  103230. */
  103231. getTransformNodeByID(id: string): Nullable<TransformNode>;
  103232. /**
  103233. * Gets a transform node with its auto-generated unique id
  103234. * @param uniqueId efines the unique id to search for
  103235. * @return the found transform node or null if not found at all.
  103236. */
  103237. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  103238. /**
  103239. * Gets a list of transform nodes using their id
  103240. * @param id defines the id to search for
  103241. * @returns a list of transform nodes
  103242. */
  103243. getTransformNodesByID(id: string): Array<TransformNode>;
  103244. /**
  103245. * Gets a mesh with its auto-generated unique id
  103246. * @param uniqueId defines the unique id to search for
  103247. * @return the found mesh or null if not found at all.
  103248. */
  103249. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  103250. /**
  103251. * Gets a the last added mesh using a given id
  103252. * @param id defines the id to search for
  103253. * @return the found mesh or null if not found at all.
  103254. */
  103255. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  103256. /**
  103257. * Gets a the last added node (Mesh, Camera, Light) using a given id
  103258. * @param id defines the id to search for
  103259. * @return the found node or null if not found at all
  103260. */
  103261. getLastEntryByID(id: string): Nullable<Node>;
  103262. /**
  103263. * Gets a node (Mesh, Camera, Light) using a given id
  103264. * @param id defines the id to search for
  103265. * @return the found node or null if not found at all
  103266. */
  103267. getNodeByID(id: string): Nullable<Node>;
  103268. /**
  103269. * Gets a node (Mesh, Camera, Light) using a given name
  103270. * @param name defines the name to search for
  103271. * @return the found node or null if not found at all.
  103272. */
  103273. getNodeByName(name: string): Nullable<Node>;
  103274. /**
  103275. * Gets a mesh using a given name
  103276. * @param name defines the name to search for
  103277. * @return the found mesh or null if not found at all.
  103278. */
  103279. getMeshByName(name: string): Nullable<AbstractMesh>;
  103280. /**
  103281. * Gets a transform node using a given name
  103282. * @param name defines the name to search for
  103283. * @return the found transform node or null if not found at all.
  103284. */
  103285. getTransformNodeByName(name: string): Nullable<TransformNode>;
  103286. /**
  103287. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  103288. * @param id defines the id to search for
  103289. * @return the found skeleton or null if not found at all.
  103290. */
  103291. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  103292. /**
  103293. * Gets a skeleton using a given auto generated unique id
  103294. * @param uniqueId defines the unique id to search for
  103295. * @return the found skeleton or null if not found at all.
  103296. */
  103297. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  103298. /**
  103299. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  103300. * @param id defines the id to search for
  103301. * @return the found skeleton or null if not found at all.
  103302. */
  103303. getSkeletonById(id: string): Nullable<Skeleton>;
  103304. /**
  103305. * Gets a skeleton using a given name
  103306. * @param name defines the name to search for
  103307. * @return the found skeleton or null if not found at all.
  103308. */
  103309. getSkeletonByName(name: string): Nullable<Skeleton>;
  103310. /**
  103311. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  103312. * @param id defines the id to search for
  103313. * @return the found morph target manager or null if not found at all.
  103314. */
  103315. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  103316. /**
  103317. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  103318. * @param id defines the id to search for
  103319. * @return the found morph target or null if not found at all.
  103320. */
  103321. getMorphTargetById(id: string): Nullable<MorphTarget>;
  103322. /**
  103323. * Gets a boolean indicating if the given mesh is active
  103324. * @param mesh defines the mesh to look for
  103325. * @returns true if the mesh is in the active list
  103326. */
  103327. isActiveMesh(mesh: AbstractMesh): boolean;
  103328. /**
  103329. * Return a unique id as a string which can serve as an identifier for the scene
  103330. */
  103331. readonly uid: string;
  103332. /**
  103333. * Add an externaly attached data from its key.
  103334. * This method call will fail and return false, if such key already exists.
  103335. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  103336. * @param key the unique key that identifies the data
  103337. * @param data the data object to associate to the key for this Engine instance
  103338. * @return true if no such key were already present and the data was added successfully, false otherwise
  103339. */
  103340. addExternalData<T>(key: string, data: T): boolean;
  103341. /**
  103342. * Get an externaly attached data from its key
  103343. * @param key the unique key that identifies the data
  103344. * @return the associated data, if present (can be null), or undefined if not present
  103345. */
  103346. getExternalData<T>(key: string): Nullable<T>;
  103347. /**
  103348. * Get an externaly attached data from its key, create it using a factory if it's not already present
  103349. * @param key the unique key that identifies the data
  103350. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  103351. * @return the associated data, can be null if the factory returned null.
  103352. */
  103353. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  103354. /**
  103355. * Remove an externaly attached data from the Engine instance
  103356. * @param key the unique key that identifies the data
  103357. * @return true if the data was successfully removed, false if it doesn't exist
  103358. */
  103359. removeExternalData(key: string): boolean;
  103360. private _evaluateSubMesh;
  103361. /**
  103362. * Clear the processed materials smart array preventing retention point in material dispose.
  103363. */
  103364. freeProcessedMaterials(): void;
  103365. private _preventFreeActiveMeshesAndRenderingGroups;
  103366. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  103367. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  103368. * when disposing several meshes in a row or a hierarchy of meshes.
  103369. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  103370. */
  103371. blockfreeActiveMeshesAndRenderingGroups: boolean;
  103372. /**
  103373. * Clear the active meshes smart array preventing retention point in mesh dispose.
  103374. */
  103375. freeActiveMeshes(): void;
  103376. /**
  103377. * Clear the info related to rendering groups preventing retention points during dispose.
  103378. */
  103379. freeRenderingGroups(): void;
  103380. /** @hidden */
  103381. _isInIntermediateRendering(): boolean;
  103382. /**
  103383. * Lambda returning the list of potentially active meshes.
  103384. */
  103385. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  103386. /**
  103387. * Lambda returning the list of potentially active sub meshes.
  103388. */
  103389. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  103390. /**
  103391. * Lambda returning the list of potentially intersecting sub meshes.
  103392. */
  103393. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  103394. /**
  103395. * Lambda returning the list of potentially colliding sub meshes.
  103396. */
  103397. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  103398. private _activeMeshesFrozen;
  103399. private _skipEvaluateActiveMeshesCompletely;
  103400. /**
  103401. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  103402. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  103403. * @returns the current scene
  103404. */
  103405. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  103406. /**
  103407. * Use this function to restart evaluating active meshes on every frame
  103408. * @returns the current scene
  103409. */
  103410. unfreezeActiveMeshes(): Scene;
  103411. private _evaluateActiveMeshes;
  103412. private _activeMesh;
  103413. /**
  103414. * Update the transform matrix to update from the current active camera
  103415. * @param force defines a boolean used to force the update even if cache is up to date
  103416. */
  103417. updateTransformMatrix(force?: boolean): void;
  103418. private _bindFrameBuffer;
  103419. /** @hidden */
  103420. _allowPostProcessClearColor: boolean;
  103421. /** @hidden */
  103422. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  103423. private _processSubCameras;
  103424. private _checkIntersections;
  103425. /** @hidden */
  103426. _advancePhysicsEngineStep(step: number): void;
  103427. /**
  103428. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  103429. */
  103430. getDeterministicFrameTime: () => number;
  103431. /** @hidden */
  103432. _animate(): void;
  103433. /** Execute all animations (for a frame) */
  103434. animate(): void;
  103435. /**
  103436. * Render the scene
  103437. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  103438. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  103439. */
  103440. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  103441. /**
  103442. * Freeze all materials
  103443. * A frozen material will not be updatable but should be faster to render
  103444. */
  103445. freezeMaterials(): void;
  103446. /**
  103447. * Unfreeze all materials
  103448. * A frozen material will not be updatable but should be faster to render
  103449. */
  103450. unfreezeMaterials(): void;
  103451. /**
  103452. * Releases all held ressources
  103453. */
  103454. dispose(): void;
  103455. /**
  103456. * Gets if the scene is already disposed
  103457. */
  103458. readonly isDisposed: boolean;
  103459. /**
  103460. * Call this function to reduce memory footprint of the scene.
  103461. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  103462. */
  103463. clearCachedVertexData(): void;
  103464. /**
  103465. * This function will remove the local cached buffer data from texture.
  103466. * It will save memory but will prevent the texture from being rebuilt
  103467. */
  103468. cleanCachedTextureBuffer(): void;
  103469. /**
  103470. * Get the world extend vectors with an optional filter
  103471. *
  103472. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  103473. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  103474. */
  103475. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  103476. min: Vector3;
  103477. max: Vector3;
  103478. };
  103479. /**
  103480. * Creates a ray that can be used to pick in the scene
  103481. * @param x defines the x coordinate of the origin (on-screen)
  103482. * @param y defines the y coordinate of the origin (on-screen)
  103483. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103484. * @param camera defines the camera to use for the picking
  103485. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103486. * @returns a Ray
  103487. */
  103488. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  103489. /**
  103490. * Creates a ray that can be used to pick in the scene
  103491. * @param x defines the x coordinate of the origin (on-screen)
  103492. * @param y defines the y coordinate of the origin (on-screen)
  103493. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  103494. * @param result defines the ray where to store the picking ray
  103495. * @param camera defines the camera to use for the picking
  103496. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  103497. * @returns the current scene
  103498. */
  103499. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  103500. /**
  103501. * Creates a ray that can be used to pick in the scene
  103502. * @param x defines the x coordinate of the origin (on-screen)
  103503. * @param y defines the y coordinate of the origin (on-screen)
  103504. * @param camera defines the camera to use for the picking
  103505. * @returns a Ray
  103506. */
  103507. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  103508. /**
  103509. * Creates a ray that can be used to pick in the scene
  103510. * @param x defines the x coordinate of the origin (on-screen)
  103511. * @param y defines the y coordinate of the origin (on-screen)
  103512. * @param result defines the ray where to store the picking ray
  103513. * @param camera defines the camera to use for the picking
  103514. * @returns the current scene
  103515. */
  103516. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  103517. /** Launch a ray to try to pick a mesh in the scene
  103518. * @param x position on screen
  103519. * @param y position on screen
  103520. * @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
  103521. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  103522. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103523. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103524. * @returns a PickingInfo
  103525. */
  103526. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103527. /** Use the given ray to pick a mesh in the scene
  103528. * @param ray The ray to use to pick meshes
  103529. * @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
  103530. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  103531. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103532. * @returns a PickingInfo
  103533. */
  103534. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  103535. /**
  103536. * Launch a ray to try to pick a mesh in the scene
  103537. * @param x X position on screen
  103538. * @param y Y position on screen
  103539. * @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
  103540. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  103541. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103542. * @returns an array of PickingInfo
  103543. */
  103544. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103545. /**
  103546. * Launch a ray to try to pick a mesh in the scene
  103547. * @param ray Ray to use
  103548. * @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
  103549. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103550. * @returns an array of PickingInfo
  103551. */
  103552. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  103553. /**
  103554. * Force the value of meshUnderPointer
  103555. * @param mesh defines the mesh to use
  103556. */
  103557. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  103558. /**
  103559. * Gets the mesh under the pointer
  103560. * @returns a Mesh or null if no mesh is under the pointer
  103561. */
  103562. getPointerOverMesh(): Nullable<AbstractMesh>;
  103563. /** @hidden */
  103564. _rebuildGeometries(): void;
  103565. /** @hidden */
  103566. _rebuildTextures(): void;
  103567. private _getByTags;
  103568. /**
  103569. * Get a list of meshes by tags
  103570. * @param tagsQuery defines the tags query to use
  103571. * @param forEach defines a predicate used to filter results
  103572. * @returns an array of Mesh
  103573. */
  103574. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  103575. /**
  103576. * Get a list of cameras by tags
  103577. * @param tagsQuery defines the tags query to use
  103578. * @param forEach defines a predicate used to filter results
  103579. * @returns an array of Camera
  103580. */
  103581. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  103582. /**
  103583. * Get a list of lights by tags
  103584. * @param tagsQuery defines the tags query to use
  103585. * @param forEach defines a predicate used to filter results
  103586. * @returns an array of Light
  103587. */
  103588. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  103589. /**
  103590. * Get a list of materials by tags
  103591. * @param tagsQuery defines the tags query to use
  103592. * @param forEach defines a predicate used to filter results
  103593. * @returns an array of Material
  103594. */
  103595. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  103596. /**
  103597. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  103598. * This allowed control for front to back rendering or reversly depending of the special needs.
  103599. *
  103600. * @param renderingGroupId The rendering group id corresponding to its index
  103601. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  103602. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  103603. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  103604. */
  103605. 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;
  103606. /**
  103607. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  103608. *
  103609. * @param renderingGroupId The rendering group id corresponding to its index
  103610. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  103611. * @param depth Automatically clears depth between groups if true and autoClear is true.
  103612. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  103613. */
  103614. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  103615. /**
  103616. * Gets the current auto clear configuration for one rendering group of the rendering
  103617. * manager.
  103618. * @param index the rendering group index to get the information for
  103619. * @returns The auto clear setup for the requested rendering group
  103620. */
  103621. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  103622. private _blockMaterialDirtyMechanism;
  103623. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  103624. blockMaterialDirtyMechanism: boolean;
  103625. /**
  103626. * Will flag all materials as dirty to trigger new shader compilation
  103627. * @param flag defines the flag used to specify which material part must be marked as dirty
  103628. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  103629. */
  103630. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  103631. /** @hidden */
  103632. _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;
  103633. /** @hidden */
  103634. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103635. /** @hidden */
  103636. _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;
  103637. /** @hidden */
  103638. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  103639. /** @hidden */
  103640. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  103641. /** @hidden */
  103642. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  103643. }
  103644. }
  103645. declare module BABYLON {
  103646. /**
  103647. * Set of assets to keep when moving a scene into an asset container.
  103648. */
  103649. export class KeepAssets extends AbstractScene {
  103650. }
  103651. /**
  103652. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  103653. */
  103654. export class InstantiatedEntries {
  103655. /**
  103656. * List of new root nodes (eg. nodes with no parent)
  103657. */
  103658. rootNodes: TransformNode[];
  103659. /**
  103660. * List of new skeletons
  103661. */
  103662. skeletons: Skeleton[];
  103663. /**
  103664. * List of new animation groups
  103665. */
  103666. animationGroups: AnimationGroup[];
  103667. }
  103668. /**
  103669. * Container with a set of assets that can be added or removed from a scene.
  103670. */
  103671. export class AssetContainer extends AbstractScene {
  103672. /**
  103673. * The scene the AssetContainer belongs to.
  103674. */
  103675. scene: Scene;
  103676. /**
  103677. * Instantiates an AssetContainer.
  103678. * @param scene The scene the AssetContainer belongs to.
  103679. */
  103680. constructor(scene: Scene);
  103681. /**
  103682. * Instantiate or clone all meshes and add the new ones to the scene.
  103683. * Skeletons and animation groups will all be cloned
  103684. * @param nameFunction defines an optional function used to get new names for clones
  103685. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  103686. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  103687. */
  103688. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  103689. /**
  103690. * Adds all the assets from the container to the scene.
  103691. */
  103692. addAllToScene(): void;
  103693. /**
  103694. * Removes all the assets in the container from the scene
  103695. */
  103696. removeAllFromScene(): void;
  103697. /**
  103698. * Disposes all the assets in the container
  103699. */
  103700. dispose(): void;
  103701. private _moveAssets;
  103702. /**
  103703. * Removes all the assets contained in the scene and adds them to the container.
  103704. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  103705. */
  103706. moveAllFromScene(keepAssets?: KeepAssets): void;
  103707. /**
  103708. * 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.
  103709. * @returns the root mesh
  103710. */
  103711. createRootMesh(): Mesh;
  103712. }
  103713. }
  103714. declare module BABYLON {
  103715. /**
  103716. * Defines how the parser contract is defined.
  103717. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  103718. */
  103719. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  103720. /**
  103721. * Defines how the individual parser contract is defined.
  103722. * These parser can parse an individual asset
  103723. */
  103724. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  103725. /**
  103726. * Base class of the scene acting as a container for the different elements composing a scene.
  103727. * This class is dynamically extended by the different components of the scene increasing
  103728. * flexibility and reducing coupling
  103729. */
  103730. export abstract class AbstractScene {
  103731. /**
  103732. * Stores the list of available parsers in the application.
  103733. */
  103734. private static _BabylonFileParsers;
  103735. /**
  103736. * Stores the list of available individual parsers in the application.
  103737. */
  103738. private static _IndividualBabylonFileParsers;
  103739. /**
  103740. * Adds a parser in the list of available ones
  103741. * @param name Defines the name of the parser
  103742. * @param parser Defines the parser to add
  103743. */
  103744. static AddParser(name: string, parser: BabylonFileParser): void;
  103745. /**
  103746. * Gets a general parser from the list of avaialble ones
  103747. * @param name Defines the name of the parser
  103748. * @returns the requested parser or null
  103749. */
  103750. static GetParser(name: string): Nullable<BabylonFileParser>;
  103751. /**
  103752. * Adds n individual parser in the list of available ones
  103753. * @param name Defines the name of the parser
  103754. * @param parser Defines the parser to add
  103755. */
  103756. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  103757. /**
  103758. * Gets an individual parser from the list of avaialble ones
  103759. * @param name Defines the name of the parser
  103760. * @returns the requested parser or null
  103761. */
  103762. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  103763. /**
  103764. * Parser json data and populate both a scene and its associated container object
  103765. * @param jsonData Defines the data to parse
  103766. * @param scene Defines the scene to parse the data for
  103767. * @param container Defines the container attached to the parsing sequence
  103768. * @param rootUrl Defines the root url of the data
  103769. */
  103770. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  103771. /**
  103772. * Gets the list of root nodes (ie. nodes with no parent)
  103773. */
  103774. rootNodes: Node[];
  103775. /** All of the cameras added to this scene
  103776. * @see http://doc.babylonjs.com/babylon101/cameras
  103777. */
  103778. cameras: Camera[];
  103779. /**
  103780. * All of the lights added to this scene
  103781. * @see http://doc.babylonjs.com/babylon101/lights
  103782. */
  103783. lights: Light[];
  103784. /**
  103785. * All of the (abstract) meshes added to this scene
  103786. */
  103787. meshes: AbstractMesh[];
  103788. /**
  103789. * The list of skeletons added to the scene
  103790. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  103791. */
  103792. skeletons: Skeleton[];
  103793. /**
  103794. * All of the particle systems added to this scene
  103795. * @see http://doc.babylonjs.com/babylon101/particles
  103796. */
  103797. particleSystems: IParticleSystem[];
  103798. /**
  103799. * Gets a list of Animations associated with the scene
  103800. */
  103801. animations: Animation[];
  103802. /**
  103803. * All of the animation groups added to this scene
  103804. * @see http://doc.babylonjs.com/how_to/group
  103805. */
  103806. animationGroups: AnimationGroup[];
  103807. /**
  103808. * All of the multi-materials added to this scene
  103809. * @see http://doc.babylonjs.com/how_to/multi_materials
  103810. */
  103811. multiMaterials: MultiMaterial[];
  103812. /**
  103813. * All of the materials added to this scene
  103814. * In the context of a Scene, it is not supposed to be modified manually.
  103815. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  103816. * Note also that the order of the Material within the array is not significant and might change.
  103817. * @see http://doc.babylonjs.com/babylon101/materials
  103818. */
  103819. materials: Material[];
  103820. /**
  103821. * The list of morph target managers added to the scene
  103822. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  103823. */
  103824. morphTargetManagers: MorphTargetManager[];
  103825. /**
  103826. * The list of geometries used in the scene.
  103827. */
  103828. geometries: Geometry[];
  103829. /**
  103830. * All of the tranform nodes added to this scene
  103831. * In the context of a Scene, it is not supposed to be modified manually.
  103832. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  103833. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  103834. * @see http://doc.babylonjs.com/how_to/transformnode
  103835. */
  103836. transformNodes: TransformNode[];
  103837. /**
  103838. * ActionManagers available on the scene.
  103839. */
  103840. actionManagers: AbstractActionManager[];
  103841. /**
  103842. * Textures to keep.
  103843. */
  103844. textures: BaseTexture[];
  103845. /**
  103846. * Environment texture for the scene
  103847. */
  103848. environmentTexture: Nullable<BaseTexture>;
  103849. }
  103850. }
  103851. declare module BABYLON {
  103852. /**
  103853. * Interface used to define options for Sound class
  103854. */
  103855. export interface ISoundOptions {
  103856. /**
  103857. * Does the sound autoplay once loaded.
  103858. */
  103859. autoplay?: boolean;
  103860. /**
  103861. * Does the sound loop after it finishes playing once.
  103862. */
  103863. loop?: boolean;
  103864. /**
  103865. * Sound's volume
  103866. */
  103867. volume?: number;
  103868. /**
  103869. * Is it a spatial sound?
  103870. */
  103871. spatialSound?: boolean;
  103872. /**
  103873. * Maximum distance to hear that sound
  103874. */
  103875. maxDistance?: number;
  103876. /**
  103877. * Uses user defined attenuation function
  103878. */
  103879. useCustomAttenuation?: boolean;
  103880. /**
  103881. * Define the roll off factor of spatial sounds.
  103882. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103883. */
  103884. rolloffFactor?: number;
  103885. /**
  103886. * Define the reference distance the sound should be heard perfectly.
  103887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103888. */
  103889. refDistance?: number;
  103890. /**
  103891. * Define the distance attenuation model the sound will follow.
  103892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103893. */
  103894. distanceModel?: string;
  103895. /**
  103896. * Defines the playback speed (1 by default)
  103897. */
  103898. playbackRate?: number;
  103899. /**
  103900. * Defines if the sound is from a streaming source
  103901. */
  103902. streaming?: boolean;
  103903. /**
  103904. * Defines an optional length (in seconds) inside the sound file
  103905. */
  103906. length?: number;
  103907. /**
  103908. * Defines an optional offset (in seconds) inside the sound file
  103909. */
  103910. offset?: number;
  103911. /**
  103912. * If true, URLs will not be required to state the audio file codec to use.
  103913. */
  103914. skipCodecCheck?: boolean;
  103915. }
  103916. /**
  103917. * Defines a sound that can be played in the application.
  103918. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  103919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103920. */
  103921. export class Sound {
  103922. /**
  103923. * The name of the sound in the scene.
  103924. */
  103925. name: string;
  103926. /**
  103927. * Does the sound autoplay once loaded.
  103928. */
  103929. autoplay: boolean;
  103930. /**
  103931. * Does the sound loop after it finishes playing once.
  103932. */
  103933. loop: boolean;
  103934. /**
  103935. * Does the sound use a custom attenuation curve to simulate the falloff
  103936. * happening when the source gets further away from the camera.
  103937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  103938. */
  103939. useCustomAttenuation: boolean;
  103940. /**
  103941. * The sound track id this sound belongs to.
  103942. */
  103943. soundTrackId: number;
  103944. /**
  103945. * Is this sound currently played.
  103946. */
  103947. isPlaying: boolean;
  103948. /**
  103949. * Is this sound currently paused.
  103950. */
  103951. isPaused: boolean;
  103952. /**
  103953. * Does this sound enables spatial sound.
  103954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103955. */
  103956. spatialSound: boolean;
  103957. /**
  103958. * Define the reference distance the sound should be heard perfectly.
  103959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103960. */
  103961. refDistance: number;
  103962. /**
  103963. * Define the roll off factor of spatial sounds.
  103964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103965. */
  103966. rolloffFactor: number;
  103967. /**
  103968. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  103969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103970. */
  103971. maxDistance: number;
  103972. /**
  103973. * Define the distance attenuation model the sound will follow.
  103974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  103975. */
  103976. distanceModel: string;
  103977. /**
  103978. * @hidden
  103979. * Back Compat
  103980. **/
  103981. onended: () => any;
  103982. /**
  103983. * Observable event when the current playing sound finishes.
  103984. */
  103985. onEndedObservable: Observable<Sound>;
  103986. private _panningModel;
  103987. private _playbackRate;
  103988. private _streaming;
  103989. private _startTime;
  103990. private _startOffset;
  103991. private _position;
  103992. /** @hidden */
  103993. _positionInEmitterSpace: boolean;
  103994. private _localDirection;
  103995. private _volume;
  103996. private _isReadyToPlay;
  103997. private _isDirectional;
  103998. private _readyToPlayCallback;
  103999. private _audioBuffer;
  104000. private _soundSource;
  104001. private _streamingSource;
  104002. private _soundPanner;
  104003. private _soundGain;
  104004. private _inputAudioNode;
  104005. private _outputAudioNode;
  104006. private _coneInnerAngle;
  104007. private _coneOuterAngle;
  104008. private _coneOuterGain;
  104009. private _scene;
  104010. private _connectedTransformNode;
  104011. private _customAttenuationFunction;
  104012. private _registerFunc;
  104013. private _isOutputConnected;
  104014. private _htmlAudioElement;
  104015. private _urlType;
  104016. private _length?;
  104017. private _offset?;
  104018. /** @hidden */
  104019. static _SceneComponentInitialization: (scene: Scene) => void;
  104020. /**
  104021. * Create a sound and attach it to a scene
  104022. * @param name Name of your sound
  104023. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  104024. * @param scene defines the scene the sound belongs to
  104025. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  104026. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  104027. */
  104028. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  104029. /**
  104030. * Release the sound and its associated resources
  104031. */
  104032. dispose(): void;
  104033. /**
  104034. * Gets if the sounds is ready to be played or not.
  104035. * @returns true if ready, otherwise false
  104036. */
  104037. isReady(): boolean;
  104038. private _soundLoaded;
  104039. /**
  104040. * Sets the data of the sound from an audiobuffer
  104041. * @param audioBuffer The audioBuffer containing the data
  104042. */
  104043. setAudioBuffer(audioBuffer: AudioBuffer): void;
  104044. /**
  104045. * Updates the current sounds options such as maxdistance, loop...
  104046. * @param options A JSON object containing values named as the object properties
  104047. */
  104048. updateOptions(options: ISoundOptions): void;
  104049. private _createSpatialParameters;
  104050. private _updateSpatialParameters;
  104051. /**
  104052. * Switch the panning model to HRTF:
  104053. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  104054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104055. */
  104056. switchPanningModelToHRTF(): void;
  104057. /**
  104058. * Switch the panning model to Equal Power:
  104059. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  104060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104061. */
  104062. switchPanningModelToEqualPower(): void;
  104063. private _switchPanningModel;
  104064. /**
  104065. * Connect this sound to a sound track audio node like gain...
  104066. * @param soundTrackAudioNode the sound track audio node to connect to
  104067. */
  104068. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  104069. /**
  104070. * Transform this sound into a directional source
  104071. * @param coneInnerAngle Size of the inner cone in degree
  104072. * @param coneOuterAngle Size of the outer cone in degree
  104073. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  104074. */
  104075. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  104076. /**
  104077. * Gets or sets the inner angle for the directional cone.
  104078. */
  104079. /**
  104080. * Gets or sets the inner angle for the directional cone.
  104081. */
  104082. directionalConeInnerAngle: number;
  104083. /**
  104084. * Gets or sets the outer angle for the directional cone.
  104085. */
  104086. /**
  104087. * Gets or sets the outer angle for the directional cone.
  104088. */
  104089. directionalConeOuterAngle: number;
  104090. /**
  104091. * Sets the position of the emitter if spatial sound is enabled
  104092. * @param newPosition Defines the new posisiton
  104093. */
  104094. setPosition(newPosition: Vector3): void;
  104095. /**
  104096. * Sets the local direction of the emitter if spatial sound is enabled
  104097. * @param newLocalDirection Defines the new local direction
  104098. */
  104099. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  104100. private _updateDirection;
  104101. /** @hidden */
  104102. updateDistanceFromListener(): void;
  104103. /**
  104104. * Sets a new custom attenuation function for the sound.
  104105. * @param callback Defines the function used for the attenuation
  104106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  104107. */
  104108. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  104109. /**
  104110. * Play the sound
  104111. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  104112. * @param offset (optional) Start the sound at a specific time in seconds
  104113. * @param length (optional) Sound duration (in seconds)
  104114. */
  104115. play(time?: number, offset?: number, length?: number): void;
  104116. private _onended;
  104117. /**
  104118. * Stop the sound
  104119. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  104120. */
  104121. stop(time?: number): void;
  104122. /**
  104123. * Put the sound in pause
  104124. */
  104125. pause(): void;
  104126. /**
  104127. * Sets a dedicated volume for this sounds
  104128. * @param newVolume Define the new volume of the sound
  104129. * @param time Define time for gradual change to new volume
  104130. */
  104131. setVolume(newVolume: number, time?: number): void;
  104132. /**
  104133. * Set the sound play back rate
  104134. * @param newPlaybackRate Define the playback rate the sound should be played at
  104135. */
  104136. setPlaybackRate(newPlaybackRate: number): void;
  104137. /**
  104138. * Gets the volume of the sound.
  104139. * @returns the volume of the sound
  104140. */
  104141. getVolume(): number;
  104142. /**
  104143. * Attach the sound to a dedicated mesh
  104144. * @param transformNode The transform node to connect the sound with
  104145. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  104146. */
  104147. attachToMesh(transformNode: TransformNode): void;
  104148. /**
  104149. * Detach the sound from the previously attached mesh
  104150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  104151. */
  104152. detachFromMesh(): void;
  104153. private _onRegisterAfterWorldMatrixUpdate;
  104154. /**
  104155. * Clone the current sound in the scene.
  104156. * @returns the new sound clone
  104157. */
  104158. clone(): Nullable<Sound>;
  104159. /**
  104160. * Gets the current underlying audio buffer containing the data
  104161. * @returns the audio buffer
  104162. */
  104163. getAudioBuffer(): Nullable<AudioBuffer>;
  104164. /**
  104165. * Serializes the Sound in a JSON representation
  104166. * @returns the JSON representation of the sound
  104167. */
  104168. serialize(): any;
  104169. /**
  104170. * Parse a JSON representation of a sound to innstantiate in a given scene
  104171. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  104172. * @param scene Define the scene the new parsed sound should be created in
  104173. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  104174. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  104175. * @returns the newly parsed sound
  104176. */
  104177. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  104178. }
  104179. }
  104180. declare module BABYLON {
  104181. /**
  104182. * This defines an action helpful to play a defined sound on a triggered action.
  104183. */
  104184. export class PlaySoundAction extends Action {
  104185. private _sound;
  104186. /**
  104187. * Instantiate the action
  104188. * @param triggerOptions defines the trigger options
  104189. * @param sound defines the sound to play
  104190. * @param condition defines the trigger related conditions
  104191. */
  104192. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  104193. /** @hidden */
  104194. _prepare(): void;
  104195. /**
  104196. * Execute the action and play the sound.
  104197. */
  104198. execute(): void;
  104199. /**
  104200. * Serializes the actions and its related information.
  104201. * @param parent defines the object to serialize in
  104202. * @returns the serialized object
  104203. */
  104204. serialize(parent: any): any;
  104205. }
  104206. /**
  104207. * This defines an action helpful to stop a defined sound on a triggered action.
  104208. */
  104209. export class StopSoundAction extends Action {
  104210. private _sound;
  104211. /**
  104212. * Instantiate the action
  104213. * @param triggerOptions defines the trigger options
  104214. * @param sound defines the sound to stop
  104215. * @param condition defines the trigger related conditions
  104216. */
  104217. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  104218. /** @hidden */
  104219. _prepare(): void;
  104220. /**
  104221. * Execute the action and stop the sound.
  104222. */
  104223. execute(): void;
  104224. /**
  104225. * Serializes the actions and its related information.
  104226. * @param parent defines the object to serialize in
  104227. * @returns the serialized object
  104228. */
  104229. serialize(parent: any): any;
  104230. }
  104231. }
  104232. declare module BABYLON {
  104233. /**
  104234. * This defines an action responsible to change the value of a property
  104235. * by interpolating between its current value and the newly set one once triggered.
  104236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  104237. */
  104238. export class InterpolateValueAction extends Action {
  104239. /**
  104240. * Defines the path of the property where the value should be interpolated
  104241. */
  104242. propertyPath: string;
  104243. /**
  104244. * Defines the target value at the end of the interpolation.
  104245. */
  104246. value: any;
  104247. /**
  104248. * Defines the time it will take for the property to interpolate to the value.
  104249. */
  104250. duration: number;
  104251. /**
  104252. * Defines if the other scene animations should be stopped when the action has been triggered
  104253. */
  104254. stopOtherAnimations?: boolean;
  104255. /**
  104256. * Defines a callback raised once the interpolation animation has been done.
  104257. */
  104258. onInterpolationDone?: () => void;
  104259. /**
  104260. * Observable triggered once the interpolation animation has been done.
  104261. */
  104262. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  104263. private _target;
  104264. private _effectiveTarget;
  104265. private _property;
  104266. /**
  104267. * Instantiate the action
  104268. * @param triggerOptions defines the trigger options
  104269. * @param target defines the object containing the value to interpolate
  104270. * @param propertyPath defines the path to the property in the target object
  104271. * @param value defines the target value at the end of the interpolation
  104272. * @param duration deines the time it will take for the property to interpolate to the value.
  104273. * @param condition defines the trigger related conditions
  104274. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  104275. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  104276. */
  104277. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  104278. /** @hidden */
  104279. _prepare(): void;
  104280. /**
  104281. * Execute the action starts the value interpolation.
  104282. */
  104283. execute(): void;
  104284. /**
  104285. * Serializes the actions and its related information.
  104286. * @param parent defines the object to serialize in
  104287. * @returns the serialized object
  104288. */
  104289. serialize(parent: any): any;
  104290. }
  104291. }
  104292. declare module BABYLON {
  104293. /**
  104294. * Options allowed during the creation of a sound track.
  104295. */
  104296. export interface ISoundTrackOptions {
  104297. /**
  104298. * The volume the sound track should take during creation
  104299. */
  104300. volume?: number;
  104301. /**
  104302. * Define if the sound track is the main sound track of the scene
  104303. */
  104304. mainTrack?: boolean;
  104305. }
  104306. /**
  104307. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  104308. * It will be also used in a future release to apply effects on a specific track.
  104309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104310. */
  104311. export class SoundTrack {
  104312. /**
  104313. * The unique identifier of the sound track in the scene.
  104314. */
  104315. id: number;
  104316. /**
  104317. * The list of sounds included in the sound track.
  104318. */
  104319. soundCollection: Array<Sound>;
  104320. private _outputAudioNode;
  104321. private _scene;
  104322. private _connectedAnalyser;
  104323. private _options;
  104324. private _isInitialized;
  104325. /**
  104326. * Creates a new sound track.
  104327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  104328. * @param scene Define the scene the sound track belongs to
  104329. * @param options
  104330. */
  104331. constructor(scene: Scene, options?: ISoundTrackOptions);
  104332. private _initializeSoundTrackAudioGraph;
  104333. /**
  104334. * Release the sound track and its associated resources
  104335. */
  104336. dispose(): void;
  104337. /**
  104338. * Adds a sound to this sound track
  104339. * @param sound define the cound to add
  104340. * @ignoreNaming
  104341. */
  104342. AddSound(sound: Sound): void;
  104343. /**
  104344. * Removes a sound to this sound track
  104345. * @param sound define the cound to remove
  104346. * @ignoreNaming
  104347. */
  104348. RemoveSound(sound: Sound): void;
  104349. /**
  104350. * Set a global volume for the full sound track.
  104351. * @param newVolume Define the new volume of the sound track
  104352. */
  104353. setVolume(newVolume: number): void;
  104354. /**
  104355. * Switch the panning model to HRTF:
  104356. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  104357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104358. */
  104359. switchPanningModelToHRTF(): void;
  104360. /**
  104361. * Switch the panning model to Equal Power:
  104362. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  104363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  104364. */
  104365. switchPanningModelToEqualPower(): void;
  104366. /**
  104367. * Connect the sound track to an audio analyser allowing some amazing
  104368. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  104369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  104370. * @param analyser The analyser to connect to the engine
  104371. */
  104372. connectToAnalyser(analyser: Analyser): void;
  104373. }
  104374. }
  104375. declare module BABYLON {
  104376. interface AbstractScene {
  104377. /**
  104378. * The list of sounds used in the scene.
  104379. */
  104380. sounds: Nullable<Array<Sound>>;
  104381. }
  104382. interface Scene {
  104383. /**
  104384. * @hidden
  104385. * Backing field
  104386. */
  104387. _mainSoundTrack: SoundTrack;
  104388. /**
  104389. * The main sound track played by the scene.
  104390. * It cotains your primary collection of sounds.
  104391. */
  104392. mainSoundTrack: SoundTrack;
  104393. /**
  104394. * The list of sound tracks added to the scene
  104395. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104396. */
  104397. soundTracks: Nullable<Array<SoundTrack>>;
  104398. /**
  104399. * Gets a sound using a given name
  104400. * @param name defines the name to search for
  104401. * @return the found sound or null if not found at all.
  104402. */
  104403. getSoundByName(name: string): Nullable<Sound>;
  104404. /**
  104405. * Gets or sets if audio support is enabled
  104406. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104407. */
  104408. audioEnabled: boolean;
  104409. /**
  104410. * Gets or sets if audio will be output to headphones
  104411. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104412. */
  104413. headphone: boolean;
  104414. /**
  104415. * Gets or sets custom audio listener position provider
  104416. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104417. */
  104418. audioListenerPositionProvider: Nullable<() => Vector3>;
  104419. /**
  104420. * Gets or sets a refresh rate when using 3D audio positioning
  104421. */
  104422. audioPositioningRefreshRate: number;
  104423. }
  104424. /**
  104425. * Defines the sound scene component responsible to manage any sounds
  104426. * in a given scene.
  104427. */
  104428. export class AudioSceneComponent implements ISceneSerializableComponent {
  104429. /**
  104430. * The component name helpfull to identify the component in the list of scene components.
  104431. */
  104432. readonly name: string;
  104433. /**
  104434. * The scene the component belongs to.
  104435. */
  104436. scene: Scene;
  104437. private _audioEnabled;
  104438. /**
  104439. * Gets whether audio is enabled or not.
  104440. * Please use related enable/disable method to switch state.
  104441. */
  104442. readonly audioEnabled: boolean;
  104443. private _headphone;
  104444. /**
  104445. * Gets whether audio is outputing to headphone or not.
  104446. * Please use the according Switch methods to change output.
  104447. */
  104448. readonly headphone: boolean;
  104449. /**
  104450. * Gets or sets a refresh rate when using 3D audio positioning
  104451. */
  104452. audioPositioningRefreshRate: number;
  104453. private _audioListenerPositionProvider;
  104454. /**
  104455. * Gets the current audio listener position provider
  104456. */
  104457. /**
  104458. * Sets a custom listener position for all sounds in the scene
  104459. * By default, this is the position of the first active camera
  104460. */
  104461. audioListenerPositionProvider: Nullable<() => Vector3>;
  104462. /**
  104463. * Creates a new instance of the component for the given scene
  104464. * @param scene Defines the scene to register the component in
  104465. */
  104466. constructor(scene: Scene);
  104467. /**
  104468. * Registers the component in a given scene
  104469. */
  104470. register(): void;
  104471. /**
  104472. * Rebuilds the elements related to this component in case of
  104473. * context lost for instance.
  104474. */
  104475. rebuild(): void;
  104476. /**
  104477. * Serializes the component data to the specified json object
  104478. * @param serializationObject The object to serialize to
  104479. */
  104480. serialize(serializationObject: any): void;
  104481. /**
  104482. * Adds all the elements from the container to the scene
  104483. * @param container the container holding the elements
  104484. */
  104485. addFromContainer(container: AbstractScene): void;
  104486. /**
  104487. * Removes all the elements in the container from the scene
  104488. * @param container contains the elements to remove
  104489. * @param dispose if the removed element should be disposed (default: false)
  104490. */
  104491. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  104492. /**
  104493. * Disposes the component and the associated ressources.
  104494. */
  104495. dispose(): void;
  104496. /**
  104497. * Disables audio in the associated scene.
  104498. */
  104499. disableAudio(): void;
  104500. /**
  104501. * Enables audio in the associated scene.
  104502. */
  104503. enableAudio(): void;
  104504. /**
  104505. * Switch audio to headphone output.
  104506. */
  104507. switchAudioModeForHeadphones(): void;
  104508. /**
  104509. * Switch audio to normal speakers.
  104510. */
  104511. switchAudioModeForNormalSpeakers(): void;
  104512. private _cachedCameraDirection;
  104513. private _cachedCameraPosition;
  104514. private _lastCheck;
  104515. private _afterRender;
  104516. }
  104517. }
  104518. declare module BABYLON {
  104519. /**
  104520. * Wraps one or more Sound objects and selects one with random weight for playback.
  104521. */
  104522. export class WeightedSound {
  104523. /** When true a Sound will be selected and played when the current playing Sound completes. */
  104524. loop: boolean;
  104525. private _coneInnerAngle;
  104526. private _coneOuterAngle;
  104527. private _volume;
  104528. /** A Sound is currently playing. */
  104529. isPlaying: boolean;
  104530. /** A Sound is currently paused. */
  104531. isPaused: boolean;
  104532. private _sounds;
  104533. private _weights;
  104534. private _currentIndex?;
  104535. /**
  104536. * Creates a new WeightedSound from the list of sounds given.
  104537. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  104538. * @param sounds Array of Sounds that will be selected from.
  104539. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  104540. */
  104541. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  104542. /**
  104543. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  104544. */
  104545. /**
  104546. * The size of cone in degress for a directional sound in which there will be no attenuation.
  104547. */
  104548. directionalConeInnerAngle: number;
  104549. /**
  104550. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104551. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104552. */
  104553. /**
  104554. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  104555. * Listener angles between innerAngle and outerAngle will falloff linearly.
  104556. */
  104557. directionalConeOuterAngle: number;
  104558. /**
  104559. * Playback volume.
  104560. */
  104561. /**
  104562. * Playback volume.
  104563. */
  104564. volume: number;
  104565. private _onended;
  104566. /**
  104567. * Suspend playback
  104568. */
  104569. pause(): void;
  104570. /**
  104571. * Stop playback
  104572. */
  104573. stop(): void;
  104574. /**
  104575. * Start playback.
  104576. * @param startOffset Position the clip head at a specific time in seconds.
  104577. */
  104578. play(startOffset?: number): void;
  104579. }
  104580. }
  104581. declare module BABYLON {
  104582. /**
  104583. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  104584. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  104585. */
  104586. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  104587. /**
  104588. * Gets the name of the behavior.
  104589. */
  104590. readonly name: string;
  104591. /**
  104592. * The easing function used by animations
  104593. */
  104594. static EasingFunction: BackEase;
  104595. /**
  104596. * The easing mode used by animations
  104597. */
  104598. static EasingMode: number;
  104599. /**
  104600. * The duration of the animation, in milliseconds
  104601. */
  104602. transitionDuration: number;
  104603. /**
  104604. * Length of the distance animated by the transition when lower radius is reached
  104605. */
  104606. lowerRadiusTransitionRange: number;
  104607. /**
  104608. * Length of the distance animated by the transition when upper radius is reached
  104609. */
  104610. upperRadiusTransitionRange: number;
  104611. private _autoTransitionRange;
  104612. /**
  104613. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104614. */
  104615. /**
  104616. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  104617. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  104618. */
  104619. autoTransitionRange: boolean;
  104620. private _attachedCamera;
  104621. private _onAfterCheckInputsObserver;
  104622. private _onMeshTargetChangedObserver;
  104623. /**
  104624. * Initializes the behavior.
  104625. */
  104626. init(): void;
  104627. /**
  104628. * Attaches the behavior to its arc rotate camera.
  104629. * @param camera Defines the camera to attach the behavior to
  104630. */
  104631. attach(camera: ArcRotateCamera): void;
  104632. /**
  104633. * Detaches the behavior from its current arc rotate camera.
  104634. */
  104635. detach(): void;
  104636. private _radiusIsAnimating;
  104637. private _radiusBounceTransition;
  104638. private _animatables;
  104639. private _cachedWheelPrecision;
  104640. /**
  104641. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  104642. * @param radiusLimit The limit to check against.
  104643. * @return Bool to indicate if at limit.
  104644. */
  104645. private _isRadiusAtLimit;
  104646. /**
  104647. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  104648. * @param radiusDelta The delta by which to animate to. Can be negative.
  104649. */
  104650. private _applyBoundRadiusAnimation;
  104651. /**
  104652. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  104653. */
  104654. protected _clearAnimationLocks(): void;
  104655. /**
  104656. * Stops and removes all animations that have been applied to the camera
  104657. */
  104658. stopAllAnimations(): void;
  104659. }
  104660. }
  104661. declare module BABYLON {
  104662. /**
  104663. * 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.
  104664. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  104665. */
  104666. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  104667. /**
  104668. * Gets the name of the behavior.
  104669. */
  104670. readonly name: string;
  104671. private _mode;
  104672. private _radiusScale;
  104673. private _positionScale;
  104674. private _defaultElevation;
  104675. private _elevationReturnTime;
  104676. private _elevationReturnWaitTime;
  104677. private _zoomStopsAnimation;
  104678. private _framingTime;
  104679. /**
  104680. * The easing function used by animations
  104681. */
  104682. static EasingFunction: ExponentialEase;
  104683. /**
  104684. * The easing mode used by animations
  104685. */
  104686. static EasingMode: number;
  104687. /**
  104688. * Sets the current mode used by the behavior
  104689. */
  104690. /**
  104691. * Gets current mode used by the behavior.
  104692. */
  104693. mode: number;
  104694. /**
  104695. * Sets the scale applied to the radius (1 by default)
  104696. */
  104697. /**
  104698. * Gets the scale applied to the radius
  104699. */
  104700. radiusScale: number;
  104701. /**
  104702. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104703. */
  104704. /**
  104705. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  104706. */
  104707. positionScale: number;
  104708. /**
  104709. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104710. * behaviour is triggered, in radians.
  104711. */
  104712. /**
  104713. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  104714. * behaviour is triggered, in radians.
  104715. */
  104716. defaultElevation: number;
  104717. /**
  104718. * Sets the time (in milliseconds) taken to return to the default beta position.
  104719. * Negative value indicates camera should not return to default.
  104720. */
  104721. /**
  104722. * Gets the time (in milliseconds) taken to return to the default beta position.
  104723. * Negative value indicates camera should not return to default.
  104724. */
  104725. elevationReturnTime: number;
  104726. /**
  104727. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104728. */
  104729. /**
  104730. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  104731. */
  104732. elevationReturnWaitTime: number;
  104733. /**
  104734. * Sets the flag that indicates if user zooming should stop animation.
  104735. */
  104736. /**
  104737. * Gets the flag that indicates if user zooming should stop animation.
  104738. */
  104739. zoomStopsAnimation: boolean;
  104740. /**
  104741. * Sets the transition time when framing the mesh, in milliseconds
  104742. */
  104743. /**
  104744. * Gets the transition time when framing the mesh, in milliseconds
  104745. */
  104746. framingTime: number;
  104747. /**
  104748. * Define if the behavior should automatically change the configured
  104749. * camera limits and sensibilities.
  104750. */
  104751. autoCorrectCameraLimitsAndSensibility: boolean;
  104752. private _onPrePointerObservableObserver;
  104753. private _onAfterCheckInputsObserver;
  104754. private _onMeshTargetChangedObserver;
  104755. private _attachedCamera;
  104756. private _isPointerDown;
  104757. private _lastInteractionTime;
  104758. /**
  104759. * Initializes the behavior.
  104760. */
  104761. init(): void;
  104762. /**
  104763. * Attaches the behavior to its arc rotate camera.
  104764. * @param camera Defines the camera to attach the behavior to
  104765. */
  104766. attach(camera: ArcRotateCamera): void;
  104767. /**
  104768. * Detaches the behavior from its current arc rotate camera.
  104769. */
  104770. detach(): void;
  104771. private _animatables;
  104772. private _betaIsAnimating;
  104773. private _betaTransition;
  104774. private _radiusTransition;
  104775. private _vectorTransition;
  104776. /**
  104777. * Targets the given mesh and updates zoom level accordingly.
  104778. * @param mesh The mesh to target.
  104779. * @param radius Optional. If a cached radius position already exists, overrides default.
  104780. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104781. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104782. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104783. */
  104784. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104785. /**
  104786. * Targets the given mesh with its children and updates zoom level accordingly.
  104787. * @param mesh The mesh to target.
  104788. * @param radius Optional. If a cached radius position already exists, overrides default.
  104789. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104790. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104791. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104792. */
  104793. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104794. /**
  104795. * Targets the given meshes with their children and updates zoom level accordingly.
  104796. * @param meshes The mesh to target.
  104797. * @param radius Optional. If a cached radius position already exists, overrides default.
  104798. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  104799. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104800. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104801. */
  104802. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104803. /**
  104804. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  104805. * @param minimumWorld Determines the smaller position of the bounding box extend
  104806. * @param maximumWorld Determines the bigger position of the bounding box extend
  104807. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  104808. * @param onAnimationEnd Callback triggered at the end of the framing animation
  104809. */
  104810. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  104811. /**
  104812. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  104813. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  104814. * frustum width.
  104815. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  104816. * to fully enclose the mesh in the viewing frustum.
  104817. */
  104818. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  104819. /**
  104820. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  104821. * is automatically returned to its default position (expected to be above ground plane).
  104822. */
  104823. private _maintainCameraAboveGround;
  104824. /**
  104825. * Returns the frustum slope based on the canvas ratio and camera FOV
  104826. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  104827. */
  104828. private _getFrustumSlope;
  104829. /**
  104830. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  104831. */
  104832. private _clearAnimationLocks;
  104833. /**
  104834. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  104835. */
  104836. private _applyUserInteraction;
  104837. /**
  104838. * Stops and removes all animations that have been applied to the camera
  104839. */
  104840. stopAllAnimations(): void;
  104841. /**
  104842. * Gets a value indicating if the user is moving the camera
  104843. */
  104844. readonly isUserIsMoving: boolean;
  104845. /**
  104846. * The camera can move all the way towards the mesh.
  104847. */
  104848. static IgnoreBoundsSizeMode: number;
  104849. /**
  104850. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  104851. */
  104852. static FitFrustumSidesMode: number;
  104853. }
  104854. }
  104855. declare module BABYLON {
  104856. /**
  104857. * Base class for Camera Pointer Inputs.
  104858. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  104859. * for example usage.
  104860. */
  104861. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  104862. /**
  104863. * Defines the camera the input is attached to.
  104864. */
  104865. abstract camera: Camera;
  104866. /**
  104867. * Whether keyboard modifier keys are pressed at time of last mouse event.
  104868. */
  104869. protected _altKey: boolean;
  104870. protected _ctrlKey: boolean;
  104871. protected _metaKey: boolean;
  104872. protected _shiftKey: boolean;
  104873. /**
  104874. * Which mouse buttons were pressed at time of last mouse event.
  104875. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  104876. */
  104877. protected _buttonsPressed: number;
  104878. /**
  104879. * Defines the buttons associated with the input to handle camera move.
  104880. */
  104881. buttons: number[];
  104882. /**
  104883. * Attach the input controls to a specific dom element to get the input from.
  104884. * @param element Defines the element the controls should be listened from
  104885. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104886. */
  104887. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104888. /**
  104889. * Detach the current controls from the specified dom element.
  104890. * @param element Defines the element to stop listening the inputs from
  104891. */
  104892. detachControl(element: Nullable<HTMLElement>): void;
  104893. /**
  104894. * Gets the class name of the current input.
  104895. * @returns the class name
  104896. */
  104897. getClassName(): string;
  104898. /**
  104899. * Get the friendly name associated with the input class.
  104900. * @returns the input friendly name
  104901. */
  104902. getSimpleName(): string;
  104903. /**
  104904. * Called on pointer POINTERDOUBLETAP event.
  104905. * Override this method to provide functionality on POINTERDOUBLETAP event.
  104906. */
  104907. protected onDoubleTap(type: string): void;
  104908. /**
  104909. * Called on pointer POINTERMOVE event if only a single touch is active.
  104910. * Override this method to provide functionality.
  104911. */
  104912. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104913. /**
  104914. * Called on pointer POINTERMOVE event if multiple touches are active.
  104915. * Override this method to provide functionality.
  104916. */
  104917. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104918. /**
  104919. * Called on JS contextmenu event.
  104920. * Override this method to provide functionality.
  104921. */
  104922. protected onContextMenu(evt: PointerEvent): void;
  104923. /**
  104924. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  104925. * press.
  104926. * Override this method to provide functionality.
  104927. */
  104928. protected onButtonDown(evt: PointerEvent): void;
  104929. /**
  104930. * Called each time a new POINTERUP event occurs. Ie, for each button
  104931. * release.
  104932. * Override this method to provide functionality.
  104933. */
  104934. protected onButtonUp(evt: PointerEvent): void;
  104935. /**
  104936. * Called when window becomes inactive.
  104937. * Override this method to provide functionality.
  104938. */
  104939. protected onLostFocus(): void;
  104940. private _pointerInput;
  104941. private _observer;
  104942. private _onLostFocus;
  104943. private pointA;
  104944. private pointB;
  104945. }
  104946. }
  104947. declare module BABYLON {
  104948. /**
  104949. * Manage the pointers inputs to control an arc rotate camera.
  104950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104951. */
  104952. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  104953. /**
  104954. * Defines the camera the input is attached to.
  104955. */
  104956. camera: ArcRotateCamera;
  104957. /**
  104958. * Gets the class name of the current input.
  104959. * @returns the class name
  104960. */
  104961. getClassName(): string;
  104962. /**
  104963. * Defines the buttons associated with the input to handle camera move.
  104964. */
  104965. buttons: number[];
  104966. /**
  104967. * Defines the pointer angular sensibility along the X axis or how fast is
  104968. * the camera rotating.
  104969. */
  104970. angularSensibilityX: number;
  104971. /**
  104972. * Defines the pointer angular sensibility along the Y axis or how fast is
  104973. * the camera rotating.
  104974. */
  104975. angularSensibilityY: number;
  104976. /**
  104977. * Defines the pointer pinch precision or how fast is the camera zooming.
  104978. */
  104979. pinchPrecision: number;
  104980. /**
  104981. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104982. * from 0.
  104983. * It defines the percentage of current camera.radius to use as delta when
  104984. * pinch zoom is used.
  104985. */
  104986. pinchDeltaPercentage: number;
  104987. /**
  104988. * Defines the pointer panning sensibility or how fast is the camera moving.
  104989. */
  104990. panningSensibility: number;
  104991. /**
  104992. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  104993. */
  104994. multiTouchPanning: boolean;
  104995. /**
  104996. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  104997. * zoom (pinch) through multitouch.
  104998. */
  104999. multiTouchPanAndZoom: boolean;
  105000. /**
  105001. * Revers pinch action direction.
  105002. */
  105003. pinchInwards: boolean;
  105004. private _isPanClick;
  105005. private _twoFingerActivityCount;
  105006. private _isPinching;
  105007. /**
  105008. * Called on pointer POINTERMOVE event if only a single touch is active.
  105009. */
  105010. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  105011. /**
  105012. * Called on pointer POINTERDOUBLETAP event.
  105013. */
  105014. protected onDoubleTap(type: string): void;
  105015. /**
  105016. * Called on pointer POINTERMOVE event if multiple touches are active.
  105017. */
  105018. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  105019. /**
  105020. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  105021. * press.
  105022. */
  105023. protected onButtonDown(evt: PointerEvent): void;
  105024. /**
  105025. * Called each time a new POINTERUP event occurs. Ie, for each button
  105026. * release.
  105027. */
  105028. protected onButtonUp(evt: PointerEvent): void;
  105029. /**
  105030. * Called when window becomes inactive.
  105031. */
  105032. protected onLostFocus(): void;
  105033. }
  105034. }
  105035. declare module BABYLON {
  105036. /**
  105037. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  105038. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105039. */
  105040. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  105041. /**
  105042. * Defines the camera the input is attached to.
  105043. */
  105044. camera: ArcRotateCamera;
  105045. /**
  105046. * Defines the list of key codes associated with the up action (increase alpha)
  105047. */
  105048. keysUp: number[];
  105049. /**
  105050. * Defines the list of key codes associated with the down action (decrease alpha)
  105051. */
  105052. keysDown: number[];
  105053. /**
  105054. * Defines the list of key codes associated with the left action (increase beta)
  105055. */
  105056. keysLeft: number[];
  105057. /**
  105058. * Defines the list of key codes associated with the right action (decrease beta)
  105059. */
  105060. keysRight: number[];
  105061. /**
  105062. * Defines the list of key codes associated with the reset action.
  105063. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  105064. */
  105065. keysReset: number[];
  105066. /**
  105067. * Defines the panning sensibility of the inputs.
  105068. * (How fast is the camera paning)
  105069. */
  105070. panningSensibility: number;
  105071. /**
  105072. * Defines the zooming sensibility of the inputs.
  105073. * (How fast is the camera zooming)
  105074. */
  105075. zoomingSensibility: number;
  105076. /**
  105077. * Defines wether maintaining the alt key down switch the movement mode from
  105078. * orientation to zoom.
  105079. */
  105080. useAltToZoom: boolean;
  105081. /**
  105082. * Rotation speed of the camera
  105083. */
  105084. angularSpeed: number;
  105085. private _keys;
  105086. private _ctrlPressed;
  105087. private _altPressed;
  105088. private _onCanvasBlurObserver;
  105089. private _onKeyboardObserver;
  105090. private _engine;
  105091. private _scene;
  105092. /**
  105093. * Attach the input controls to a specific dom element to get the input from.
  105094. * @param element Defines the element the controls should be listened from
  105095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105096. */
  105097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105098. /**
  105099. * Detach the current controls from the specified dom element.
  105100. * @param element Defines the element to stop listening the inputs from
  105101. */
  105102. detachControl(element: Nullable<HTMLElement>): void;
  105103. /**
  105104. * Update the current camera state depending on the inputs that have been used this frame.
  105105. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105106. */
  105107. checkInputs(): void;
  105108. /**
  105109. * Gets the class name of the current intput.
  105110. * @returns the class name
  105111. */
  105112. getClassName(): string;
  105113. /**
  105114. * Get the friendly name associated with the input class.
  105115. * @returns the input friendly name
  105116. */
  105117. getSimpleName(): string;
  105118. }
  105119. }
  105120. declare module BABYLON {
  105121. /**
  105122. * Manage the mouse wheel inputs to control an arc rotate camera.
  105123. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105124. */
  105125. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  105126. /**
  105127. * Defines the camera the input is attached to.
  105128. */
  105129. camera: ArcRotateCamera;
  105130. /**
  105131. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  105132. */
  105133. wheelPrecision: number;
  105134. /**
  105135. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  105136. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  105137. */
  105138. wheelDeltaPercentage: number;
  105139. private _wheel;
  105140. private _observer;
  105141. private computeDeltaFromMouseWheelLegacyEvent;
  105142. /**
  105143. * Attach the input controls to a specific dom element to get the input from.
  105144. * @param element Defines the element the controls should be listened from
  105145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105146. */
  105147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105148. /**
  105149. * Detach the current controls from the specified dom element.
  105150. * @param element Defines the element to stop listening the inputs from
  105151. */
  105152. detachControl(element: Nullable<HTMLElement>): void;
  105153. /**
  105154. * Gets the class name of the current intput.
  105155. * @returns the class name
  105156. */
  105157. getClassName(): string;
  105158. /**
  105159. * Get the friendly name associated with the input class.
  105160. * @returns the input friendly name
  105161. */
  105162. getSimpleName(): string;
  105163. }
  105164. }
  105165. declare module BABYLON {
  105166. /**
  105167. * Default Inputs manager for the ArcRotateCamera.
  105168. * It groups all the default supported inputs for ease of use.
  105169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105170. */
  105171. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  105172. /**
  105173. * Instantiates a new ArcRotateCameraInputsManager.
  105174. * @param camera Defines the camera the inputs belong to
  105175. */
  105176. constructor(camera: ArcRotateCamera);
  105177. /**
  105178. * Add mouse wheel input support to the input manager.
  105179. * @returns the current input manager
  105180. */
  105181. addMouseWheel(): ArcRotateCameraInputsManager;
  105182. /**
  105183. * Add pointers input support to the input manager.
  105184. * @returns the current input manager
  105185. */
  105186. addPointers(): ArcRotateCameraInputsManager;
  105187. /**
  105188. * Add keyboard input support to the input manager.
  105189. * @returns the current input manager
  105190. */
  105191. addKeyboard(): ArcRotateCameraInputsManager;
  105192. }
  105193. }
  105194. declare module BABYLON {
  105195. /**
  105196. * This represents an orbital type of camera.
  105197. *
  105198. * 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.
  105199. * 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.
  105200. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  105201. */
  105202. export class ArcRotateCamera extends TargetCamera {
  105203. /**
  105204. * Defines the rotation angle of the camera along the longitudinal axis.
  105205. */
  105206. alpha: number;
  105207. /**
  105208. * Defines the rotation angle of the camera along the latitudinal axis.
  105209. */
  105210. beta: number;
  105211. /**
  105212. * Defines the radius of the camera from it s target point.
  105213. */
  105214. radius: number;
  105215. protected _target: Vector3;
  105216. protected _targetHost: Nullable<AbstractMesh>;
  105217. /**
  105218. * Defines the target point of the camera.
  105219. * The camera looks towards it form the radius distance.
  105220. */
  105221. target: Vector3;
  105222. /**
  105223. * Define the current local position of the camera in the scene
  105224. */
  105225. position: Vector3;
  105226. protected _upVector: Vector3;
  105227. protected _upToYMatrix: Matrix;
  105228. protected _YToUpMatrix: Matrix;
  105229. /**
  105230. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  105231. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  105232. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  105233. */
  105234. upVector: Vector3;
  105235. /**
  105236. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  105237. */
  105238. setMatUp(): void;
  105239. /**
  105240. * Current inertia value on the longitudinal axis.
  105241. * The bigger this number the longer it will take for the camera to stop.
  105242. */
  105243. inertialAlphaOffset: number;
  105244. /**
  105245. * Current inertia value on the latitudinal axis.
  105246. * The bigger this number the longer it will take for the camera to stop.
  105247. */
  105248. inertialBetaOffset: number;
  105249. /**
  105250. * Current inertia value on the radius axis.
  105251. * The bigger this number the longer it will take for the camera to stop.
  105252. */
  105253. inertialRadiusOffset: number;
  105254. /**
  105255. * Minimum allowed angle on the longitudinal axis.
  105256. * This can help limiting how the Camera is able to move in the scene.
  105257. */
  105258. lowerAlphaLimit: Nullable<number>;
  105259. /**
  105260. * Maximum allowed angle on the longitudinal axis.
  105261. * This can help limiting how the Camera is able to move in the scene.
  105262. */
  105263. upperAlphaLimit: Nullable<number>;
  105264. /**
  105265. * Minimum allowed angle on the latitudinal axis.
  105266. * This can help limiting how the Camera is able to move in the scene.
  105267. */
  105268. lowerBetaLimit: number;
  105269. /**
  105270. * Maximum allowed angle on the latitudinal axis.
  105271. * This can help limiting how the Camera is able to move in the scene.
  105272. */
  105273. upperBetaLimit: number;
  105274. /**
  105275. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  105276. * This can help limiting how the Camera is able to move in the scene.
  105277. */
  105278. lowerRadiusLimit: Nullable<number>;
  105279. /**
  105280. * Maximum allowed distance of the camera to the target (The camera can not get further).
  105281. * This can help limiting how the Camera is able to move in the scene.
  105282. */
  105283. upperRadiusLimit: Nullable<number>;
  105284. /**
  105285. * Defines the current inertia value used during panning of the camera along the X axis.
  105286. */
  105287. inertialPanningX: number;
  105288. /**
  105289. * Defines the current inertia value used during panning of the camera along the Y axis.
  105290. */
  105291. inertialPanningY: number;
  105292. /**
  105293. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  105294. * Basically if your fingers moves away from more than this distance you will be considered
  105295. * in pinch mode.
  105296. */
  105297. pinchToPanMaxDistance: number;
  105298. /**
  105299. * Defines the maximum distance the camera can pan.
  105300. * This could help keeping the cammera always in your scene.
  105301. */
  105302. panningDistanceLimit: Nullable<number>;
  105303. /**
  105304. * Defines the target of the camera before paning.
  105305. */
  105306. panningOriginTarget: Vector3;
  105307. /**
  105308. * Defines the value of the inertia used during panning.
  105309. * 0 would mean stop inertia and one would mean no decelleration at all.
  105310. */
  105311. panningInertia: number;
  105312. /**
  105313. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  105314. */
  105315. angularSensibilityX: number;
  105316. /**
  105317. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  105318. */
  105319. angularSensibilityY: number;
  105320. /**
  105321. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  105322. */
  105323. pinchPrecision: number;
  105324. /**
  105325. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  105326. * It will be used instead of pinchDeltaPrecision if different from 0.
  105327. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105328. */
  105329. pinchDeltaPercentage: number;
  105330. /**
  105331. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  105332. */
  105333. panningSensibility: number;
  105334. /**
  105335. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  105336. */
  105337. keysUp: number[];
  105338. /**
  105339. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  105340. */
  105341. keysDown: number[];
  105342. /**
  105343. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  105344. */
  105345. keysLeft: number[];
  105346. /**
  105347. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  105348. */
  105349. keysRight: number[];
  105350. /**
  105351. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  105352. */
  105353. wheelPrecision: number;
  105354. /**
  105355. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  105356. * It will be used instead of pinchDeltaPrecision if different from 0.
  105357. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  105358. */
  105359. wheelDeltaPercentage: number;
  105360. /**
  105361. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  105362. */
  105363. zoomOnFactor: number;
  105364. /**
  105365. * Defines a screen offset for the camera position.
  105366. */
  105367. targetScreenOffset: Vector2;
  105368. /**
  105369. * Allows the camera to be completely reversed.
  105370. * If false the camera can not arrive upside down.
  105371. */
  105372. allowUpsideDown: boolean;
  105373. /**
  105374. * Define if double tap/click is used to restore the previously saved state of the camera.
  105375. */
  105376. useInputToRestoreState: boolean;
  105377. /** @hidden */
  105378. _viewMatrix: Matrix;
  105379. /** @hidden */
  105380. _useCtrlForPanning: boolean;
  105381. /** @hidden */
  105382. _panningMouseButton: number;
  105383. /**
  105384. * Defines the input associated to the camera.
  105385. */
  105386. inputs: ArcRotateCameraInputsManager;
  105387. /** @hidden */
  105388. _reset: () => void;
  105389. /**
  105390. * Defines the allowed panning axis.
  105391. */
  105392. panningAxis: Vector3;
  105393. protected _localDirection: Vector3;
  105394. protected _transformedDirection: Vector3;
  105395. private _bouncingBehavior;
  105396. /**
  105397. * Gets the bouncing behavior of the camera if it has been enabled.
  105398. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105399. */
  105400. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  105401. /**
  105402. * Defines if the bouncing behavior of the camera is enabled on the camera.
  105403. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  105404. */
  105405. useBouncingBehavior: boolean;
  105406. private _framingBehavior;
  105407. /**
  105408. * Gets the framing behavior of the camera if it has been enabled.
  105409. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105410. */
  105411. readonly framingBehavior: Nullable<FramingBehavior>;
  105412. /**
  105413. * Defines if the framing behavior of the camera is enabled on the camera.
  105414. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  105415. */
  105416. useFramingBehavior: boolean;
  105417. private _autoRotationBehavior;
  105418. /**
  105419. * Gets the auto rotation behavior of the camera if it has been enabled.
  105420. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105421. */
  105422. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  105423. /**
  105424. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  105425. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105426. */
  105427. useAutoRotationBehavior: boolean;
  105428. /**
  105429. * Observable triggered when the mesh target has been changed on the camera.
  105430. */
  105431. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  105432. /**
  105433. * Event raised when the camera is colliding with a mesh.
  105434. */
  105435. onCollide: (collidedMesh: AbstractMesh) => void;
  105436. /**
  105437. * Defines whether the camera should check collision with the objects oh the scene.
  105438. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  105439. */
  105440. checkCollisions: boolean;
  105441. /**
  105442. * Defines the collision radius of the camera.
  105443. * This simulates a sphere around the camera.
  105444. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105445. */
  105446. collisionRadius: Vector3;
  105447. protected _collider: Collider;
  105448. protected _previousPosition: Vector3;
  105449. protected _collisionVelocity: Vector3;
  105450. protected _newPosition: Vector3;
  105451. protected _previousAlpha: number;
  105452. protected _previousBeta: number;
  105453. protected _previousRadius: number;
  105454. protected _collisionTriggered: boolean;
  105455. protected _targetBoundingCenter: Nullable<Vector3>;
  105456. private _computationVector;
  105457. /**
  105458. * Instantiates a new ArcRotateCamera in a given scene
  105459. * @param name Defines the name of the camera
  105460. * @param alpha Defines the camera rotation along the logitudinal axis
  105461. * @param beta Defines the camera rotation along the latitudinal axis
  105462. * @param radius Defines the camera distance from its target
  105463. * @param target Defines the camera target
  105464. * @param scene Defines the scene the camera belongs to
  105465. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  105466. */
  105467. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105468. /** @hidden */
  105469. _initCache(): void;
  105470. /** @hidden */
  105471. _updateCache(ignoreParentClass?: boolean): void;
  105472. protected _getTargetPosition(): Vector3;
  105473. private _storedAlpha;
  105474. private _storedBeta;
  105475. private _storedRadius;
  105476. private _storedTarget;
  105477. private _storedTargetScreenOffset;
  105478. /**
  105479. * Stores the current state of the camera (alpha, beta, radius and target)
  105480. * @returns the camera itself
  105481. */
  105482. storeState(): Camera;
  105483. /**
  105484. * @hidden
  105485. * Restored camera state. You must call storeState() first
  105486. */
  105487. _restoreStateValues(): boolean;
  105488. /** @hidden */
  105489. _isSynchronizedViewMatrix(): boolean;
  105490. /**
  105491. * Attached controls to the current camera.
  105492. * @param element Defines the element the controls should be listened from
  105493. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105494. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  105495. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  105496. */
  105497. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  105498. /**
  105499. * Detach the current controls from the camera.
  105500. * The camera will stop reacting to inputs.
  105501. * @param element Defines the element to stop listening the inputs from
  105502. */
  105503. detachControl(element: HTMLElement): void;
  105504. /** @hidden */
  105505. _checkInputs(): void;
  105506. protected _checkLimits(): void;
  105507. /**
  105508. * Rebuilds angles (alpha, beta) and radius from the give position and target
  105509. */
  105510. rebuildAnglesAndRadius(): void;
  105511. /**
  105512. * Use a position to define the current camera related information like alpha, beta and radius
  105513. * @param position Defines the position to set the camera at
  105514. */
  105515. setPosition(position: Vector3): void;
  105516. /**
  105517. * Defines the target the camera should look at.
  105518. * This will automatically adapt alpha beta and radius to fit within the new target.
  105519. * @param target Defines the new target as a Vector or a mesh
  105520. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  105521. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  105522. */
  105523. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  105524. /** @hidden */
  105525. _getViewMatrix(): Matrix;
  105526. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  105527. /**
  105528. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  105529. * @param meshes Defines the mesh to zoom on
  105530. * @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)
  105531. */
  105532. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  105533. /**
  105534. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  105535. * The target will be changed but the radius
  105536. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  105537. * @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)
  105538. */
  105539. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  105540. min: Vector3;
  105541. max: Vector3;
  105542. distance: number;
  105543. }, doNotUpdateMaxZ?: boolean): void;
  105544. /**
  105545. * @override
  105546. * Override Camera.createRigCamera
  105547. */
  105548. createRigCamera(name: string, cameraIndex: number): Camera;
  105549. /**
  105550. * @hidden
  105551. * @override
  105552. * Override Camera._updateRigCameras
  105553. */
  105554. _updateRigCameras(): void;
  105555. /**
  105556. * Destroy the camera and release the current resources hold by it.
  105557. */
  105558. dispose(): void;
  105559. /**
  105560. * Gets the current object class name.
  105561. * @return the class name
  105562. */
  105563. getClassName(): string;
  105564. }
  105565. }
  105566. declare module BABYLON {
  105567. /**
  105568. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  105569. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  105570. */
  105571. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  105572. /**
  105573. * Gets the name of the behavior.
  105574. */
  105575. readonly name: string;
  105576. private _zoomStopsAnimation;
  105577. private _idleRotationSpeed;
  105578. private _idleRotationWaitTime;
  105579. private _idleRotationSpinupTime;
  105580. /**
  105581. * Sets the flag that indicates if user zooming should stop animation.
  105582. */
  105583. /**
  105584. * Gets the flag that indicates if user zooming should stop animation.
  105585. */
  105586. zoomStopsAnimation: boolean;
  105587. /**
  105588. * Sets the default speed at which the camera rotates around the model.
  105589. */
  105590. /**
  105591. * Gets the default speed at which the camera rotates around the model.
  105592. */
  105593. idleRotationSpeed: number;
  105594. /**
  105595. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  105596. */
  105597. /**
  105598. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  105599. */
  105600. idleRotationWaitTime: number;
  105601. /**
  105602. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105603. */
  105604. /**
  105605. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  105606. */
  105607. idleRotationSpinupTime: number;
  105608. /**
  105609. * Gets a value indicating if the camera is currently rotating because of this behavior
  105610. */
  105611. readonly rotationInProgress: boolean;
  105612. private _onPrePointerObservableObserver;
  105613. private _onAfterCheckInputsObserver;
  105614. private _attachedCamera;
  105615. private _isPointerDown;
  105616. private _lastFrameTime;
  105617. private _lastInteractionTime;
  105618. private _cameraRotationSpeed;
  105619. /**
  105620. * Initializes the behavior.
  105621. */
  105622. init(): void;
  105623. /**
  105624. * Attaches the behavior to its arc rotate camera.
  105625. * @param camera Defines the camera to attach the behavior to
  105626. */
  105627. attach(camera: ArcRotateCamera): void;
  105628. /**
  105629. * Detaches the behavior from its current arc rotate camera.
  105630. */
  105631. detach(): void;
  105632. /**
  105633. * Returns true if user is scrolling.
  105634. * @return true if user is scrolling.
  105635. */
  105636. private _userIsZooming;
  105637. private _lastFrameRadius;
  105638. private _shouldAnimationStopForInteraction;
  105639. /**
  105640. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  105641. */
  105642. private _applyUserInteraction;
  105643. private _userIsMoving;
  105644. }
  105645. }
  105646. declare module BABYLON {
  105647. /**
  105648. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  105649. */
  105650. export class AttachToBoxBehavior implements Behavior<Mesh> {
  105651. private ui;
  105652. /**
  105653. * The name of the behavior
  105654. */
  105655. name: string;
  105656. /**
  105657. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  105658. */
  105659. distanceAwayFromFace: number;
  105660. /**
  105661. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  105662. */
  105663. distanceAwayFromBottomOfFace: number;
  105664. private _faceVectors;
  105665. private _target;
  105666. private _scene;
  105667. private _onRenderObserver;
  105668. private _tmpMatrix;
  105669. private _tmpVector;
  105670. /**
  105671. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  105672. * @param ui The transform node that should be attched to the mesh
  105673. */
  105674. constructor(ui: TransformNode);
  105675. /**
  105676. * Initializes the behavior
  105677. */
  105678. init(): void;
  105679. private _closestFace;
  105680. private _zeroVector;
  105681. private _lookAtTmpMatrix;
  105682. private _lookAtToRef;
  105683. /**
  105684. * Attaches the AttachToBoxBehavior to the passed in mesh
  105685. * @param target The mesh that the specified node will be attached to
  105686. */
  105687. attach(target: Mesh): void;
  105688. /**
  105689. * Detaches the behavior from the mesh
  105690. */
  105691. detach(): void;
  105692. }
  105693. }
  105694. declare module BABYLON {
  105695. /**
  105696. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  105697. */
  105698. export class FadeInOutBehavior implements Behavior<Mesh> {
  105699. /**
  105700. * Time in milliseconds to delay before fading in (Default: 0)
  105701. */
  105702. delay: number;
  105703. /**
  105704. * Time in milliseconds for the mesh to fade in (Default: 300)
  105705. */
  105706. fadeInTime: number;
  105707. private _millisecondsPerFrame;
  105708. private _hovered;
  105709. private _hoverValue;
  105710. private _ownerNode;
  105711. /**
  105712. * Instatiates the FadeInOutBehavior
  105713. */
  105714. constructor();
  105715. /**
  105716. * The name of the behavior
  105717. */
  105718. readonly name: string;
  105719. /**
  105720. * Initializes the behavior
  105721. */
  105722. init(): void;
  105723. /**
  105724. * Attaches the fade behavior on the passed in mesh
  105725. * @param ownerNode The mesh that will be faded in/out once attached
  105726. */
  105727. attach(ownerNode: Mesh): void;
  105728. /**
  105729. * Detaches the behavior from the mesh
  105730. */
  105731. detach(): void;
  105732. /**
  105733. * Triggers the mesh to begin fading in or out
  105734. * @param value if the object should fade in or out (true to fade in)
  105735. */
  105736. fadeIn(value: boolean): void;
  105737. private _update;
  105738. private _setAllVisibility;
  105739. }
  105740. }
  105741. declare module BABYLON {
  105742. /**
  105743. * Class containing a set of static utilities functions for managing Pivots
  105744. * @hidden
  105745. */
  105746. export class PivotTools {
  105747. private static _PivotCached;
  105748. private static _OldPivotPoint;
  105749. private static _PivotTranslation;
  105750. private static _PivotTmpVector;
  105751. /** @hidden */
  105752. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  105753. /** @hidden */
  105754. static _RestorePivotPoint(mesh: AbstractMesh): void;
  105755. }
  105756. }
  105757. declare module BABYLON {
  105758. /**
  105759. * Class containing static functions to help procedurally build meshes
  105760. */
  105761. export class PlaneBuilder {
  105762. /**
  105763. * Creates a plane mesh
  105764. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  105765. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  105766. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  105767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105770. * @param name defines the name of the mesh
  105771. * @param options defines the options used to create the mesh
  105772. * @param scene defines the hosting scene
  105773. * @returns the plane mesh
  105774. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  105775. */
  105776. static CreatePlane(name: string, options: {
  105777. size?: number;
  105778. width?: number;
  105779. height?: number;
  105780. sideOrientation?: number;
  105781. frontUVs?: Vector4;
  105782. backUVs?: Vector4;
  105783. updatable?: boolean;
  105784. sourcePlane?: Plane;
  105785. }, scene?: Nullable<Scene>): Mesh;
  105786. }
  105787. }
  105788. declare module BABYLON {
  105789. /**
  105790. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  105791. */
  105792. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  105793. private static _AnyMouseID;
  105794. /**
  105795. * Abstract mesh the behavior is set on
  105796. */
  105797. attachedNode: AbstractMesh;
  105798. private _dragPlane;
  105799. private _scene;
  105800. private _pointerObserver;
  105801. private _beforeRenderObserver;
  105802. private static _planeScene;
  105803. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  105804. /**
  105805. * 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)
  105806. */
  105807. maxDragAngle: number;
  105808. /**
  105809. * @hidden
  105810. */
  105811. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  105812. /**
  105813. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  105814. */
  105815. currentDraggingPointerID: number;
  105816. /**
  105817. * The last position where the pointer hit the drag plane in world space
  105818. */
  105819. lastDragPosition: Vector3;
  105820. /**
  105821. * If the behavior is currently in a dragging state
  105822. */
  105823. dragging: boolean;
  105824. /**
  105825. * 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)
  105826. */
  105827. dragDeltaRatio: number;
  105828. /**
  105829. * If the drag plane orientation should be updated during the dragging (Default: true)
  105830. */
  105831. updateDragPlane: boolean;
  105832. private _debugMode;
  105833. private _moving;
  105834. /**
  105835. * Fires each time the attached mesh is dragged with the pointer
  105836. * * delta between last drag position and current drag position in world space
  105837. * * dragDistance along the drag axis
  105838. * * dragPlaneNormal normal of the current drag plane used during the drag
  105839. * * dragPlanePoint in world space where the drag intersects the drag plane
  105840. */
  105841. onDragObservable: Observable<{
  105842. delta: Vector3;
  105843. dragPlanePoint: Vector3;
  105844. dragPlaneNormal: Vector3;
  105845. dragDistance: number;
  105846. pointerId: number;
  105847. }>;
  105848. /**
  105849. * Fires each time a drag begins (eg. mouse down on mesh)
  105850. */
  105851. onDragStartObservable: Observable<{
  105852. dragPlanePoint: Vector3;
  105853. pointerId: number;
  105854. }>;
  105855. /**
  105856. * Fires each time a drag ends (eg. mouse release after drag)
  105857. */
  105858. onDragEndObservable: Observable<{
  105859. dragPlanePoint: Vector3;
  105860. pointerId: number;
  105861. }>;
  105862. /**
  105863. * If the attached mesh should be moved when dragged
  105864. */
  105865. moveAttached: boolean;
  105866. /**
  105867. * If the drag behavior will react to drag events (Default: true)
  105868. */
  105869. enabled: boolean;
  105870. /**
  105871. * If pointer events should start and release the drag (Default: true)
  105872. */
  105873. startAndReleaseDragOnPointerEvents: boolean;
  105874. /**
  105875. * If camera controls should be detached during the drag
  105876. */
  105877. detachCameraControls: boolean;
  105878. /**
  105879. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  105880. */
  105881. useObjectOrienationForDragging: boolean;
  105882. private _options;
  105883. /**
  105884. * Creates a pointer drag behavior that can be attached to a mesh
  105885. * @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)
  105886. */
  105887. constructor(options?: {
  105888. dragAxis?: Vector3;
  105889. dragPlaneNormal?: Vector3;
  105890. });
  105891. /**
  105892. * Predicate to determine if it is valid to move the object to a new position when it is moved
  105893. */
  105894. validateDrag: (targetPosition: Vector3) => boolean;
  105895. /**
  105896. * The name of the behavior
  105897. */
  105898. readonly name: string;
  105899. /**
  105900. * Initializes the behavior
  105901. */
  105902. init(): void;
  105903. private _tmpVector;
  105904. private _alternatePickedPoint;
  105905. private _worldDragAxis;
  105906. private _targetPosition;
  105907. private _attachedElement;
  105908. /**
  105909. * Attaches the drag behavior the passed in mesh
  105910. * @param ownerNode The mesh that will be dragged around once attached
  105911. * @param predicate Predicate to use for pick filtering
  105912. */
  105913. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  105914. /**
  105915. * Force relase the drag action by code.
  105916. */
  105917. releaseDrag(): void;
  105918. private _startDragRay;
  105919. private _lastPointerRay;
  105920. /**
  105921. * Simulates the start of a pointer drag event on the behavior
  105922. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  105923. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  105924. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  105925. */
  105926. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  105927. private _startDrag;
  105928. private _dragDelta;
  105929. private _moveDrag;
  105930. private _pickWithRayOnDragPlane;
  105931. private _pointA;
  105932. private _pointB;
  105933. private _pointC;
  105934. private _lineA;
  105935. private _lineB;
  105936. private _localAxis;
  105937. private _lookAt;
  105938. private _updateDragPlanePosition;
  105939. /**
  105940. * Detaches the behavior from the mesh
  105941. */
  105942. detach(): void;
  105943. }
  105944. }
  105945. declare module BABYLON {
  105946. /**
  105947. * A behavior that when attached to a mesh will allow the mesh to be scaled
  105948. */
  105949. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  105950. private _dragBehaviorA;
  105951. private _dragBehaviorB;
  105952. private _startDistance;
  105953. private _initialScale;
  105954. private _targetScale;
  105955. private _ownerNode;
  105956. private _sceneRenderObserver;
  105957. /**
  105958. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  105959. */
  105960. constructor();
  105961. /**
  105962. * The name of the behavior
  105963. */
  105964. readonly name: string;
  105965. /**
  105966. * Initializes the behavior
  105967. */
  105968. init(): void;
  105969. private _getCurrentDistance;
  105970. /**
  105971. * Attaches the scale behavior the passed in mesh
  105972. * @param ownerNode The mesh that will be scaled around once attached
  105973. */
  105974. attach(ownerNode: Mesh): void;
  105975. /**
  105976. * Detaches the behavior from the mesh
  105977. */
  105978. detach(): void;
  105979. }
  105980. }
  105981. declare module BABYLON {
  105982. /**
  105983. * 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
  105984. */
  105985. export class SixDofDragBehavior implements Behavior<Mesh> {
  105986. private static _virtualScene;
  105987. private _ownerNode;
  105988. private _sceneRenderObserver;
  105989. private _scene;
  105990. private _targetPosition;
  105991. private _virtualOriginMesh;
  105992. private _virtualDragMesh;
  105993. private _pointerObserver;
  105994. private _moving;
  105995. private _startingOrientation;
  105996. /**
  105997. * 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)
  105998. */
  105999. private zDragFactor;
  106000. /**
  106001. * If the object should rotate to face the drag origin
  106002. */
  106003. rotateDraggedObject: boolean;
  106004. /**
  106005. * If the behavior is currently in a dragging state
  106006. */
  106007. dragging: boolean;
  106008. /**
  106009. * 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)
  106010. */
  106011. dragDeltaRatio: number;
  106012. /**
  106013. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  106014. */
  106015. currentDraggingPointerID: number;
  106016. /**
  106017. * If camera controls should be detached during the drag
  106018. */
  106019. detachCameraControls: boolean;
  106020. /**
  106021. * Fires each time a drag starts
  106022. */
  106023. onDragStartObservable: Observable<{}>;
  106024. /**
  106025. * Fires each time a drag ends (eg. mouse release after drag)
  106026. */
  106027. onDragEndObservable: Observable<{}>;
  106028. /**
  106029. * 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
  106030. */
  106031. constructor();
  106032. /**
  106033. * The name of the behavior
  106034. */
  106035. readonly name: string;
  106036. /**
  106037. * Initializes the behavior
  106038. */
  106039. init(): void;
  106040. /**
  106041. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  106042. */
  106043. private readonly _pointerCamera;
  106044. /**
  106045. * Attaches the scale behavior the passed in mesh
  106046. * @param ownerNode The mesh that will be scaled around once attached
  106047. */
  106048. attach(ownerNode: Mesh): void;
  106049. /**
  106050. * Detaches the behavior from the mesh
  106051. */
  106052. detach(): void;
  106053. }
  106054. }
  106055. declare module BABYLON {
  106056. /**
  106057. * Class used to apply inverse kinematics to bones
  106058. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  106059. */
  106060. export class BoneIKController {
  106061. private static _tmpVecs;
  106062. private static _tmpQuat;
  106063. private static _tmpMats;
  106064. /**
  106065. * Gets or sets the target mesh
  106066. */
  106067. targetMesh: AbstractMesh;
  106068. /** Gets or sets the mesh used as pole */
  106069. poleTargetMesh: AbstractMesh;
  106070. /**
  106071. * Gets or sets the bone used as pole
  106072. */
  106073. poleTargetBone: Nullable<Bone>;
  106074. /**
  106075. * Gets or sets the target position
  106076. */
  106077. targetPosition: Vector3;
  106078. /**
  106079. * Gets or sets the pole target position
  106080. */
  106081. poleTargetPosition: Vector3;
  106082. /**
  106083. * Gets or sets the pole target local offset
  106084. */
  106085. poleTargetLocalOffset: Vector3;
  106086. /**
  106087. * Gets or sets the pole angle
  106088. */
  106089. poleAngle: number;
  106090. /**
  106091. * Gets or sets the mesh associated with the controller
  106092. */
  106093. mesh: AbstractMesh;
  106094. /**
  106095. * 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)
  106096. */
  106097. slerpAmount: number;
  106098. private _bone1Quat;
  106099. private _bone1Mat;
  106100. private _bone2Ang;
  106101. private _bone1;
  106102. private _bone2;
  106103. private _bone1Length;
  106104. private _bone2Length;
  106105. private _maxAngle;
  106106. private _maxReach;
  106107. private _rightHandedSystem;
  106108. private _bendAxis;
  106109. private _slerping;
  106110. private _adjustRoll;
  106111. /**
  106112. * Gets or sets maximum allowed angle
  106113. */
  106114. maxAngle: number;
  106115. /**
  106116. * Creates a new BoneIKController
  106117. * @param mesh defines the mesh to control
  106118. * @param bone defines the bone to control
  106119. * @param options defines options to set up the controller
  106120. */
  106121. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  106122. targetMesh?: AbstractMesh;
  106123. poleTargetMesh?: AbstractMesh;
  106124. poleTargetBone?: Bone;
  106125. poleTargetLocalOffset?: Vector3;
  106126. poleAngle?: number;
  106127. bendAxis?: Vector3;
  106128. maxAngle?: number;
  106129. slerpAmount?: number;
  106130. });
  106131. private _setMaxAngle;
  106132. /**
  106133. * Force the controller to update the bones
  106134. */
  106135. update(): void;
  106136. }
  106137. }
  106138. declare module BABYLON {
  106139. /**
  106140. * Class used to make a bone look toward a point in space
  106141. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  106142. */
  106143. export class BoneLookController {
  106144. private static _tmpVecs;
  106145. private static _tmpQuat;
  106146. private static _tmpMats;
  106147. /**
  106148. * The target Vector3 that the bone will look at
  106149. */
  106150. target: Vector3;
  106151. /**
  106152. * The mesh that the bone is attached to
  106153. */
  106154. mesh: AbstractMesh;
  106155. /**
  106156. * The bone that will be looking to the target
  106157. */
  106158. bone: Bone;
  106159. /**
  106160. * The up axis of the coordinate system that is used when the bone is rotated
  106161. */
  106162. upAxis: Vector3;
  106163. /**
  106164. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  106165. */
  106166. upAxisSpace: Space;
  106167. /**
  106168. * Used to make an adjustment to the yaw of the bone
  106169. */
  106170. adjustYaw: number;
  106171. /**
  106172. * Used to make an adjustment to the pitch of the bone
  106173. */
  106174. adjustPitch: number;
  106175. /**
  106176. * Used to make an adjustment to the roll of the bone
  106177. */
  106178. adjustRoll: number;
  106179. /**
  106180. * 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)
  106181. */
  106182. slerpAmount: number;
  106183. private _minYaw;
  106184. private _maxYaw;
  106185. private _minPitch;
  106186. private _maxPitch;
  106187. private _minYawSin;
  106188. private _minYawCos;
  106189. private _maxYawSin;
  106190. private _maxYawCos;
  106191. private _midYawConstraint;
  106192. private _minPitchTan;
  106193. private _maxPitchTan;
  106194. private _boneQuat;
  106195. private _slerping;
  106196. private _transformYawPitch;
  106197. private _transformYawPitchInv;
  106198. private _firstFrameSkipped;
  106199. private _yawRange;
  106200. private _fowardAxis;
  106201. /**
  106202. * Gets or sets the minimum yaw angle that the bone can look to
  106203. */
  106204. minYaw: number;
  106205. /**
  106206. * Gets or sets the maximum yaw angle that the bone can look to
  106207. */
  106208. maxYaw: number;
  106209. /**
  106210. * Gets or sets the minimum pitch angle that the bone can look to
  106211. */
  106212. minPitch: number;
  106213. /**
  106214. * Gets or sets the maximum pitch angle that the bone can look to
  106215. */
  106216. maxPitch: number;
  106217. /**
  106218. * Create a BoneLookController
  106219. * @param mesh the mesh that the bone belongs to
  106220. * @param bone the bone that will be looking to the target
  106221. * @param target the target Vector3 to look at
  106222. * @param options optional settings:
  106223. * * maxYaw: the maximum angle the bone will yaw to
  106224. * * minYaw: the minimum angle the bone will yaw to
  106225. * * maxPitch: the maximum angle the bone will pitch to
  106226. * * minPitch: the minimum angle the bone will yaw to
  106227. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  106228. * * upAxis: the up axis of the coordinate system
  106229. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  106230. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  106231. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  106232. * * adjustYaw: used to make an adjustment to the yaw of the bone
  106233. * * adjustPitch: used to make an adjustment to the pitch of the bone
  106234. * * adjustRoll: used to make an adjustment to the roll of the bone
  106235. **/
  106236. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  106237. maxYaw?: number;
  106238. minYaw?: number;
  106239. maxPitch?: number;
  106240. minPitch?: number;
  106241. slerpAmount?: number;
  106242. upAxis?: Vector3;
  106243. upAxisSpace?: Space;
  106244. yawAxis?: Vector3;
  106245. pitchAxis?: Vector3;
  106246. adjustYaw?: number;
  106247. adjustPitch?: number;
  106248. adjustRoll?: number;
  106249. });
  106250. /**
  106251. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  106252. */
  106253. update(): void;
  106254. private _getAngleDiff;
  106255. private _getAngleBetween;
  106256. private _isAngleBetween;
  106257. }
  106258. }
  106259. declare module BABYLON {
  106260. /**
  106261. * Manage the gamepad inputs to control an arc rotate camera.
  106262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106263. */
  106264. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  106265. /**
  106266. * Defines the camera the input is attached to.
  106267. */
  106268. camera: ArcRotateCamera;
  106269. /**
  106270. * Defines the gamepad the input is gathering event from.
  106271. */
  106272. gamepad: Nullable<Gamepad>;
  106273. /**
  106274. * Defines the gamepad rotation sensiblity.
  106275. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106276. */
  106277. gamepadRotationSensibility: number;
  106278. /**
  106279. * Defines the gamepad move sensiblity.
  106280. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106281. */
  106282. gamepadMoveSensibility: number;
  106283. private _yAxisScale;
  106284. /**
  106285. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  106286. */
  106287. invertYAxis: boolean;
  106288. private _onGamepadConnectedObserver;
  106289. private _onGamepadDisconnectedObserver;
  106290. /**
  106291. * Attach the input controls to a specific dom element to get the input from.
  106292. * @param element Defines the element the controls should be listened from
  106293. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106294. */
  106295. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106296. /**
  106297. * Detach the current controls from the specified dom element.
  106298. * @param element Defines the element to stop listening the inputs from
  106299. */
  106300. detachControl(element: Nullable<HTMLElement>): void;
  106301. /**
  106302. * Update the current camera state depending on the inputs that have been used this frame.
  106303. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106304. */
  106305. checkInputs(): void;
  106306. /**
  106307. * Gets the class name of the current intput.
  106308. * @returns the class name
  106309. */
  106310. getClassName(): string;
  106311. /**
  106312. * Get the friendly name associated with the input class.
  106313. * @returns the input friendly name
  106314. */
  106315. getSimpleName(): string;
  106316. }
  106317. }
  106318. declare module BABYLON {
  106319. interface ArcRotateCameraInputsManager {
  106320. /**
  106321. * Add orientation input support to the input manager.
  106322. * @returns the current input manager
  106323. */
  106324. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  106325. }
  106326. /**
  106327. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  106328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106329. */
  106330. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  106331. /**
  106332. * Defines the camera the input is attached to.
  106333. */
  106334. camera: ArcRotateCamera;
  106335. /**
  106336. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  106337. */
  106338. alphaCorrection: number;
  106339. /**
  106340. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  106341. */
  106342. gammaCorrection: number;
  106343. private _alpha;
  106344. private _gamma;
  106345. private _dirty;
  106346. private _deviceOrientationHandler;
  106347. /**
  106348. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  106349. */
  106350. constructor();
  106351. /**
  106352. * Attach the input controls to a specific dom element to get the input from.
  106353. * @param element Defines the element the controls should be listened from
  106354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106355. */
  106356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106357. /** @hidden */
  106358. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  106359. /**
  106360. * Update the current camera state depending on the inputs that have been used this frame.
  106361. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106362. */
  106363. checkInputs(): void;
  106364. /**
  106365. * Detach the current controls from the specified dom element.
  106366. * @param element Defines the element to stop listening the inputs from
  106367. */
  106368. detachControl(element: Nullable<HTMLElement>): void;
  106369. /**
  106370. * Gets the class name of the current intput.
  106371. * @returns the class name
  106372. */
  106373. getClassName(): string;
  106374. /**
  106375. * Get the friendly name associated with the input class.
  106376. * @returns the input friendly name
  106377. */
  106378. getSimpleName(): string;
  106379. }
  106380. }
  106381. declare module BABYLON {
  106382. /**
  106383. * Listen to mouse events to control the camera.
  106384. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106385. */
  106386. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  106387. /**
  106388. * Defines the camera the input is attached to.
  106389. */
  106390. camera: FlyCamera;
  106391. /**
  106392. * Defines if touch is enabled. (Default is true.)
  106393. */
  106394. touchEnabled: boolean;
  106395. /**
  106396. * Defines the buttons associated with the input to handle camera rotation.
  106397. */
  106398. buttons: number[];
  106399. /**
  106400. * Assign buttons for Yaw control.
  106401. */
  106402. buttonsYaw: number[];
  106403. /**
  106404. * Assign buttons for Pitch control.
  106405. */
  106406. buttonsPitch: number[];
  106407. /**
  106408. * Assign buttons for Roll control.
  106409. */
  106410. buttonsRoll: number[];
  106411. /**
  106412. * Detect if any button is being pressed while mouse is moved.
  106413. * -1 = Mouse locked.
  106414. * 0 = Left button.
  106415. * 1 = Middle Button.
  106416. * 2 = Right Button.
  106417. */
  106418. activeButton: number;
  106419. /**
  106420. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  106421. * Higher values reduce its sensitivity.
  106422. */
  106423. angularSensibility: number;
  106424. private _mousemoveCallback;
  106425. private _observer;
  106426. private _rollObserver;
  106427. private previousPosition;
  106428. private noPreventDefault;
  106429. private element;
  106430. /**
  106431. * Listen to mouse events to control the camera.
  106432. * @param touchEnabled Define if touch is enabled. (Default is true.)
  106433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106434. */
  106435. constructor(touchEnabled?: boolean);
  106436. /**
  106437. * Attach the mouse control to the HTML DOM element.
  106438. * @param element Defines the element that listens to the input events.
  106439. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  106440. */
  106441. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106442. /**
  106443. * Detach the current controls from the specified dom element.
  106444. * @param element Defines the element to stop listening the inputs from
  106445. */
  106446. detachControl(element: Nullable<HTMLElement>): void;
  106447. /**
  106448. * Gets the class name of the current input.
  106449. * @returns the class name.
  106450. */
  106451. getClassName(): string;
  106452. /**
  106453. * Get the friendly name associated with the input class.
  106454. * @returns the input's friendly name.
  106455. */
  106456. getSimpleName(): string;
  106457. private _pointerInput;
  106458. private _onMouseMove;
  106459. /**
  106460. * Rotate camera by mouse offset.
  106461. */
  106462. private rotateCamera;
  106463. }
  106464. }
  106465. declare module BABYLON {
  106466. /**
  106467. * Default Inputs manager for the FlyCamera.
  106468. * It groups all the default supported inputs for ease of use.
  106469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106470. */
  106471. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  106472. /**
  106473. * Instantiates a new FlyCameraInputsManager.
  106474. * @param camera Defines the camera the inputs belong to.
  106475. */
  106476. constructor(camera: FlyCamera);
  106477. /**
  106478. * Add keyboard input support to the input manager.
  106479. * @returns the new FlyCameraKeyboardMoveInput().
  106480. */
  106481. addKeyboard(): FlyCameraInputsManager;
  106482. /**
  106483. * Add mouse input support to the input manager.
  106484. * @param touchEnabled Enable touch screen support.
  106485. * @returns the new FlyCameraMouseInput().
  106486. */
  106487. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  106488. }
  106489. }
  106490. declare module BABYLON {
  106491. /**
  106492. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106493. * such as in a 3D Space Shooter or a Flight Simulator.
  106494. */
  106495. export class FlyCamera extends TargetCamera {
  106496. /**
  106497. * Define the collision ellipsoid of the camera.
  106498. * This is helpful for simulating a camera body, like a player's body.
  106499. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  106500. */
  106501. ellipsoid: Vector3;
  106502. /**
  106503. * Define an offset for the position of the ellipsoid around the camera.
  106504. * This can be helpful if the camera is attached away from the player's body center,
  106505. * such as at its head.
  106506. */
  106507. ellipsoidOffset: Vector3;
  106508. /**
  106509. * Enable or disable collisions of the camera with the rest of the scene objects.
  106510. */
  106511. checkCollisions: boolean;
  106512. /**
  106513. * Enable or disable gravity on the camera.
  106514. */
  106515. applyGravity: boolean;
  106516. /**
  106517. * Define the current direction the camera is moving to.
  106518. */
  106519. cameraDirection: Vector3;
  106520. /**
  106521. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  106522. * This overrides and empties cameraRotation.
  106523. */
  106524. rotationQuaternion: Quaternion;
  106525. /**
  106526. * Track Roll to maintain the wanted Rolling when looking around.
  106527. */
  106528. _trackRoll: number;
  106529. /**
  106530. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  106531. */
  106532. rollCorrect: number;
  106533. /**
  106534. * Mimic a banked turn, Rolling the camera when Yawing.
  106535. * It's recommended to use rollCorrect = 10 for faster banking correction.
  106536. */
  106537. bankedTurn: boolean;
  106538. /**
  106539. * Limit in radians for how much Roll banking will add. (Default: 90°)
  106540. */
  106541. bankedTurnLimit: number;
  106542. /**
  106543. * Value of 0 disables the banked Roll.
  106544. * Value of 1 is equal to the Yaw angle in radians.
  106545. */
  106546. bankedTurnMultiplier: number;
  106547. /**
  106548. * The inputs manager loads all the input sources, such as keyboard and mouse.
  106549. */
  106550. inputs: FlyCameraInputsManager;
  106551. /**
  106552. * Gets the input sensibility for mouse input.
  106553. * Higher values reduce sensitivity.
  106554. */
  106555. /**
  106556. * Sets the input sensibility for a mouse input.
  106557. * Higher values reduce sensitivity.
  106558. */
  106559. angularSensibility: number;
  106560. /**
  106561. * Get the keys for camera movement forward.
  106562. */
  106563. /**
  106564. * Set the keys for camera movement forward.
  106565. */
  106566. keysForward: number[];
  106567. /**
  106568. * Get the keys for camera movement backward.
  106569. */
  106570. keysBackward: number[];
  106571. /**
  106572. * Get the keys for camera movement up.
  106573. */
  106574. /**
  106575. * Set the keys for camera movement up.
  106576. */
  106577. keysUp: number[];
  106578. /**
  106579. * Get the keys for camera movement down.
  106580. */
  106581. /**
  106582. * Set the keys for camera movement down.
  106583. */
  106584. keysDown: number[];
  106585. /**
  106586. * Get the keys for camera movement left.
  106587. */
  106588. /**
  106589. * Set the keys for camera movement left.
  106590. */
  106591. keysLeft: number[];
  106592. /**
  106593. * Set the keys for camera movement right.
  106594. */
  106595. /**
  106596. * Set the keys for camera movement right.
  106597. */
  106598. keysRight: number[];
  106599. /**
  106600. * Event raised when the camera collides with a mesh in the scene.
  106601. */
  106602. onCollide: (collidedMesh: AbstractMesh) => void;
  106603. private _collider;
  106604. private _needMoveForGravity;
  106605. private _oldPosition;
  106606. private _diffPosition;
  106607. private _newPosition;
  106608. /** @hidden */
  106609. _localDirection: Vector3;
  106610. /** @hidden */
  106611. _transformedDirection: Vector3;
  106612. /**
  106613. * Instantiates a FlyCamera.
  106614. * This is a flying camera, designed for 3D movement and rotation in all directions,
  106615. * such as in a 3D Space Shooter or a Flight Simulator.
  106616. * @param name Define the name of the camera in the scene.
  106617. * @param position Define the starting position of the camera in the scene.
  106618. * @param scene Define the scene the camera belongs to.
  106619. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  106620. */
  106621. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106622. /**
  106623. * Attach a control to the HTML DOM element.
  106624. * @param element Defines the element that listens to the input events.
  106625. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  106626. */
  106627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106628. /**
  106629. * Detach a control from the HTML DOM element.
  106630. * The camera will stop reacting to that input.
  106631. * @param element Defines the element that listens to the input events.
  106632. */
  106633. detachControl(element: HTMLElement): void;
  106634. private _collisionMask;
  106635. /**
  106636. * Get the mask that the camera ignores in collision events.
  106637. */
  106638. /**
  106639. * Set the mask that the camera ignores in collision events.
  106640. */
  106641. collisionMask: number;
  106642. /** @hidden */
  106643. _collideWithWorld(displacement: Vector3): void;
  106644. /** @hidden */
  106645. private _onCollisionPositionChange;
  106646. /** @hidden */
  106647. _checkInputs(): void;
  106648. /** @hidden */
  106649. _decideIfNeedsToMove(): boolean;
  106650. /** @hidden */
  106651. _updatePosition(): void;
  106652. /**
  106653. * Restore the Roll to its target value at the rate specified.
  106654. * @param rate - Higher means slower restoring.
  106655. * @hidden
  106656. */
  106657. restoreRoll(rate: number): void;
  106658. /**
  106659. * Destroy the camera and release the current resources held by it.
  106660. */
  106661. dispose(): void;
  106662. /**
  106663. * Get the current object class name.
  106664. * @returns the class name.
  106665. */
  106666. getClassName(): string;
  106667. }
  106668. }
  106669. declare module BABYLON {
  106670. /**
  106671. * Listen to keyboard events to control the camera.
  106672. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106673. */
  106674. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  106675. /**
  106676. * Defines the camera the input is attached to.
  106677. */
  106678. camera: FlyCamera;
  106679. /**
  106680. * The list of keyboard keys used to control the forward move of the camera.
  106681. */
  106682. keysForward: number[];
  106683. /**
  106684. * The list of keyboard keys used to control the backward move of the camera.
  106685. */
  106686. keysBackward: number[];
  106687. /**
  106688. * The list of keyboard keys used to control the forward move of the camera.
  106689. */
  106690. keysUp: number[];
  106691. /**
  106692. * The list of keyboard keys used to control the backward move of the camera.
  106693. */
  106694. keysDown: number[];
  106695. /**
  106696. * The list of keyboard keys used to control the right strafe move of the camera.
  106697. */
  106698. keysRight: number[];
  106699. /**
  106700. * The list of keyboard keys used to control the left strafe move of the camera.
  106701. */
  106702. keysLeft: number[];
  106703. private _keys;
  106704. private _onCanvasBlurObserver;
  106705. private _onKeyboardObserver;
  106706. private _engine;
  106707. private _scene;
  106708. /**
  106709. * Attach the input controls to a specific dom element to get the input from.
  106710. * @param element Defines the element the controls should be listened from
  106711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106712. */
  106713. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106714. /**
  106715. * Detach the current controls from the specified dom element.
  106716. * @param element Defines the element to stop listening the inputs from
  106717. */
  106718. detachControl(element: Nullable<HTMLElement>): void;
  106719. /**
  106720. * Gets the class name of the current intput.
  106721. * @returns the class name
  106722. */
  106723. getClassName(): string;
  106724. /** @hidden */
  106725. _onLostFocus(e: FocusEvent): void;
  106726. /**
  106727. * Get the friendly name associated with the input class.
  106728. * @returns the input friendly name
  106729. */
  106730. getSimpleName(): string;
  106731. /**
  106732. * Update the current camera state depending on the inputs that have been used this frame.
  106733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  106734. */
  106735. checkInputs(): void;
  106736. }
  106737. }
  106738. declare module BABYLON {
  106739. /**
  106740. * Manage the mouse wheel inputs to control a follow camera.
  106741. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106742. */
  106743. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  106744. /**
  106745. * Defines the camera the input is attached to.
  106746. */
  106747. camera: FollowCamera;
  106748. /**
  106749. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  106750. */
  106751. axisControlRadius: boolean;
  106752. /**
  106753. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  106754. */
  106755. axisControlHeight: boolean;
  106756. /**
  106757. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  106758. */
  106759. axisControlRotation: boolean;
  106760. /**
  106761. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  106762. * relation to mouseWheel events.
  106763. */
  106764. wheelPrecision: number;
  106765. /**
  106766. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  106767. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  106768. */
  106769. wheelDeltaPercentage: number;
  106770. private _wheel;
  106771. private _observer;
  106772. /**
  106773. * Attach the input controls to a specific dom element to get the input from.
  106774. * @param element Defines the element the controls should be listened from
  106775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106776. */
  106777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106778. /**
  106779. * Detach the current controls from the specified dom element.
  106780. * @param element Defines the element to stop listening the inputs from
  106781. */
  106782. detachControl(element: Nullable<HTMLElement>): void;
  106783. /**
  106784. * Gets the class name of the current intput.
  106785. * @returns the class name
  106786. */
  106787. getClassName(): string;
  106788. /**
  106789. * Get the friendly name associated with the input class.
  106790. * @returns the input friendly name
  106791. */
  106792. getSimpleName(): string;
  106793. }
  106794. }
  106795. declare module BABYLON {
  106796. /**
  106797. * Manage the pointers inputs to control an follow camera.
  106798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106799. */
  106800. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  106801. /**
  106802. * Defines the camera the input is attached to.
  106803. */
  106804. camera: FollowCamera;
  106805. /**
  106806. * Gets the class name of the current input.
  106807. * @returns the class name
  106808. */
  106809. getClassName(): string;
  106810. /**
  106811. * Defines the pointer angular sensibility along the X axis or how fast is
  106812. * the camera rotating.
  106813. * A negative number will reverse the axis direction.
  106814. */
  106815. angularSensibilityX: number;
  106816. /**
  106817. * Defines the pointer angular sensibility along the Y axis or how fast is
  106818. * the camera rotating.
  106819. * A negative number will reverse the axis direction.
  106820. */
  106821. angularSensibilityY: number;
  106822. /**
  106823. * Defines the pointer pinch precision or how fast is the camera zooming.
  106824. * A negative number will reverse the axis direction.
  106825. */
  106826. pinchPrecision: number;
  106827. /**
  106828. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  106829. * from 0.
  106830. * It defines the percentage of current camera.radius to use as delta when
  106831. * pinch zoom is used.
  106832. */
  106833. pinchDeltaPercentage: number;
  106834. /**
  106835. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  106836. */
  106837. axisXControlRadius: boolean;
  106838. /**
  106839. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  106840. */
  106841. axisXControlHeight: boolean;
  106842. /**
  106843. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  106844. */
  106845. axisXControlRotation: boolean;
  106846. /**
  106847. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  106848. */
  106849. axisYControlRadius: boolean;
  106850. /**
  106851. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  106852. */
  106853. axisYControlHeight: boolean;
  106854. /**
  106855. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  106856. */
  106857. axisYControlRotation: boolean;
  106858. /**
  106859. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  106860. */
  106861. axisPinchControlRadius: boolean;
  106862. /**
  106863. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  106864. */
  106865. axisPinchControlHeight: boolean;
  106866. /**
  106867. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  106868. */
  106869. axisPinchControlRotation: boolean;
  106870. /**
  106871. * Log error messages if basic misconfiguration has occurred.
  106872. */
  106873. warningEnable: boolean;
  106874. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  106875. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  106876. private _warningCounter;
  106877. private _warning;
  106878. }
  106879. }
  106880. declare module BABYLON {
  106881. /**
  106882. * Default Inputs manager for the FollowCamera.
  106883. * It groups all the default supported inputs for ease of use.
  106884. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  106885. */
  106886. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  106887. /**
  106888. * Instantiates a new FollowCameraInputsManager.
  106889. * @param camera Defines the camera the inputs belong to
  106890. */
  106891. constructor(camera: FollowCamera);
  106892. /**
  106893. * Add keyboard input support to the input manager.
  106894. * @returns the current input manager
  106895. */
  106896. addKeyboard(): FollowCameraInputsManager;
  106897. /**
  106898. * Add mouse wheel input support to the input manager.
  106899. * @returns the current input manager
  106900. */
  106901. addMouseWheel(): FollowCameraInputsManager;
  106902. /**
  106903. * Add pointers input support to the input manager.
  106904. * @returns the current input manager
  106905. */
  106906. addPointers(): FollowCameraInputsManager;
  106907. /**
  106908. * Add orientation input support to the input manager.
  106909. * @returns the current input manager
  106910. */
  106911. addVRDeviceOrientation(): FollowCameraInputsManager;
  106912. }
  106913. }
  106914. declare module BABYLON {
  106915. /**
  106916. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  106917. * an arc rotate version arcFollowCamera are available.
  106918. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106919. */
  106920. export class FollowCamera extends TargetCamera {
  106921. /**
  106922. * Distance the follow camera should follow an object at
  106923. */
  106924. radius: number;
  106925. /**
  106926. * Minimum allowed distance of the camera to the axis of rotation
  106927. * (The camera can not get closer).
  106928. * This can help limiting how the Camera is able to move in the scene.
  106929. */
  106930. lowerRadiusLimit: Nullable<number>;
  106931. /**
  106932. * Maximum allowed distance of the camera to the axis of rotation
  106933. * (The camera can not get further).
  106934. * This can help limiting how the Camera is able to move in the scene.
  106935. */
  106936. upperRadiusLimit: Nullable<number>;
  106937. /**
  106938. * Define a rotation offset between the camera and the object it follows
  106939. */
  106940. rotationOffset: number;
  106941. /**
  106942. * Minimum allowed angle to camera position relative to target object.
  106943. * This can help limiting how the Camera is able to move in the scene.
  106944. */
  106945. lowerRotationOffsetLimit: Nullable<number>;
  106946. /**
  106947. * Maximum allowed angle to camera position relative to target object.
  106948. * This can help limiting how the Camera is able to move in the scene.
  106949. */
  106950. upperRotationOffsetLimit: Nullable<number>;
  106951. /**
  106952. * Define a height offset between the camera and the object it follows.
  106953. * It can help following an object from the top (like a car chaing a plane)
  106954. */
  106955. heightOffset: number;
  106956. /**
  106957. * Minimum allowed height of camera position relative to target object.
  106958. * This can help limiting how the Camera is able to move in the scene.
  106959. */
  106960. lowerHeightOffsetLimit: Nullable<number>;
  106961. /**
  106962. * Maximum allowed height of camera position relative to target object.
  106963. * This can help limiting how the Camera is able to move in the scene.
  106964. */
  106965. upperHeightOffsetLimit: Nullable<number>;
  106966. /**
  106967. * Define how fast the camera can accelerate to follow it s target.
  106968. */
  106969. cameraAcceleration: number;
  106970. /**
  106971. * Define the speed limit of the camera following an object.
  106972. */
  106973. maxCameraSpeed: number;
  106974. /**
  106975. * Define the target of the camera.
  106976. */
  106977. lockedTarget: Nullable<AbstractMesh>;
  106978. /**
  106979. * Defines the input associated with the camera.
  106980. */
  106981. inputs: FollowCameraInputsManager;
  106982. /**
  106983. * Instantiates the follow camera.
  106984. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  106985. * @param name Define the name of the camera in the scene
  106986. * @param position Define the position of the camera
  106987. * @param scene Define the scene the camera belong to
  106988. * @param lockedTarget Define the target of the camera
  106989. */
  106990. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  106991. private _follow;
  106992. /**
  106993. * Attached controls to the current camera.
  106994. * @param element Defines the element the controls should be listened from
  106995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106996. */
  106997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106998. /**
  106999. * Detach the current controls from the camera.
  107000. * The camera will stop reacting to inputs.
  107001. * @param element Defines the element to stop listening the inputs from
  107002. */
  107003. detachControl(element: HTMLElement): void;
  107004. /** @hidden */
  107005. _checkInputs(): void;
  107006. private _checkLimits;
  107007. /**
  107008. * Gets the camera class name.
  107009. * @returns the class name
  107010. */
  107011. getClassName(): string;
  107012. }
  107013. /**
  107014. * Arc Rotate version of the follow camera.
  107015. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  107016. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  107017. */
  107018. export class ArcFollowCamera extends TargetCamera {
  107019. /** The longitudinal angle of the camera */
  107020. alpha: number;
  107021. /** The latitudinal angle of the camera */
  107022. beta: number;
  107023. /** The radius of the camera from its target */
  107024. radius: number;
  107025. /** Define the camera target (the messh it should follow) */
  107026. target: Nullable<AbstractMesh>;
  107027. private _cartesianCoordinates;
  107028. /**
  107029. * Instantiates a new ArcFollowCamera
  107030. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  107031. * @param name Define the name of the camera
  107032. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  107033. * @param beta Define the rotation angle of the camera around the elevation axis
  107034. * @param radius Define the radius of the camera from its target point
  107035. * @param target Define the target of the camera
  107036. * @param scene Define the scene the camera belongs to
  107037. */
  107038. constructor(name: string,
  107039. /** The longitudinal angle of the camera */
  107040. alpha: number,
  107041. /** The latitudinal angle of the camera */
  107042. beta: number,
  107043. /** The radius of the camera from its target */
  107044. radius: number,
  107045. /** Define the camera target (the messh it should follow) */
  107046. target: Nullable<AbstractMesh>, scene: Scene);
  107047. private _follow;
  107048. /** @hidden */
  107049. _checkInputs(): void;
  107050. /**
  107051. * Returns the class name of the object.
  107052. * It is mostly used internally for serialization purposes.
  107053. */
  107054. getClassName(): string;
  107055. }
  107056. }
  107057. declare module BABYLON {
  107058. /**
  107059. * Manage the keyboard inputs to control the movement of a follow camera.
  107060. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107061. */
  107062. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  107063. /**
  107064. * Defines the camera the input is attached to.
  107065. */
  107066. camera: FollowCamera;
  107067. /**
  107068. * Defines the list of key codes associated with the up action (increase heightOffset)
  107069. */
  107070. keysHeightOffsetIncr: number[];
  107071. /**
  107072. * Defines the list of key codes associated with the down action (decrease heightOffset)
  107073. */
  107074. keysHeightOffsetDecr: number[];
  107075. /**
  107076. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  107077. */
  107078. keysHeightOffsetModifierAlt: boolean;
  107079. /**
  107080. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  107081. */
  107082. keysHeightOffsetModifierCtrl: boolean;
  107083. /**
  107084. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  107085. */
  107086. keysHeightOffsetModifierShift: boolean;
  107087. /**
  107088. * Defines the list of key codes associated with the left action (increase rotationOffset)
  107089. */
  107090. keysRotationOffsetIncr: number[];
  107091. /**
  107092. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  107093. */
  107094. keysRotationOffsetDecr: number[];
  107095. /**
  107096. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  107097. */
  107098. keysRotationOffsetModifierAlt: boolean;
  107099. /**
  107100. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  107101. */
  107102. keysRotationOffsetModifierCtrl: boolean;
  107103. /**
  107104. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  107105. */
  107106. keysRotationOffsetModifierShift: boolean;
  107107. /**
  107108. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  107109. */
  107110. keysRadiusIncr: number[];
  107111. /**
  107112. * Defines the list of key codes associated with the zoom-out action (increase radius)
  107113. */
  107114. keysRadiusDecr: number[];
  107115. /**
  107116. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  107117. */
  107118. keysRadiusModifierAlt: boolean;
  107119. /**
  107120. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  107121. */
  107122. keysRadiusModifierCtrl: boolean;
  107123. /**
  107124. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  107125. */
  107126. keysRadiusModifierShift: boolean;
  107127. /**
  107128. * Defines the rate of change of heightOffset.
  107129. */
  107130. heightSensibility: number;
  107131. /**
  107132. * Defines the rate of change of rotationOffset.
  107133. */
  107134. rotationSensibility: number;
  107135. /**
  107136. * Defines the rate of change of radius.
  107137. */
  107138. radiusSensibility: number;
  107139. private _keys;
  107140. private _ctrlPressed;
  107141. private _altPressed;
  107142. private _shiftPressed;
  107143. private _onCanvasBlurObserver;
  107144. private _onKeyboardObserver;
  107145. private _engine;
  107146. private _scene;
  107147. /**
  107148. * Attach the input controls to a specific dom element to get the input from.
  107149. * @param element Defines the element the controls should be listened from
  107150. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107151. */
  107152. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107153. /**
  107154. * Detach the current controls from the specified dom element.
  107155. * @param element Defines the element to stop listening the inputs from
  107156. */
  107157. detachControl(element: Nullable<HTMLElement>): void;
  107158. /**
  107159. * Update the current camera state depending on the inputs that have been used this frame.
  107160. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107161. */
  107162. checkInputs(): void;
  107163. /**
  107164. * Gets the class name of the current input.
  107165. * @returns the class name
  107166. */
  107167. getClassName(): string;
  107168. /**
  107169. * Get the friendly name associated with the input class.
  107170. * @returns the input friendly name
  107171. */
  107172. getSimpleName(): string;
  107173. /**
  107174. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107175. * allow modification of the heightOffset value.
  107176. */
  107177. private _modifierHeightOffset;
  107178. /**
  107179. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107180. * allow modification of the rotationOffset value.
  107181. */
  107182. private _modifierRotationOffset;
  107183. /**
  107184. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  107185. * allow modification of the radius value.
  107186. */
  107187. private _modifierRadius;
  107188. }
  107189. }
  107190. declare module BABYLON {
  107191. interface FreeCameraInputsManager {
  107192. /**
  107193. * @hidden
  107194. */
  107195. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  107196. /**
  107197. * Add orientation input support to the input manager.
  107198. * @returns the current input manager
  107199. */
  107200. addDeviceOrientation(): FreeCameraInputsManager;
  107201. }
  107202. /**
  107203. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  107204. * Screen rotation is taken into account.
  107205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107206. */
  107207. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  107208. private _camera;
  107209. private _screenOrientationAngle;
  107210. private _constantTranform;
  107211. private _screenQuaternion;
  107212. private _alpha;
  107213. private _beta;
  107214. private _gamma;
  107215. /**
  107216. * Can be used to detect if a device orientation sensor is availible on a device
  107217. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  107218. * @returns a promise that will resolve on orientation change
  107219. */
  107220. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  107221. /**
  107222. * @hidden
  107223. */
  107224. _onDeviceOrientationChangedObservable: Observable<void>;
  107225. /**
  107226. * Instantiates a new input
  107227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107228. */
  107229. constructor();
  107230. /**
  107231. * Define the camera controlled by the input.
  107232. */
  107233. camera: FreeCamera;
  107234. /**
  107235. * Attach the input controls to a specific dom element to get the input from.
  107236. * @param element Defines the element the controls should be listened from
  107237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107238. */
  107239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107240. private _orientationChanged;
  107241. private _deviceOrientation;
  107242. /**
  107243. * Detach the current controls from the specified dom element.
  107244. * @param element Defines the element to stop listening the inputs from
  107245. */
  107246. detachControl(element: Nullable<HTMLElement>): void;
  107247. /**
  107248. * Update the current camera state depending on the inputs that have been used this frame.
  107249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107250. */
  107251. checkInputs(): void;
  107252. /**
  107253. * Gets the class name of the current intput.
  107254. * @returns the class name
  107255. */
  107256. getClassName(): string;
  107257. /**
  107258. * Get the friendly name associated with the input class.
  107259. * @returns the input friendly name
  107260. */
  107261. getSimpleName(): string;
  107262. }
  107263. }
  107264. declare module BABYLON {
  107265. /**
  107266. * Manage the gamepad inputs to control a free camera.
  107267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107268. */
  107269. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  107270. /**
  107271. * Define the camera the input is attached to.
  107272. */
  107273. camera: FreeCamera;
  107274. /**
  107275. * Define the Gamepad controlling the input
  107276. */
  107277. gamepad: Nullable<Gamepad>;
  107278. /**
  107279. * Defines the gamepad rotation sensiblity.
  107280. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  107281. */
  107282. gamepadAngularSensibility: number;
  107283. /**
  107284. * Defines the gamepad move sensiblity.
  107285. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  107286. */
  107287. gamepadMoveSensibility: number;
  107288. private _yAxisScale;
  107289. /**
  107290. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  107291. */
  107292. invertYAxis: boolean;
  107293. private _onGamepadConnectedObserver;
  107294. private _onGamepadDisconnectedObserver;
  107295. private _cameraTransform;
  107296. private _deltaTransform;
  107297. private _vector3;
  107298. private _vector2;
  107299. /**
  107300. * Attach the input controls to a specific dom element to get the input from.
  107301. * @param element Defines the element the controls should be listened from
  107302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107303. */
  107304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107305. /**
  107306. * Detach the current controls from the specified dom element.
  107307. * @param element Defines the element to stop listening the inputs from
  107308. */
  107309. detachControl(element: Nullable<HTMLElement>): void;
  107310. /**
  107311. * Update the current camera state depending on the inputs that have been used this frame.
  107312. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107313. */
  107314. checkInputs(): void;
  107315. /**
  107316. * Gets the class name of the current intput.
  107317. * @returns the class name
  107318. */
  107319. getClassName(): string;
  107320. /**
  107321. * Get the friendly name associated with the input class.
  107322. * @returns the input friendly name
  107323. */
  107324. getSimpleName(): string;
  107325. }
  107326. }
  107327. declare module BABYLON {
  107328. /**
  107329. * Defines the potential axis of a Joystick
  107330. */
  107331. export enum JoystickAxis {
  107332. /** X axis */
  107333. X = 0,
  107334. /** Y axis */
  107335. Y = 1,
  107336. /** Z axis */
  107337. Z = 2
  107338. }
  107339. /**
  107340. * Class used to define virtual joystick (used in touch mode)
  107341. */
  107342. export class VirtualJoystick {
  107343. /**
  107344. * Gets or sets a boolean indicating that left and right values must be inverted
  107345. */
  107346. reverseLeftRight: boolean;
  107347. /**
  107348. * Gets or sets a boolean indicating that up and down values must be inverted
  107349. */
  107350. reverseUpDown: boolean;
  107351. /**
  107352. * Gets the offset value for the position (ie. the change of the position value)
  107353. */
  107354. deltaPosition: Vector3;
  107355. /**
  107356. * Gets a boolean indicating if the virtual joystick was pressed
  107357. */
  107358. pressed: boolean;
  107359. /**
  107360. * Canvas the virtual joystick will render onto, default z-index of this is 5
  107361. */
  107362. static Canvas: Nullable<HTMLCanvasElement>;
  107363. private static _globalJoystickIndex;
  107364. private static vjCanvasContext;
  107365. private static vjCanvasWidth;
  107366. private static vjCanvasHeight;
  107367. private static halfWidth;
  107368. private _action;
  107369. private _axisTargetedByLeftAndRight;
  107370. private _axisTargetedByUpAndDown;
  107371. private _joystickSensibility;
  107372. private _inversedSensibility;
  107373. private _joystickPointerID;
  107374. private _joystickColor;
  107375. private _joystickPointerPos;
  107376. private _joystickPreviousPointerPos;
  107377. private _joystickPointerStartPos;
  107378. private _deltaJoystickVector;
  107379. private _leftJoystick;
  107380. private _touches;
  107381. private _onPointerDownHandlerRef;
  107382. private _onPointerMoveHandlerRef;
  107383. private _onPointerUpHandlerRef;
  107384. private _onResize;
  107385. /**
  107386. * Creates a new virtual joystick
  107387. * @param leftJoystick defines that the joystick is for left hand (false by default)
  107388. */
  107389. constructor(leftJoystick?: boolean);
  107390. /**
  107391. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  107392. * @param newJoystickSensibility defines the new sensibility
  107393. */
  107394. setJoystickSensibility(newJoystickSensibility: number): void;
  107395. private _onPointerDown;
  107396. private _onPointerMove;
  107397. private _onPointerUp;
  107398. /**
  107399. * Change the color of the virtual joystick
  107400. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  107401. */
  107402. setJoystickColor(newColor: string): void;
  107403. /**
  107404. * Defines a callback to call when the joystick is touched
  107405. * @param action defines the callback
  107406. */
  107407. setActionOnTouch(action: () => any): void;
  107408. /**
  107409. * Defines which axis you'd like to control for left & right
  107410. * @param axis defines the axis to use
  107411. */
  107412. setAxisForLeftRight(axis: JoystickAxis): void;
  107413. /**
  107414. * Defines which axis you'd like to control for up & down
  107415. * @param axis defines the axis to use
  107416. */
  107417. setAxisForUpDown(axis: JoystickAxis): void;
  107418. private _drawVirtualJoystick;
  107419. /**
  107420. * Release internal HTML canvas
  107421. */
  107422. releaseCanvas(): void;
  107423. }
  107424. }
  107425. declare module BABYLON {
  107426. interface FreeCameraInputsManager {
  107427. /**
  107428. * Add virtual joystick input support to the input manager.
  107429. * @returns the current input manager
  107430. */
  107431. addVirtualJoystick(): FreeCameraInputsManager;
  107432. }
  107433. /**
  107434. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  107435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  107436. */
  107437. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  107438. /**
  107439. * Defines the camera the input is attached to.
  107440. */
  107441. camera: FreeCamera;
  107442. private _leftjoystick;
  107443. private _rightjoystick;
  107444. /**
  107445. * Gets the left stick of the virtual joystick.
  107446. * @returns The virtual Joystick
  107447. */
  107448. getLeftJoystick(): VirtualJoystick;
  107449. /**
  107450. * Gets the right stick of the virtual joystick.
  107451. * @returns The virtual Joystick
  107452. */
  107453. getRightJoystick(): VirtualJoystick;
  107454. /**
  107455. * Update the current camera state depending on the inputs that have been used this frame.
  107456. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  107457. */
  107458. checkInputs(): void;
  107459. /**
  107460. * Attach the input controls to a specific dom element to get the input from.
  107461. * @param element Defines the element the controls should be listened from
  107462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107463. */
  107464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107465. /**
  107466. * Detach the current controls from the specified dom element.
  107467. * @param element Defines the element to stop listening the inputs from
  107468. */
  107469. detachControl(element: Nullable<HTMLElement>): void;
  107470. /**
  107471. * Gets the class name of the current intput.
  107472. * @returns the class name
  107473. */
  107474. getClassName(): string;
  107475. /**
  107476. * Get the friendly name associated with the input class.
  107477. * @returns the input friendly name
  107478. */
  107479. getSimpleName(): string;
  107480. }
  107481. }
  107482. declare module BABYLON {
  107483. /**
  107484. * This represents a FPS type of camera controlled by touch.
  107485. * This is like a universal camera minus the Gamepad controls.
  107486. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107487. */
  107488. export class TouchCamera extends FreeCamera {
  107489. /**
  107490. * Defines the touch sensibility for rotation.
  107491. * The higher the faster.
  107492. */
  107493. touchAngularSensibility: number;
  107494. /**
  107495. * Defines the touch sensibility for move.
  107496. * The higher the faster.
  107497. */
  107498. touchMoveSensibility: number;
  107499. /**
  107500. * Instantiates a new touch camera.
  107501. * This represents a FPS type of camera controlled by touch.
  107502. * This is like a universal camera minus the Gamepad controls.
  107503. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  107504. * @param name Define the name of the camera in the scene
  107505. * @param position Define the start position of the camera in the scene
  107506. * @param scene Define the scene the camera belongs to
  107507. */
  107508. constructor(name: string, position: Vector3, scene: Scene);
  107509. /**
  107510. * Gets the current object class name.
  107511. * @return the class name
  107512. */
  107513. getClassName(): string;
  107514. /** @hidden */
  107515. _setupInputs(): void;
  107516. }
  107517. }
  107518. declare module BABYLON {
  107519. /**
  107520. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  107521. * being tilted forward or back and left or right.
  107522. */
  107523. export class DeviceOrientationCamera extends FreeCamera {
  107524. private _initialQuaternion;
  107525. private _quaternionCache;
  107526. private _tmpDragQuaternion;
  107527. private _disablePointerInputWhenUsingDeviceOrientation;
  107528. /**
  107529. * Creates a new device orientation camera
  107530. * @param name The name of the camera
  107531. * @param position The start position camera
  107532. * @param scene The scene the camera belongs to
  107533. */
  107534. constructor(name: string, position: Vector3, scene: Scene);
  107535. /**
  107536. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  107537. */
  107538. disablePointerInputWhenUsingDeviceOrientation: boolean;
  107539. private _dragFactor;
  107540. /**
  107541. * Enabled turning on the y axis when the orientation sensor is active
  107542. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  107543. */
  107544. enableHorizontalDragging(dragFactor?: number): void;
  107545. /**
  107546. * Gets the current instance class name ("DeviceOrientationCamera").
  107547. * This helps avoiding instanceof at run time.
  107548. * @returns the class name
  107549. */
  107550. getClassName(): string;
  107551. /**
  107552. * @hidden
  107553. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  107554. */
  107555. _checkInputs(): void;
  107556. /**
  107557. * Reset the camera to its default orientation on the specified axis only.
  107558. * @param axis The axis to reset
  107559. */
  107560. resetToCurrentRotation(axis?: Axis): void;
  107561. }
  107562. }
  107563. declare module BABYLON {
  107564. /**
  107565. * Defines supported buttons for XBox360 compatible gamepads
  107566. */
  107567. export enum Xbox360Button {
  107568. /** A */
  107569. A = 0,
  107570. /** B */
  107571. B = 1,
  107572. /** X */
  107573. X = 2,
  107574. /** Y */
  107575. Y = 3,
  107576. /** Start */
  107577. Start = 4,
  107578. /** Back */
  107579. Back = 5,
  107580. /** Left button */
  107581. LB = 6,
  107582. /** Right button */
  107583. RB = 7,
  107584. /** Left stick */
  107585. LeftStick = 8,
  107586. /** Right stick */
  107587. RightStick = 9
  107588. }
  107589. /** Defines values for XBox360 DPad */
  107590. export enum Xbox360Dpad {
  107591. /** Up */
  107592. Up = 0,
  107593. /** Down */
  107594. Down = 1,
  107595. /** Left */
  107596. Left = 2,
  107597. /** Right */
  107598. Right = 3
  107599. }
  107600. /**
  107601. * Defines a XBox360 gamepad
  107602. */
  107603. export class Xbox360Pad extends Gamepad {
  107604. private _leftTrigger;
  107605. private _rightTrigger;
  107606. private _onlefttriggerchanged;
  107607. private _onrighttriggerchanged;
  107608. private _onbuttondown;
  107609. private _onbuttonup;
  107610. private _ondpaddown;
  107611. private _ondpadup;
  107612. /** Observable raised when a button is pressed */
  107613. onButtonDownObservable: Observable<Xbox360Button>;
  107614. /** Observable raised when a button is released */
  107615. onButtonUpObservable: Observable<Xbox360Button>;
  107616. /** Observable raised when a pad is pressed */
  107617. onPadDownObservable: Observable<Xbox360Dpad>;
  107618. /** Observable raised when a pad is released */
  107619. onPadUpObservable: Observable<Xbox360Dpad>;
  107620. private _buttonA;
  107621. private _buttonB;
  107622. private _buttonX;
  107623. private _buttonY;
  107624. private _buttonBack;
  107625. private _buttonStart;
  107626. private _buttonLB;
  107627. private _buttonRB;
  107628. private _buttonLeftStick;
  107629. private _buttonRightStick;
  107630. private _dPadUp;
  107631. private _dPadDown;
  107632. private _dPadLeft;
  107633. private _dPadRight;
  107634. private _isXboxOnePad;
  107635. /**
  107636. * Creates a new XBox360 gamepad object
  107637. * @param id defines the id of this gamepad
  107638. * @param index defines its index
  107639. * @param gamepad defines the internal HTML gamepad object
  107640. * @param xboxOne defines if it is a XBox One gamepad
  107641. */
  107642. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  107643. /**
  107644. * Defines the callback to call when left trigger is pressed
  107645. * @param callback defines the callback to use
  107646. */
  107647. onlefttriggerchanged(callback: (value: number) => void): void;
  107648. /**
  107649. * Defines the callback to call when right trigger is pressed
  107650. * @param callback defines the callback to use
  107651. */
  107652. onrighttriggerchanged(callback: (value: number) => void): void;
  107653. /**
  107654. * Gets the left trigger value
  107655. */
  107656. /**
  107657. * Sets the left trigger value
  107658. */
  107659. leftTrigger: number;
  107660. /**
  107661. * Gets the right trigger value
  107662. */
  107663. /**
  107664. * Sets the right trigger value
  107665. */
  107666. rightTrigger: number;
  107667. /**
  107668. * Defines the callback to call when a button is pressed
  107669. * @param callback defines the callback to use
  107670. */
  107671. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  107672. /**
  107673. * Defines the callback to call when a button is released
  107674. * @param callback defines the callback to use
  107675. */
  107676. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  107677. /**
  107678. * Defines the callback to call when a pad is pressed
  107679. * @param callback defines the callback to use
  107680. */
  107681. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  107682. /**
  107683. * Defines the callback to call when a pad is released
  107684. * @param callback defines the callback to use
  107685. */
  107686. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  107687. private _setButtonValue;
  107688. private _setDPadValue;
  107689. /**
  107690. * Gets the value of the `A` button
  107691. */
  107692. /**
  107693. * Sets the value of the `A` button
  107694. */
  107695. buttonA: number;
  107696. /**
  107697. * Gets the value of the `B` button
  107698. */
  107699. /**
  107700. * Sets the value of the `B` button
  107701. */
  107702. buttonB: number;
  107703. /**
  107704. * Gets the value of the `X` button
  107705. */
  107706. /**
  107707. * Sets the value of the `X` button
  107708. */
  107709. buttonX: number;
  107710. /**
  107711. * Gets the value of the `Y` button
  107712. */
  107713. /**
  107714. * Sets the value of the `Y` button
  107715. */
  107716. buttonY: number;
  107717. /**
  107718. * Gets the value of the `Start` button
  107719. */
  107720. /**
  107721. * Sets the value of the `Start` button
  107722. */
  107723. buttonStart: number;
  107724. /**
  107725. * Gets the value of the `Back` button
  107726. */
  107727. /**
  107728. * Sets the value of the `Back` button
  107729. */
  107730. buttonBack: number;
  107731. /**
  107732. * Gets the value of the `Left` button
  107733. */
  107734. /**
  107735. * Sets the value of the `Left` button
  107736. */
  107737. buttonLB: number;
  107738. /**
  107739. * Gets the value of the `Right` button
  107740. */
  107741. /**
  107742. * Sets the value of the `Right` button
  107743. */
  107744. buttonRB: number;
  107745. /**
  107746. * Gets the value of the Left joystick
  107747. */
  107748. /**
  107749. * Sets the value of the Left joystick
  107750. */
  107751. buttonLeftStick: number;
  107752. /**
  107753. * Gets the value of the Right joystick
  107754. */
  107755. /**
  107756. * Sets the value of the Right joystick
  107757. */
  107758. buttonRightStick: number;
  107759. /**
  107760. * Gets the value of D-pad up
  107761. */
  107762. /**
  107763. * Sets the value of D-pad up
  107764. */
  107765. dPadUp: number;
  107766. /**
  107767. * Gets the value of D-pad down
  107768. */
  107769. /**
  107770. * Sets the value of D-pad down
  107771. */
  107772. dPadDown: number;
  107773. /**
  107774. * Gets the value of D-pad left
  107775. */
  107776. /**
  107777. * Sets the value of D-pad left
  107778. */
  107779. dPadLeft: number;
  107780. /**
  107781. * Gets the value of D-pad right
  107782. */
  107783. /**
  107784. * Sets the value of D-pad right
  107785. */
  107786. dPadRight: number;
  107787. /**
  107788. * Force the gamepad to synchronize with device values
  107789. */
  107790. update(): void;
  107791. /**
  107792. * Disposes the gamepad
  107793. */
  107794. dispose(): void;
  107795. }
  107796. }
  107797. declare module BABYLON {
  107798. /**
  107799. * Defines supported buttons for DualShock compatible gamepads
  107800. */
  107801. export enum DualShockButton {
  107802. /** Cross */
  107803. Cross = 0,
  107804. /** Circle */
  107805. Circle = 1,
  107806. /** Square */
  107807. Square = 2,
  107808. /** Triangle */
  107809. Triangle = 3,
  107810. /** Options */
  107811. Options = 4,
  107812. /** Share */
  107813. Share = 5,
  107814. /** L1 */
  107815. L1 = 6,
  107816. /** R1 */
  107817. R1 = 7,
  107818. /** Left stick */
  107819. LeftStick = 8,
  107820. /** Right stick */
  107821. RightStick = 9
  107822. }
  107823. /** Defines values for DualShock DPad */
  107824. export enum DualShockDpad {
  107825. /** Up */
  107826. Up = 0,
  107827. /** Down */
  107828. Down = 1,
  107829. /** Left */
  107830. Left = 2,
  107831. /** Right */
  107832. Right = 3
  107833. }
  107834. /**
  107835. * Defines a DualShock gamepad
  107836. */
  107837. export class DualShockPad extends Gamepad {
  107838. private _leftTrigger;
  107839. private _rightTrigger;
  107840. private _onlefttriggerchanged;
  107841. private _onrighttriggerchanged;
  107842. private _onbuttondown;
  107843. private _onbuttonup;
  107844. private _ondpaddown;
  107845. private _ondpadup;
  107846. /** Observable raised when a button is pressed */
  107847. onButtonDownObservable: Observable<DualShockButton>;
  107848. /** Observable raised when a button is released */
  107849. onButtonUpObservable: Observable<DualShockButton>;
  107850. /** Observable raised when a pad is pressed */
  107851. onPadDownObservable: Observable<DualShockDpad>;
  107852. /** Observable raised when a pad is released */
  107853. onPadUpObservable: Observable<DualShockDpad>;
  107854. private _buttonCross;
  107855. private _buttonCircle;
  107856. private _buttonSquare;
  107857. private _buttonTriangle;
  107858. private _buttonShare;
  107859. private _buttonOptions;
  107860. private _buttonL1;
  107861. private _buttonR1;
  107862. private _buttonLeftStick;
  107863. private _buttonRightStick;
  107864. private _dPadUp;
  107865. private _dPadDown;
  107866. private _dPadLeft;
  107867. private _dPadRight;
  107868. /**
  107869. * Creates a new DualShock gamepad object
  107870. * @param id defines the id of this gamepad
  107871. * @param index defines its index
  107872. * @param gamepad defines the internal HTML gamepad object
  107873. */
  107874. constructor(id: string, index: number, gamepad: any);
  107875. /**
  107876. * Defines the callback to call when left trigger is pressed
  107877. * @param callback defines the callback to use
  107878. */
  107879. onlefttriggerchanged(callback: (value: number) => void): void;
  107880. /**
  107881. * Defines the callback to call when right trigger is pressed
  107882. * @param callback defines the callback to use
  107883. */
  107884. onrighttriggerchanged(callback: (value: number) => void): void;
  107885. /**
  107886. * Gets the left trigger value
  107887. */
  107888. /**
  107889. * Sets the left trigger value
  107890. */
  107891. leftTrigger: number;
  107892. /**
  107893. * Gets the right trigger value
  107894. */
  107895. /**
  107896. * Sets the right trigger value
  107897. */
  107898. rightTrigger: number;
  107899. /**
  107900. * Defines the callback to call when a button is pressed
  107901. * @param callback defines the callback to use
  107902. */
  107903. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  107904. /**
  107905. * Defines the callback to call when a button is released
  107906. * @param callback defines the callback to use
  107907. */
  107908. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  107909. /**
  107910. * Defines the callback to call when a pad is pressed
  107911. * @param callback defines the callback to use
  107912. */
  107913. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  107914. /**
  107915. * Defines the callback to call when a pad is released
  107916. * @param callback defines the callback to use
  107917. */
  107918. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  107919. private _setButtonValue;
  107920. private _setDPadValue;
  107921. /**
  107922. * Gets the value of the `Cross` button
  107923. */
  107924. /**
  107925. * Sets the value of the `Cross` button
  107926. */
  107927. buttonCross: number;
  107928. /**
  107929. * Gets the value of the `Circle` button
  107930. */
  107931. /**
  107932. * Sets the value of the `Circle` button
  107933. */
  107934. buttonCircle: number;
  107935. /**
  107936. * Gets the value of the `Square` button
  107937. */
  107938. /**
  107939. * Sets the value of the `Square` button
  107940. */
  107941. buttonSquare: number;
  107942. /**
  107943. * Gets the value of the `Triangle` button
  107944. */
  107945. /**
  107946. * Sets the value of the `Triangle` button
  107947. */
  107948. buttonTriangle: number;
  107949. /**
  107950. * Gets the value of the `Options` button
  107951. */
  107952. /**
  107953. * Sets the value of the `Options` button
  107954. */
  107955. buttonOptions: number;
  107956. /**
  107957. * Gets the value of the `Share` button
  107958. */
  107959. /**
  107960. * Sets the value of the `Share` button
  107961. */
  107962. buttonShare: number;
  107963. /**
  107964. * Gets the value of the `L1` button
  107965. */
  107966. /**
  107967. * Sets the value of the `L1` button
  107968. */
  107969. buttonL1: number;
  107970. /**
  107971. * Gets the value of the `R1` button
  107972. */
  107973. /**
  107974. * Sets the value of the `R1` button
  107975. */
  107976. buttonR1: number;
  107977. /**
  107978. * Gets the value of the Left joystick
  107979. */
  107980. /**
  107981. * Sets the value of the Left joystick
  107982. */
  107983. buttonLeftStick: number;
  107984. /**
  107985. * Gets the value of the Right joystick
  107986. */
  107987. /**
  107988. * Sets the value of the Right joystick
  107989. */
  107990. buttonRightStick: number;
  107991. /**
  107992. * Gets the value of D-pad up
  107993. */
  107994. /**
  107995. * Sets the value of D-pad up
  107996. */
  107997. dPadUp: number;
  107998. /**
  107999. * Gets the value of D-pad down
  108000. */
  108001. /**
  108002. * Sets the value of D-pad down
  108003. */
  108004. dPadDown: number;
  108005. /**
  108006. * Gets the value of D-pad left
  108007. */
  108008. /**
  108009. * Sets the value of D-pad left
  108010. */
  108011. dPadLeft: number;
  108012. /**
  108013. * Gets the value of D-pad right
  108014. */
  108015. /**
  108016. * Sets the value of D-pad right
  108017. */
  108018. dPadRight: number;
  108019. /**
  108020. * Force the gamepad to synchronize with device values
  108021. */
  108022. update(): void;
  108023. /**
  108024. * Disposes the gamepad
  108025. */
  108026. dispose(): void;
  108027. }
  108028. }
  108029. declare module BABYLON {
  108030. /**
  108031. * Manager for handling gamepads
  108032. */
  108033. export class GamepadManager {
  108034. private _scene?;
  108035. private _babylonGamepads;
  108036. private _oneGamepadConnected;
  108037. /** @hidden */
  108038. _isMonitoring: boolean;
  108039. private _gamepadEventSupported;
  108040. private _gamepadSupport;
  108041. /**
  108042. * observable to be triggered when the gamepad controller has been connected
  108043. */
  108044. onGamepadConnectedObservable: Observable<Gamepad>;
  108045. /**
  108046. * observable to be triggered when the gamepad controller has been disconnected
  108047. */
  108048. onGamepadDisconnectedObservable: Observable<Gamepad>;
  108049. private _onGamepadConnectedEvent;
  108050. private _onGamepadDisconnectedEvent;
  108051. /**
  108052. * Initializes the gamepad manager
  108053. * @param _scene BabylonJS scene
  108054. */
  108055. constructor(_scene?: Scene | undefined);
  108056. /**
  108057. * The gamepads in the game pad manager
  108058. */
  108059. readonly gamepads: Gamepad[];
  108060. /**
  108061. * Get the gamepad controllers based on type
  108062. * @param type The type of gamepad controller
  108063. * @returns Nullable gamepad
  108064. */
  108065. getGamepadByType(type?: number): Nullable<Gamepad>;
  108066. /**
  108067. * Disposes the gamepad manager
  108068. */
  108069. dispose(): void;
  108070. private _addNewGamepad;
  108071. private _startMonitoringGamepads;
  108072. private _stopMonitoringGamepads;
  108073. /** @hidden */
  108074. _checkGamepadsStatus(): void;
  108075. private _updateGamepadObjects;
  108076. }
  108077. }
  108078. declare module BABYLON {
  108079. interface Scene {
  108080. /** @hidden */
  108081. _gamepadManager: Nullable<GamepadManager>;
  108082. /**
  108083. * Gets the gamepad manager associated with the scene
  108084. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  108085. */
  108086. gamepadManager: GamepadManager;
  108087. }
  108088. /**
  108089. * Interface representing a free camera inputs manager
  108090. */
  108091. interface FreeCameraInputsManager {
  108092. /**
  108093. * Adds gamepad input support to the FreeCameraInputsManager.
  108094. * @returns the FreeCameraInputsManager
  108095. */
  108096. addGamepad(): FreeCameraInputsManager;
  108097. }
  108098. /**
  108099. * Interface representing an arc rotate camera inputs manager
  108100. */
  108101. interface ArcRotateCameraInputsManager {
  108102. /**
  108103. * Adds gamepad input support to the ArcRotateCamera InputManager.
  108104. * @returns the camera inputs manager
  108105. */
  108106. addGamepad(): ArcRotateCameraInputsManager;
  108107. }
  108108. /**
  108109. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  108110. */
  108111. export class GamepadSystemSceneComponent implements ISceneComponent {
  108112. /**
  108113. * The component name helpfull to identify the component in the list of scene components.
  108114. */
  108115. readonly name: string;
  108116. /**
  108117. * The scene the component belongs to.
  108118. */
  108119. scene: Scene;
  108120. /**
  108121. * Creates a new instance of the component for the given scene
  108122. * @param scene Defines the scene to register the component in
  108123. */
  108124. constructor(scene: Scene);
  108125. /**
  108126. * Registers the component in a given scene
  108127. */
  108128. register(): void;
  108129. /**
  108130. * Rebuilds the elements related to this component in case of
  108131. * context lost for instance.
  108132. */
  108133. rebuild(): void;
  108134. /**
  108135. * Disposes the component and the associated ressources
  108136. */
  108137. dispose(): void;
  108138. private _beforeCameraUpdate;
  108139. }
  108140. }
  108141. declare module BABYLON {
  108142. /**
  108143. * 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,
  108144. * which still works and will still be found in many Playgrounds.
  108145. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108146. */
  108147. export class UniversalCamera extends TouchCamera {
  108148. /**
  108149. * Defines the gamepad rotation sensiblity.
  108150. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  108151. */
  108152. gamepadAngularSensibility: number;
  108153. /**
  108154. * Defines the gamepad move sensiblity.
  108155. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  108156. */
  108157. gamepadMoveSensibility: number;
  108158. /**
  108159. * 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,
  108160. * which still works and will still be found in many Playgrounds.
  108161. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108162. * @param name Define the name of the camera in the scene
  108163. * @param position Define the start position of the camera in the scene
  108164. * @param scene Define the scene the camera belongs to
  108165. */
  108166. constructor(name: string, position: Vector3, scene: Scene);
  108167. /**
  108168. * Gets the current object class name.
  108169. * @return the class name
  108170. */
  108171. getClassName(): string;
  108172. }
  108173. }
  108174. declare module BABYLON {
  108175. /**
  108176. * This represents a FPS type of camera. This is only here for back compat purpose.
  108177. * Please use the UniversalCamera instead as both are identical.
  108178. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108179. */
  108180. export class GamepadCamera extends UniversalCamera {
  108181. /**
  108182. * Instantiates a new Gamepad Camera
  108183. * This represents a FPS type of camera. This is only here for back compat purpose.
  108184. * Please use the UniversalCamera instead as both are identical.
  108185. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  108186. * @param name Define the name of the camera in the scene
  108187. * @param position Define the start position of the camera in the scene
  108188. * @param scene Define the scene the camera belongs to
  108189. */
  108190. constructor(name: string, position: Vector3, scene: Scene);
  108191. /**
  108192. * Gets the current object class name.
  108193. * @return the class name
  108194. */
  108195. getClassName(): string;
  108196. }
  108197. }
  108198. declare module BABYLON {
  108199. /** @hidden */
  108200. export var passPixelShader: {
  108201. name: string;
  108202. shader: string;
  108203. };
  108204. }
  108205. declare module BABYLON {
  108206. /** @hidden */
  108207. export var passCubePixelShader: {
  108208. name: string;
  108209. shader: string;
  108210. };
  108211. }
  108212. declare module BABYLON {
  108213. /**
  108214. * PassPostProcess which produces an output the same as it's input
  108215. */
  108216. export class PassPostProcess extends PostProcess {
  108217. /**
  108218. * Creates the PassPostProcess
  108219. * @param name The name of the effect.
  108220. * @param options The required width/height ratio to downsize to before computing the render pass.
  108221. * @param camera The camera to apply the render pass to.
  108222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108223. * @param engine The engine which the post process will be applied. (default: current engine)
  108224. * @param reusable If the post process can be reused on the same frame. (default: false)
  108225. * @param textureType The type of texture to be used when performing the post processing.
  108226. * @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)
  108227. */
  108228. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108229. }
  108230. /**
  108231. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  108232. */
  108233. export class PassCubePostProcess extends PostProcess {
  108234. private _face;
  108235. /**
  108236. * Gets or sets the cube face to display.
  108237. * * 0 is +X
  108238. * * 1 is -X
  108239. * * 2 is +Y
  108240. * * 3 is -Y
  108241. * * 4 is +Z
  108242. * * 5 is -Z
  108243. */
  108244. face: number;
  108245. /**
  108246. * Creates the PassCubePostProcess
  108247. * @param name The name of the effect.
  108248. * @param options The required width/height ratio to downsize to before computing the render pass.
  108249. * @param camera The camera to apply the render pass to.
  108250. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108251. * @param engine The engine which the post process will be applied. (default: current engine)
  108252. * @param reusable If the post process can be reused on the same frame. (default: false)
  108253. * @param textureType The type of texture to be used when performing the post processing.
  108254. * @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)
  108255. */
  108256. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  108257. }
  108258. }
  108259. declare module BABYLON {
  108260. /** @hidden */
  108261. export var anaglyphPixelShader: {
  108262. name: string;
  108263. shader: string;
  108264. };
  108265. }
  108266. declare module BABYLON {
  108267. /**
  108268. * Postprocess used to generate anaglyphic rendering
  108269. */
  108270. export class AnaglyphPostProcess extends PostProcess {
  108271. private _passedProcess;
  108272. /**
  108273. * Creates a new AnaglyphPostProcess
  108274. * @param name defines postprocess name
  108275. * @param options defines creation options or target ratio scale
  108276. * @param rigCameras defines cameras using this postprocess
  108277. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  108278. * @param engine defines hosting engine
  108279. * @param reusable defines if the postprocess will be reused multiple times per frame
  108280. */
  108281. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  108282. }
  108283. }
  108284. declare module BABYLON {
  108285. /**
  108286. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  108287. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108288. */
  108289. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  108290. /**
  108291. * Creates a new AnaglyphArcRotateCamera
  108292. * @param name defines camera name
  108293. * @param alpha defines alpha angle (in radians)
  108294. * @param beta defines beta angle (in radians)
  108295. * @param radius defines radius
  108296. * @param target defines camera target
  108297. * @param interaxialDistance defines distance between each color axis
  108298. * @param scene defines the hosting scene
  108299. */
  108300. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  108301. /**
  108302. * Gets camera class name
  108303. * @returns AnaglyphArcRotateCamera
  108304. */
  108305. getClassName(): string;
  108306. }
  108307. }
  108308. declare module BABYLON {
  108309. /**
  108310. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  108311. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108312. */
  108313. export class AnaglyphFreeCamera extends FreeCamera {
  108314. /**
  108315. * Creates a new AnaglyphFreeCamera
  108316. * @param name defines camera name
  108317. * @param position defines initial position
  108318. * @param interaxialDistance defines distance between each color axis
  108319. * @param scene defines the hosting scene
  108320. */
  108321. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108322. /**
  108323. * Gets camera class name
  108324. * @returns AnaglyphFreeCamera
  108325. */
  108326. getClassName(): string;
  108327. }
  108328. }
  108329. declare module BABYLON {
  108330. /**
  108331. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  108332. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108333. */
  108334. export class AnaglyphGamepadCamera extends GamepadCamera {
  108335. /**
  108336. * Creates a new AnaglyphGamepadCamera
  108337. * @param name defines camera name
  108338. * @param position defines initial position
  108339. * @param interaxialDistance defines distance between each color axis
  108340. * @param scene defines the hosting scene
  108341. */
  108342. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108343. /**
  108344. * Gets camera class name
  108345. * @returns AnaglyphGamepadCamera
  108346. */
  108347. getClassName(): string;
  108348. }
  108349. }
  108350. declare module BABYLON {
  108351. /**
  108352. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  108353. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  108354. */
  108355. export class AnaglyphUniversalCamera extends UniversalCamera {
  108356. /**
  108357. * Creates a new AnaglyphUniversalCamera
  108358. * @param name defines camera name
  108359. * @param position defines initial position
  108360. * @param interaxialDistance defines distance between each color axis
  108361. * @param scene defines the hosting scene
  108362. */
  108363. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  108364. /**
  108365. * Gets camera class name
  108366. * @returns AnaglyphUniversalCamera
  108367. */
  108368. getClassName(): string;
  108369. }
  108370. }
  108371. declare module BABYLON {
  108372. /** @hidden */
  108373. export var stereoscopicInterlacePixelShader: {
  108374. name: string;
  108375. shader: string;
  108376. };
  108377. }
  108378. declare module BABYLON {
  108379. /**
  108380. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  108381. */
  108382. export class StereoscopicInterlacePostProcess extends PostProcess {
  108383. private _stepSize;
  108384. private _passedProcess;
  108385. /**
  108386. * Initializes a StereoscopicInterlacePostProcess
  108387. * @param name The name of the effect.
  108388. * @param rigCameras The rig cameras to be appled to the post process
  108389. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  108390. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  108391. * @param engine The engine which the post process will be applied. (default: current engine)
  108392. * @param reusable If the post process can be reused on the same frame. (default: false)
  108393. */
  108394. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  108395. }
  108396. }
  108397. declare module BABYLON {
  108398. /**
  108399. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  108400. * @see http://doc.babylonjs.com/features/cameras
  108401. */
  108402. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  108403. /**
  108404. * Creates a new StereoscopicArcRotateCamera
  108405. * @param name defines camera name
  108406. * @param alpha defines alpha angle (in radians)
  108407. * @param beta defines beta angle (in radians)
  108408. * @param radius defines radius
  108409. * @param target defines camera target
  108410. * @param interaxialDistance defines distance between each color axis
  108411. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108412. * @param scene defines the hosting scene
  108413. */
  108414. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108415. /**
  108416. * Gets camera class name
  108417. * @returns StereoscopicArcRotateCamera
  108418. */
  108419. getClassName(): string;
  108420. }
  108421. }
  108422. declare module BABYLON {
  108423. /**
  108424. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  108425. * @see http://doc.babylonjs.com/features/cameras
  108426. */
  108427. export class StereoscopicFreeCamera extends FreeCamera {
  108428. /**
  108429. * Creates a new StereoscopicFreeCamera
  108430. * @param name defines camera name
  108431. * @param position defines initial position
  108432. * @param interaxialDistance defines distance between each color axis
  108433. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108434. * @param scene defines the hosting scene
  108435. */
  108436. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108437. /**
  108438. * Gets camera class name
  108439. * @returns StereoscopicFreeCamera
  108440. */
  108441. getClassName(): string;
  108442. }
  108443. }
  108444. declare module BABYLON {
  108445. /**
  108446. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  108447. * @see http://doc.babylonjs.com/features/cameras
  108448. */
  108449. export class StereoscopicGamepadCamera extends GamepadCamera {
  108450. /**
  108451. * Creates a new StereoscopicGamepadCamera
  108452. * @param name defines camera name
  108453. * @param position defines initial position
  108454. * @param interaxialDistance defines distance between each color axis
  108455. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108456. * @param scene defines the hosting scene
  108457. */
  108458. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108459. /**
  108460. * Gets camera class name
  108461. * @returns StereoscopicGamepadCamera
  108462. */
  108463. getClassName(): string;
  108464. }
  108465. }
  108466. declare module BABYLON {
  108467. /**
  108468. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  108469. * @see http://doc.babylonjs.com/features/cameras
  108470. */
  108471. export class StereoscopicUniversalCamera extends UniversalCamera {
  108472. /**
  108473. * Creates a new StereoscopicUniversalCamera
  108474. * @param name defines camera name
  108475. * @param position defines initial position
  108476. * @param interaxialDistance defines distance between each color axis
  108477. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  108478. * @param scene defines the hosting scene
  108479. */
  108480. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  108481. /**
  108482. * Gets camera class name
  108483. * @returns StereoscopicUniversalCamera
  108484. */
  108485. getClassName(): string;
  108486. }
  108487. }
  108488. declare module BABYLON {
  108489. /**
  108490. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  108491. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108492. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108493. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108494. */
  108495. export class VirtualJoysticksCamera extends FreeCamera {
  108496. /**
  108497. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  108498. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  108499. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  108500. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  108501. * @param name Define the name of the camera in the scene
  108502. * @param position Define the start position of the camera in the scene
  108503. * @param scene Define the scene the camera belongs to
  108504. */
  108505. constructor(name: string, position: Vector3, scene: Scene);
  108506. /**
  108507. * Gets the current object class name.
  108508. * @return the class name
  108509. */
  108510. getClassName(): string;
  108511. }
  108512. }
  108513. declare module BABYLON {
  108514. /**
  108515. * This represents all the required metrics to create a VR camera.
  108516. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  108517. */
  108518. export class VRCameraMetrics {
  108519. /**
  108520. * Define the horizontal resolution off the screen.
  108521. */
  108522. hResolution: number;
  108523. /**
  108524. * Define the vertical resolution off the screen.
  108525. */
  108526. vResolution: number;
  108527. /**
  108528. * Define the horizontal screen size.
  108529. */
  108530. hScreenSize: number;
  108531. /**
  108532. * Define the vertical screen size.
  108533. */
  108534. vScreenSize: number;
  108535. /**
  108536. * Define the vertical screen center position.
  108537. */
  108538. vScreenCenter: number;
  108539. /**
  108540. * Define the distance of the eyes to the screen.
  108541. */
  108542. eyeToScreenDistance: number;
  108543. /**
  108544. * Define the distance between both lenses
  108545. */
  108546. lensSeparationDistance: number;
  108547. /**
  108548. * Define the distance between both viewer's eyes.
  108549. */
  108550. interpupillaryDistance: number;
  108551. /**
  108552. * Define the distortion factor of the VR postprocess.
  108553. * Please, touch with care.
  108554. */
  108555. distortionK: number[];
  108556. /**
  108557. * Define the chromatic aberration correction factors for the VR post process.
  108558. */
  108559. chromaAbCorrection: number[];
  108560. /**
  108561. * Define the scale factor of the post process.
  108562. * The smaller the better but the slower.
  108563. */
  108564. postProcessScaleFactor: number;
  108565. /**
  108566. * Define an offset for the lens center.
  108567. */
  108568. lensCenterOffset: number;
  108569. /**
  108570. * Define if the current vr camera should compensate the distortion of the lense or not.
  108571. */
  108572. compensateDistortion: boolean;
  108573. /**
  108574. * Defines if multiview should be enabled when rendering (Default: false)
  108575. */
  108576. multiviewEnabled: boolean;
  108577. /**
  108578. * Gets the rendering aspect ratio based on the provided resolutions.
  108579. */
  108580. readonly aspectRatio: number;
  108581. /**
  108582. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  108583. */
  108584. readonly aspectRatioFov: number;
  108585. /**
  108586. * @hidden
  108587. */
  108588. readonly leftHMatrix: Matrix;
  108589. /**
  108590. * @hidden
  108591. */
  108592. readonly rightHMatrix: Matrix;
  108593. /**
  108594. * @hidden
  108595. */
  108596. readonly leftPreViewMatrix: Matrix;
  108597. /**
  108598. * @hidden
  108599. */
  108600. readonly rightPreViewMatrix: Matrix;
  108601. /**
  108602. * Get the default VRMetrics based on the most generic setup.
  108603. * @returns the default vr metrics
  108604. */
  108605. static GetDefault(): VRCameraMetrics;
  108606. }
  108607. }
  108608. declare module BABYLON {
  108609. /** @hidden */
  108610. export var vrDistortionCorrectionPixelShader: {
  108611. name: string;
  108612. shader: string;
  108613. };
  108614. }
  108615. declare module BABYLON {
  108616. /**
  108617. * VRDistortionCorrectionPostProcess used for mobile VR
  108618. */
  108619. export class VRDistortionCorrectionPostProcess extends PostProcess {
  108620. private _isRightEye;
  108621. private _distortionFactors;
  108622. private _postProcessScaleFactor;
  108623. private _lensCenterOffset;
  108624. private _scaleIn;
  108625. private _scaleFactor;
  108626. private _lensCenter;
  108627. /**
  108628. * Initializes the VRDistortionCorrectionPostProcess
  108629. * @param name The name of the effect.
  108630. * @param camera The camera to apply the render pass to.
  108631. * @param isRightEye If this is for the right eye distortion
  108632. * @param vrMetrics All the required metrics for the VR camera
  108633. */
  108634. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  108635. }
  108636. }
  108637. declare module BABYLON {
  108638. /**
  108639. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  108640. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108641. */
  108642. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  108643. /**
  108644. * Creates a new VRDeviceOrientationArcRotateCamera
  108645. * @param name defines camera name
  108646. * @param alpha defines the camera rotation along the logitudinal axis
  108647. * @param beta defines the camera rotation along the latitudinal axis
  108648. * @param radius defines the camera distance from its target
  108649. * @param target defines the camera target
  108650. * @param scene defines the scene the camera belongs to
  108651. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108652. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108653. */
  108654. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108655. /**
  108656. * Gets camera class name
  108657. * @returns VRDeviceOrientationArcRotateCamera
  108658. */
  108659. getClassName(): string;
  108660. }
  108661. }
  108662. declare module BABYLON {
  108663. /**
  108664. * Camera used to simulate VR rendering (based on FreeCamera)
  108665. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108666. */
  108667. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  108668. /**
  108669. * Creates a new VRDeviceOrientationFreeCamera
  108670. * @param name defines camera name
  108671. * @param position defines the start position of the camera
  108672. * @param scene defines the scene the camera belongs to
  108673. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108674. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108675. */
  108676. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108677. /**
  108678. * Gets camera class name
  108679. * @returns VRDeviceOrientationFreeCamera
  108680. */
  108681. getClassName(): string;
  108682. }
  108683. }
  108684. declare module BABYLON {
  108685. /**
  108686. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  108687. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  108688. */
  108689. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  108690. /**
  108691. * Creates a new VRDeviceOrientationGamepadCamera
  108692. * @param name defines camera name
  108693. * @param position defines the start position of the camera
  108694. * @param scene defines the scene the camera belongs to
  108695. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  108696. * @param vrCameraMetrics defines the vr metrics associated to the camera
  108697. */
  108698. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  108699. /**
  108700. * Gets camera class name
  108701. * @returns VRDeviceOrientationGamepadCamera
  108702. */
  108703. getClassName(): string;
  108704. }
  108705. }
  108706. declare module BABYLON {
  108707. /**
  108708. * Base class of materials working in push mode in babylon JS
  108709. * @hidden
  108710. */
  108711. export class PushMaterial extends Material {
  108712. protected _activeEffect: Effect;
  108713. protected _normalMatrix: Matrix;
  108714. /**
  108715. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  108716. * This means that the material can keep using a previous shader while a new one is being compiled.
  108717. * This is mostly used when shader parallel compilation is supported (true by default)
  108718. */
  108719. allowShaderHotSwapping: boolean;
  108720. constructor(name: string, scene: Scene);
  108721. getEffect(): Effect;
  108722. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  108723. /**
  108724. * Binds the given world matrix to the active effect
  108725. *
  108726. * @param world the matrix to bind
  108727. */
  108728. bindOnlyWorldMatrix(world: Matrix): void;
  108729. /**
  108730. * Binds the given normal matrix to the active effect
  108731. *
  108732. * @param normalMatrix the matrix to bind
  108733. */
  108734. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  108735. bind(world: Matrix, mesh?: Mesh): void;
  108736. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  108737. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  108738. }
  108739. }
  108740. declare module BABYLON {
  108741. /**
  108742. * This groups all the flags used to control the materials channel.
  108743. */
  108744. export class MaterialFlags {
  108745. private static _DiffuseTextureEnabled;
  108746. /**
  108747. * Are diffuse textures enabled in the application.
  108748. */
  108749. static DiffuseTextureEnabled: boolean;
  108750. private static _AmbientTextureEnabled;
  108751. /**
  108752. * Are ambient textures enabled in the application.
  108753. */
  108754. static AmbientTextureEnabled: boolean;
  108755. private static _OpacityTextureEnabled;
  108756. /**
  108757. * Are opacity textures enabled in the application.
  108758. */
  108759. static OpacityTextureEnabled: boolean;
  108760. private static _ReflectionTextureEnabled;
  108761. /**
  108762. * Are reflection textures enabled in the application.
  108763. */
  108764. static ReflectionTextureEnabled: boolean;
  108765. private static _EmissiveTextureEnabled;
  108766. /**
  108767. * Are emissive textures enabled in the application.
  108768. */
  108769. static EmissiveTextureEnabled: boolean;
  108770. private static _SpecularTextureEnabled;
  108771. /**
  108772. * Are specular textures enabled in the application.
  108773. */
  108774. static SpecularTextureEnabled: boolean;
  108775. private static _BumpTextureEnabled;
  108776. /**
  108777. * Are bump textures enabled in the application.
  108778. */
  108779. static BumpTextureEnabled: boolean;
  108780. private static _LightmapTextureEnabled;
  108781. /**
  108782. * Are lightmap textures enabled in the application.
  108783. */
  108784. static LightmapTextureEnabled: boolean;
  108785. private static _RefractionTextureEnabled;
  108786. /**
  108787. * Are refraction textures enabled in the application.
  108788. */
  108789. static RefractionTextureEnabled: boolean;
  108790. private static _ColorGradingTextureEnabled;
  108791. /**
  108792. * Are color grading textures enabled in the application.
  108793. */
  108794. static ColorGradingTextureEnabled: boolean;
  108795. private static _FresnelEnabled;
  108796. /**
  108797. * Are fresnels enabled in the application.
  108798. */
  108799. static FresnelEnabled: boolean;
  108800. private static _ClearCoatTextureEnabled;
  108801. /**
  108802. * Are clear coat textures enabled in the application.
  108803. */
  108804. static ClearCoatTextureEnabled: boolean;
  108805. private static _ClearCoatBumpTextureEnabled;
  108806. /**
  108807. * Are clear coat bump textures enabled in the application.
  108808. */
  108809. static ClearCoatBumpTextureEnabled: boolean;
  108810. private static _ClearCoatTintTextureEnabled;
  108811. /**
  108812. * Are clear coat tint textures enabled in the application.
  108813. */
  108814. static ClearCoatTintTextureEnabled: boolean;
  108815. private static _SheenTextureEnabled;
  108816. /**
  108817. * Are sheen textures enabled in the application.
  108818. */
  108819. static SheenTextureEnabled: boolean;
  108820. private static _AnisotropicTextureEnabled;
  108821. /**
  108822. * Are anisotropic textures enabled in the application.
  108823. */
  108824. static AnisotropicTextureEnabled: boolean;
  108825. private static _ThicknessTextureEnabled;
  108826. /**
  108827. * Are thickness textures enabled in the application.
  108828. */
  108829. static ThicknessTextureEnabled: boolean;
  108830. }
  108831. }
  108832. declare module BABYLON {
  108833. /** @hidden */
  108834. export var defaultFragmentDeclaration: {
  108835. name: string;
  108836. shader: string;
  108837. };
  108838. }
  108839. declare module BABYLON {
  108840. /** @hidden */
  108841. export var defaultUboDeclaration: {
  108842. name: string;
  108843. shader: string;
  108844. };
  108845. }
  108846. declare module BABYLON {
  108847. /** @hidden */
  108848. export var lightFragmentDeclaration: {
  108849. name: string;
  108850. shader: string;
  108851. };
  108852. }
  108853. declare module BABYLON {
  108854. /** @hidden */
  108855. export var lightUboDeclaration: {
  108856. name: string;
  108857. shader: string;
  108858. };
  108859. }
  108860. declare module BABYLON {
  108861. /** @hidden */
  108862. export var lightsFragmentFunctions: {
  108863. name: string;
  108864. shader: string;
  108865. };
  108866. }
  108867. declare module BABYLON {
  108868. /** @hidden */
  108869. export var shadowsFragmentFunctions: {
  108870. name: string;
  108871. shader: string;
  108872. };
  108873. }
  108874. declare module BABYLON {
  108875. /** @hidden */
  108876. export var fresnelFunction: {
  108877. name: string;
  108878. shader: string;
  108879. };
  108880. }
  108881. declare module BABYLON {
  108882. /** @hidden */
  108883. export var reflectionFunction: {
  108884. name: string;
  108885. shader: string;
  108886. };
  108887. }
  108888. declare module BABYLON {
  108889. /** @hidden */
  108890. export var bumpFragmentFunctions: {
  108891. name: string;
  108892. shader: string;
  108893. };
  108894. }
  108895. declare module BABYLON {
  108896. /** @hidden */
  108897. export var logDepthDeclaration: {
  108898. name: string;
  108899. shader: string;
  108900. };
  108901. }
  108902. declare module BABYLON {
  108903. /** @hidden */
  108904. export var bumpFragment: {
  108905. name: string;
  108906. shader: string;
  108907. };
  108908. }
  108909. declare module BABYLON {
  108910. /** @hidden */
  108911. export var depthPrePass: {
  108912. name: string;
  108913. shader: string;
  108914. };
  108915. }
  108916. declare module BABYLON {
  108917. /** @hidden */
  108918. export var lightFragment: {
  108919. name: string;
  108920. shader: string;
  108921. };
  108922. }
  108923. declare module BABYLON {
  108924. /** @hidden */
  108925. export var logDepthFragment: {
  108926. name: string;
  108927. shader: string;
  108928. };
  108929. }
  108930. declare module BABYLON {
  108931. /** @hidden */
  108932. export var defaultPixelShader: {
  108933. name: string;
  108934. shader: string;
  108935. };
  108936. }
  108937. declare module BABYLON {
  108938. /** @hidden */
  108939. export var defaultVertexDeclaration: {
  108940. name: string;
  108941. shader: string;
  108942. };
  108943. }
  108944. declare module BABYLON {
  108945. /** @hidden */
  108946. export var bumpVertexDeclaration: {
  108947. name: string;
  108948. shader: string;
  108949. };
  108950. }
  108951. declare module BABYLON {
  108952. /** @hidden */
  108953. export var bumpVertex: {
  108954. name: string;
  108955. shader: string;
  108956. };
  108957. }
  108958. declare module BABYLON {
  108959. /** @hidden */
  108960. export var fogVertex: {
  108961. name: string;
  108962. shader: string;
  108963. };
  108964. }
  108965. declare module BABYLON {
  108966. /** @hidden */
  108967. export var shadowsVertex: {
  108968. name: string;
  108969. shader: string;
  108970. };
  108971. }
  108972. declare module BABYLON {
  108973. /** @hidden */
  108974. export var pointCloudVertex: {
  108975. name: string;
  108976. shader: string;
  108977. };
  108978. }
  108979. declare module BABYLON {
  108980. /** @hidden */
  108981. export var logDepthVertex: {
  108982. name: string;
  108983. shader: string;
  108984. };
  108985. }
  108986. declare module BABYLON {
  108987. /** @hidden */
  108988. export var defaultVertexShader: {
  108989. name: string;
  108990. shader: string;
  108991. };
  108992. }
  108993. declare module BABYLON {
  108994. /** @hidden */
  108995. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  108996. MAINUV1: boolean;
  108997. MAINUV2: boolean;
  108998. DIFFUSE: boolean;
  108999. DIFFUSEDIRECTUV: number;
  109000. AMBIENT: boolean;
  109001. AMBIENTDIRECTUV: number;
  109002. OPACITY: boolean;
  109003. OPACITYDIRECTUV: number;
  109004. OPACITYRGB: boolean;
  109005. REFLECTION: boolean;
  109006. EMISSIVE: boolean;
  109007. EMISSIVEDIRECTUV: number;
  109008. SPECULAR: boolean;
  109009. SPECULARDIRECTUV: number;
  109010. BUMP: boolean;
  109011. BUMPDIRECTUV: number;
  109012. PARALLAX: boolean;
  109013. PARALLAXOCCLUSION: boolean;
  109014. SPECULAROVERALPHA: boolean;
  109015. CLIPPLANE: boolean;
  109016. CLIPPLANE2: boolean;
  109017. CLIPPLANE3: boolean;
  109018. CLIPPLANE4: boolean;
  109019. ALPHATEST: boolean;
  109020. DEPTHPREPASS: boolean;
  109021. ALPHAFROMDIFFUSE: boolean;
  109022. POINTSIZE: boolean;
  109023. FOG: boolean;
  109024. SPECULARTERM: boolean;
  109025. DIFFUSEFRESNEL: boolean;
  109026. OPACITYFRESNEL: boolean;
  109027. REFLECTIONFRESNEL: boolean;
  109028. REFRACTIONFRESNEL: boolean;
  109029. EMISSIVEFRESNEL: boolean;
  109030. FRESNEL: boolean;
  109031. NORMAL: boolean;
  109032. UV1: boolean;
  109033. UV2: boolean;
  109034. VERTEXCOLOR: boolean;
  109035. VERTEXALPHA: boolean;
  109036. NUM_BONE_INFLUENCERS: number;
  109037. BonesPerMesh: number;
  109038. BONETEXTURE: boolean;
  109039. INSTANCES: boolean;
  109040. GLOSSINESS: boolean;
  109041. ROUGHNESS: boolean;
  109042. EMISSIVEASILLUMINATION: boolean;
  109043. LINKEMISSIVEWITHDIFFUSE: boolean;
  109044. REFLECTIONFRESNELFROMSPECULAR: boolean;
  109045. LIGHTMAP: boolean;
  109046. LIGHTMAPDIRECTUV: number;
  109047. OBJECTSPACE_NORMALMAP: boolean;
  109048. USELIGHTMAPASSHADOWMAP: boolean;
  109049. REFLECTIONMAP_3D: boolean;
  109050. REFLECTIONMAP_SPHERICAL: boolean;
  109051. REFLECTIONMAP_PLANAR: boolean;
  109052. REFLECTIONMAP_CUBIC: boolean;
  109053. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109054. REFLECTIONMAP_PROJECTION: boolean;
  109055. REFLECTIONMAP_SKYBOX: boolean;
  109056. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  109057. REFLECTIONMAP_EXPLICIT: boolean;
  109058. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109059. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109060. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109061. INVERTCUBICMAP: boolean;
  109062. LOGARITHMICDEPTH: boolean;
  109063. REFRACTION: boolean;
  109064. REFRACTIONMAP_3D: boolean;
  109065. REFLECTIONOVERALPHA: boolean;
  109066. TWOSIDEDLIGHTING: boolean;
  109067. SHADOWFLOAT: boolean;
  109068. MORPHTARGETS: boolean;
  109069. MORPHTARGETS_NORMAL: boolean;
  109070. MORPHTARGETS_TANGENT: boolean;
  109071. MORPHTARGETS_UV: boolean;
  109072. NUM_MORPH_INFLUENCERS: number;
  109073. NONUNIFORMSCALING: boolean;
  109074. PREMULTIPLYALPHA: boolean;
  109075. IMAGEPROCESSING: boolean;
  109076. VIGNETTE: boolean;
  109077. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109078. VIGNETTEBLENDMODEOPAQUE: boolean;
  109079. TONEMAPPING: boolean;
  109080. TONEMAPPING_ACES: boolean;
  109081. CONTRAST: boolean;
  109082. COLORCURVES: boolean;
  109083. COLORGRADING: boolean;
  109084. COLORGRADING3D: boolean;
  109085. SAMPLER3DGREENDEPTH: boolean;
  109086. SAMPLER3DBGRMAP: boolean;
  109087. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109088. MULTIVIEW: boolean;
  109089. /**
  109090. * If the reflection texture on this material is in linear color space
  109091. * @hidden
  109092. */
  109093. IS_REFLECTION_LINEAR: boolean;
  109094. /**
  109095. * If the refraction texture on this material is in linear color space
  109096. * @hidden
  109097. */
  109098. IS_REFRACTION_LINEAR: boolean;
  109099. EXPOSURE: boolean;
  109100. constructor();
  109101. setReflectionMode(modeToEnable: string): void;
  109102. }
  109103. /**
  109104. * This is the default material used in Babylon. It is the best trade off between quality
  109105. * and performances.
  109106. * @see http://doc.babylonjs.com/babylon101/materials
  109107. */
  109108. export class StandardMaterial extends PushMaterial {
  109109. private _diffuseTexture;
  109110. /**
  109111. * The basic texture of the material as viewed under a light.
  109112. */
  109113. diffuseTexture: Nullable<BaseTexture>;
  109114. private _ambientTexture;
  109115. /**
  109116. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  109117. */
  109118. ambientTexture: Nullable<BaseTexture>;
  109119. private _opacityTexture;
  109120. /**
  109121. * Define the transparency of the material from a texture.
  109122. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  109123. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  109124. */
  109125. opacityTexture: Nullable<BaseTexture>;
  109126. private _reflectionTexture;
  109127. /**
  109128. * Define the texture used to display the reflection.
  109129. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109130. */
  109131. reflectionTexture: Nullable<BaseTexture>;
  109132. private _emissiveTexture;
  109133. /**
  109134. * Define texture of the material as if self lit.
  109135. * This will be mixed in the final result even in the absence of light.
  109136. */
  109137. emissiveTexture: Nullable<BaseTexture>;
  109138. private _specularTexture;
  109139. /**
  109140. * Define how the color and intensity of the highlight given by the light in the material.
  109141. */
  109142. specularTexture: Nullable<BaseTexture>;
  109143. private _bumpTexture;
  109144. /**
  109145. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  109146. * 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.
  109147. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  109148. */
  109149. bumpTexture: Nullable<BaseTexture>;
  109150. private _lightmapTexture;
  109151. /**
  109152. * Complex lighting can be computationally expensive to compute at runtime.
  109153. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  109154. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  109155. */
  109156. lightmapTexture: Nullable<BaseTexture>;
  109157. private _refractionTexture;
  109158. /**
  109159. * Define the texture used to display the refraction.
  109160. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109161. */
  109162. refractionTexture: Nullable<BaseTexture>;
  109163. /**
  109164. * The color of the material lit by the environmental background lighting.
  109165. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  109166. */
  109167. ambientColor: Color3;
  109168. /**
  109169. * The basic color of the material as viewed under a light.
  109170. */
  109171. diffuseColor: Color3;
  109172. /**
  109173. * Define how the color and intensity of the highlight given by the light in the material.
  109174. */
  109175. specularColor: Color3;
  109176. /**
  109177. * Define the color of the material as if self lit.
  109178. * This will be mixed in the final result even in the absence of light.
  109179. */
  109180. emissiveColor: Color3;
  109181. /**
  109182. * Defines how sharp are the highlights in the material.
  109183. * The bigger the value the sharper giving a more glossy feeling to the result.
  109184. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  109185. */
  109186. specularPower: number;
  109187. private _useAlphaFromDiffuseTexture;
  109188. /**
  109189. * Does the transparency come from the diffuse texture alpha channel.
  109190. */
  109191. useAlphaFromDiffuseTexture: boolean;
  109192. private _useEmissiveAsIllumination;
  109193. /**
  109194. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  109195. */
  109196. useEmissiveAsIllumination: boolean;
  109197. private _linkEmissiveWithDiffuse;
  109198. /**
  109199. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  109200. * the emissive level when the final color is close to one.
  109201. */
  109202. linkEmissiveWithDiffuse: boolean;
  109203. private _useSpecularOverAlpha;
  109204. /**
  109205. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  109206. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  109207. */
  109208. useSpecularOverAlpha: boolean;
  109209. private _useReflectionOverAlpha;
  109210. /**
  109211. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109212. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109213. */
  109214. useReflectionOverAlpha: boolean;
  109215. private _disableLighting;
  109216. /**
  109217. * Does lights from the scene impacts this material.
  109218. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  109219. */
  109220. disableLighting: boolean;
  109221. private _useObjectSpaceNormalMap;
  109222. /**
  109223. * Allows using an object space normal map (instead of tangent space).
  109224. */
  109225. useObjectSpaceNormalMap: boolean;
  109226. private _useParallax;
  109227. /**
  109228. * Is parallax enabled or not.
  109229. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  109230. */
  109231. useParallax: boolean;
  109232. private _useParallaxOcclusion;
  109233. /**
  109234. * Is parallax occlusion enabled or not.
  109235. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  109236. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  109237. */
  109238. useParallaxOcclusion: boolean;
  109239. /**
  109240. * 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.
  109241. */
  109242. parallaxScaleBias: number;
  109243. private _roughness;
  109244. /**
  109245. * Helps to define how blurry the reflections should appears in the material.
  109246. */
  109247. roughness: number;
  109248. /**
  109249. * In case of refraction, define the value of the index of refraction.
  109250. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109251. */
  109252. indexOfRefraction: number;
  109253. /**
  109254. * Invert the refraction texture alongside the y axis.
  109255. * It can be useful with procedural textures or probe for instance.
  109256. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  109257. */
  109258. invertRefractionY: boolean;
  109259. /**
  109260. * Defines the alpha limits in alpha test mode.
  109261. */
  109262. alphaCutOff: number;
  109263. private _useLightmapAsShadowmap;
  109264. /**
  109265. * In case of light mapping, define whether the map contains light or shadow informations.
  109266. */
  109267. useLightmapAsShadowmap: boolean;
  109268. private _diffuseFresnelParameters;
  109269. /**
  109270. * Define the diffuse fresnel parameters of the material.
  109271. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109272. */
  109273. diffuseFresnelParameters: FresnelParameters;
  109274. private _opacityFresnelParameters;
  109275. /**
  109276. * Define the opacity fresnel parameters of the material.
  109277. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109278. */
  109279. opacityFresnelParameters: FresnelParameters;
  109280. private _reflectionFresnelParameters;
  109281. /**
  109282. * Define the reflection fresnel parameters of the material.
  109283. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109284. */
  109285. reflectionFresnelParameters: FresnelParameters;
  109286. private _refractionFresnelParameters;
  109287. /**
  109288. * Define the refraction fresnel parameters of the material.
  109289. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109290. */
  109291. refractionFresnelParameters: FresnelParameters;
  109292. private _emissiveFresnelParameters;
  109293. /**
  109294. * Define the emissive fresnel parameters of the material.
  109295. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109296. */
  109297. emissiveFresnelParameters: FresnelParameters;
  109298. private _useReflectionFresnelFromSpecular;
  109299. /**
  109300. * If true automatically deducts the fresnels values from the material specularity.
  109301. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  109302. */
  109303. useReflectionFresnelFromSpecular: boolean;
  109304. private _useGlossinessFromSpecularMapAlpha;
  109305. /**
  109306. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  109307. */
  109308. useGlossinessFromSpecularMapAlpha: boolean;
  109309. private _maxSimultaneousLights;
  109310. /**
  109311. * Defines the maximum number of lights that can be used in the material
  109312. */
  109313. maxSimultaneousLights: number;
  109314. private _invertNormalMapX;
  109315. /**
  109316. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109317. */
  109318. invertNormalMapX: boolean;
  109319. private _invertNormalMapY;
  109320. /**
  109321. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109322. */
  109323. invertNormalMapY: boolean;
  109324. private _twoSidedLighting;
  109325. /**
  109326. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109327. */
  109328. twoSidedLighting: boolean;
  109329. /**
  109330. * Default configuration related to image processing available in the standard Material.
  109331. */
  109332. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109333. /**
  109334. * Gets the image processing configuration used either in this material.
  109335. */
  109336. /**
  109337. * Sets the Default image processing configuration used either in the this material.
  109338. *
  109339. * If sets to null, the scene one is in use.
  109340. */
  109341. imageProcessingConfiguration: ImageProcessingConfiguration;
  109342. /**
  109343. * Keep track of the image processing observer to allow dispose and replace.
  109344. */
  109345. private _imageProcessingObserver;
  109346. /**
  109347. * Attaches a new image processing configuration to the Standard Material.
  109348. * @param configuration
  109349. */
  109350. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  109351. /**
  109352. * Gets wether the color curves effect is enabled.
  109353. */
  109354. /**
  109355. * Sets wether the color curves effect is enabled.
  109356. */
  109357. cameraColorCurvesEnabled: boolean;
  109358. /**
  109359. * Gets wether the color grading effect is enabled.
  109360. */
  109361. /**
  109362. * Gets wether the color grading effect is enabled.
  109363. */
  109364. cameraColorGradingEnabled: boolean;
  109365. /**
  109366. * Gets wether tonemapping is enabled or not.
  109367. */
  109368. /**
  109369. * Sets wether tonemapping is enabled or not
  109370. */
  109371. cameraToneMappingEnabled: boolean;
  109372. /**
  109373. * The camera exposure used on this material.
  109374. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109375. * This corresponds to a photographic exposure.
  109376. */
  109377. /**
  109378. * The camera exposure used on this material.
  109379. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109380. * This corresponds to a photographic exposure.
  109381. */
  109382. cameraExposure: number;
  109383. /**
  109384. * Gets The camera contrast used on this material.
  109385. */
  109386. /**
  109387. * Sets The camera contrast used on this material.
  109388. */
  109389. cameraContrast: number;
  109390. /**
  109391. * Gets the Color Grading 2D Lookup Texture.
  109392. */
  109393. /**
  109394. * Sets the Color Grading 2D Lookup Texture.
  109395. */
  109396. cameraColorGradingTexture: Nullable<BaseTexture>;
  109397. /**
  109398. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109399. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109400. * 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;
  109401. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109402. */
  109403. /**
  109404. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109405. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109406. * 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;
  109407. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109408. */
  109409. cameraColorCurves: Nullable<ColorCurves>;
  109410. /**
  109411. * Custom callback helping to override the default shader used in the material.
  109412. */
  109413. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  109414. protected _renderTargets: SmartArray<RenderTargetTexture>;
  109415. protected _worldViewProjectionMatrix: Matrix;
  109416. protected _globalAmbientColor: Color3;
  109417. protected _useLogarithmicDepth: boolean;
  109418. protected _rebuildInParallel: boolean;
  109419. /**
  109420. * Instantiates a new standard material.
  109421. * This is the default material used in Babylon. It is the best trade off between quality
  109422. * and performances.
  109423. * @see http://doc.babylonjs.com/babylon101/materials
  109424. * @param name Define the name of the material in the scene
  109425. * @param scene Define the scene the material belong to
  109426. */
  109427. constructor(name: string, scene: Scene);
  109428. /**
  109429. * Gets a boolean indicating that current material needs to register RTT
  109430. */
  109431. readonly hasRenderTargetTextures: boolean;
  109432. /**
  109433. * Gets the current class name of the material e.g. "StandardMaterial"
  109434. * Mainly use in serialization.
  109435. * @returns the class name
  109436. */
  109437. getClassName(): string;
  109438. /**
  109439. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  109440. * You can try switching to logarithmic depth.
  109441. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  109442. */
  109443. useLogarithmicDepth: boolean;
  109444. /**
  109445. * Specifies if the material will require alpha blending
  109446. * @returns a boolean specifying if alpha blending is needed
  109447. */
  109448. needAlphaBlending(): boolean;
  109449. /**
  109450. * Specifies if this material should be rendered in alpha test mode
  109451. * @returns a boolean specifying if an alpha test is needed.
  109452. */
  109453. needAlphaTesting(): boolean;
  109454. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  109455. /**
  109456. * Get the texture used for alpha test purpose.
  109457. * @returns the diffuse texture in case of the standard material.
  109458. */
  109459. getAlphaTestTexture(): Nullable<BaseTexture>;
  109460. /**
  109461. * Get if the submesh is ready to be used and all its information available.
  109462. * Child classes can use it to update shaders
  109463. * @param mesh defines the mesh to check
  109464. * @param subMesh defines which submesh to check
  109465. * @param useInstances specifies that instances should be used
  109466. * @returns a boolean indicating that the submesh is ready or not
  109467. */
  109468. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109469. /**
  109470. * Builds the material UBO layouts.
  109471. * Used internally during the effect preparation.
  109472. */
  109473. buildUniformLayout(): void;
  109474. /**
  109475. * Unbinds the material from the mesh
  109476. */
  109477. unbind(): void;
  109478. /**
  109479. * Binds the submesh to this material by preparing the effect and shader to draw
  109480. * @param world defines the world transformation matrix
  109481. * @param mesh defines the mesh containing the submesh
  109482. * @param subMesh defines the submesh to bind the material to
  109483. */
  109484. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109485. /**
  109486. * Get the list of animatables in the material.
  109487. * @returns the list of animatables object used in the material
  109488. */
  109489. getAnimatables(): IAnimatable[];
  109490. /**
  109491. * Gets the active textures from the material
  109492. * @returns an array of textures
  109493. */
  109494. getActiveTextures(): BaseTexture[];
  109495. /**
  109496. * Specifies if the material uses a texture
  109497. * @param texture defines the texture to check against the material
  109498. * @returns a boolean specifying if the material uses the texture
  109499. */
  109500. hasTexture(texture: BaseTexture): boolean;
  109501. /**
  109502. * Disposes the material
  109503. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109504. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109505. */
  109506. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  109507. /**
  109508. * Makes a duplicate of the material, and gives it a new name
  109509. * @param name defines the new name for the duplicated material
  109510. * @returns the cloned material
  109511. */
  109512. clone(name: string): StandardMaterial;
  109513. /**
  109514. * Serializes this material in a JSON representation
  109515. * @returns the serialized material object
  109516. */
  109517. serialize(): any;
  109518. /**
  109519. * Creates a standard material from parsed material data
  109520. * @param source defines the JSON representation of the material
  109521. * @param scene defines the hosting scene
  109522. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109523. * @returns a new standard material
  109524. */
  109525. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  109526. /**
  109527. * Are diffuse textures enabled in the application.
  109528. */
  109529. static DiffuseTextureEnabled: boolean;
  109530. /**
  109531. * Are ambient textures enabled in the application.
  109532. */
  109533. static AmbientTextureEnabled: boolean;
  109534. /**
  109535. * Are opacity textures enabled in the application.
  109536. */
  109537. static OpacityTextureEnabled: boolean;
  109538. /**
  109539. * Are reflection textures enabled in the application.
  109540. */
  109541. static ReflectionTextureEnabled: boolean;
  109542. /**
  109543. * Are emissive textures enabled in the application.
  109544. */
  109545. static EmissiveTextureEnabled: boolean;
  109546. /**
  109547. * Are specular textures enabled in the application.
  109548. */
  109549. static SpecularTextureEnabled: boolean;
  109550. /**
  109551. * Are bump textures enabled in the application.
  109552. */
  109553. static BumpTextureEnabled: boolean;
  109554. /**
  109555. * Are lightmap textures enabled in the application.
  109556. */
  109557. static LightmapTextureEnabled: boolean;
  109558. /**
  109559. * Are refraction textures enabled in the application.
  109560. */
  109561. static RefractionTextureEnabled: boolean;
  109562. /**
  109563. * Are color grading textures enabled in the application.
  109564. */
  109565. static ColorGradingTextureEnabled: boolean;
  109566. /**
  109567. * Are fresnels enabled in the application.
  109568. */
  109569. static FresnelEnabled: boolean;
  109570. }
  109571. }
  109572. declare module BABYLON {
  109573. /** @hidden */
  109574. export var imageProcessingPixelShader: {
  109575. name: string;
  109576. shader: string;
  109577. };
  109578. }
  109579. declare module BABYLON {
  109580. /**
  109581. * ImageProcessingPostProcess
  109582. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  109583. */
  109584. export class ImageProcessingPostProcess extends PostProcess {
  109585. /**
  109586. * Default configuration related to image processing available in the PBR Material.
  109587. */
  109588. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109589. /**
  109590. * Gets the image processing configuration used either in this material.
  109591. */
  109592. /**
  109593. * Sets the Default image processing configuration used either in the this material.
  109594. *
  109595. * If sets to null, the scene one is in use.
  109596. */
  109597. imageProcessingConfiguration: ImageProcessingConfiguration;
  109598. /**
  109599. * Keep track of the image processing observer to allow dispose and replace.
  109600. */
  109601. private _imageProcessingObserver;
  109602. /**
  109603. * Attaches a new image processing configuration to the PBR Material.
  109604. * @param configuration
  109605. */
  109606. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  109607. /**
  109608. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109609. */
  109610. /**
  109611. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  109612. */
  109613. colorCurves: Nullable<ColorCurves>;
  109614. /**
  109615. * Gets wether the color curves effect is enabled.
  109616. */
  109617. /**
  109618. * Sets wether the color curves effect is enabled.
  109619. */
  109620. colorCurvesEnabled: boolean;
  109621. /**
  109622. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109623. */
  109624. /**
  109625. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  109626. */
  109627. colorGradingTexture: Nullable<BaseTexture>;
  109628. /**
  109629. * Gets wether the color grading effect is enabled.
  109630. */
  109631. /**
  109632. * Gets wether the color grading effect is enabled.
  109633. */
  109634. colorGradingEnabled: boolean;
  109635. /**
  109636. * Gets exposure used in the effect.
  109637. */
  109638. /**
  109639. * Sets exposure used in the effect.
  109640. */
  109641. exposure: number;
  109642. /**
  109643. * Gets wether tonemapping is enabled or not.
  109644. */
  109645. /**
  109646. * Sets wether tonemapping is enabled or not
  109647. */
  109648. toneMappingEnabled: boolean;
  109649. /**
  109650. * Gets the type of tone mapping effect.
  109651. */
  109652. /**
  109653. * Sets the type of tone mapping effect.
  109654. */
  109655. toneMappingType: number;
  109656. /**
  109657. * Gets contrast used in the effect.
  109658. */
  109659. /**
  109660. * Sets contrast used in the effect.
  109661. */
  109662. contrast: number;
  109663. /**
  109664. * Gets Vignette stretch size.
  109665. */
  109666. /**
  109667. * Sets Vignette stretch size.
  109668. */
  109669. vignetteStretch: number;
  109670. /**
  109671. * Gets Vignette centre X Offset.
  109672. */
  109673. /**
  109674. * Sets Vignette centre X Offset.
  109675. */
  109676. vignetteCentreX: number;
  109677. /**
  109678. * Gets Vignette centre Y Offset.
  109679. */
  109680. /**
  109681. * Sets Vignette centre Y Offset.
  109682. */
  109683. vignetteCentreY: number;
  109684. /**
  109685. * Gets Vignette weight or intensity of the vignette effect.
  109686. */
  109687. /**
  109688. * Sets Vignette weight or intensity of the vignette effect.
  109689. */
  109690. vignetteWeight: number;
  109691. /**
  109692. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109693. * if vignetteEnabled is set to true.
  109694. */
  109695. /**
  109696. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  109697. * if vignetteEnabled is set to true.
  109698. */
  109699. vignetteColor: Color4;
  109700. /**
  109701. * Gets Camera field of view used by the Vignette effect.
  109702. */
  109703. /**
  109704. * Sets Camera field of view used by the Vignette effect.
  109705. */
  109706. vignetteCameraFov: number;
  109707. /**
  109708. * Gets the vignette blend mode allowing different kind of effect.
  109709. */
  109710. /**
  109711. * Sets the vignette blend mode allowing different kind of effect.
  109712. */
  109713. vignetteBlendMode: number;
  109714. /**
  109715. * Gets wether the vignette effect is enabled.
  109716. */
  109717. /**
  109718. * Sets wether the vignette effect is enabled.
  109719. */
  109720. vignetteEnabled: boolean;
  109721. private _fromLinearSpace;
  109722. /**
  109723. * Gets wether the input of the processing is in Gamma or Linear Space.
  109724. */
  109725. /**
  109726. * Sets wether the input of the processing is in Gamma or Linear Space.
  109727. */
  109728. fromLinearSpace: boolean;
  109729. /**
  109730. * Defines cache preventing GC.
  109731. */
  109732. private _defines;
  109733. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  109734. /**
  109735. * "ImageProcessingPostProcess"
  109736. * @returns "ImageProcessingPostProcess"
  109737. */
  109738. getClassName(): string;
  109739. protected _updateParameters(): void;
  109740. dispose(camera?: Camera): void;
  109741. }
  109742. }
  109743. declare module BABYLON {
  109744. /**
  109745. * Class containing static functions to help procedurally build meshes
  109746. */
  109747. export class GroundBuilder {
  109748. /**
  109749. * Creates a ground mesh
  109750. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109751. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109753. * @param name defines the name of the mesh
  109754. * @param options defines the options used to create the mesh
  109755. * @param scene defines the hosting scene
  109756. * @returns the ground mesh
  109757. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109758. */
  109759. static CreateGround(name: string, options: {
  109760. width?: number;
  109761. height?: number;
  109762. subdivisions?: number;
  109763. subdivisionsX?: number;
  109764. subdivisionsY?: number;
  109765. updatable?: boolean;
  109766. }, scene: any): Mesh;
  109767. /**
  109768. * Creates a tiled ground mesh
  109769. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109770. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109771. * * 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
  109772. * * 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
  109773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109774. * @param name defines the name of the mesh
  109775. * @param options defines the options used to create the mesh
  109776. * @param scene defines the hosting scene
  109777. * @returns the tiled ground mesh
  109778. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109779. */
  109780. static CreateTiledGround(name: string, options: {
  109781. xmin: number;
  109782. zmin: number;
  109783. xmax: number;
  109784. zmax: number;
  109785. subdivisions?: {
  109786. w: number;
  109787. h: number;
  109788. };
  109789. precision?: {
  109790. w: number;
  109791. h: number;
  109792. };
  109793. updatable?: boolean;
  109794. }, scene?: Nullable<Scene>): Mesh;
  109795. /**
  109796. * Creates a ground mesh from a height map
  109797. * * The parameter `url` sets the URL of the height map image resource.
  109798. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109799. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109800. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109801. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109802. * * 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.
  109803. * * 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).
  109804. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109806. * @param name defines the name of the mesh
  109807. * @param url defines the url to the height map
  109808. * @param options defines the options used to create the mesh
  109809. * @param scene defines the hosting scene
  109810. * @returns the ground mesh
  109811. * @see https://doc.babylonjs.com/babylon101/height_map
  109812. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109813. */
  109814. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109815. width?: number;
  109816. height?: number;
  109817. subdivisions?: number;
  109818. minHeight?: number;
  109819. maxHeight?: number;
  109820. colorFilter?: Color3;
  109821. alphaFilter?: number;
  109822. updatable?: boolean;
  109823. onReady?: (mesh: GroundMesh) => void;
  109824. }, scene?: Nullable<Scene>): GroundMesh;
  109825. }
  109826. }
  109827. declare module BABYLON {
  109828. /**
  109829. * Class containing static functions to help procedurally build meshes
  109830. */
  109831. export class TorusBuilder {
  109832. /**
  109833. * Creates a torus mesh
  109834. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109835. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109836. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109840. * @param name defines the name of the mesh
  109841. * @param options defines the options used to create the mesh
  109842. * @param scene defines the hosting scene
  109843. * @returns the torus mesh
  109844. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109845. */
  109846. static CreateTorus(name: string, options: {
  109847. diameter?: number;
  109848. thickness?: number;
  109849. tessellation?: number;
  109850. updatable?: boolean;
  109851. sideOrientation?: number;
  109852. frontUVs?: Vector4;
  109853. backUVs?: Vector4;
  109854. }, scene: any): Mesh;
  109855. }
  109856. }
  109857. declare module BABYLON {
  109858. /**
  109859. * Class containing static functions to help procedurally build meshes
  109860. */
  109861. export class CylinderBuilder {
  109862. /**
  109863. * Creates a cylinder or a cone mesh
  109864. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109865. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109866. * * 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.
  109867. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109868. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109869. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109870. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109871. * * 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).
  109872. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109873. * * 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).
  109874. * * 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
  109875. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109876. * * 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
  109877. * * 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.
  109878. * * If `enclose` is false, a ring surface is one element.
  109879. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109880. * * 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
  109881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109884. * @param name defines the name of the mesh
  109885. * @param options defines the options used to create the mesh
  109886. * @param scene defines the hosting scene
  109887. * @returns the cylinder mesh
  109888. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109889. */
  109890. static CreateCylinder(name: string, options: {
  109891. height?: number;
  109892. diameterTop?: number;
  109893. diameterBottom?: number;
  109894. diameter?: number;
  109895. tessellation?: number;
  109896. subdivisions?: number;
  109897. arc?: number;
  109898. faceColors?: Color4[];
  109899. faceUV?: Vector4[];
  109900. updatable?: boolean;
  109901. hasRings?: boolean;
  109902. enclose?: boolean;
  109903. cap?: number;
  109904. sideOrientation?: number;
  109905. frontUVs?: Vector4;
  109906. backUVs?: Vector4;
  109907. }, scene: any): Mesh;
  109908. }
  109909. }
  109910. declare module BABYLON {
  109911. /**
  109912. * Options to modify the vr teleportation behavior.
  109913. */
  109914. export interface VRTeleportationOptions {
  109915. /**
  109916. * The name of the mesh which should be used as the teleportation floor. (default: null)
  109917. */
  109918. floorMeshName?: string;
  109919. /**
  109920. * A list of meshes to be used as the teleportation floor. (default: empty)
  109921. */
  109922. floorMeshes?: Mesh[];
  109923. }
  109924. /**
  109925. * Options to modify the vr experience helper's behavior.
  109926. */
  109927. export interface VRExperienceHelperOptions extends WebVROptions {
  109928. /**
  109929. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  109930. */
  109931. createDeviceOrientationCamera?: boolean;
  109932. /**
  109933. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  109934. */
  109935. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  109936. /**
  109937. * Uses the main button on the controller to toggle the laser casted. (default: true)
  109938. */
  109939. laserToggle?: boolean;
  109940. /**
  109941. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  109942. */
  109943. floorMeshes?: Mesh[];
  109944. /**
  109945. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  109946. */
  109947. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  109948. }
  109949. /**
  109950. * Event containing information after VR has been entered
  109951. */
  109952. export class OnAfterEnteringVRObservableEvent {
  109953. /**
  109954. * If entering vr was successful
  109955. */
  109956. success: boolean;
  109957. }
  109958. /**
  109959. * Helps to quickly add VR support to an existing scene.
  109960. * See http://doc.babylonjs.com/how_to/webvr_helper
  109961. */
  109962. export class VRExperienceHelper {
  109963. /** Options to modify the vr experience helper's behavior. */
  109964. webVROptions: VRExperienceHelperOptions;
  109965. private _scene;
  109966. private _position;
  109967. private _btnVR;
  109968. private _btnVRDisplayed;
  109969. private _webVRsupported;
  109970. private _webVRready;
  109971. private _webVRrequesting;
  109972. private _webVRpresenting;
  109973. private _hasEnteredVR;
  109974. private _fullscreenVRpresenting;
  109975. private _inputElement;
  109976. private _webVRCamera;
  109977. private _vrDeviceOrientationCamera;
  109978. private _deviceOrientationCamera;
  109979. private _existingCamera;
  109980. private _onKeyDown;
  109981. private _onVrDisplayPresentChange;
  109982. private _onVRDisplayChanged;
  109983. private _onVRRequestPresentStart;
  109984. private _onVRRequestPresentComplete;
  109985. /**
  109986. * 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)
  109987. */
  109988. enableGazeEvenWhenNoPointerLock: boolean;
  109989. /**
  109990. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  109991. */
  109992. exitVROnDoubleTap: boolean;
  109993. /**
  109994. * Observable raised right before entering VR.
  109995. */
  109996. onEnteringVRObservable: Observable<VRExperienceHelper>;
  109997. /**
  109998. * Observable raised when entering VR has completed.
  109999. */
  110000. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  110001. /**
  110002. * Observable raised when exiting VR.
  110003. */
  110004. onExitingVRObservable: Observable<VRExperienceHelper>;
  110005. /**
  110006. * Observable raised when controller mesh is loaded.
  110007. */
  110008. onControllerMeshLoadedObservable: Observable<WebVRController>;
  110009. /** Return this.onEnteringVRObservable
  110010. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  110011. */
  110012. readonly onEnteringVR: Observable<VRExperienceHelper>;
  110013. /** Return this.onExitingVRObservable
  110014. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  110015. */
  110016. readonly onExitingVR: Observable<VRExperienceHelper>;
  110017. /** Return this.onControllerMeshLoadedObservable
  110018. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  110019. */
  110020. readonly onControllerMeshLoaded: Observable<WebVRController>;
  110021. private _rayLength;
  110022. private _useCustomVRButton;
  110023. private _teleportationRequested;
  110024. private _teleportActive;
  110025. private _floorMeshName;
  110026. private _floorMeshesCollection;
  110027. private _rotationAllowed;
  110028. private _teleportBackwardsVector;
  110029. private _teleportationTarget;
  110030. private _isDefaultTeleportationTarget;
  110031. private _postProcessMove;
  110032. private _teleportationFillColor;
  110033. private _teleportationBorderColor;
  110034. private _rotationAngle;
  110035. private _haloCenter;
  110036. private _cameraGazer;
  110037. private _padSensibilityUp;
  110038. private _padSensibilityDown;
  110039. private _leftController;
  110040. private _rightController;
  110041. /**
  110042. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  110043. */
  110044. onNewMeshSelected: Observable<AbstractMesh>;
  110045. /**
  110046. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  110047. * This observable will provide the mesh and the controller used to select the mesh
  110048. */
  110049. onMeshSelectedWithController: Observable<{
  110050. mesh: AbstractMesh;
  110051. controller: WebVRController;
  110052. }>;
  110053. /**
  110054. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  110055. */
  110056. onNewMeshPicked: Observable<PickingInfo>;
  110057. private _circleEase;
  110058. /**
  110059. * Observable raised before camera teleportation
  110060. */
  110061. onBeforeCameraTeleport: Observable<Vector3>;
  110062. /**
  110063. * Observable raised after camera teleportation
  110064. */
  110065. onAfterCameraTeleport: Observable<Vector3>;
  110066. /**
  110067. * Observable raised when current selected mesh gets unselected
  110068. */
  110069. onSelectedMeshUnselected: Observable<AbstractMesh>;
  110070. private _raySelectionPredicate;
  110071. /**
  110072. * To be optionaly changed by user to define custom ray selection
  110073. */
  110074. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  110075. /**
  110076. * To be optionaly changed by user to define custom selection logic (after ray selection)
  110077. */
  110078. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  110079. /**
  110080. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  110081. */
  110082. teleportationEnabled: boolean;
  110083. private _defaultHeight;
  110084. private _teleportationInitialized;
  110085. private _interactionsEnabled;
  110086. private _interactionsRequested;
  110087. private _displayGaze;
  110088. private _displayLaserPointer;
  110089. /**
  110090. * The mesh used to display where the user is going to teleport.
  110091. */
  110092. /**
  110093. * Sets the mesh to be used to display where the user is going to teleport.
  110094. */
  110095. teleportationTarget: Mesh;
  110096. /**
  110097. * 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
  110098. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  110099. * See http://doc.babylonjs.com/resources/baking_transformations
  110100. */
  110101. gazeTrackerMesh: Mesh;
  110102. /**
  110103. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  110104. */
  110105. updateGazeTrackerScale: boolean;
  110106. /**
  110107. * If the gaze trackers color should be updated when selecting meshes
  110108. */
  110109. updateGazeTrackerColor: boolean;
  110110. /**
  110111. * If the controller laser color should be updated when selecting meshes
  110112. */
  110113. updateControllerLaserColor: boolean;
  110114. /**
  110115. * The gaze tracking mesh corresponding to the left controller
  110116. */
  110117. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  110118. /**
  110119. * The gaze tracking mesh corresponding to the right controller
  110120. */
  110121. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  110122. /**
  110123. * If the ray of the gaze should be displayed.
  110124. */
  110125. /**
  110126. * Sets if the ray of the gaze should be displayed.
  110127. */
  110128. displayGaze: boolean;
  110129. /**
  110130. * If the ray of the LaserPointer should be displayed.
  110131. */
  110132. /**
  110133. * Sets if the ray of the LaserPointer should be displayed.
  110134. */
  110135. displayLaserPointer: boolean;
  110136. /**
  110137. * The deviceOrientationCamera used as the camera when not in VR.
  110138. */
  110139. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  110140. /**
  110141. * Based on the current WebVR support, returns the current VR camera used.
  110142. */
  110143. readonly currentVRCamera: Nullable<Camera>;
  110144. /**
  110145. * The webVRCamera which is used when in VR.
  110146. */
  110147. readonly webVRCamera: WebVRFreeCamera;
  110148. /**
  110149. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  110150. */
  110151. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  110152. /**
  110153. * The html button that is used to trigger entering into VR.
  110154. */
  110155. readonly vrButton: Nullable<HTMLButtonElement>;
  110156. private readonly _teleportationRequestInitiated;
  110157. /**
  110158. * Defines wether or not Pointer lock should be requested when switching to
  110159. * full screen.
  110160. */
  110161. requestPointerLockOnFullScreen: boolean;
  110162. /**
  110163. * Instantiates a VRExperienceHelper.
  110164. * Helps to quickly add VR support to an existing scene.
  110165. * @param scene The scene the VRExperienceHelper belongs to.
  110166. * @param webVROptions Options to modify the vr experience helper's behavior.
  110167. */
  110168. constructor(scene: Scene,
  110169. /** Options to modify the vr experience helper's behavior. */
  110170. webVROptions?: VRExperienceHelperOptions);
  110171. private _onDefaultMeshLoaded;
  110172. private _onResize;
  110173. private _onFullscreenChange;
  110174. /**
  110175. * Gets a value indicating if we are currently in VR mode.
  110176. */
  110177. readonly isInVRMode: boolean;
  110178. private onVrDisplayPresentChange;
  110179. private onVRDisplayChanged;
  110180. private moveButtonToBottomRight;
  110181. private displayVRButton;
  110182. private updateButtonVisibility;
  110183. private _cachedAngularSensibility;
  110184. /**
  110185. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  110186. * Otherwise, will use the fullscreen API.
  110187. */
  110188. enterVR(): void;
  110189. /**
  110190. * Attempt to exit VR, or fullscreen.
  110191. */
  110192. exitVR(): void;
  110193. /**
  110194. * The position of the vr experience helper.
  110195. */
  110196. /**
  110197. * Sets the position of the vr experience helper.
  110198. */
  110199. position: Vector3;
  110200. /**
  110201. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  110202. */
  110203. enableInteractions(): void;
  110204. private readonly _noControllerIsActive;
  110205. private beforeRender;
  110206. private _isTeleportationFloor;
  110207. /**
  110208. * Adds a floor mesh to be used for teleportation.
  110209. * @param floorMesh the mesh to be used for teleportation.
  110210. */
  110211. addFloorMesh(floorMesh: Mesh): void;
  110212. /**
  110213. * Removes a floor mesh from being used for teleportation.
  110214. * @param floorMesh the mesh to be removed.
  110215. */
  110216. removeFloorMesh(floorMesh: Mesh): void;
  110217. /**
  110218. * Enables interactions and teleportation using the VR controllers and gaze.
  110219. * @param vrTeleportationOptions options to modify teleportation behavior.
  110220. */
  110221. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  110222. private _onNewGamepadConnected;
  110223. private _tryEnableInteractionOnController;
  110224. private _onNewGamepadDisconnected;
  110225. private _enableInteractionOnController;
  110226. private _checkTeleportWithRay;
  110227. private _checkRotate;
  110228. private _checkTeleportBackwards;
  110229. private _enableTeleportationOnController;
  110230. private _createTeleportationCircles;
  110231. private _displayTeleportationTarget;
  110232. private _hideTeleportationTarget;
  110233. private _rotateCamera;
  110234. private _moveTeleportationSelectorTo;
  110235. private _workingVector;
  110236. private _workingQuaternion;
  110237. private _workingMatrix;
  110238. /**
  110239. * Teleports the users feet to the desired location
  110240. * @param location The location where the user's feet should be placed
  110241. */
  110242. teleportCamera(location: Vector3): void;
  110243. private _convertNormalToDirectionOfRay;
  110244. private _castRayAndSelectObject;
  110245. private _notifySelectedMeshUnselected;
  110246. /**
  110247. * Sets the color of the laser ray from the vr controllers.
  110248. * @param color new color for the ray.
  110249. */
  110250. changeLaserColor(color: Color3): void;
  110251. /**
  110252. * Sets the color of the ray from the vr headsets gaze.
  110253. * @param color new color for the ray.
  110254. */
  110255. changeGazeColor(color: Color3): void;
  110256. /**
  110257. * Exits VR and disposes of the vr experience helper
  110258. */
  110259. dispose(): void;
  110260. /**
  110261. * Gets the name of the VRExperienceHelper class
  110262. * @returns "VRExperienceHelper"
  110263. */
  110264. getClassName(): string;
  110265. }
  110266. }
  110267. declare module BABYLON {
  110268. /**
  110269. * States of the webXR experience
  110270. */
  110271. export enum WebXRState {
  110272. /**
  110273. * Transitioning to being in XR mode
  110274. */
  110275. ENTERING_XR = 0,
  110276. /**
  110277. * Transitioning to non XR mode
  110278. */
  110279. EXITING_XR = 1,
  110280. /**
  110281. * In XR mode and presenting
  110282. */
  110283. IN_XR = 2,
  110284. /**
  110285. * Not entered XR mode
  110286. */
  110287. NOT_IN_XR = 3
  110288. }
  110289. /**
  110290. * Abstraction of the XR render target
  110291. */
  110292. export interface WebXRRenderTarget extends IDisposable {
  110293. /**
  110294. * xrpresent context of the canvas which can be used to display/mirror xr content
  110295. */
  110296. canvasContext: WebGLRenderingContext;
  110297. /**
  110298. * xr layer for the canvas
  110299. */
  110300. xrLayer: Nullable<XRWebGLLayer>;
  110301. /**
  110302. * Initializes the xr layer for the session
  110303. * @param xrSession xr session
  110304. * @returns a promise that will resolve once the XR Layer has been created
  110305. */
  110306. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  110307. }
  110308. }
  110309. declare module BABYLON {
  110310. /**
  110311. * COnfiguration object for WebXR output canvas
  110312. */
  110313. export class WebXRManagedOutputCanvasOptions {
  110314. /**
  110315. * Options for this XR Layer output
  110316. */
  110317. canvasOptions: XRWebGLLayerOptions;
  110318. /**
  110319. * CSS styling for a newly created canvas (if not provided)
  110320. */
  110321. newCanvasCssStyle?: string;
  110322. /**
  110323. * Get the default values of the configuration object
  110324. * @returns default values of this configuration object
  110325. */
  110326. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  110327. }
  110328. /**
  110329. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  110330. */
  110331. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  110332. private configuration;
  110333. private _engine;
  110334. private _canvas;
  110335. /**
  110336. * xrpresent context of the canvas which can be used to display/mirror xr content
  110337. */
  110338. canvasContext: WebGLRenderingContext;
  110339. /**
  110340. * xr layer for the canvas
  110341. */
  110342. xrLayer: Nullable<XRWebGLLayer>;
  110343. /**
  110344. * Initializes the xr layer for the session
  110345. * @param xrSession xr session
  110346. * @returns a promise that will resolve once the XR Layer has been created
  110347. */
  110348. initializeXRLayerAsync(xrSession: any): any;
  110349. /**
  110350. * Initializes the canvas to be added/removed upon entering/exiting xr
  110351. * @param engine the Babylon engine
  110352. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  110353. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  110354. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  110355. */
  110356. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  110357. /**
  110358. * Disposes of the object
  110359. */
  110360. dispose(): void;
  110361. private _setManagedOutputCanvas;
  110362. private _addCanvas;
  110363. private _removeCanvas;
  110364. }
  110365. }
  110366. declare module BABYLON {
  110367. /**
  110368. * Manages an XRSession to work with Babylon's engine
  110369. * @see https://doc.babylonjs.com/how_to/webxr
  110370. */
  110371. export class WebXRSessionManager implements IDisposable {
  110372. private scene;
  110373. /**
  110374. * Fires every time a new xrFrame arrives which can be used to update the camera
  110375. */
  110376. onXRFrameObservable: Observable<any>;
  110377. /**
  110378. * Fires when the xr session is ended either by the device or manually done
  110379. */
  110380. onXRSessionEnded: Observable<any>;
  110381. /**
  110382. * Underlying xr session
  110383. */
  110384. session: XRSession;
  110385. /**
  110386. * Type of reference space used when creating the session
  110387. */
  110388. referenceSpace: XRReferenceSpace;
  110389. /**
  110390. * Current XR frame
  110391. */
  110392. currentFrame: Nullable<XRFrame>;
  110393. private _xrNavigator;
  110394. private baseLayer;
  110395. private _rttProvider;
  110396. private _sessionEnded;
  110397. /**
  110398. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  110399. * @param scene The scene which the session should be created for
  110400. */
  110401. constructor(scene: Scene);
  110402. /**
  110403. * Initializes the manager
  110404. * After initialization enterXR can be called to start an XR session
  110405. * @returns Promise which resolves after it is initialized
  110406. */
  110407. initializeAsync(): Promise<void>;
  110408. /**
  110409. * Initializes an xr session
  110410. * @param xrSessionMode mode to initialize
  110411. * @param optionalFeatures defines optional values to pass to the session builder
  110412. * @returns a promise which will resolve once the session has been initialized
  110413. */
  110414. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  110415. /**
  110416. * Sets the reference space on the xr session
  110417. * @param referenceSpace space to set
  110418. * @returns a promise that will resolve once the reference space has been set
  110419. */
  110420. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  110421. /**
  110422. * Updates the render state of the session
  110423. * @param state state to set
  110424. * @returns a promise that resolves once the render state has been updated
  110425. */
  110426. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  110427. /**
  110428. * Starts rendering to the xr layer
  110429. * @returns a promise that will resolve once rendering has started
  110430. */
  110431. startRenderingToXRAsync(): Promise<void>;
  110432. /**
  110433. * Gets the correct render target texture to be rendered this frame for this eye
  110434. * @param eye the eye for which to get the render target
  110435. * @returns the render target for the specified eye
  110436. */
  110437. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  110438. /**
  110439. * Stops the xrSession and restores the renderloop
  110440. * @returns Promise which resolves after it exits XR
  110441. */
  110442. exitXRAsync(): Promise<void>;
  110443. /**
  110444. * Checks if a session would be supported for the creation options specified
  110445. * @param sessionMode session mode to check if supported eg. immersive-vr
  110446. * @returns true if supported
  110447. */
  110448. supportsSessionAsync(sessionMode: XRSessionMode): any;
  110449. /**
  110450. * Creates a WebXRRenderTarget object for the XR session
  110451. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  110452. * @param options optional options to provide when creating a new render target
  110453. * @returns a WebXR render target to which the session can render
  110454. */
  110455. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  110456. /**
  110457. * @hidden
  110458. * Converts the render layer of xrSession to a render target
  110459. * @param session session to create render target for
  110460. * @param scene scene the new render target should be created for
  110461. */
  110462. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  110463. /**
  110464. * Disposes of the session manager
  110465. */
  110466. dispose(): void;
  110467. }
  110468. }
  110469. declare module BABYLON {
  110470. /**
  110471. * WebXR Camera which holds the views for the xrSession
  110472. * @see https://doc.babylonjs.com/how_to/webxr
  110473. */
  110474. export class WebXRCamera extends FreeCamera {
  110475. /**
  110476. * Is the camera in debug mode. Used when using an emulator
  110477. */
  110478. debugMode: boolean;
  110479. /**
  110480. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  110481. * @param name the name of the camera
  110482. * @param scene the scene to add the camera to
  110483. */
  110484. constructor(name: string, scene: Scene);
  110485. private _updateNumberOfRigCameras;
  110486. /** @hidden */
  110487. _updateForDualEyeDebugging(): void;
  110488. /**
  110489. * Updates the cameras position from the current pose information of the XR session
  110490. * @param xrSessionManager the session containing pose information
  110491. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  110492. */
  110493. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  110494. }
  110495. }
  110496. declare module BABYLON {
  110497. /**
  110498. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  110499. * @see https://doc.babylonjs.com/how_to/webxr
  110500. */
  110501. export class WebXRExperienceHelper implements IDisposable {
  110502. private scene;
  110503. /**
  110504. * 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
  110505. */
  110506. container: AbstractMesh;
  110507. /**
  110508. * Camera used to render xr content
  110509. */
  110510. camera: WebXRCamera;
  110511. /**
  110512. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  110513. */
  110514. state: WebXRState;
  110515. private _setState;
  110516. private static _TmpVector;
  110517. /**
  110518. * Fires when the state of the experience helper has changed
  110519. */
  110520. onStateChangedObservable: Observable<WebXRState>;
  110521. /** Session manager used to keep track of xr session */
  110522. sessionManager: WebXRSessionManager;
  110523. private _nonVRCamera;
  110524. private _originalSceneAutoClear;
  110525. private _supported;
  110526. /**
  110527. * Creates the experience helper
  110528. * @param scene the scene to attach the experience helper to
  110529. * @returns a promise for the experience helper
  110530. */
  110531. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  110532. /**
  110533. * Creates a WebXRExperienceHelper
  110534. * @param scene The scene the helper should be created in
  110535. */
  110536. private constructor();
  110537. /**
  110538. * Exits XR mode and returns the scene to its original state
  110539. * @returns promise that resolves after xr mode has exited
  110540. */
  110541. exitXRAsync(): Promise<void>;
  110542. /**
  110543. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  110544. * @param sessionMode options for the XR session
  110545. * @param referenceSpaceType frame of reference of the XR session
  110546. * @param renderTarget the output canvas that will be used to enter XR mode
  110547. * @returns promise that resolves after xr mode has entered
  110548. */
  110549. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  110550. /**
  110551. * Updates the global position of the camera by moving the camera's container
  110552. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  110553. * @param position The desired global position of the camera
  110554. */
  110555. setPositionOfCameraUsingContainer(position: Vector3): void;
  110556. /**
  110557. * Rotates the xr camera by rotating the camera's container around the camera's position
  110558. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  110559. * @param rotation the desired quaternion rotation to apply to the camera
  110560. */
  110561. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  110562. /**
  110563. * Disposes of the experience helper
  110564. */
  110565. dispose(): void;
  110566. }
  110567. }
  110568. declare module BABYLON {
  110569. /**
  110570. * Button which can be used to enter a different mode of XR
  110571. */
  110572. export class WebXREnterExitUIButton {
  110573. /** button element */
  110574. element: HTMLElement;
  110575. /** XR initialization options for the button */
  110576. sessionMode: XRSessionMode;
  110577. /** Reference space type */
  110578. referenceSpaceType: XRReferenceSpaceType;
  110579. /**
  110580. * Creates a WebXREnterExitUIButton
  110581. * @param element button element
  110582. * @param sessionMode XR initialization session mode
  110583. * @param referenceSpaceType the type of reference space to be used
  110584. */
  110585. constructor(
  110586. /** button element */
  110587. element: HTMLElement,
  110588. /** XR initialization options for the button */
  110589. sessionMode: XRSessionMode,
  110590. /** Reference space type */
  110591. referenceSpaceType: XRReferenceSpaceType);
  110592. /**
  110593. * Overwritable function which can be used to update the button's visuals when the state changes
  110594. * @param activeButton the current active button in the UI
  110595. */
  110596. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  110597. }
  110598. /**
  110599. * Options to create the webXR UI
  110600. */
  110601. export class WebXREnterExitUIOptions {
  110602. /**
  110603. * Context to enter xr with
  110604. */
  110605. renderTarget?: Nullable<WebXRRenderTarget>;
  110606. /**
  110607. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  110608. */
  110609. customButtons?: Array<WebXREnterExitUIButton>;
  110610. /**
  110611. * A session mode to use when creating the default button.
  110612. * Default is immersive-vr
  110613. */
  110614. sessionMode?: XRSessionMode;
  110615. /**
  110616. * A reference space type to use when creating the default button.
  110617. * Default is local-floor
  110618. */
  110619. referenceSpaceType?: XRReferenceSpaceType;
  110620. }
  110621. /**
  110622. * UI to allow the user to enter/exit XR mode
  110623. */
  110624. export class WebXREnterExitUI implements IDisposable {
  110625. private scene;
  110626. private _overlay;
  110627. private _buttons;
  110628. private _activeButton;
  110629. /**
  110630. * Fired every time the active button is changed.
  110631. *
  110632. * When xr is entered via a button that launches xr that button will be the callback parameter
  110633. *
  110634. * When exiting xr the callback parameter will be null)
  110635. */
  110636. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  110637. /**
  110638. * Creates UI to allow the user to enter/exit XR mode
  110639. * @param scene the scene to add the ui to
  110640. * @param helper the xr experience helper to enter/exit xr with
  110641. * @param options options to configure the UI
  110642. * @returns the created ui
  110643. */
  110644. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  110645. private constructor();
  110646. private _updateButtons;
  110647. /**
  110648. * Disposes of the object
  110649. */
  110650. dispose(): void;
  110651. }
  110652. }
  110653. declare module BABYLON {
  110654. /**
  110655. * Represents an XR input
  110656. */
  110657. export class WebXRController {
  110658. private scene;
  110659. /** The underlying input source for the controller */
  110660. inputSource: XRInputSource;
  110661. private parentContainer;
  110662. /**
  110663. * 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
  110664. */
  110665. grip?: AbstractMesh;
  110666. /**
  110667. * Pointer which can be used to select objects or attach a visible laser to
  110668. */
  110669. pointer: AbstractMesh;
  110670. private _gamepadMode;
  110671. /**
  110672. * If available, this is the gamepad object related to this controller.
  110673. * Using this object it is possible to get click events and trackpad changes of the
  110674. * webxr controller that is currently being used.
  110675. */
  110676. gamepadController?: WebVRController;
  110677. /**
  110678. * Event that fires when the controller is removed/disposed
  110679. */
  110680. onDisposeObservable: Observable<{}>;
  110681. private _tmpMatrix;
  110682. private _tmpQuaternion;
  110683. private _tmpVector;
  110684. /**
  110685. * Creates the controller
  110686. * @see https://doc.babylonjs.com/how_to/webxr
  110687. * @param scene the scene which the controller should be associated to
  110688. * @param inputSource the underlying input source for the controller
  110689. * @param parentContainer parent that the controller meshes should be children of
  110690. */
  110691. constructor(scene: Scene,
  110692. /** The underlying input source for the controller */
  110693. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  110694. /**
  110695. * Updates the controller pose based on the given XRFrame
  110696. * @param xrFrame xr frame to update the pose with
  110697. * @param referenceSpace reference space to use
  110698. */
  110699. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  110700. /**
  110701. * Gets a world space ray coming from the controller
  110702. * @param result the resulting ray
  110703. */
  110704. getWorldPointerRayToRef(result: Ray): void;
  110705. /**
  110706. * Get the scene associated with this controller
  110707. * @returns the scene object
  110708. */
  110709. getScene(): Scene;
  110710. /**
  110711. * Disposes of the object
  110712. */
  110713. dispose(): void;
  110714. }
  110715. }
  110716. declare module BABYLON {
  110717. /**
  110718. * XR input used to track XR inputs such as controllers/rays
  110719. */
  110720. export class WebXRInput implements IDisposable {
  110721. /**
  110722. * Base experience the input listens to
  110723. */
  110724. baseExperience: WebXRExperienceHelper;
  110725. /**
  110726. * XR controllers being tracked
  110727. */
  110728. controllers: Array<WebXRController>;
  110729. private _frameObserver;
  110730. private _stateObserver;
  110731. /**
  110732. * Event when a controller has been connected/added
  110733. */
  110734. onControllerAddedObservable: Observable<WebXRController>;
  110735. /**
  110736. * Event when a controller has been removed/disconnected
  110737. */
  110738. onControllerRemovedObservable: Observable<WebXRController>;
  110739. /**
  110740. * Initializes the WebXRInput
  110741. * @param baseExperience experience helper which the input should be created for
  110742. */
  110743. constructor(
  110744. /**
  110745. * Base experience the input listens to
  110746. */
  110747. baseExperience: WebXRExperienceHelper);
  110748. private _onInputSourcesChange;
  110749. private _addAndRemoveControllers;
  110750. /**
  110751. * Disposes of the object
  110752. */
  110753. dispose(): void;
  110754. }
  110755. }
  110756. declare module BABYLON {
  110757. /**
  110758. * Enables teleportation
  110759. */
  110760. export class WebXRControllerTeleportation {
  110761. private _teleportationFillColor;
  110762. private _teleportationBorderColor;
  110763. private _tmpRay;
  110764. private _tmpVector;
  110765. /**
  110766. * Creates a WebXRControllerTeleportation
  110767. * @param input input manager to add teleportation to
  110768. * @param floorMeshes floormeshes which can be teleported to
  110769. */
  110770. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  110771. }
  110772. }
  110773. declare module BABYLON {
  110774. /**
  110775. * Handles pointer input automatically for the pointer of XR controllers
  110776. */
  110777. export class WebXRControllerPointerSelection {
  110778. private static _idCounter;
  110779. private _tmpRay;
  110780. /**
  110781. * Creates a WebXRControllerPointerSelection
  110782. * @param input input manager to setup pointer selection
  110783. */
  110784. constructor(input: WebXRInput);
  110785. private _convertNormalToDirectionOfRay;
  110786. private _updatePointerDistance;
  110787. }
  110788. }
  110789. declare module BABYLON {
  110790. /**
  110791. * Class used to represent data loading progression
  110792. */
  110793. export class SceneLoaderProgressEvent {
  110794. /** defines if data length to load can be evaluated */
  110795. readonly lengthComputable: boolean;
  110796. /** defines the loaded data length */
  110797. readonly loaded: number;
  110798. /** defines the data length to load */
  110799. readonly total: number;
  110800. /**
  110801. * Create a new progress event
  110802. * @param lengthComputable defines if data length to load can be evaluated
  110803. * @param loaded defines the loaded data length
  110804. * @param total defines the data length to load
  110805. */
  110806. constructor(
  110807. /** defines if data length to load can be evaluated */
  110808. lengthComputable: boolean,
  110809. /** defines the loaded data length */
  110810. loaded: number,
  110811. /** defines the data length to load */
  110812. total: number);
  110813. /**
  110814. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  110815. * @param event defines the source event
  110816. * @returns a new SceneLoaderProgressEvent
  110817. */
  110818. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  110819. }
  110820. /**
  110821. * Interface used by SceneLoader plugins to define supported file extensions
  110822. */
  110823. export interface ISceneLoaderPluginExtensions {
  110824. /**
  110825. * Defines the list of supported extensions
  110826. */
  110827. [extension: string]: {
  110828. isBinary: boolean;
  110829. };
  110830. }
  110831. /**
  110832. * Interface used by SceneLoader plugin factory
  110833. */
  110834. export interface ISceneLoaderPluginFactory {
  110835. /**
  110836. * Defines the name of the factory
  110837. */
  110838. name: string;
  110839. /**
  110840. * Function called to create a new plugin
  110841. * @return the new plugin
  110842. */
  110843. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  110844. /**
  110845. * The callback that returns true if the data can be directly loaded.
  110846. * @param data string containing the file data
  110847. * @returns if the data can be loaded directly
  110848. */
  110849. canDirectLoad?(data: string): boolean;
  110850. }
  110851. /**
  110852. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  110853. */
  110854. export interface ISceneLoaderPluginBase {
  110855. /**
  110856. * The friendly name of this plugin.
  110857. */
  110858. name: string;
  110859. /**
  110860. * The file extensions supported by this plugin.
  110861. */
  110862. extensions: string | ISceneLoaderPluginExtensions;
  110863. /**
  110864. * The callback called when loading from a url.
  110865. * @param scene scene loading this url
  110866. * @param url url to load
  110867. * @param onSuccess callback called when the file successfully loads
  110868. * @param onProgress callback called while file is loading (if the server supports this mode)
  110869. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  110870. * @param onError callback called when the file fails to load
  110871. * @returns a file request object
  110872. */
  110873. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110874. /**
  110875. * The callback called when loading from a file object.
  110876. * @param scene scene loading this file
  110877. * @param file defines the file to load
  110878. * @param onSuccess defines the callback to call when data is loaded
  110879. * @param onProgress defines the callback to call during loading process
  110880. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  110881. * @param onError defines the callback to call when an error occurs
  110882. * @returns a file request object
  110883. */
  110884. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  110885. /**
  110886. * The callback that returns true if the data can be directly loaded.
  110887. * @param data string containing the file data
  110888. * @returns if the data can be loaded directly
  110889. */
  110890. canDirectLoad?(data: string): boolean;
  110891. /**
  110892. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  110893. * @param scene scene loading this data
  110894. * @param data string containing the data
  110895. * @returns data to pass to the plugin
  110896. */
  110897. directLoad?(scene: Scene, data: string): any;
  110898. /**
  110899. * The callback that allows custom handling of the root url based on the response url.
  110900. * @param rootUrl the original root url
  110901. * @param responseURL the response url if available
  110902. * @returns the new root url
  110903. */
  110904. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  110905. }
  110906. /**
  110907. * Interface used to define a SceneLoader plugin
  110908. */
  110909. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  110910. /**
  110911. * Import meshes into a scene.
  110912. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110913. * @param scene The scene to import into
  110914. * @param data The data to import
  110915. * @param rootUrl The root url for scene and resources
  110916. * @param meshes The meshes array to import into
  110917. * @param particleSystems The particle systems array to import into
  110918. * @param skeletons The skeletons array to import into
  110919. * @param onError The callback when import fails
  110920. * @returns True if successful or false otherwise
  110921. */
  110922. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  110923. /**
  110924. * Load into a scene.
  110925. * @param scene The scene to load into
  110926. * @param data The data to import
  110927. * @param rootUrl The root url for scene and resources
  110928. * @param onError The callback when import fails
  110929. * @returns True if successful or false otherwise
  110930. */
  110931. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  110932. /**
  110933. * Load into an asset container.
  110934. * @param scene The scene to load into
  110935. * @param data The data to import
  110936. * @param rootUrl The root url for scene and resources
  110937. * @param onError The callback when import fails
  110938. * @returns The loaded asset container
  110939. */
  110940. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  110941. }
  110942. /**
  110943. * Interface used to define an async SceneLoader plugin
  110944. */
  110945. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  110946. /**
  110947. * Import meshes into a scene.
  110948. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  110949. * @param scene The scene to import into
  110950. * @param data The data to import
  110951. * @param rootUrl The root url for scene and resources
  110952. * @param onProgress The callback when the load progresses
  110953. * @param fileName Defines the name of the file to load
  110954. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  110955. */
  110956. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  110957. meshes: AbstractMesh[];
  110958. particleSystems: IParticleSystem[];
  110959. skeletons: Skeleton[];
  110960. animationGroups: AnimationGroup[];
  110961. }>;
  110962. /**
  110963. * Load into a scene.
  110964. * @param scene The scene to load into
  110965. * @param data The data to import
  110966. * @param rootUrl The root url for scene and resources
  110967. * @param onProgress The callback when the load progresses
  110968. * @param fileName Defines the name of the file to load
  110969. * @returns Nothing
  110970. */
  110971. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  110972. /**
  110973. * Load into an asset container.
  110974. * @param scene The scene to load into
  110975. * @param data The data to import
  110976. * @param rootUrl The root url for scene and resources
  110977. * @param onProgress The callback when the load progresses
  110978. * @param fileName Defines the name of the file to load
  110979. * @returns The loaded asset container
  110980. */
  110981. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  110982. }
  110983. /**
  110984. * Class used to load scene from various file formats using registered plugins
  110985. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  110986. */
  110987. export class SceneLoader {
  110988. /**
  110989. * No logging while loading
  110990. */
  110991. static readonly NO_LOGGING: number;
  110992. /**
  110993. * Minimal logging while loading
  110994. */
  110995. static readonly MINIMAL_LOGGING: number;
  110996. /**
  110997. * Summary logging while loading
  110998. */
  110999. static readonly SUMMARY_LOGGING: number;
  111000. /**
  111001. * Detailled logging while loading
  111002. */
  111003. static readonly DETAILED_LOGGING: number;
  111004. /**
  111005. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111006. */
  111007. static ForceFullSceneLoadingForIncremental: boolean;
  111008. /**
  111009. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111010. */
  111011. static ShowLoadingScreen: boolean;
  111012. /**
  111013. * Defines the current logging level (while loading the scene)
  111014. * @ignorenaming
  111015. */
  111016. static loggingLevel: number;
  111017. /**
  111018. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111019. */
  111020. static CleanBoneMatrixWeights: boolean;
  111021. /**
  111022. * Event raised when a plugin is used to load a scene
  111023. */
  111024. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  111025. private static _registeredPlugins;
  111026. private static _getDefaultPlugin;
  111027. private static _getPluginForExtension;
  111028. private static _getPluginForDirectLoad;
  111029. private static _getPluginForFilename;
  111030. private static _getDirectLoad;
  111031. private static _loadData;
  111032. private static _getFileInfo;
  111033. /**
  111034. * Gets a plugin that can load the given extension
  111035. * @param extension defines the extension to load
  111036. * @returns a plugin or null if none works
  111037. */
  111038. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  111039. /**
  111040. * Gets a boolean indicating that the given extension can be loaded
  111041. * @param extension defines the extension to load
  111042. * @returns true if the extension is supported
  111043. */
  111044. static IsPluginForExtensionAvailable(extension: string): boolean;
  111045. /**
  111046. * Adds a new plugin to the list of registered plugins
  111047. * @param plugin defines the plugin to add
  111048. */
  111049. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  111050. /**
  111051. * Import meshes into a scene
  111052. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111053. * @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)
  111054. * @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)
  111055. * @param scene the instance of BABYLON.Scene to append to
  111056. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  111057. * @param onProgress a callback with a progress event for each file being loaded
  111058. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111059. * @param pluginExtension the extension used to determine the plugin
  111060. * @returns The loaded plugin
  111061. */
  111062. 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>;
  111063. /**
  111064. * Import meshes into a scene
  111065. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  111066. * @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)
  111067. * @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)
  111068. * @param scene the instance of BABYLON.Scene to append to
  111069. * @param onProgress a callback with a progress event for each file being loaded
  111070. * @param pluginExtension the extension used to determine the plugin
  111071. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  111072. */
  111073. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  111074. meshes: AbstractMesh[];
  111075. particleSystems: IParticleSystem[];
  111076. skeletons: Skeleton[];
  111077. animationGroups: AnimationGroup[];
  111078. }>;
  111079. /**
  111080. * Load a scene
  111081. * @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)
  111082. * @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)
  111083. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111084. * @param onSuccess a callback with the scene when import succeeds
  111085. * @param onProgress a callback with a progress event for each file being loaded
  111086. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111087. * @param pluginExtension the extension used to determine the plugin
  111088. * @returns The loaded plugin
  111089. */
  111090. 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>;
  111091. /**
  111092. * Load a scene
  111093. * @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)
  111094. * @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)
  111095. * @param engine is the instance of BABYLON.Engine to use to create the scene
  111096. * @param onProgress a callback with a progress event for each file being loaded
  111097. * @param pluginExtension the extension used to determine the plugin
  111098. * @returns The loaded scene
  111099. */
  111100. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111101. /**
  111102. * Append a scene
  111103. * @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)
  111104. * @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)
  111105. * @param scene is the instance of BABYLON.Scene to append to
  111106. * @param onSuccess a callback with the scene when import succeeds
  111107. * @param onProgress a callback with a progress event for each file being loaded
  111108. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111109. * @param pluginExtension the extension used to determine the plugin
  111110. * @returns The loaded plugin
  111111. */
  111112. 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>;
  111113. /**
  111114. * Append a scene
  111115. * @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)
  111116. * @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)
  111117. * @param scene is the instance of BABYLON.Scene to append to
  111118. * @param onProgress a callback with a progress event for each file being loaded
  111119. * @param pluginExtension the extension used to determine the plugin
  111120. * @returns The given scene
  111121. */
  111122. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  111123. /**
  111124. * Load a scene into an asset container
  111125. * @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)
  111126. * @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)
  111127. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111128. * @param onSuccess a callback with the scene when import succeeds
  111129. * @param onProgress a callback with a progress event for each file being loaded
  111130. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  111131. * @param pluginExtension the extension used to determine the plugin
  111132. * @returns The loaded plugin
  111133. */
  111134. 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>;
  111135. /**
  111136. * Load a scene into an asset container
  111137. * @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)
  111138. * @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)
  111139. * @param scene is the instance of Scene to append to
  111140. * @param onProgress a callback with a progress event for each file being loaded
  111141. * @param pluginExtension the extension used to determine the plugin
  111142. * @returns The loaded asset container
  111143. */
  111144. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  111145. }
  111146. }
  111147. declare module BABYLON {
  111148. /**
  111149. * Generic Controller
  111150. */
  111151. export class GenericController extends WebVRController {
  111152. /**
  111153. * Base Url for the controller model.
  111154. */
  111155. static readonly MODEL_BASE_URL: string;
  111156. /**
  111157. * File name for the controller model.
  111158. */
  111159. static readonly MODEL_FILENAME: string;
  111160. /**
  111161. * Creates a new GenericController from a gamepad
  111162. * @param vrGamepad the gamepad that the controller should be created from
  111163. */
  111164. constructor(vrGamepad: any);
  111165. /**
  111166. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111167. * @param scene scene in which to add meshes
  111168. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111169. */
  111170. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111171. /**
  111172. * Called once for each button that changed state since the last frame
  111173. * @param buttonIdx Which button index changed
  111174. * @param state New state of the button
  111175. * @param changes Which properties on the state changed since last frame
  111176. */
  111177. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111178. }
  111179. }
  111180. declare module BABYLON {
  111181. /**
  111182. * Defines the WindowsMotionController object that the state of the windows motion controller
  111183. */
  111184. export class WindowsMotionController extends WebVRController {
  111185. /**
  111186. * The base url used to load the left and right controller models
  111187. */
  111188. static MODEL_BASE_URL: string;
  111189. /**
  111190. * The name of the left controller model file
  111191. */
  111192. static MODEL_LEFT_FILENAME: string;
  111193. /**
  111194. * The name of the right controller model file
  111195. */
  111196. static MODEL_RIGHT_FILENAME: string;
  111197. /**
  111198. * The controller name prefix for this controller type
  111199. */
  111200. static readonly GAMEPAD_ID_PREFIX: string;
  111201. /**
  111202. * The controller id pattern for this controller type
  111203. */
  111204. private static readonly GAMEPAD_ID_PATTERN;
  111205. private _loadedMeshInfo;
  111206. private readonly _mapping;
  111207. /**
  111208. * Fired when the trackpad on this controller is clicked
  111209. */
  111210. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  111211. /**
  111212. * Fired when the trackpad on this controller is modified
  111213. */
  111214. onTrackpadValuesChangedObservable: Observable<StickValues>;
  111215. /**
  111216. * The current x and y values of this controller's trackpad
  111217. */
  111218. trackpad: StickValues;
  111219. /**
  111220. * Creates a new WindowsMotionController from a gamepad
  111221. * @param vrGamepad the gamepad that the controller should be created from
  111222. */
  111223. constructor(vrGamepad: any);
  111224. /**
  111225. * Fired when the trigger on this controller is modified
  111226. */
  111227. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111228. /**
  111229. * Fired when the menu button on this controller is modified
  111230. */
  111231. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111232. /**
  111233. * Fired when the grip button on this controller is modified
  111234. */
  111235. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111236. /**
  111237. * Fired when the thumbstick button on this controller is modified
  111238. */
  111239. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111240. /**
  111241. * Fired when the touchpad button on this controller is modified
  111242. */
  111243. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111244. /**
  111245. * Fired when the touchpad values on this controller are modified
  111246. */
  111247. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  111248. private _updateTrackpad;
  111249. /**
  111250. * Called once per frame by the engine.
  111251. */
  111252. update(): void;
  111253. /**
  111254. * Called once for each button that changed state since the last frame
  111255. * @param buttonIdx Which button index changed
  111256. * @param state New state of the button
  111257. * @param changes Which properties on the state changed since last frame
  111258. */
  111259. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111260. /**
  111261. * Moves the buttons on the controller mesh based on their current state
  111262. * @param buttonName the name of the button to move
  111263. * @param buttonValue the value of the button which determines the buttons new position
  111264. */
  111265. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  111266. /**
  111267. * Moves the axis on the controller mesh based on its current state
  111268. * @param axis the index of the axis
  111269. * @param axisValue the value of the axis which determines the meshes new position
  111270. * @hidden
  111271. */
  111272. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  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, forceDefault?: boolean): void;
  111279. /**
  111280. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  111281. * can be transformed by button presses and axes values, based on this._mapping.
  111282. *
  111283. * @param scene scene in which the meshes exist
  111284. * @param meshes list of meshes that make up the controller model to process
  111285. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  111286. */
  111287. private processModel;
  111288. private createMeshInfo;
  111289. /**
  111290. * Gets the ray of the controller in the direction the controller is pointing
  111291. * @param length the length the resulting ray should be
  111292. * @returns a ray in the direction the controller is pointing
  111293. */
  111294. getForwardRay(length?: number): Ray;
  111295. /**
  111296. * Disposes of the controller
  111297. */
  111298. dispose(): void;
  111299. }
  111300. }
  111301. declare module BABYLON {
  111302. /**
  111303. * Oculus Touch Controller
  111304. */
  111305. export class OculusTouchController extends WebVRController {
  111306. /**
  111307. * Base Url for the controller model.
  111308. */
  111309. static MODEL_BASE_URL: string;
  111310. /**
  111311. * File name for the left controller model.
  111312. */
  111313. static MODEL_LEFT_FILENAME: string;
  111314. /**
  111315. * File name for the right controller model.
  111316. */
  111317. static MODEL_RIGHT_FILENAME: string;
  111318. /**
  111319. * Base Url for the Quest controller model.
  111320. */
  111321. static QUEST_MODEL_BASE_URL: string;
  111322. /**
  111323. * @hidden
  111324. * If the controllers are running on a device that needs the updated Quest controller models
  111325. */
  111326. static _IsQuest: boolean;
  111327. /**
  111328. * Fired when the secondary trigger on this controller is modified
  111329. */
  111330. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  111331. /**
  111332. * Fired when the thumb rest on this controller is modified
  111333. */
  111334. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  111335. /**
  111336. * Creates a new OculusTouchController from a gamepad
  111337. * @param vrGamepad the gamepad that the controller should be created from
  111338. */
  111339. constructor(vrGamepad: any);
  111340. /**
  111341. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111342. * @param scene scene in which to add meshes
  111343. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111344. */
  111345. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111346. /**
  111347. * Fired when the A button on this controller is modified
  111348. */
  111349. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111350. /**
  111351. * Fired when the B button on this controller is modified
  111352. */
  111353. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111354. /**
  111355. * Fired when the X button on this controller is modified
  111356. */
  111357. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111358. /**
  111359. * Fired when the Y button on this controller is modified
  111360. */
  111361. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111362. /**
  111363. * Called once for each button that changed state since the last frame
  111364. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  111365. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  111366. * 2) secondary trigger (same)
  111367. * 3) A (right) X (left), touch, pressed = value
  111368. * 4) B / Y
  111369. * 5) thumb rest
  111370. * @param buttonIdx Which button index changed
  111371. * @param state New state of the button
  111372. * @param changes Which properties on the state changed since last frame
  111373. */
  111374. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111375. }
  111376. }
  111377. declare module BABYLON {
  111378. /**
  111379. * Vive Controller
  111380. */
  111381. export class ViveController extends WebVRController {
  111382. /**
  111383. * Base Url for the controller model.
  111384. */
  111385. static MODEL_BASE_URL: string;
  111386. /**
  111387. * File name for the controller model.
  111388. */
  111389. static MODEL_FILENAME: string;
  111390. /**
  111391. * Creates a new ViveController from a gamepad
  111392. * @param vrGamepad the gamepad that the controller should be created from
  111393. */
  111394. constructor(vrGamepad: any);
  111395. /**
  111396. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111397. * @param scene scene in which to add meshes
  111398. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111399. */
  111400. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111401. /**
  111402. * Fired when the left button on this controller is modified
  111403. */
  111404. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111405. /**
  111406. * Fired when the right button on this controller is modified
  111407. */
  111408. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111409. /**
  111410. * Fired when the menu button on this controller is modified
  111411. */
  111412. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  111413. /**
  111414. * Called once for each button that changed state since the last frame
  111415. * Vive mapping:
  111416. * 0: touchpad
  111417. * 1: trigger
  111418. * 2: left AND right buttons
  111419. * 3: menu button
  111420. * @param buttonIdx Which button index changed
  111421. * @param state New state of the button
  111422. * @param changes Which properties on the state changed since last frame
  111423. */
  111424. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111425. }
  111426. }
  111427. declare module BABYLON {
  111428. /**
  111429. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  111430. */
  111431. export class WebXRControllerModelLoader {
  111432. /**
  111433. * an observable that triggers when a new model (the mesh itself) was initialized.
  111434. * To know when the mesh was loaded use the controller's own modelLoaded() method
  111435. */
  111436. onControllerModelLoaded: Observable<WebXRController>;
  111437. /**
  111438. * Creates the WebXRControllerModelLoader
  111439. * @param input xr input that creates the controllers
  111440. */
  111441. constructor(input: WebXRInput);
  111442. }
  111443. }
  111444. declare module BABYLON {
  111445. /**
  111446. * Options for the default xr helper
  111447. */
  111448. export class WebXRDefaultExperienceOptions {
  111449. /**
  111450. * Floor meshes that should be used for teleporting
  111451. */
  111452. floorMeshes: Array<AbstractMesh>;
  111453. /**
  111454. * Enable or disable default UI to enter XR
  111455. */
  111456. disableDefaultUI: boolean;
  111457. /**
  111458. * optional configuration for the output canvas
  111459. */
  111460. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  111461. }
  111462. /**
  111463. * Default experience which provides a similar setup to the previous webVRExperience
  111464. */
  111465. export class WebXRDefaultExperience {
  111466. /**
  111467. * Base experience
  111468. */
  111469. baseExperience: WebXRExperienceHelper;
  111470. /**
  111471. * Input experience extension
  111472. */
  111473. input: WebXRInput;
  111474. /**
  111475. * Loads the controller models
  111476. */
  111477. controllerModelLoader: WebXRControllerModelLoader;
  111478. /**
  111479. * Enables laser pointer and selection
  111480. */
  111481. pointerSelection: WebXRControllerPointerSelection;
  111482. /**
  111483. * Enables teleportation
  111484. */
  111485. teleportation: WebXRControllerTeleportation;
  111486. /**
  111487. * Enables ui for enetering/exiting xr
  111488. */
  111489. enterExitUI: WebXREnterExitUI;
  111490. /**
  111491. * Default target xr should render to
  111492. */
  111493. renderTarget: WebXRRenderTarget;
  111494. /**
  111495. * Creates the default xr experience
  111496. * @param scene scene
  111497. * @param options options for basic configuration
  111498. * @returns resulting WebXRDefaultExperience
  111499. */
  111500. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111501. private constructor();
  111502. /**
  111503. * DIsposes of the experience helper
  111504. */
  111505. dispose(): void;
  111506. }
  111507. }
  111508. declare module BABYLON {
  111509. /**
  111510. * Contains an array of blocks representing the octree
  111511. */
  111512. export interface IOctreeContainer<T> {
  111513. /**
  111514. * Blocks within the octree
  111515. */
  111516. blocks: Array<OctreeBlock<T>>;
  111517. }
  111518. /**
  111519. * Class used to store a cell in an octree
  111520. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111521. */
  111522. export class OctreeBlock<T> {
  111523. /**
  111524. * Gets the content of the current block
  111525. */
  111526. entries: T[];
  111527. /**
  111528. * Gets the list of block children
  111529. */
  111530. blocks: Array<OctreeBlock<T>>;
  111531. private _depth;
  111532. private _maxDepth;
  111533. private _capacity;
  111534. private _minPoint;
  111535. private _maxPoint;
  111536. private _boundingVectors;
  111537. private _creationFunc;
  111538. /**
  111539. * Creates a new block
  111540. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  111541. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  111542. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111543. * @param depth defines the current depth of this block in the octree
  111544. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  111545. * @param creationFunc defines a callback to call when an element is added to the block
  111546. */
  111547. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  111548. /**
  111549. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  111550. */
  111551. readonly capacity: number;
  111552. /**
  111553. * Gets the minimum vector (in world space) of the block's bounding box
  111554. */
  111555. readonly minPoint: Vector3;
  111556. /**
  111557. * Gets the maximum vector (in world space) of the block's bounding box
  111558. */
  111559. readonly maxPoint: Vector3;
  111560. /**
  111561. * Add a new element to this block
  111562. * @param entry defines the element to add
  111563. */
  111564. addEntry(entry: T): void;
  111565. /**
  111566. * Remove an element from this block
  111567. * @param entry defines the element to remove
  111568. */
  111569. removeEntry(entry: T): void;
  111570. /**
  111571. * Add an array of elements to this block
  111572. * @param entries defines the array of elements to add
  111573. */
  111574. addEntries(entries: T[]): void;
  111575. /**
  111576. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  111577. * @param frustumPlanes defines the frustum planes to test
  111578. * @param selection defines the array to store current content if selection is positive
  111579. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111580. */
  111581. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111582. /**
  111583. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  111584. * @param sphereCenter defines the bounding sphere center
  111585. * @param sphereRadius defines the bounding sphere radius
  111586. * @param selection defines the array to store current content if selection is positive
  111587. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111588. */
  111589. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  111590. /**
  111591. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  111592. * @param ray defines the ray to test with
  111593. * @param selection defines the array to store current content if selection is positive
  111594. */
  111595. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  111596. /**
  111597. * Subdivide the content into child blocks (this block will then be empty)
  111598. */
  111599. createInnerBlocks(): void;
  111600. /**
  111601. * @hidden
  111602. */
  111603. 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;
  111604. }
  111605. }
  111606. declare module BABYLON {
  111607. /**
  111608. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  111609. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111610. */
  111611. export class Octree<T> {
  111612. /** 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.) */
  111613. maxDepth: number;
  111614. /**
  111615. * Blocks within the octree containing objects
  111616. */
  111617. blocks: Array<OctreeBlock<T>>;
  111618. /**
  111619. * Content stored in the octree
  111620. */
  111621. dynamicContent: T[];
  111622. private _maxBlockCapacity;
  111623. private _selectionContent;
  111624. private _creationFunc;
  111625. /**
  111626. * Creates a octree
  111627. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111628. * @param creationFunc function to be used to instatiate the octree
  111629. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  111630. * @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.)
  111631. */
  111632. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  111633. /** 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.) */
  111634. maxDepth?: number);
  111635. /**
  111636. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  111637. * @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);
  111638. * @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);
  111639. * @param entries meshes to be added to the octree blocks
  111640. */
  111641. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  111642. /**
  111643. * Adds a mesh to the octree
  111644. * @param entry Mesh to add to the octree
  111645. */
  111646. addMesh(entry: T): void;
  111647. /**
  111648. * Remove an element from the octree
  111649. * @param entry defines the element to remove
  111650. */
  111651. removeMesh(entry: T): void;
  111652. /**
  111653. * Selects an array of meshes within the frustum
  111654. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  111655. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  111656. * @returns array of meshes within the frustum
  111657. */
  111658. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  111659. /**
  111660. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  111661. * @param sphereCenter defines the bounding sphere center
  111662. * @param sphereRadius defines the bounding sphere radius
  111663. * @param allowDuplicate defines if the selection array can contains duplicated entries
  111664. * @returns an array of objects that intersect the sphere
  111665. */
  111666. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  111667. /**
  111668. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  111669. * @param ray defines the ray to test with
  111670. * @returns array of intersected objects
  111671. */
  111672. intersectsRay(ray: Ray): SmartArray<T>;
  111673. /**
  111674. * Adds a mesh into the octree block if it intersects the block
  111675. */
  111676. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  111677. /**
  111678. * Adds a submesh into the octree block if it intersects the block
  111679. */
  111680. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  111681. }
  111682. }
  111683. declare module BABYLON {
  111684. interface Scene {
  111685. /**
  111686. * @hidden
  111687. * Backing Filed
  111688. */
  111689. _selectionOctree: Octree<AbstractMesh>;
  111690. /**
  111691. * Gets the octree used to boost mesh selection (picking)
  111692. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111693. */
  111694. selectionOctree: Octree<AbstractMesh>;
  111695. /**
  111696. * Creates or updates the octree used to boost selection (picking)
  111697. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111698. * @param maxCapacity defines the maximum capacity per leaf
  111699. * @param maxDepth defines the maximum depth of the octree
  111700. * @returns an octree of AbstractMesh
  111701. */
  111702. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  111703. }
  111704. interface AbstractMesh {
  111705. /**
  111706. * @hidden
  111707. * Backing Field
  111708. */
  111709. _submeshesOctree: Octree<SubMesh>;
  111710. /**
  111711. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  111712. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  111713. * @param maxCapacity defines the maximum size of each block (64 by default)
  111714. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  111715. * @returns the new octree
  111716. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  111717. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  111718. */
  111719. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  111720. }
  111721. /**
  111722. * Defines the octree scene component responsible to manage any octrees
  111723. * in a given scene.
  111724. */
  111725. export class OctreeSceneComponent {
  111726. /**
  111727. * The component name help to identify the component in the list of scene components.
  111728. */
  111729. readonly name: string;
  111730. /**
  111731. * The scene the component belongs to.
  111732. */
  111733. scene: Scene;
  111734. /**
  111735. * Indicates if the meshes have been checked to make sure they are isEnabled()
  111736. */
  111737. readonly checksIsEnabled: boolean;
  111738. /**
  111739. * Creates a new instance of the component for the given scene
  111740. * @param scene Defines the scene to register the component in
  111741. */
  111742. constructor(scene: Scene);
  111743. /**
  111744. * Registers the component in a given scene
  111745. */
  111746. register(): void;
  111747. /**
  111748. * Return the list of active meshes
  111749. * @returns the list of active meshes
  111750. */
  111751. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  111752. /**
  111753. * Return the list of active sub meshes
  111754. * @param mesh The mesh to get the candidates sub meshes from
  111755. * @returns the list of active sub meshes
  111756. */
  111757. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  111758. private _tempRay;
  111759. /**
  111760. * Return the list of sub meshes intersecting with a given local ray
  111761. * @param mesh defines the mesh to find the submesh for
  111762. * @param localRay defines the ray in local space
  111763. * @returns the list of intersecting sub meshes
  111764. */
  111765. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  111766. /**
  111767. * Return the list of sub meshes colliding with a collider
  111768. * @param mesh defines the mesh to find the submesh for
  111769. * @param collider defines the collider to evaluate the collision against
  111770. * @returns the list of colliding sub meshes
  111771. */
  111772. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  111773. /**
  111774. * Rebuilds the elements related to this component in case of
  111775. * context lost for instance.
  111776. */
  111777. rebuild(): void;
  111778. /**
  111779. * Disposes the component and the associated ressources.
  111780. */
  111781. dispose(): void;
  111782. }
  111783. }
  111784. declare module BABYLON {
  111785. /**
  111786. * Renders a layer on top of an existing scene
  111787. */
  111788. export class UtilityLayerRenderer implements IDisposable {
  111789. /** the original scene that will be rendered on top of */
  111790. originalScene: Scene;
  111791. private _pointerCaptures;
  111792. private _lastPointerEvents;
  111793. private static _DefaultUtilityLayer;
  111794. private static _DefaultKeepDepthUtilityLayer;
  111795. private _sharedGizmoLight;
  111796. private _renderCamera;
  111797. /**
  111798. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  111799. * @returns the camera that is used when rendering the utility layer
  111800. */
  111801. getRenderCamera(): Nullable<Camera>;
  111802. /**
  111803. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  111804. * @param cam the camera that should be used when rendering the utility layer
  111805. */
  111806. setRenderCamera(cam: Nullable<Camera>): void;
  111807. /**
  111808. * @hidden
  111809. * Light which used by gizmos to get light shading
  111810. */
  111811. _getSharedGizmoLight(): HemisphericLight;
  111812. /**
  111813. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  111814. */
  111815. pickUtilitySceneFirst: boolean;
  111816. /**
  111817. * 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)
  111818. */
  111819. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  111820. /**
  111821. * 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)
  111822. */
  111823. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  111824. /**
  111825. * The scene that is rendered on top of the original scene
  111826. */
  111827. utilityLayerScene: Scene;
  111828. /**
  111829. * If the utility layer should automatically be rendered on top of existing scene
  111830. */
  111831. shouldRender: boolean;
  111832. /**
  111833. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  111834. */
  111835. onlyCheckPointerDownEvents: boolean;
  111836. /**
  111837. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  111838. */
  111839. processAllEvents: boolean;
  111840. /**
  111841. * Observable raised when the pointer move from the utility layer scene to the main scene
  111842. */
  111843. onPointerOutObservable: Observable<number>;
  111844. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  111845. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  111846. private _afterRenderObserver;
  111847. private _sceneDisposeObserver;
  111848. private _originalPointerObserver;
  111849. /**
  111850. * Instantiates a UtilityLayerRenderer
  111851. * @param originalScene the original scene that will be rendered on top of
  111852. * @param handleEvents boolean indicating if the utility layer should handle events
  111853. */
  111854. constructor(
  111855. /** the original scene that will be rendered on top of */
  111856. originalScene: Scene, handleEvents?: boolean);
  111857. private _notifyObservers;
  111858. /**
  111859. * Renders the utility layers scene on top of the original scene
  111860. */
  111861. render(): void;
  111862. /**
  111863. * Disposes of the renderer
  111864. */
  111865. dispose(): void;
  111866. private _updateCamera;
  111867. }
  111868. }
  111869. declare module BABYLON {
  111870. /**
  111871. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  111872. */
  111873. export class Gizmo implements IDisposable {
  111874. /** The utility layer the gizmo will be added to */
  111875. gizmoLayer: UtilityLayerRenderer;
  111876. /**
  111877. * The root mesh of the gizmo
  111878. */
  111879. _rootMesh: Mesh;
  111880. private _attachedMesh;
  111881. /**
  111882. * Ratio for the scale of the gizmo (Default: 1)
  111883. */
  111884. scaleRatio: number;
  111885. /**
  111886. * If a custom mesh has been set (Default: false)
  111887. */
  111888. protected _customMeshSet: boolean;
  111889. /**
  111890. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  111891. * * When set, interactions will be enabled
  111892. */
  111893. attachedMesh: Nullable<AbstractMesh>;
  111894. /**
  111895. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111896. * @param mesh The mesh to replace the default mesh of the gizmo
  111897. */
  111898. setCustomMesh(mesh: Mesh): void;
  111899. /**
  111900. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  111901. */
  111902. updateGizmoRotationToMatchAttachedMesh: boolean;
  111903. /**
  111904. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  111905. */
  111906. updateGizmoPositionToMatchAttachedMesh: boolean;
  111907. /**
  111908. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  111909. */
  111910. updateScale: boolean;
  111911. protected _interactionsEnabled: boolean;
  111912. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111913. private _beforeRenderObserver;
  111914. private _tempVector;
  111915. /**
  111916. * Creates a gizmo
  111917. * @param gizmoLayer The utility layer the gizmo will be added to
  111918. */
  111919. constructor(
  111920. /** The utility layer the gizmo will be added to */
  111921. gizmoLayer?: UtilityLayerRenderer);
  111922. /**
  111923. * Updates the gizmo to match the attached mesh's position/rotation
  111924. */
  111925. protected _update(): void;
  111926. /**
  111927. * Disposes of the gizmo
  111928. */
  111929. dispose(): void;
  111930. }
  111931. }
  111932. declare module BABYLON {
  111933. /**
  111934. * Single plane drag gizmo
  111935. */
  111936. export class PlaneDragGizmo extends Gizmo {
  111937. /**
  111938. * Drag behavior responsible for the gizmos dragging interactions
  111939. */
  111940. dragBehavior: PointerDragBehavior;
  111941. private _pointerObserver;
  111942. /**
  111943. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111944. */
  111945. snapDistance: number;
  111946. /**
  111947. * Event that fires each time the gizmo snaps to a new location.
  111948. * * snapDistance is the the change in distance
  111949. */
  111950. onSnapObservable: Observable<{
  111951. snapDistance: number;
  111952. }>;
  111953. private _plane;
  111954. private _coloredMaterial;
  111955. private _hoverMaterial;
  111956. private _isEnabled;
  111957. private _parent;
  111958. /** @hidden */
  111959. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  111960. /** @hidden */
  111961. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  111962. /**
  111963. * Creates a PlaneDragGizmo
  111964. * @param gizmoLayer The utility layer the gizmo will be added to
  111965. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  111966. * @param color The color of the gizmo
  111967. */
  111968. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  111969. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111970. /**
  111971. * If the gizmo is enabled
  111972. */
  111973. isEnabled: boolean;
  111974. /**
  111975. * Disposes of the gizmo
  111976. */
  111977. dispose(): void;
  111978. }
  111979. }
  111980. declare module BABYLON {
  111981. /**
  111982. * Gizmo that enables dragging a mesh along 3 axis
  111983. */
  111984. export class PositionGizmo extends Gizmo {
  111985. /**
  111986. * Internal gizmo used for interactions on the x axis
  111987. */
  111988. xGizmo: AxisDragGizmo;
  111989. /**
  111990. * Internal gizmo used for interactions on the y axis
  111991. */
  111992. yGizmo: AxisDragGizmo;
  111993. /**
  111994. * Internal gizmo used for interactions on the z axis
  111995. */
  111996. zGizmo: AxisDragGizmo;
  111997. /**
  111998. * Internal gizmo used for interactions on the yz plane
  111999. */
  112000. xPlaneGizmo: PlaneDragGizmo;
  112001. /**
  112002. * Internal gizmo used for interactions on the xz plane
  112003. */
  112004. yPlaneGizmo: PlaneDragGizmo;
  112005. /**
  112006. * Internal gizmo used for interactions on the xy plane
  112007. */
  112008. zPlaneGizmo: PlaneDragGizmo;
  112009. /**
  112010. * private variables
  112011. */
  112012. private _meshAttached;
  112013. private _updateGizmoRotationToMatchAttachedMesh;
  112014. private _snapDistance;
  112015. private _scaleRatio;
  112016. /** Fires an event when any of it's sub gizmos are dragged */
  112017. onDragStartObservable: Observable<unknown>;
  112018. /** Fires an event when any of it's sub gizmos are released from dragging */
  112019. onDragEndObservable: Observable<unknown>;
  112020. /**
  112021. * If set to true, planar drag is enabled
  112022. */
  112023. private _planarGizmoEnabled;
  112024. attachedMesh: Nullable<AbstractMesh>;
  112025. /**
  112026. * Creates a PositionGizmo
  112027. * @param gizmoLayer The utility layer the gizmo will be added to
  112028. */
  112029. constructor(gizmoLayer?: UtilityLayerRenderer);
  112030. /**
  112031. * If the planar drag gizmo is enabled
  112032. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  112033. */
  112034. planarGizmoEnabled: boolean;
  112035. updateGizmoRotationToMatchAttachedMesh: boolean;
  112036. /**
  112037. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112038. */
  112039. snapDistance: number;
  112040. /**
  112041. * Ratio for the scale of the gizmo (Default: 1)
  112042. */
  112043. scaleRatio: number;
  112044. /**
  112045. * Disposes of the gizmo
  112046. */
  112047. dispose(): void;
  112048. /**
  112049. * CustomMeshes are not supported by this gizmo
  112050. * @param mesh The mesh to replace the default mesh of the gizmo
  112051. */
  112052. setCustomMesh(mesh: Mesh): void;
  112053. }
  112054. }
  112055. declare module BABYLON {
  112056. /**
  112057. * Single axis drag gizmo
  112058. */
  112059. export class AxisDragGizmo extends Gizmo {
  112060. /**
  112061. * Drag behavior responsible for the gizmos dragging interactions
  112062. */
  112063. dragBehavior: PointerDragBehavior;
  112064. private _pointerObserver;
  112065. /**
  112066. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112067. */
  112068. snapDistance: number;
  112069. /**
  112070. * Event that fires each time the gizmo snaps to a new location.
  112071. * * snapDistance is the the change in distance
  112072. */
  112073. onSnapObservable: Observable<{
  112074. snapDistance: number;
  112075. }>;
  112076. private _isEnabled;
  112077. private _parent;
  112078. private _arrow;
  112079. private _coloredMaterial;
  112080. private _hoverMaterial;
  112081. /** @hidden */
  112082. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  112083. /** @hidden */
  112084. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  112085. /**
  112086. * Creates an AxisDragGizmo
  112087. * @param gizmoLayer The utility layer the gizmo will be added to
  112088. * @param dragAxis The axis which the gizmo will be able to drag on
  112089. * @param color The color of the gizmo
  112090. */
  112091. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  112092. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112093. /**
  112094. * If the gizmo is enabled
  112095. */
  112096. isEnabled: boolean;
  112097. /**
  112098. * Disposes of the gizmo
  112099. */
  112100. dispose(): void;
  112101. }
  112102. }
  112103. declare module BABYLON.Debug {
  112104. /**
  112105. * The Axes viewer will show 3 axes in a specific point in space
  112106. */
  112107. export class AxesViewer {
  112108. private _xAxis;
  112109. private _yAxis;
  112110. private _zAxis;
  112111. private _scaleLinesFactor;
  112112. private _instanced;
  112113. /**
  112114. * Gets the hosting scene
  112115. */
  112116. scene: Scene;
  112117. /**
  112118. * Gets or sets a number used to scale line length
  112119. */
  112120. scaleLines: number;
  112121. /** Gets the node hierarchy used to render x-axis */
  112122. readonly xAxis: TransformNode;
  112123. /** Gets the node hierarchy used to render y-axis */
  112124. readonly yAxis: TransformNode;
  112125. /** Gets the node hierarchy used to render z-axis */
  112126. readonly zAxis: TransformNode;
  112127. /**
  112128. * Creates a new AxesViewer
  112129. * @param scene defines the hosting scene
  112130. * @param scaleLines defines a number used to scale line length (1 by default)
  112131. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  112132. * @param xAxis defines the node hierarchy used to render the x-axis
  112133. * @param yAxis defines the node hierarchy used to render the y-axis
  112134. * @param zAxis defines the node hierarchy used to render the z-axis
  112135. */
  112136. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  112137. /**
  112138. * Force the viewer to update
  112139. * @param position defines the position of the viewer
  112140. * @param xaxis defines the x axis of the viewer
  112141. * @param yaxis defines the y axis of the viewer
  112142. * @param zaxis defines the z axis of the viewer
  112143. */
  112144. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  112145. /**
  112146. * Creates an instance of this axes viewer.
  112147. * @returns a new axes viewer with instanced meshes
  112148. */
  112149. createInstance(): AxesViewer;
  112150. /** Releases resources */
  112151. dispose(): void;
  112152. private static _SetRenderingGroupId;
  112153. }
  112154. }
  112155. declare module BABYLON.Debug {
  112156. /**
  112157. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  112158. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  112159. */
  112160. export class BoneAxesViewer extends AxesViewer {
  112161. /**
  112162. * Gets or sets the target mesh where to display the axes viewer
  112163. */
  112164. mesh: Nullable<Mesh>;
  112165. /**
  112166. * Gets or sets the target bone where to display the axes viewer
  112167. */
  112168. bone: Nullable<Bone>;
  112169. /** Gets current position */
  112170. pos: Vector3;
  112171. /** Gets direction of X axis */
  112172. xaxis: Vector3;
  112173. /** Gets direction of Y axis */
  112174. yaxis: Vector3;
  112175. /** Gets direction of Z axis */
  112176. zaxis: Vector3;
  112177. /**
  112178. * Creates a new BoneAxesViewer
  112179. * @param scene defines the hosting scene
  112180. * @param bone defines the target bone
  112181. * @param mesh defines the target mesh
  112182. * @param scaleLines defines a scaling factor for line length (1 by default)
  112183. */
  112184. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  112185. /**
  112186. * Force the viewer to update
  112187. */
  112188. update(): void;
  112189. /** Releases resources */
  112190. dispose(): void;
  112191. }
  112192. }
  112193. declare module BABYLON {
  112194. /**
  112195. * Interface used to define scene explorer extensibility option
  112196. */
  112197. export interface IExplorerExtensibilityOption {
  112198. /**
  112199. * Define the option label
  112200. */
  112201. label: string;
  112202. /**
  112203. * Defines the action to execute on click
  112204. */
  112205. action: (entity: any) => void;
  112206. }
  112207. /**
  112208. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  112209. */
  112210. export interface IExplorerExtensibilityGroup {
  112211. /**
  112212. * Defines a predicate to test if a given type mut be extended
  112213. */
  112214. predicate: (entity: any) => boolean;
  112215. /**
  112216. * Gets the list of options added to a type
  112217. */
  112218. entries: IExplorerExtensibilityOption[];
  112219. }
  112220. /**
  112221. * Interface used to define the options to use to create the Inspector
  112222. */
  112223. export interface IInspectorOptions {
  112224. /**
  112225. * Display in overlay mode (default: false)
  112226. */
  112227. overlay?: boolean;
  112228. /**
  112229. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  112230. */
  112231. globalRoot?: HTMLElement;
  112232. /**
  112233. * Display the Scene explorer
  112234. */
  112235. showExplorer?: boolean;
  112236. /**
  112237. * Display the property inspector
  112238. */
  112239. showInspector?: boolean;
  112240. /**
  112241. * Display in embed mode (both panes on the right)
  112242. */
  112243. embedMode?: boolean;
  112244. /**
  112245. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  112246. */
  112247. handleResize?: boolean;
  112248. /**
  112249. * Allow the panes to popup (default: true)
  112250. */
  112251. enablePopup?: boolean;
  112252. /**
  112253. * Allow the panes to be closed by users (default: true)
  112254. */
  112255. enableClose?: boolean;
  112256. /**
  112257. * Optional list of extensibility entries
  112258. */
  112259. explorerExtensibility?: IExplorerExtensibilityGroup[];
  112260. /**
  112261. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  112262. */
  112263. inspectorURL?: string;
  112264. }
  112265. interface Scene {
  112266. /**
  112267. * @hidden
  112268. * Backing field
  112269. */
  112270. _debugLayer: DebugLayer;
  112271. /**
  112272. * Gets the debug layer (aka Inspector) associated with the scene
  112273. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112274. */
  112275. debugLayer: DebugLayer;
  112276. }
  112277. /**
  112278. * The debug layer (aka Inspector) is the go to tool in order to better understand
  112279. * what is happening in your scene
  112280. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112281. */
  112282. export class DebugLayer {
  112283. /**
  112284. * Define the url to get the inspector script from.
  112285. * By default it uses the babylonjs CDN.
  112286. * @ignoreNaming
  112287. */
  112288. static InspectorURL: string;
  112289. private _scene;
  112290. private BJSINSPECTOR;
  112291. private _onPropertyChangedObservable?;
  112292. /**
  112293. * Observable triggered when a property is changed through the inspector.
  112294. */
  112295. readonly onPropertyChangedObservable: any;
  112296. /**
  112297. * Instantiates a new debug layer.
  112298. * The debug layer (aka Inspector) is the go to tool in order to better understand
  112299. * what is happening in your scene
  112300. * @see http://doc.babylonjs.com/features/playground_debuglayer
  112301. * @param scene Defines the scene to inspect
  112302. */
  112303. constructor(scene: Scene);
  112304. /** Creates the inspector window. */
  112305. private _createInspector;
  112306. /**
  112307. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  112308. * @param entity defines the entity to select
  112309. * @param lineContainerTitle defines the specific block to highlight
  112310. */
  112311. select(entity: any, lineContainerTitle?: string): void;
  112312. /** Get the inspector from bundle or global */
  112313. private _getGlobalInspector;
  112314. /**
  112315. * Get if the inspector is visible or not.
  112316. * @returns true if visible otherwise, false
  112317. */
  112318. isVisible(): boolean;
  112319. /**
  112320. * Hide the inspector and close its window.
  112321. */
  112322. hide(): void;
  112323. /**
  112324. * Launch the debugLayer.
  112325. * @param config Define the configuration of the inspector
  112326. * @return a promise fulfilled when the debug layer is visible
  112327. */
  112328. show(config?: IInspectorOptions): Promise<DebugLayer>;
  112329. }
  112330. }
  112331. declare module BABYLON {
  112332. /**
  112333. * Class containing static functions to help procedurally build meshes
  112334. */
  112335. export class BoxBuilder {
  112336. /**
  112337. * Creates a box mesh
  112338. * * The parameter `size` sets the size (float) of each box side (default 1)
  112339. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  112340. * * 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)
  112341. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  112342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112345. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  112346. * @param name defines the name of the mesh
  112347. * @param options defines the options used to create the mesh
  112348. * @param scene defines the hosting scene
  112349. * @returns the box mesh
  112350. */
  112351. static CreateBox(name: string, options: {
  112352. size?: number;
  112353. width?: number;
  112354. height?: number;
  112355. depth?: number;
  112356. faceUV?: Vector4[];
  112357. faceColors?: Color4[];
  112358. sideOrientation?: number;
  112359. frontUVs?: Vector4;
  112360. backUVs?: Vector4;
  112361. wrap?: boolean;
  112362. topBaseAt?: number;
  112363. bottomBaseAt?: number;
  112364. updatable?: boolean;
  112365. }, scene?: Nullable<Scene>): Mesh;
  112366. }
  112367. }
  112368. declare module BABYLON {
  112369. /**
  112370. * Class containing static functions to help procedurally build meshes
  112371. */
  112372. export class SphereBuilder {
  112373. /**
  112374. * Creates a sphere mesh
  112375. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  112376. * * 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`)
  112377. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  112378. * * 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
  112379. * * 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)
  112380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112383. * @param name defines the name of the mesh
  112384. * @param options defines the options used to create the mesh
  112385. * @param scene defines the hosting scene
  112386. * @returns the sphere mesh
  112387. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  112388. */
  112389. static CreateSphere(name: string, options: {
  112390. segments?: number;
  112391. diameter?: number;
  112392. diameterX?: number;
  112393. diameterY?: number;
  112394. diameterZ?: number;
  112395. arc?: number;
  112396. slice?: number;
  112397. sideOrientation?: number;
  112398. frontUVs?: Vector4;
  112399. backUVs?: Vector4;
  112400. updatable?: boolean;
  112401. }, scene?: Nullable<Scene>): Mesh;
  112402. }
  112403. }
  112404. declare module BABYLON.Debug {
  112405. /**
  112406. * Used to show the physics impostor around the specific mesh
  112407. */
  112408. export class PhysicsViewer {
  112409. /** @hidden */
  112410. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  112411. /** @hidden */
  112412. protected _meshes: Array<Nullable<AbstractMesh>>;
  112413. /** @hidden */
  112414. protected _scene: Nullable<Scene>;
  112415. /** @hidden */
  112416. protected _numMeshes: number;
  112417. /** @hidden */
  112418. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  112419. private _renderFunction;
  112420. private _utilityLayer;
  112421. private _debugBoxMesh;
  112422. private _debugSphereMesh;
  112423. private _debugCylinderMesh;
  112424. private _debugMaterial;
  112425. private _debugMeshMeshes;
  112426. /**
  112427. * Creates a new PhysicsViewer
  112428. * @param scene defines the hosting scene
  112429. */
  112430. constructor(scene: Scene);
  112431. /** @hidden */
  112432. protected _updateDebugMeshes(): void;
  112433. /**
  112434. * Renders a specified physic impostor
  112435. * @param impostor defines the impostor to render
  112436. * @param targetMesh defines the mesh represented by the impostor
  112437. * @returns the new debug mesh used to render the impostor
  112438. */
  112439. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  112440. /**
  112441. * Hides a specified physic impostor
  112442. * @param impostor defines the impostor to hide
  112443. */
  112444. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  112445. private _getDebugMaterial;
  112446. private _getDebugBoxMesh;
  112447. private _getDebugSphereMesh;
  112448. private _getDebugCylinderMesh;
  112449. private _getDebugMeshMesh;
  112450. private _getDebugMesh;
  112451. /** Releases all resources */
  112452. dispose(): void;
  112453. }
  112454. }
  112455. declare module BABYLON {
  112456. /**
  112457. * Class containing static functions to help procedurally build meshes
  112458. */
  112459. export class LinesBuilder {
  112460. /**
  112461. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  112462. * * 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
  112463. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  112464. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  112465. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  112466. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  112467. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  112468. * * 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
  112469. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  112470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112471. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  112472. * @param name defines the name of the new line system
  112473. * @param options defines the options used to create the line system
  112474. * @param scene defines the hosting scene
  112475. * @returns a new line system mesh
  112476. */
  112477. static CreateLineSystem(name: string, options: {
  112478. lines: Vector3[][];
  112479. updatable?: boolean;
  112480. instance?: Nullable<LinesMesh>;
  112481. colors?: Nullable<Color4[][]>;
  112482. useVertexAlpha?: boolean;
  112483. }, scene: Nullable<Scene>): LinesMesh;
  112484. /**
  112485. * Creates a line mesh
  112486. * 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
  112487. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112488. * * The parameter `points` is an array successive Vector3
  112489. * * 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
  112490. * * The optional parameter `colors` is an array of successive Color4, one per line point
  112491. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  112492. * * When updating an instance, remember that only point positions can change, not the number of points
  112493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  112495. * @param name defines the name of the new line system
  112496. * @param options defines the options used to create the line system
  112497. * @param scene defines the hosting scene
  112498. * @returns a new line mesh
  112499. */
  112500. static CreateLines(name: string, options: {
  112501. points: Vector3[];
  112502. updatable?: boolean;
  112503. instance?: Nullable<LinesMesh>;
  112504. colors?: Color4[];
  112505. useVertexAlpha?: boolean;
  112506. }, scene?: Nullable<Scene>): LinesMesh;
  112507. /**
  112508. * Creates a dashed line mesh
  112509. * * 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
  112510. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  112511. * * The parameter `points` is an array successive Vector3
  112512. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  112513. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  112514. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  112515. * * 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
  112516. * * When updating an instance, remember that only point positions can change, not the number of points
  112517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112518. * @param name defines the name of the mesh
  112519. * @param options defines the options used to create the mesh
  112520. * @param scene defines the hosting scene
  112521. * @returns the dashed line mesh
  112522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  112523. */
  112524. static CreateDashedLines(name: string, options: {
  112525. points: Vector3[];
  112526. dashSize?: number;
  112527. gapSize?: number;
  112528. dashNb?: number;
  112529. updatable?: boolean;
  112530. instance?: LinesMesh;
  112531. }, scene?: Nullable<Scene>): LinesMesh;
  112532. }
  112533. }
  112534. declare module BABYLON {
  112535. /**
  112536. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112537. * in order to better appreciate the issue one might have.
  112538. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112539. */
  112540. export class RayHelper {
  112541. /**
  112542. * Defines the ray we are currently tryin to visualize.
  112543. */
  112544. ray: Nullable<Ray>;
  112545. private _renderPoints;
  112546. private _renderLine;
  112547. private _renderFunction;
  112548. private _scene;
  112549. private _updateToMeshFunction;
  112550. private _attachedToMesh;
  112551. private _meshSpaceDirection;
  112552. private _meshSpaceOrigin;
  112553. /**
  112554. * Helper function to create a colored helper in a scene in one line.
  112555. * @param ray Defines the ray we are currently tryin to visualize
  112556. * @param scene Defines the scene the ray is used in
  112557. * @param color Defines the color we want to see the ray in
  112558. * @returns The newly created ray helper.
  112559. */
  112560. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  112561. /**
  112562. * Instantiate a new ray helper.
  112563. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  112564. * in order to better appreciate the issue one might have.
  112565. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  112566. * @param ray Defines the ray we are currently tryin to visualize
  112567. */
  112568. constructor(ray: Ray);
  112569. /**
  112570. * Shows the ray we are willing to debug.
  112571. * @param scene Defines the scene the ray needs to be rendered in
  112572. * @param color Defines the color the ray needs to be rendered in
  112573. */
  112574. show(scene: Scene, color?: Color3): void;
  112575. /**
  112576. * Hides the ray we are debugging.
  112577. */
  112578. hide(): void;
  112579. private _render;
  112580. /**
  112581. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  112582. * @param mesh Defines the mesh we want the helper attached to
  112583. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  112584. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  112585. * @param length Defines the length of the ray
  112586. */
  112587. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  112588. /**
  112589. * Detach the ray helper from the mesh it has previously been attached to.
  112590. */
  112591. detachFromMesh(): void;
  112592. private _updateToMesh;
  112593. /**
  112594. * Dispose the helper and release its associated resources.
  112595. */
  112596. dispose(): void;
  112597. }
  112598. }
  112599. declare module BABYLON.Debug {
  112600. /**
  112601. * Class used to render a debug view of a given skeleton
  112602. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  112603. */
  112604. export class SkeletonViewer {
  112605. /** defines the skeleton to render */
  112606. skeleton: Skeleton;
  112607. /** defines the mesh attached to the skeleton */
  112608. mesh: AbstractMesh;
  112609. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112610. autoUpdateBonesMatrices: boolean;
  112611. /** defines the rendering group id to use with the viewer */
  112612. renderingGroupId: number;
  112613. /** Gets or sets the color used to render the skeleton */
  112614. color: Color3;
  112615. private _scene;
  112616. private _debugLines;
  112617. private _debugMesh;
  112618. private _isEnabled;
  112619. private _renderFunction;
  112620. private _utilityLayer;
  112621. /**
  112622. * Returns the mesh used to render the bones
  112623. */
  112624. readonly debugMesh: Nullable<LinesMesh>;
  112625. /**
  112626. * Creates a new SkeletonViewer
  112627. * @param skeleton defines the skeleton to render
  112628. * @param mesh defines the mesh attached to the skeleton
  112629. * @param scene defines the hosting scene
  112630. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  112631. * @param renderingGroupId defines the rendering group id to use with the viewer
  112632. */
  112633. constructor(
  112634. /** defines the skeleton to render */
  112635. skeleton: Skeleton,
  112636. /** defines the mesh attached to the skeleton */
  112637. mesh: AbstractMesh, scene: Scene,
  112638. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  112639. autoUpdateBonesMatrices?: boolean,
  112640. /** defines the rendering group id to use with the viewer */
  112641. renderingGroupId?: number);
  112642. /** Gets or sets a boolean indicating if the viewer is enabled */
  112643. isEnabled: boolean;
  112644. private _getBonePosition;
  112645. private _getLinesForBonesWithLength;
  112646. private _getLinesForBonesNoLength;
  112647. /** Update the viewer to sync with current skeleton state */
  112648. update(): void;
  112649. /** Release associated resources */
  112650. dispose(): void;
  112651. }
  112652. }
  112653. declare module BABYLON {
  112654. /**
  112655. * Options to create the null engine
  112656. */
  112657. export class NullEngineOptions {
  112658. /**
  112659. * Render width (Default: 512)
  112660. */
  112661. renderWidth: number;
  112662. /**
  112663. * Render height (Default: 256)
  112664. */
  112665. renderHeight: number;
  112666. /**
  112667. * Texture size (Default: 512)
  112668. */
  112669. textureSize: number;
  112670. /**
  112671. * If delta time between frames should be constant
  112672. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112673. */
  112674. deterministicLockstep: boolean;
  112675. /**
  112676. * Maximum about of steps between frames (Default: 4)
  112677. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112678. */
  112679. lockstepMaxSteps: number;
  112680. }
  112681. /**
  112682. * The null engine class provides support for headless version of babylon.js.
  112683. * This can be used in server side scenario or for testing purposes
  112684. */
  112685. export class NullEngine extends Engine {
  112686. private _options;
  112687. /**
  112688. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  112689. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112690. * @returns true if engine is in deterministic lock step mode
  112691. */
  112692. isDeterministicLockStep(): boolean;
  112693. /**
  112694. * Gets the max steps when engine is running in deterministic lock step
  112695. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112696. * @returns the max steps
  112697. */
  112698. getLockstepMaxSteps(): number;
  112699. /**
  112700. * Gets the current hardware scaling level.
  112701. * By default the hardware scaling level is computed from the window device ratio.
  112702. * 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.
  112703. * @returns a number indicating the current hardware scaling level
  112704. */
  112705. getHardwareScalingLevel(): number;
  112706. constructor(options?: NullEngineOptions);
  112707. /**
  112708. * Creates a vertex buffer
  112709. * @param vertices the data for the vertex buffer
  112710. * @returns the new WebGL static buffer
  112711. */
  112712. createVertexBuffer(vertices: FloatArray): DataBuffer;
  112713. /**
  112714. * Creates a new index buffer
  112715. * @param indices defines the content of the index buffer
  112716. * @param updatable defines if the index buffer must be updatable
  112717. * @returns a new webGL buffer
  112718. */
  112719. createIndexBuffer(indices: IndicesArray): DataBuffer;
  112720. /**
  112721. * Clear the current render buffer or the current render target (if any is set up)
  112722. * @param color defines the color to use
  112723. * @param backBuffer defines if the back buffer must be cleared
  112724. * @param depth defines if the depth buffer must be cleared
  112725. * @param stencil defines if the stencil buffer must be cleared
  112726. */
  112727. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112728. /**
  112729. * Gets the current render width
  112730. * @param useScreen defines if screen size must be used (or the current render target if any)
  112731. * @returns a number defining the current render width
  112732. */
  112733. getRenderWidth(useScreen?: boolean): number;
  112734. /**
  112735. * Gets the current render height
  112736. * @param useScreen defines if screen size must be used (or the current render target if any)
  112737. * @returns a number defining the current render height
  112738. */
  112739. getRenderHeight(useScreen?: boolean): number;
  112740. /**
  112741. * Set the WebGL's viewport
  112742. * @param viewport defines the viewport element to be used
  112743. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112744. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112745. */
  112746. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112747. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  112748. /**
  112749. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112750. * @param pipelineContext defines the pipeline context to use
  112751. * @param uniformsNames defines the list of uniform names
  112752. * @returns an array of webGL uniform locations
  112753. */
  112754. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112755. /**
  112756. * Gets the lsit of active attributes for a given webGL program
  112757. * @param pipelineContext defines the pipeline context to use
  112758. * @param attributesNames defines the list of attribute names to get
  112759. * @returns an array of indices indicating the offset of each attribute
  112760. */
  112761. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112762. /**
  112763. * Binds an effect to the webGL context
  112764. * @param effect defines the effect to bind
  112765. */
  112766. bindSamplers(effect: Effect): void;
  112767. /**
  112768. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112769. * @param effect defines the effect to activate
  112770. */
  112771. enableEffect(effect: Effect): void;
  112772. /**
  112773. * Set various states to the webGL context
  112774. * @param culling defines backface culling state
  112775. * @param zOffset defines the value to apply to zOffset (0 by default)
  112776. * @param force defines if states must be applied even if cache is up to date
  112777. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  112778. */
  112779. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  112780. /**
  112781. * Set the value of an uniform to an array of int32
  112782. * @param uniform defines the webGL uniform location where to store the value
  112783. * @param array defines the array of int32 to store
  112784. */
  112785. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  112786. /**
  112787. * Set the value of an uniform to an array of int32 (stored as vec2)
  112788. * @param uniform defines the webGL uniform location where to store the value
  112789. * @param array defines the array of int32 to store
  112790. */
  112791. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  112792. /**
  112793. * Set the value of an uniform to an array of int32 (stored as vec3)
  112794. * @param uniform defines the webGL uniform location where to store the value
  112795. * @param array defines the array of int32 to store
  112796. */
  112797. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  112798. /**
  112799. * Set the value of an uniform to an array of int32 (stored as vec4)
  112800. * @param uniform defines the webGL uniform location where to store the value
  112801. * @param array defines the array of int32 to store
  112802. */
  112803. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  112804. /**
  112805. * Set the value of an uniform to an array of float32
  112806. * @param uniform defines the webGL uniform location where to store the value
  112807. * @param array defines the array of float32 to store
  112808. */
  112809. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  112810. /**
  112811. * Set the value of an uniform to an array of float32 (stored as vec2)
  112812. * @param uniform defines the webGL uniform location where to store the value
  112813. * @param array defines the array of float32 to store
  112814. */
  112815. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  112816. /**
  112817. * Set the value of an uniform to an array of float32 (stored as vec3)
  112818. * @param uniform defines the webGL uniform location where to store the value
  112819. * @param array defines the array of float32 to store
  112820. */
  112821. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  112822. /**
  112823. * Set the value of an uniform to an array of float32 (stored as vec4)
  112824. * @param uniform defines the webGL uniform location where to store the value
  112825. * @param array defines the array of float32 to store
  112826. */
  112827. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  112828. /**
  112829. * Set the value of an uniform to an array of number
  112830. * @param uniform defines the webGL uniform location where to store the value
  112831. * @param array defines the array of number to store
  112832. */
  112833. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  112834. /**
  112835. * Set the value of an uniform to an array of number (stored as vec2)
  112836. * @param uniform defines the webGL uniform location where to store the value
  112837. * @param array defines the array of number to store
  112838. */
  112839. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  112840. /**
  112841. * Set the value of an uniform to an array of number (stored as vec3)
  112842. * @param uniform defines the webGL uniform location where to store the value
  112843. * @param array defines the array of number to store
  112844. */
  112845. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  112846. /**
  112847. * Set the value of an uniform to an array of number (stored as vec4)
  112848. * @param uniform defines the webGL uniform location where to store the value
  112849. * @param array defines the array of number to store
  112850. */
  112851. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  112852. /**
  112853. * Set the value of an uniform to an array of float32 (stored as matrices)
  112854. * @param uniform defines the webGL uniform location where to store the value
  112855. * @param matrices defines the array of float32 to store
  112856. */
  112857. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  112858. /**
  112859. * Set the value of an uniform to a matrix (3x3)
  112860. * @param uniform defines the webGL uniform location where to store the value
  112861. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112862. */
  112863. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112864. /**
  112865. * Set the value of an uniform to a matrix (2x2)
  112866. * @param uniform defines the webGL uniform location where to store the value
  112867. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112868. */
  112869. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  112870. /**
  112871. * Set the value of an uniform to a number (float)
  112872. * @param uniform defines the webGL uniform location where to store the value
  112873. * @param value defines the float number to store
  112874. */
  112875. setFloat(uniform: WebGLUniformLocation, value: number): void;
  112876. /**
  112877. * Set the value of an uniform to a vec2
  112878. * @param uniform defines the webGL uniform location where to store the value
  112879. * @param x defines the 1st component of the value
  112880. * @param y defines the 2nd component of the value
  112881. */
  112882. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  112883. /**
  112884. * Set the value of an uniform to a vec3
  112885. * @param uniform defines the webGL uniform location where to store the value
  112886. * @param x defines the 1st component of the value
  112887. * @param y defines the 2nd component of the value
  112888. * @param z defines the 3rd component of the value
  112889. */
  112890. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  112891. /**
  112892. * Set the value of an uniform to a boolean
  112893. * @param uniform defines the webGL uniform location where to store the value
  112894. * @param bool defines the boolean to store
  112895. */
  112896. setBool(uniform: WebGLUniformLocation, bool: number): void;
  112897. /**
  112898. * Set the value of an uniform to a vec4
  112899. * @param uniform defines the webGL uniform location where to store the value
  112900. * @param x defines the 1st component of the value
  112901. * @param y defines the 2nd component of the value
  112902. * @param z defines the 3rd component of the value
  112903. * @param w defines the 4th component of the value
  112904. */
  112905. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  112906. /**
  112907. * Sets the current alpha mode
  112908. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  112909. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  112910. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  112911. */
  112912. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  112913. /**
  112914. * Bind webGl buffers directly to the webGL context
  112915. * @param vertexBuffers defines the vertex buffer to bind
  112916. * @param indexBuffer defines the index buffer to bind
  112917. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112918. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112919. * @param effect defines the effect associated with the vertex buffer
  112920. */
  112921. bindBuffers(vertexBuffers: {
  112922. [key: string]: VertexBuffer;
  112923. }, indexBuffer: DataBuffer, effect: Effect): void;
  112924. /**
  112925. * Force the entire cache to be cleared
  112926. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112927. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112928. */
  112929. wipeCaches(bruteForce?: boolean): void;
  112930. /**
  112931. * Send a draw order
  112932. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112933. * @param indexStart defines the starting index
  112934. * @param indexCount defines the number of index to draw
  112935. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112936. */
  112937. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112938. /**
  112939. * Draw a list of indexed primitives
  112940. * @param fillMode defines the primitive to use
  112941. * @param indexStart defines the starting index
  112942. * @param indexCount defines the number of index to draw
  112943. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112944. */
  112945. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112946. /**
  112947. * Draw a list of unindexed primitives
  112948. * @param fillMode defines the primitive to use
  112949. * @param verticesStart defines the index of first vertex to draw
  112950. * @param verticesCount defines the count of vertices to draw
  112951. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112952. */
  112953. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112954. /** @hidden */
  112955. _createTexture(): WebGLTexture;
  112956. /** @hidden */
  112957. _releaseTexture(texture: InternalTexture): void;
  112958. /**
  112959. * Usually called from Texture.ts.
  112960. * Passed information to create a WebGLTexture
  112961. * @param urlArg defines a value which contains one of the following:
  112962. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112963. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112964. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112965. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112966. * @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)
  112967. * @param scene needed for loading to the correct scene
  112968. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112969. * @param onLoad optional callback to be called upon successful completion
  112970. * @param onError optional callback to be called upon failure
  112971. * @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
  112972. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112973. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112974. * @param forcedExtension defines the extension to use to pick the right loader
  112975. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  112976. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112977. */
  112978. 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;
  112979. /**
  112980. * Creates a new render target texture
  112981. * @param size defines the size of the texture
  112982. * @param options defines the options used to create the texture
  112983. * @returns a new render target texture stored in an InternalTexture
  112984. */
  112985. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  112986. /**
  112987. * Update the sampling mode of a given texture
  112988. * @param samplingMode defines the required sampling mode
  112989. * @param texture defines the texture to update
  112990. */
  112991. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  112992. /**
  112993. * Binds the frame buffer to the specified texture.
  112994. * @param texture The texture to render to or null for the default canvas
  112995. * @param faceIndex The face of the texture to render to in case of cube texture
  112996. * @param requiredWidth The width of the target to render to
  112997. * @param requiredHeight The height of the target to render to
  112998. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112999. * @param depthStencilTexture The depth stencil texture to use to render
  113000. * @param lodLevel defines le lod level to bind to the frame buffer
  113001. */
  113002. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113003. /**
  113004. * Unbind the current render target texture from the webGL context
  113005. * @param texture defines the render target texture to unbind
  113006. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113007. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113008. */
  113009. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113010. /**
  113011. * Creates a dynamic vertex buffer
  113012. * @param vertices the data for the dynamic vertex buffer
  113013. * @returns the new WebGL dynamic buffer
  113014. */
  113015. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  113016. /**
  113017. * Update the content of a dynamic texture
  113018. * @param texture defines the texture to update
  113019. * @param canvas defines the canvas containing the source
  113020. * @param invertY defines if data must be stored with Y axis inverted
  113021. * @param premulAlpha defines if alpha is stored as premultiplied
  113022. * @param format defines the format of the data
  113023. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  113024. */
  113025. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  113026. /**
  113027. * Gets a boolean indicating if all created effects are ready
  113028. * @returns true if all effects are ready
  113029. */
  113030. areAllEffectsReady(): boolean;
  113031. /**
  113032. * @hidden
  113033. * Get the current error code of the webGL context
  113034. * @returns the error code
  113035. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113036. */
  113037. getError(): number;
  113038. /** @hidden */
  113039. _getUnpackAlignement(): number;
  113040. /** @hidden */
  113041. _unpackFlipY(value: boolean): void;
  113042. /**
  113043. * Update a dynamic index buffer
  113044. * @param indexBuffer defines the target index buffer
  113045. * @param indices defines the data to update
  113046. * @param offset defines the offset in the target index buffer where update should start
  113047. */
  113048. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  113049. /**
  113050. * Updates a dynamic vertex buffer.
  113051. * @param vertexBuffer the vertex buffer to update
  113052. * @param vertices the data used to update the vertex buffer
  113053. * @param byteOffset the byte offset of the data (optional)
  113054. * @param byteLength the byte length of the data (optional)
  113055. */
  113056. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  113057. /** @hidden */
  113058. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  113059. /** @hidden */
  113060. _bindTexture(channel: number, texture: InternalTexture): void;
  113061. protected _deleteBuffer(buffer: WebGLBuffer): void;
  113062. /**
  113063. * 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
  113064. */
  113065. releaseEffects(): void;
  113066. displayLoadingUI(): void;
  113067. hideLoadingUI(): void;
  113068. /** @hidden */
  113069. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113070. /** @hidden */
  113071. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113072. /** @hidden */
  113073. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113074. /** @hidden */
  113075. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113076. }
  113077. }
  113078. declare module BABYLON {
  113079. /** @hidden */
  113080. export class _OcclusionDataStorage {
  113081. /** @hidden */
  113082. occlusionInternalRetryCounter: number;
  113083. /** @hidden */
  113084. isOcclusionQueryInProgress: boolean;
  113085. /** @hidden */
  113086. isOccluded: boolean;
  113087. /** @hidden */
  113088. occlusionRetryCount: number;
  113089. /** @hidden */
  113090. occlusionType: number;
  113091. /** @hidden */
  113092. occlusionQueryAlgorithmType: number;
  113093. }
  113094. interface Engine {
  113095. /**
  113096. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  113097. * @return the new query
  113098. */
  113099. createQuery(): WebGLQuery;
  113100. /**
  113101. * Delete and release a webGL query
  113102. * @param query defines the query to delete
  113103. * @return the current engine
  113104. */
  113105. deleteQuery(query: WebGLQuery): Engine;
  113106. /**
  113107. * Check if a given query has resolved and got its value
  113108. * @param query defines the query to check
  113109. * @returns true if the query got its value
  113110. */
  113111. isQueryResultAvailable(query: WebGLQuery): boolean;
  113112. /**
  113113. * Gets the value of a given query
  113114. * @param query defines the query to check
  113115. * @returns the value of the query
  113116. */
  113117. getQueryResult(query: WebGLQuery): number;
  113118. /**
  113119. * Initiates an occlusion query
  113120. * @param algorithmType defines the algorithm to use
  113121. * @param query defines the query to use
  113122. * @returns the current engine
  113123. * @see http://doc.babylonjs.com/features/occlusionquery
  113124. */
  113125. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  113126. /**
  113127. * Ends an occlusion query
  113128. * @see http://doc.babylonjs.com/features/occlusionquery
  113129. * @param algorithmType defines the algorithm to use
  113130. * @returns the current engine
  113131. */
  113132. endOcclusionQuery(algorithmType: number): Engine;
  113133. /**
  113134. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  113135. * Please note that only one query can be issued at a time
  113136. * @returns a time token used to track the time span
  113137. */
  113138. startTimeQuery(): Nullable<_TimeToken>;
  113139. /**
  113140. * Ends a time query
  113141. * @param token defines the token used to measure the time span
  113142. * @returns the time spent (in ns)
  113143. */
  113144. endTimeQuery(token: _TimeToken): int;
  113145. /** @hidden */
  113146. _currentNonTimestampToken: Nullable<_TimeToken>;
  113147. /** @hidden */
  113148. _createTimeQuery(): WebGLQuery;
  113149. /** @hidden */
  113150. _deleteTimeQuery(query: WebGLQuery): void;
  113151. /** @hidden */
  113152. _getGlAlgorithmType(algorithmType: number): number;
  113153. /** @hidden */
  113154. _getTimeQueryResult(query: WebGLQuery): any;
  113155. /** @hidden */
  113156. _getTimeQueryAvailability(query: WebGLQuery): any;
  113157. }
  113158. interface AbstractMesh {
  113159. /**
  113160. * Backing filed
  113161. * @hidden
  113162. */
  113163. __occlusionDataStorage: _OcclusionDataStorage;
  113164. /**
  113165. * Access property
  113166. * @hidden
  113167. */
  113168. _occlusionDataStorage: _OcclusionDataStorage;
  113169. /**
  113170. * 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.
  113171. * The default value is -1 which means don't break the query and wait till the result
  113172. * @see http://doc.babylonjs.com/features/occlusionquery
  113173. */
  113174. occlusionRetryCount: number;
  113175. /**
  113176. * 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:
  113177. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  113178. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  113179. * * 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.
  113180. * @see http://doc.babylonjs.com/features/occlusionquery
  113181. */
  113182. occlusionType: number;
  113183. /**
  113184. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  113185. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  113186. * * 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.
  113187. * @see http://doc.babylonjs.com/features/occlusionquery
  113188. */
  113189. occlusionQueryAlgorithmType: number;
  113190. /**
  113191. * 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
  113192. * @see http://doc.babylonjs.com/features/occlusionquery
  113193. */
  113194. isOccluded: boolean;
  113195. /**
  113196. * Flag to check the progress status of the query
  113197. * @see http://doc.babylonjs.com/features/occlusionquery
  113198. */
  113199. isOcclusionQueryInProgress: boolean;
  113200. }
  113201. }
  113202. declare module BABYLON {
  113203. /** @hidden */
  113204. export var _forceTransformFeedbackToBundle: boolean;
  113205. interface Engine {
  113206. /**
  113207. * Creates a webGL transform feedback object
  113208. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  113209. * @returns the webGL transform feedback object
  113210. */
  113211. createTransformFeedback(): WebGLTransformFeedback;
  113212. /**
  113213. * Delete a webGL transform feedback object
  113214. * @param value defines the webGL transform feedback object to delete
  113215. */
  113216. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  113217. /**
  113218. * Bind a webGL transform feedback object to the webgl context
  113219. * @param value defines the webGL transform feedback object to bind
  113220. */
  113221. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  113222. /**
  113223. * Begins a transform feedback operation
  113224. * @param usePoints defines if points or triangles must be used
  113225. */
  113226. beginTransformFeedback(usePoints: boolean): void;
  113227. /**
  113228. * Ends a transform feedback operation
  113229. */
  113230. endTransformFeedback(): void;
  113231. /**
  113232. * Specify the varyings to use with transform feedback
  113233. * @param program defines the associated webGL program
  113234. * @param value defines the list of strings representing the varying names
  113235. */
  113236. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  113237. /**
  113238. * Bind a webGL buffer for a transform feedback operation
  113239. * @param value defines the webGL buffer to bind
  113240. */
  113241. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  113242. }
  113243. }
  113244. declare module BABYLON {
  113245. /**
  113246. * Creation options of the multi render target texture.
  113247. */
  113248. export interface IMultiRenderTargetOptions {
  113249. /**
  113250. * Define if the texture needs to create mip maps after render.
  113251. */
  113252. generateMipMaps?: boolean;
  113253. /**
  113254. * Define the types of all the draw buffers we want to create
  113255. */
  113256. types?: number[];
  113257. /**
  113258. * Define the sampling modes of all the draw buffers we want to create
  113259. */
  113260. samplingModes?: number[];
  113261. /**
  113262. * Define if a depth buffer is required
  113263. */
  113264. generateDepthBuffer?: boolean;
  113265. /**
  113266. * Define if a stencil buffer is required
  113267. */
  113268. generateStencilBuffer?: boolean;
  113269. /**
  113270. * Define if a depth texture is required instead of a depth buffer
  113271. */
  113272. generateDepthTexture?: boolean;
  113273. /**
  113274. * Define the number of desired draw buffers
  113275. */
  113276. textureCount?: number;
  113277. /**
  113278. * Define if aspect ratio should be adapted to the texture or stay the scene one
  113279. */
  113280. doNotChangeAspectRatio?: boolean;
  113281. /**
  113282. * Define the default type of the buffers we are creating
  113283. */
  113284. defaultType?: number;
  113285. }
  113286. /**
  113287. * A multi render target, like a render target provides the ability to render to a texture.
  113288. * Unlike the render target, it can render to several draw buffers in one draw.
  113289. * This is specially interesting in deferred rendering or for any effects requiring more than
  113290. * just one color from a single pass.
  113291. */
  113292. export class MultiRenderTarget extends RenderTargetTexture {
  113293. private _internalTextures;
  113294. private _textures;
  113295. private _multiRenderTargetOptions;
  113296. /**
  113297. * Get if draw buffers are currently supported by the used hardware and browser.
  113298. */
  113299. readonly isSupported: boolean;
  113300. /**
  113301. * Get the list of textures generated by the multi render target.
  113302. */
  113303. readonly textures: Texture[];
  113304. /**
  113305. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  113306. */
  113307. readonly depthTexture: Texture;
  113308. /**
  113309. * Set the wrapping mode on U of all the textures we are rendering to.
  113310. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  113311. */
  113312. wrapU: number;
  113313. /**
  113314. * Set the wrapping mode on V of all the textures we are rendering to.
  113315. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  113316. */
  113317. wrapV: number;
  113318. /**
  113319. * Instantiate a new multi render target texture.
  113320. * A multi render target, like a render target provides the ability to render to a texture.
  113321. * Unlike the render target, it can render to several draw buffers in one draw.
  113322. * This is specially interesting in deferred rendering or for any effects requiring more than
  113323. * just one color from a single pass.
  113324. * @param name Define the name of the texture
  113325. * @param size Define the size of the buffers to render to
  113326. * @param count Define the number of target we are rendering into
  113327. * @param scene Define the scene the texture belongs to
  113328. * @param options Define the options used to create the multi render target
  113329. */
  113330. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  113331. /** @hidden */
  113332. _rebuild(): void;
  113333. private _createInternalTextures;
  113334. private _createTextures;
  113335. /**
  113336. * Define the number of samples used if MSAA is enabled.
  113337. */
  113338. samples: number;
  113339. /**
  113340. * Resize all the textures in the multi render target.
  113341. * Be carrefull as it will recreate all the data in the new texture.
  113342. * @param size Define the new size
  113343. */
  113344. resize(size: any): void;
  113345. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  113346. /**
  113347. * Dispose the render targets and their associated resources
  113348. */
  113349. dispose(): void;
  113350. /**
  113351. * Release all the underlying texture used as draw buffers.
  113352. */
  113353. releaseInternalTextures(): void;
  113354. }
  113355. }
  113356. declare module BABYLON {
  113357. interface ThinEngine {
  113358. /**
  113359. * Unbind a list of render target textures from the webGL context
  113360. * This is used only when drawBuffer extension or webGL2 are active
  113361. * @param textures defines the render target textures to unbind
  113362. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113363. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113364. */
  113365. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  113366. /**
  113367. * Create a multi render target texture
  113368. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  113369. * @param size defines the size of the texture
  113370. * @param options defines the creation options
  113371. * @returns the cube texture as an InternalTexture
  113372. */
  113373. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  113374. /**
  113375. * Update the sample count for a given multiple render target texture
  113376. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  113377. * @param textures defines the textures to update
  113378. * @param samples defines the sample count to set
  113379. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  113380. */
  113381. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  113382. }
  113383. }
  113384. declare module BABYLON {
  113385. /**
  113386. * Class used to define an additional view for the engine
  113387. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113388. */
  113389. export class EngineView {
  113390. /** Defines the canvas where to render the view */
  113391. target: HTMLCanvasElement;
  113392. /** Defines an optional camera used to render the view (will use active camera else) */
  113393. camera?: Camera;
  113394. }
  113395. interface Engine {
  113396. /**
  113397. * Gets or sets the HTML element to use for attaching events
  113398. */
  113399. inputElement: Nullable<HTMLElement>;
  113400. /**
  113401. * Gets the current engine view
  113402. * @see https://doc.babylonjs.com/how_to/multi_canvases
  113403. */
  113404. activeView: Nullable<EngineView>;
  113405. /** Gets or sets the list of views */
  113406. views: EngineView[];
  113407. /**
  113408. * Register a new child canvas
  113409. * @param canvas defines the canvas to register
  113410. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  113411. * @returns the associated view
  113412. */
  113413. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  113414. /**
  113415. * Remove a registered child canvas
  113416. * @param canvas defines the canvas to remove
  113417. * @returns the current engine
  113418. */
  113419. unRegisterView(canvas: HTMLCanvasElement): Engine;
  113420. }
  113421. }
  113422. declare module BABYLON {
  113423. /**
  113424. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  113425. */
  113426. export interface CubeMapInfo {
  113427. /**
  113428. * The pixel array for the front face.
  113429. * This is stored in format, left to right, up to down format.
  113430. */
  113431. front: Nullable<ArrayBufferView>;
  113432. /**
  113433. * The pixel array for the back face.
  113434. * This is stored in format, left to right, up to down format.
  113435. */
  113436. back: Nullable<ArrayBufferView>;
  113437. /**
  113438. * The pixel array for the left face.
  113439. * This is stored in format, left to right, up to down format.
  113440. */
  113441. left: Nullable<ArrayBufferView>;
  113442. /**
  113443. * The pixel array for the right face.
  113444. * This is stored in format, left to right, up to down format.
  113445. */
  113446. right: Nullable<ArrayBufferView>;
  113447. /**
  113448. * The pixel array for the up face.
  113449. * This is stored in format, left to right, up to down format.
  113450. */
  113451. up: Nullable<ArrayBufferView>;
  113452. /**
  113453. * The pixel array for the down face.
  113454. * This is stored in format, left to right, up to down format.
  113455. */
  113456. down: Nullable<ArrayBufferView>;
  113457. /**
  113458. * The size of the cubemap stored.
  113459. *
  113460. * Each faces will be size * size pixels.
  113461. */
  113462. size: number;
  113463. /**
  113464. * The format of the texture.
  113465. *
  113466. * RGBA, RGB.
  113467. */
  113468. format: number;
  113469. /**
  113470. * The type of the texture data.
  113471. *
  113472. * UNSIGNED_INT, FLOAT.
  113473. */
  113474. type: number;
  113475. /**
  113476. * Specifies whether the texture is in gamma space.
  113477. */
  113478. gammaSpace: boolean;
  113479. }
  113480. /**
  113481. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  113482. */
  113483. export class PanoramaToCubeMapTools {
  113484. private static FACE_FRONT;
  113485. private static FACE_BACK;
  113486. private static FACE_RIGHT;
  113487. private static FACE_LEFT;
  113488. private static FACE_DOWN;
  113489. private static FACE_UP;
  113490. /**
  113491. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  113492. *
  113493. * @param float32Array The source data.
  113494. * @param inputWidth The width of the input panorama.
  113495. * @param inputHeight The height of the input panorama.
  113496. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  113497. * @return The cubemap data
  113498. */
  113499. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  113500. private static CreateCubemapTexture;
  113501. private static CalcProjectionSpherical;
  113502. }
  113503. }
  113504. declare module BABYLON {
  113505. /**
  113506. * Helper class dealing with the extraction of spherical polynomial dataArray
  113507. * from a cube map.
  113508. */
  113509. export class CubeMapToSphericalPolynomialTools {
  113510. private static FileFaces;
  113511. /**
  113512. * Converts a texture to the according Spherical Polynomial data.
  113513. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113514. *
  113515. * @param texture The texture to extract the information from.
  113516. * @return The Spherical Polynomial data.
  113517. */
  113518. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  113519. /**
  113520. * Converts a cubemap to the according Spherical Polynomial data.
  113521. * This extracts the first 3 orders only as they are the only one used in the lighting.
  113522. *
  113523. * @param cubeInfo The Cube map to extract the information from.
  113524. * @return The Spherical Polynomial data.
  113525. */
  113526. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  113527. }
  113528. }
  113529. declare module BABYLON {
  113530. interface BaseTexture {
  113531. /**
  113532. * Get the polynomial representation of the texture data.
  113533. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  113534. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  113535. */
  113536. sphericalPolynomial: Nullable<SphericalPolynomial>;
  113537. }
  113538. }
  113539. declare module BABYLON {
  113540. /** @hidden */
  113541. export var rgbdEncodePixelShader: {
  113542. name: string;
  113543. shader: string;
  113544. };
  113545. }
  113546. declare module BABYLON {
  113547. /** @hidden */
  113548. export var rgbdDecodePixelShader: {
  113549. name: string;
  113550. shader: string;
  113551. };
  113552. }
  113553. declare module BABYLON {
  113554. /**
  113555. * Raw texture data and descriptor sufficient for WebGL texture upload
  113556. */
  113557. export interface EnvironmentTextureInfo {
  113558. /**
  113559. * Version of the environment map
  113560. */
  113561. version: number;
  113562. /**
  113563. * Width of image
  113564. */
  113565. width: number;
  113566. /**
  113567. * Irradiance information stored in the file.
  113568. */
  113569. irradiance: any;
  113570. /**
  113571. * Specular information stored in the file.
  113572. */
  113573. specular: any;
  113574. }
  113575. /**
  113576. * Defines One Image in the file. It requires only the position in the file
  113577. * as well as the length.
  113578. */
  113579. interface BufferImageData {
  113580. /**
  113581. * Length of the image data.
  113582. */
  113583. length: number;
  113584. /**
  113585. * Position of the data from the null terminator delimiting the end of the JSON.
  113586. */
  113587. position: number;
  113588. }
  113589. /**
  113590. * Defines the specular data enclosed in the file.
  113591. * This corresponds to the version 1 of the data.
  113592. */
  113593. export interface EnvironmentTextureSpecularInfoV1 {
  113594. /**
  113595. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  113596. */
  113597. specularDataPosition?: number;
  113598. /**
  113599. * This contains all the images data needed to reconstruct the cubemap.
  113600. */
  113601. mipmaps: Array<BufferImageData>;
  113602. /**
  113603. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  113604. */
  113605. lodGenerationScale: number;
  113606. }
  113607. /**
  113608. * Sets of helpers addressing the serialization and deserialization of environment texture
  113609. * stored in a BabylonJS env file.
  113610. * Those files are usually stored as .env files.
  113611. */
  113612. export class EnvironmentTextureTools {
  113613. /**
  113614. * Magic number identifying the env file.
  113615. */
  113616. private static _MagicBytes;
  113617. /**
  113618. * Gets the environment info from an env file.
  113619. * @param data The array buffer containing the .env bytes.
  113620. * @returns the environment file info (the json header) if successfully parsed.
  113621. */
  113622. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  113623. /**
  113624. * Creates an environment texture from a loaded cube texture.
  113625. * @param texture defines the cube texture to convert in env file
  113626. * @return a promise containing the environment data if succesfull.
  113627. */
  113628. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  113629. /**
  113630. * Creates a JSON representation of the spherical data.
  113631. * @param texture defines the texture containing the polynomials
  113632. * @return the JSON representation of the spherical info
  113633. */
  113634. private static _CreateEnvTextureIrradiance;
  113635. /**
  113636. * Creates the ArrayBufferViews used for initializing environment texture image data.
  113637. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  113638. * @param info parameters that determine what views will be created for accessing the underlying buffer
  113639. * @return the views described by info providing access to the underlying buffer
  113640. */
  113641. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  113642. /**
  113643. * Uploads the texture info contained in the env file to the GPU.
  113644. * @param texture defines the internal texture to upload to
  113645. * @param arrayBuffer defines the buffer cotaining the data to load
  113646. * @param info defines the texture info retrieved through the GetEnvInfo method
  113647. * @returns a promise
  113648. */
  113649. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  113650. private static _OnImageReadyAsync;
  113651. /**
  113652. * Uploads the levels of image data to the GPU.
  113653. * @param texture defines the internal texture to upload to
  113654. * @param imageData defines the array buffer views of image data [mipmap][face]
  113655. * @returns a promise
  113656. */
  113657. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  113658. /**
  113659. * Uploads spherical polynomials information to the texture.
  113660. * @param texture defines the texture we are trying to upload the information to
  113661. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  113662. */
  113663. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  113664. /** @hidden */
  113665. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113666. }
  113667. }
  113668. declare module BABYLON {
  113669. /**
  113670. * Contains position and normal vectors for a vertex
  113671. */
  113672. export class PositionNormalVertex {
  113673. /** the position of the vertex (defaut: 0,0,0) */
  113674. position: Vector3;
  113675. /** the normal of the vertex (defaut: 0,1,0) */
  113676. normal: Vector3;
  113677. /**
  113678. * Creates a PositionNormalVertex
  113679. * @param position the position of the vertex (defaut: 0,0,0)
  113680. * @param normal the normal of the vertex (defaut: 0,1,0)
  113681. */
  113682. constructor(
  113683. /** the position of the vertex (defaut: 0,0,0) */
  113684. position?: Vector3,
  113685. /** the normal of the vertex (defaut: 0,1,0) */
  113686. normal?: Vector3);
  113687. /**
  113688. * Clones the PositionNormalVertex
  113689. * @returns the cloned PositionNormalVertex
  113690. */
  113691. clone(): PositionNormalVertex;
  113692. }
  113693. /**
  113694. * Contains position, normal and uv vectors for a vertex
  113695. */
  113696. export class PositionNormalTextureVertex {
  113697. /** the position of the vertex (defaut: 0,0,0) */
  113698. position: Vector3;
  113699. /** the normal of the vertex (defaut: 0,1,0) */
  113700. normal: Vector3;
  113701. /** the uv of the vertex (default: 0,0) */
  113702. uv: Vector2;
  113703. /**
  113704. * Creates a PositionNormalTextureVertex
  113705. * @param position the position of the vertex (defaut: 0,0,0)
  113706. * @param normal the normal of the vertex (defaut: 0,1,0)
  113707. * @param uv the uv of the vertex (default: 0,0)
  113708. */
  113709. constructor(
  113710. /** the position of the vertex (defaut: 0,0,0) */
  113711. position?: Vector3,
  113712. /** the normal of the vertex (defaut: 0,1,0) */
  113713. normal?: Vector3,
  113714. /** the uv of the vertex (default: 0,0) */
  113715. uv?: Vector2);
  113716. /**
  113717. * Clones the PositionNormalTextureVertex
  113718. * @returns the cloned PositionNormalTextureVertex
  113719. */
  113720. clone(): PositionNormalTextureVertex;
  113721. }
  113722. }
  113723. declare module BABYLON {
  113724. /** @hidden */
  113725. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  113726. private _genericAttributeLocation;
  113727. private _varyingLocationCount;
  113728. private _varyingLocationMap;
  113729. private _replacements;
  113730. private _textureCount;
  113731. private _uniforms;
  113732. lineProcessor(line: string): string;
  113733. attributeProcessor(attribute: string): string;
  113734. varyingProcessor(varying: string, isFragment: boolean): string;
  113735. uniformProcessor(uniform: string): string;
  113736. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  113737. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  113738. }
  113739. }
  113740. declare module BABYLON {
  113741. /**
  113742. * Container for accessors for natively-stored mesh data buffers.
  113743. */
  113744. class NativeDataBuffer extends DataBuffer {
  113745. /**
  113746. * Accessor value used to identify/retrieve a natively-stored index buffer.
  113747. */
  113748. nativeIndexBuffer?: any;
  113749. /**
  113750. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  113751. */
  113752. nativeVertexBuffer?: any;
  113753. }
  113754. /** @hidden */
  113755. class NativeTexture extends InternalTexture {
  113756. getInternalTexture(): InternalTexture;
  113757. getViewCount(): number;
  113758. }
  113759. /** @hidden */
  113760. export class NativeEngine extends Engine {
  113761. private readonly _native;
  113762. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  113763. private readonly INVALID_HANDLE;
  113764. getHardwareScalingLevel(): number;
  113765. constructor();
  113766. /**
  113767. * Can be used to override the current requestAnimationFrame requester.
  113768. * @hidden
  113769. */
  113770. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113771. /**
  113772. * Override default engine behavior.
  113773. * @param color
  113774. * @param backBuffer
  113775. * @param depth
  113776. * @param stencil
  113777. */
  113778. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113779. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113780. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  113781. createVertexBuffer(data: DataArray): NativeDataBuffer;
  113782. recordVertexArrayObject(vertexBuffers: {
  113783. [key: string]: VertexBuffer;
  113784. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  113785. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113786. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  113787. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113788. /**
  113789. * Draw a list of indexed primitives
  113790. * @param fillMode defines the primitive to use
  113791. * @param indexStart defines the starting index
  113792. * @param indexCount defines the number of index to draw
  113793. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113794. */
  113795. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113796. /**
  113797. * Draw a list of unindexed primitives
  113798. * @param fillMode defines the primitive to use
  113799. * @param verticesStart defines the index of first vertex to draw
  113800. * @param verticesCount defines the count of vertices to draw
  113801. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113802. */
  113803. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113804. createPipelineContext(): IPipelineContext;
  113805. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113806. /** @hidden */
  113807. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113808. /** @hidden */
  113809. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113810. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113811. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  113812. protected _setProgram(program: WebGLProgram): void;
  113813. _releaseEffect(effect: Effect): void;
  113814. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113815. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  113816. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  113817. bindSamplers(effect: Effect): void;
  113818. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  113819. getRenderWidth(useScreen?: boolean): number;
  113820. getRenderHeight(useScreen?: boolean): number;
  113821. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  113822. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  113823. /**
  113824. * Set the z offset to apply to current rendering
  113825. * @param value defines the offset to apply
  113826. */
  113827. setZOffset(value: number): void;
  113828. /**
  113829. * Gets the current value of the zOffset
  113830. * @returns the current zOffset state
  113831. */
  113832. getZOffset(): number;
  113833. /**
  113834. * Enable or disable depth buffering
  113835. * @param enable defines the state to set
  113836. */
  113837. setDepthBuffer(enable: boolean): void;
  113838. /**
  113839. * Gets a boolean indicating if depth writing is enabled
  113840. * @returns the current depth writing state
  113841. */
  113842. getDepthWrite(): boolean;
  113843. /**
  113844. * Enable or disable depth writing
  113845. * @param enable defines the state to set
  113846. */
  113847. setDepthWrite(enable: boolean): void;
  113848. /**
  113849. * Enable or disable color writing
  113850. * @param enable defines the state to set
  113851. */
  113852. setColorWrite(enable: boolean): void;
  113853. /**
  113854. * Gets a boolean indicating if color writing is enabled
  113855. * @returns the current color writing state
  113856. */
  113857. getColorWrite(): boolean;
  113858. /**
  113859. * Sets alpha constants used by some alpha blending modes
  113860. * @param r defines the red component
  113861. * @param g defines the green component
  113862. * @param b defines the blue component
  113863. * @param a defines the alpha component
  113864. */
  113865. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113866. /**
  113867. * Sets the current alpha mode
  113868. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  113869. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113870. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113871. */
  113872. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113873. /**
  113874. * Gets the current alpha mode
  113875. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113876. * @returns the current alpha mode
  113877. */
  113878. getAlphaMode(): number;
  113879. setInt(uniform: WebGLUniformLocation, int: number): void;
  113880. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  113881. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  113882. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  113883. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  113884. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  113885. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  113886. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  113887. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  113888. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  113889. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  113890. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  113891. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  113892. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  113893. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113894. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  113895. setFloat(uniform: WebGLUniformLocation, value: number): void;
  113896. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  113897. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  113898. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  113899. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  113900. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  113901. wipeCaches(bruteForce?: boolean): void;
  113902. _createTexture(): WebGLTexture;
  113903. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113904. /**
  113905. * Usually called from BABYLON.Texture.ts.
  113906. * Passed information to create a WebGLTexture
  113907. * @param urlArg defines a value which contains one of the following:
  113908. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113909. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113910. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113911. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113912. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  113913. * @param scene needed for loading to the correct scene
  113914. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  113915. * @param onLoad optional callback to be called upon successful completion
  113916. * @param onError optional callback to be called upon failure
  113917. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  113918. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113919. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113920. * @param forcedExtension defines the extension to use to pick the right loader
  113921. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113922. */
  113923. 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;
  113924. /**
  113925. * Creates a cube texture
  113926. * @param rootUrl defines the url where the files to load is located
  113927. * @param scene defines the current scene
  113928. * @param files defines the list of files to load (1 per face)
  113929. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  113930. * @param onLoad defines an optional callback raised when the texture is loaded
  113931. * @param onError defines an optional callback raised if there is an issue to load the texture
  113932. * @param format defines the format of the data
  113933. * @param forcedExtension defines the extension to use to pick the right loader
  113934. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  113935. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113936. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113937. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  113938. * @returns the cube texture as an InternalTexture
  113939. */
  113940. 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;
  113941. private _getSamplingFilter;
  113942. private static _GetNativeTextureFormat;
  113943. createRenderTargetTexture(size: number | {
  113944. width: number;
  113945. height: number;
  113946. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  113947. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  113948. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  113949. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113950. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113951. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  113952. /**
  113953. * Updates a dynamic vertex buffer.
  113954. * @param vertexBuffer the vertex buffer to update
  113955. * @param data the data used to update the vertex buffer
  113956. * @param byteOffset the byte offset of the data (optional)
  113957. * @param byteLength the byte length of the data (optional)
  113958. */
  113959. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  113960. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113961. private _updateAnisotropicLevel;
  113962. private _getAddressMode;
  113963. /** @hidden */
  113964. _bindTexture(channel: number, texture: InternalTexture): void;
  113965. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  113966. releaseEffects(): void;
  113967. /** @hidden */
  113968. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113969. /** @hidden */
  113970. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113971. /** @hidden */
  113972. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113973. /** @hidden */
  113974. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  113975. }
  113976. }
  113977. declare module BABYLON {
  113978. /**
  113979. * Gather the list of clipboard event types as constants.
  113980. */
  113981. export class ClipboardEventTypes {
  113982. /**
  113983. * The clipboard event is fired when a copy command is active (pressed).
  113984. */
  113985. static readonly COPY: number;
  113986. /**
  113987. * The clipboard event is fired when a cut command is active (pressed).
  113988. */
  113989. static readonly CUT: number;
  113990. /**
  113991. * The clipboard event is fired when a paste command is active (pressed).
  113992. */
  113993. static readonly PASTE: number;
  113994. }
  113995. /**
  113996. * This class is used to store clipboard related info for the onClipboardObservable event.
  113997. */
  113998. export class ClipboardInfo {
  113999. /**
  114000. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114001. */
  114002. type: number;
  114003. /**
  114004. * Defines the related dom event
  114005. */
  114006. event: ClipboardEvent;
  114007. /**
  114008. *Creates an instance of ClipboardInfo.
  114009. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  114010. * @param event Defines the related dom event
  114011. */
  114012. constructor(
  114013. /**
  114014. * Defines the type of event (BABYLON.ClipboardEventTypes)
  114015. */
  114016. type: number,
  114017. /**
  114018. * Defines the related dom event
  114019. */
  114020. event: ClipboardEvent);
  114021. /**
  114022. * Get the clipboard event's type from the keycode.
  114023. * @param keyCode Defines the keyCode for the current keyboard event.
  114024. * @return {number}
  114025. */
  114026. static GetTypeFromCharacter(keyCode: number): number;
  114027. }
  114028. }
  114029. declare module BABYLON {
  114030. /**
  114031. * Google Daydream controller
  114032. */
  114033. export class DaydreamController extends WebVRController {
  114034. /**
  114035. * Base Url for the controller model.
  114036. */
  114037. static MODEL_BASE_URL: string;
  114038. /**
  114039. * File name for the controller model.
  114040. */
  114041. static MODEL_FILENAME: string;
  114042. /**
  114043. * Gamepad Id prefix used to identify Daydream Controller.
  114044. */
  114045. static readonly GAMEPAD_ID_PREFIX: string;
  114046. /**
  114047. * Creates a new DaydreamController from a gamepad
  114048. * @param vrGamepad the gamepad that the controller should be created from
  114049. */
  114050. constructor(vrGamepad: any);
  114051. /**
  114052. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114053. * @param scene scene in which to add meshes
  114054. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114055. */
  114056. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114057. /**
  114058. * Called once for each button that changed state since the last frame
  114059. * @param buttonIdx Which button index changed
  114060. * @param state New state of the button
  114061. * @param changes Which properties on the state changed since last frame
  114062. */
  114063. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114064. }
  114065. }
  114066. declare module BABYLON {
  114067. /**
  114068. * Gear VR Controller
  114069. */
  114070. export class GearVRController extends WebVRController {
  114071. /**
  114072. * Base Url for the controller model.
  114073. */
  114074. static MODEL_BASE_URL: string;
  114075. /**
  114076. * File name for the controller model.
  114077. */
  114078. static MODEL_FILENAME: string;
  114079. /**
  114080. * Gamepad Id prefix used to identify this controller.
  114081. */
  114082. static readonly GAMEPAD_ID_PREFIX: string;
  114083. private readonly _buttonIndexToObservableNameMap;
  114084. /**
  114085. * Creates a new GearVRController from a gamepad
  114086. * @param vrGamepad the gamepad that the controller should be created from
  114087. */
  114088. constructor(vrGamepad: any);
  114089. /**
  114090. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  114091. * @param scene scene in which to add meshes
  114092. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  114093. */
  114094. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  114095. /**
  114096. * Called once for each button that changed state since the last frame
  114097. * @param buttonIdx Which button index changed
  114098. * @param state New state of the button
  114099. * @param changes Which properties on the state changed since last frame
  114100. */
  114101. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  114102. }
  114103. }
  114104. declare module BABYLON {
  114105. /**
  114106. * Class containing static functions to help procedurally build meshes
  114107. */
  114108. export class PolyhedronBuilder {
  114109. /**
  114110. * Creates a polyhedron mesh
  114111. * * 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
  114112. * * The parameter `size` (positive float, default 1) sets the polygon size
  114113. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114114. * * 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`
  114115. * * 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
  114116. * * 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)`)
  114117. * * 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
  114118. * * 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
  114119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114122. * @param name defines the name of the mesh
  114123. * @param options defines the options used to create the mesh
  114124. * @param scene defines the hosting scene
  114125. * @returns the polyhedron mesh
  114126. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  114127. */
  114128. static CreatePolyhedron(name: string, options: {
  114129. type?: number;
  114130. size?: number;
  114131. sizeX?: number;
  114132. sizeY?: number;
  114133. sizeZ?: number;
  114134. custom?: any;
  114135. faceUV?: Vector4[];
  114136. faceColors?: Color4[];
  114137. flat?: boolean;
  114138. updatable?: boolean;
  114139. sideOrientation?: number;
  114140. frontUVs?: Vector4;
  114141. backUVs?: Vector4;
  114142. }, scene?: Nullable<Scene>): Mesh;
  114143. }
  114144. }
  114145. declare module BABYLON {
  114146. /**
  114147. * Gizmo that enables scaling a mesh along 3 axis
  114148. */
  114149. export class ScaleGizmo extends Gizmo {
  114150. /**
  114151. * Internal gizmo used for interactions on the x axis
  114152. */
  114153. xGizmo: AxisScaleGizmo;
  114154. /**
  114155. * Internal gizmo used for interactions on the y axis
  114156. */
  114157. yGizmo: AxisScaleGizmo;
  114158. /**
  114159. * Internal gizmo used for interactions on the z axis
  114160. */
  114161. zGizmo: AxisScaleGizmo;
  114162. /**
  114163. * Internal gizmo used to scale all axis equally
  114164. */
  114165. uniformScaleGizmo: AxisScaleGizmo;
  114166. private _meshAttached;
  114167. private _updateGizmoRotationToMatchAttachedMesh;
  114168. private _snapDistance;
  114169. private _scaleRatio;
  114170. private _uniformScalingMesh;
  114171. private _octahedron;
  114172. private _sensitivity;
  114173. /** Fires an event when any of it's sub gizmos are dragged */
  114174. onDragStartObservable: Observable<unknown>;
  114175. /** Fires an event when any of it's sub gizmos are released from dragging */
  114176. onDragEndObservable: Observable<unknown>;
  114177. attachedMesh: Nullable<AbstractMesh>;
  114178. /**
  114179. * Creates a ScaleGizmo
  114180. * @param gizmoLayer The utility layer the gizmo will be added to
  114181. */
  114182. constructor(gizmoLayer?: UtilityLayerRenderer);
  114183. updateGizmoRotationToMatchAttachedMesh: boolean;
  114184. /**
  114185. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114186. */
  114187. snapDistance: number;
  114188. /**
  114189. * Ratio for the scale of the gizmo (Default: 1)
  114190. */
  114191. scaleRatio: number;
  114192. /**
  114193. * Sensitivity factor for dragging (Default: 1)
  114194. */
  114195. sensitivity: number;
  114196. /**
  114197. * Disposes of the gizmo
  114198. */
  114199. dispose(): void;
  114200. }
  114201. }
  114202. declare module BABYLON {
  114203. /**
  114204. * Single axis scale gizmo
  114205. */
  114206. export class AxisScaleGizmo extends Gizmo {
  114207. /**
  114208. * Drag behavior responsible for the gizmos dragging interactions
  114209. */
  114210. dragBehavior: PointerDragBehavior;
  114211. private _pointerObserver;
  114212. /**
  114213. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114214. */
  114215. snapDistance: number;
  114216. /**
  114217. * Event that fires each time the gizmo snaps to a new location.
  114218. * * snapDistance is the the change in distance
  114219. */
  114220. onSnapObservable: Observable<{
  114221. snapDistance: number;
  114222. }>;
  114223. /**
  114224. * If the scaling operation should be done on all axis (default: false)
  114225. */
  114226. uniformScaling: boolean;
  114227. /**
  114228. * Custom sensitivity value for the drag strength
  114229. */
  114230. sensitivity: number;
  114231. private _isEnabled;
  114232. private _parent;
  114233. private _arrow;
  114234. private _coloredMaterial;
  114235. private _hoverMaterial;
  114236. /**
  114237. * Creates an AxisScaleGizmo
  114238. * @param gizmoLayer The utility layer the gizmo will be added to
  114239. * @param dragAxis The axis which the gizmo will be able to scale on
  114240. * @param color The color of the gizmo
  114241. */
  114242. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  114243. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114244. /**
  114245. * If the gizmo is enabled
  114246. */
  114247. isEnabled: boolean;
  114248. /**
  114249. * Disposes of the gizmo
  114250. */
  114251. dispose(): void;
  114252. /**
  114253. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  114254. * @param mesh The mesh to replace the default mesh of the gizmo
  114255. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  114256. */
  114257. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  114258. }
  114259. }
  114260. declare module BABYLON {
  114261. /**
  114262. * Bounding box gizmo
  114263. */
  114264. export class BoundingBoxGizmo extends Gizmo {
  114265. private _lineBoundingBox;
  114266. private _rotateSpheresParent;
  114267. private _scaleBoxesParent;
  114268. private _boundingDimensions;
  114269. private _renderObserver;
  114270. private _pointerObserver;
  114271. private _scaleDragSpeed;
  114272. private _tmpQuaternion;
  114273. private _tmpVector;
  114274. private _tmpRotationMatrix;
  114275. /**
  114276. * 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)
  114277. */
  114278. ignoreChildren: boolean;
  114279. /**
  114280. * 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)
  114281. */
  114282. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  114283. /**
  114284. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  114285. */
  114286. rotationSphereSize: number;
  114287. /**
  114288. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  114289. */
  114290. scaleBoxSize: number;
  114291. /**
  114292. * 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)
  114293. */
  114294. fixedDragMeshScreenSize: boolean;
  114295. /**
  114296. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  114297. */
  114298. fixedDragMeshScreenSizeDistanceFactor: number;
  114299. /**
  114300. * Fired when a rotation sphere or scale box is dragged
  114301. */
  114302. onDragStartObservable: Observable<{}>;
  114303. /**
  114304. * Fired when a scale box is dragged
  114305. */
  114306. onScaleBoxDragObservable: Observable<{}>;
  114307. /**
  114308. * Fired when a scale box drag is ended
  114309. */
  114310. onScaleBoxDragEndObservable: Observable<{}>;
  114311. /**
  114312. * Fired when a rotation sphere is dragged
  114313. */
  114314. onRotationSphereDragObservable: Observable<{}>;
  114315. /**
  114316. * Fired when a rotation sphere drag is ended
  114317. */
  114318. onRotationSphereDragEndObservable: Observable<{}>;
  114319. /**
  114320. * 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)
  114321. */
  114322. scalePivot: Nullable<Vector3>;
  114323. /**
  114324. * Mesh used as a pivot to rotate the attached mesh
  114325. */
  114326. private _anchorMesh;
  114327. private _existingMeshScale;
  114328. private _dragMesh;
  114329. private pointerDragBehavior;
  114330. private coloredMaterial;
  114331. private hoverColoredMaterial;
  114332. /**
  114333. * Sets the color of the bounding box gizmo
  114334. * @param color the color to set
  114335. */
  114336. setColor(color: Color3): void;
  114337. /**
  114338. * Creates an BoundingBoxGizmo
  114339. * @param gizmoLayer The utility layer the gizmo will be added to
  114340. * @param color The color of the gizmo
  114341. */
  114342. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  114343. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114344. private _selectNode;
  114345. /**
  114346. * Updates the bounding box information for the Gizmo
  114347. */
  114348. updateBoundingBox(): void;
  114349. private _updateRotationSpheres;
  114350. private _updateScaleBoxes;
  114351. /**
  114352. * Enables rotation on the specified axis and disables rotation on the others
  114353. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  114354. */
  114355. setEnabledRotationAxis(axis: string): void;
  114356. /**
  114357. * Enables/disables scaling
  114358. * @param enable if scaling should be enabled
  114359. */
  114360. setEnabledScaling(enable: boolean): void;
  114361. private _updateDummy;
  114362. /**
  114363. * Enables a pointer drag behavior on the bounding box of the gizmo
  114364. */
  114365. enableDragBehavior(): void;
  114366. /**
  114367. * Disposes of the gizmo
  114368. */
  114369. dispose(): void;
  114370. /**
  114371. * 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)
  114372. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  114373. * @returns the bounding box mesh with the passed in mesh as a child
  114374. */
  114375. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  114376. /**
  114377. * CustomMeshes are not supported by this gizmo
  114378. * @param mesh The mesh to replace the default mesh of the gizmo
  114379. */
  114380. setCustomMesh(mesh: Mesh): void;
  114381. }
  114382. }
  114383. declare module BABYLON {
  114384. /**
  114385. * Single plane rotation gizmo
  114386. */
  114387. export class PlaneRotationGizmo extends Gizmo {
  114388. /**
  114389. * Drag behavior responsible for the gizmos dragging interactions
  114390. */
  114391. dragBehavior: PointerDragBehavior;
  114392. private _pointerObserver;
  114393. /**
  114394. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  114395. */
  114396. snapDistance: number;
  114397. /**
  114398. * Event that fires each time the gizmo snaps to a new location.
  114399. * * snapDistance is the the change in distance
  114400. */
  114401. onSnapObservable: Observable<{
  114402. snapDistance: number;
  114403. }>;
  114404. private _isEnabled;
  114405. private _parent;
  114406. /**
  114407. * Creates a PlaneRotationGizmo
  114408. * @param gizmoLayer The utility layer the gizmo will be added to
  114409. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  114410. * @param color The color of the gizmo
  114411. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114412. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114413. */
  114414. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  114415. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  114416. /**
  114417. * If the gizmo is enabled
  114418. */
  114419. isEnabled: boolean;
  114420. /**
  114421. * Disposes of the gizmo
  114422. */
  114423. dispose(): void;
  114424. }
  114425. }
  114426. declare module BABYLON {
  114427. /**
  114428. * Gizmo that enables rotating a mesh along 3 axis
  114429. */
  114430. export class RotationGizmo extends Gizmo {
  114431. /**
  114432. * Internal gizmo used for interactions on the x axis
  114433. */
  114434. xGizmo: PlaneRotationGizmo;
  114435. /**
  114436. * Internal gizmo used for interactions on the y axis
  114437. */
  114438. yGizmo: PlaneRotationGizmo;
  114439. /**
  114440. * Internal gizmo used for interactions on the z axis
  114441. */
  114442. zGizmo: PlaneRotationGizmo;
  114443. /** Fires an event when any of it's sub gizmos are dragged */
  114444. onDragStartObservable: Observable<unknown>;
  114445. /** Fires an event when any of it's sub gizmos are released from dragging */
  114446. onDragEndObservable: Observable<unknown>;
  114447. private _meshAttached;
  114448. attachedMesh: Nullable<AbstractMesh>;
  114449. /**
  114450. * Creates a RotationGizmo
  114451. * @param gizmoLayer The utility layer the gizmo will be added to
  114452. * @param tessellation Amount of tessellation to be used when creating rotation circles
  114453. * @param useEulerRotation Use and update Euler angle instead of quaternion
  114454. */
  114455. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  114456. updateGizmoRotationToMatchAttachedMesh: boolean;
  114457. /**
  114458. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  114459. */
  114460. snapDistance: number;
  114461. /**
  114462. * Ratio for the scale of the gizmo (Default: 1)
  114463. */
  114464. scaleRatio: number;
  114465. /**
  114466. * Disposes of the gizmo
  114467. */
  114468. dispose(): void;
  114469. /**
  114470. * CustomMeshes are not supported by this gizmo
  114471. * @param mesh The mesh to replace the default mesh of the gizmo
  114472. */
  114473. setCustomMesh(mesh: Mesh): void;
  114474. }
  114475. }
  114476. declare module BABYLON {
  114477. /**
  114478. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  114479. */
  114480. export class GizmoManager implements IDisposable {
  114481. private scene;
  114482. /**
  114483. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  114484. */
  114485. gizmos: {
  114486. positionGizmo: Nullable<PositionGizmo>;
  114487. rotationGizmo: Nullable<RotationGizmo>;
  114488. scaleGizmo: Nullable<ScaleGizmo>;
  114489. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  114490. };
  114491. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  114492. clearGizmoOnEmptyPointerEvent: boolean;
  114493. /** Fires an event when the manager is attached to a mesh */
  114494. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  114495. private _gizmosEnabled;
  114496. private _pointerObserver;
  114497. private _attachedMesh;
  114498. private _boundingBoxColor;
  114499. private _defaultUtilityLayer;
  114500. private _defaultKeepDepthUtilityLayer;
  114501. /**
  114502. * When bounding box gizmo is enabled, this can be used to track drag/end events
  114503. */
  114504. boundingBoxDragBehavior: SixDofDragBehavior;
  114505. /**
  114506. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  114507. */
  114508. attachableMeshes: Nullable<Array<AbstractMesh>>;
  114509. /**
  114510. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  114511. */
  114512. usePointerToAttachGizmos: boolean;
  114513. /**
  114514. * Utility layer that the bounding box gizmo belongs to
  114515. */
  114516. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  114517. /**
  114518. * Utility layer that all gizmos besides bounding box belong to
  114519. */
  114520. readonly utilityLayer: UtilityLayerRenderer;
  114521. /**
  114522. * Instatiates a gizmo manager
  114523. * @param scene the scene to overlay the gizmos on top of
  114524. */
  114525. constructor(scene: Scene);
  114526. /**
  114527. * Attaches a set of gizmos to the specified mesh
  114528. * @param mesh The mesh the gizmo's should be attached to
  114529. */
  114530. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114531. /**
  114532. * If the position gizmo is enabled
  114533. */
  114534. positionGizmoEnabled: boolean;
  114535. /**
  114536. * If the rotation gizmo is enabled
  114537. */
  114538. rotationGizmoEnabled: boolean;
  114539. /**
  114540. * If the scale gizmo is enabled
  114541. */
  114542. scaleGizmoEnabled: boolean;
  114543. /**
  114544. * If the boundingBox gizmo is enabled
  114545. */
  114546. boundingBoxGizmoEnabled: boolean;
  114547. /**
  114548. * Disposes of the gizmo manager
  114549. */
  114550. dispose(): void;
  114551. }
  114552. }
  114553. declare module BABYLON {
  114554. /**
  114555. * A directional light is defined by a direction (what a surprise!).
  114556. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  114557. * 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.
  114558. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114559. */
  114560. export class DirectionalLight extends ShadowLight {
  114561. private _shadowFrustumSize;
  114562. /**
  114563. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  114564. */
  114565. /**
  114566. * Specifies a fix frustum size for the shadow generation.
  114567. */
  114568. shadowFrustumSize: number;
  114569. private _shadowOrthoScale;
  114570. /**
  114571. * Gets the shadow projection scale against the optimal computed one.
  114572. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114573. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114574. */
  114575. /**
  114576. * Sets the shadow projection scale against the optimal computed one.
  114577. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  114578. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  114579. */
  114580. shadowOrthoScale: number;
  114581. /**
  114582. * Automatically compute the projection matrix to best fit (including all the casters)
  114583. * on each frame.
  114584. */
  114585. autoUpdateExtends: boolean;
  114586. private _orthoLeft;
  114587. private _orthoRight;
  114588. private _orthoTop;
  114589. private _orthoBottom;
  114590. /**
  114591. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  114592. * The directional light is emitted from everywhere in the given direction.
  114593. * It can cast shadows.
  114594. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114595. * @param name The friendly name of the light
  114596. * @param direction The direction of the light
  114597. * @param scene The scene the light belongs to
  114598. */
  114599. constructor(name: string, direction: Vector3, scene: Scene);
  114600. /**
  114601. * Returns the string "DirectionalLight".
  114602. * @return The class name
  114603. */
  114604. getClassName(): string;
  114605. /**
  114606. * Returns the integer 1.
  114607. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114608. */
  114609. getTypeID(): number;
  114610. /**
  114611. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  114612. * Returns the DirectionalLight Shadow projection matrix.
  114613. */
  114614. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114615. /**
  114616. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  114617. * Returns the DirectionalLight Shadow projection matrix.
  114618. */
  114619. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  114620. /**
  114621. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  114622. * Returns the DirectionalLight Shadow projection matrix.
  114623. */
  114624. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114625. protected _buildUniformLayout(): void;
  114626. /**
  114627. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  114628. * @param effect The effect to update
  114629. * @param lightIndex The index of the light in the effect to update
  114630. * @returns The directional light
  114631. */
  114632. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  114633. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  114634. /**
  114635. * Gets the minZ used for shadow according to both the scene and the light.
  114636. *
  114637. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114638. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114639. * @param activeCamera The camera we are returning the min for
  114640. * @returns the depth min z
  114641. */
  114642. getDepthMinZ(activeCamera: Camera): number;
  114643. /**
  114644. * Gets the maxZ used for shadow according to both the scene and the light.
  114645. *
  114646. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  114647. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  114648. * @param activeCamera The camera we are returning the max for
  114649. * @returns the depth max z
  114650. */
  114651. getDepthMaxZ(activeCamera: Camera): number;
  114652. /**
  114653. * Prepares the list of defines specific to the light type.
  114654. * @param defines the list of defines
  114655. * @param lightIndex defines the index of the light for the effect
  114656. */
  114657. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114658. }
  114659. }
  114660. declare module BABYLON {
  114661. /**
  114662. * Class containing static functions to help procedurally build meshes
  114663. */
  114664. export class HemisphereBuilder {
  114665. /**
  114666. * Creates a hemisphere mesh
  114667. * @param name defines the name of the mesh
  114668. * @param options defines the options used to create the mesh
  114669. * @param scene defines the hosting scene
  114670. * @returns the hemisphere mesh
  114671. */
  114672. static CreateHemisphere(name: string, options: {
  114673. segments?: number;
  114674. diameter?: number;
  114675. sideOrientation?: number;
  114676. }, scene: any): Mesh;
  114677. }
  114678. }
  114679. declare module BABYLON {
  114680. /**
  114681. * A spot light is defined by a position, a direction, an angle, and an exponent.
  114682. * These values define a cone of light starting from the position, emitting toward the direction.
  114683. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  114684. * and the exponent defines the speed of the decay of the light with distance (reach).
  114685. * Documentation: https://doc.babylonjs.com/babylon101/lights
  114686. */
  114687. export class SpotLight extends ShadowLight {
  114688. private _angle;
  114689. private _innerAngle;
  114690. private _cosHalfAngle;
  114691. private _lightAngleScale;
  114692. private _lightAngleOffset;
  114693. /**
  114694. * Gets the cone angle of the spot light in Radians.
  114695. */
  114696. /**
  114697. * Sets the cone angle of the spot light in Radians.
  114698. */
  114699. angle: number;
  114700. /**
  114701. * Only used in gltf falloff mode, this defines the angle where
  114702. * the directional falloff will start before cutting at angle which could be seen
  114703. * as outer angle.
  114704. */
  114705. /**
  114706. * Only used in gltf falloff mode, this defines the angle where
  114707. * the directional falloff will start before cutting at angle which could be seen
  114708. * as outer angle.
  114709. */
  114710. innerAngle: number;
  114711. private _shadowAngleScale;
  114712. /**
  114713. * Allows scaling the angle of the light for shadow generation only.
  114714. */
  114715. /**
  114716. * Allows scaling the angle of the light for shadow generation only.
  114717. */
  114718. shadowAngleScale: number;
  114719. /**
  114720. * The light decay speed with the distance from the emission spot.
  114721. */
  114722. exponent: number;
  114723. private _projectionTextureMatrix;
  114724. /**
  114725. * Allows reading the projecton texture
  114726. */
  114727. readonly projectionTextureMatrix: Matrix;
  114728. protected _projectionTextureLightNear: number;
  114729. /**
  114730. * Gets the near clip of the Spotlight for texture projection.
  114731. */
  114732. /**
  114733. * Sets the near clip of the Spotlight for texture projection.
  114734. */
  114735. projectionTextureLightNear: number;
  114736. protected _projectionTextureLightFar: number;
  114737. /**
  114738. * Gets the far clip of the Spotlight for texture projection.
  114739. */
  114740. /**
  114741. * Sets the far clip of the Spotlight for texture projection.
  114742. */
  114743. projectionTextureLightFar: number;
  114744. protected _projectionTextureUpDirection: Vector3;
  114745. /**
  114746. * Gets the Up vector of the Spotlight for texture projection.
  114747. */
  114748. /**
  114749. * Sets the Up vector of the Spotlight for texture projection.
  114750. */
  114751. projectionTextureUpDirection: Vector3;
  114752. private _projectionTexture;
  114753. /**
  114754. * Gets the projection texture of the light.
  114755. */
  114756. /**
  114757. * Sets the projection texture of the light.
  114758. */
  114759. projectionTexture: Nullable<BaseTexture>;
  114760. private _projectionTextureViewLightDirty;
  114761. private _projectionTextureProjectionLightDirty;
  114762. private _projectionTextureDirty;
  114763. private _projectionTextureViewTargetVector;
  114764. private _projectionTextureViewLightMatrix;
  114765. private _projectionTextureProjectionLightMatrix;
  114766. private _projectionTextureScalingMatrix;
  114767. /**
  114768. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  114769. * It can cast shadows.
  114770. * Documentation : https://doc.babylonjs.com/babylon101/lights
  114771. * @param name The light friendly name
  114772. * @param position The position of the spot light in the scene
  114773. * @param direction The direction of the light in the scene
  114774. * @param angle The cone angle of the light in Radians
  114775. * @param exponent The light decay speed with the distance from the emission spot
  114776. * @param scene The scene the lights belongs to
  114777. */
  114778. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  114779. /**
  114780. * Returns the string "SpotLight".
  114781. * @returns the class name
  114782. */
  114783. getClassName(): string;
  114784. /**
  114785. * Returns the integer 2.
  114786. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  114787. */
  114788. getTypeID(): number;
  114789. /**
  114790. * Overrides the direction setter to recompute the projection texture view light Matrix.
  114791. */
  114792. protected _setDirection(value: Vector3): void;
  114793. /**
  114794. * Overrides the position setter to recompute the projection texture view light Matrix.
  114795. */
  114796. protected _setPosition(value: Vector3): void;
  114797. /**
  114798. * 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.
  114799. * Returns the SpotLight.
  114800. */
  114801. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  114802. protected _computeProjectionTextureViewLightMatrix(): void;
  114803. protected _computeProjectionTextureProjectionLightMatrix(): void;
  114804. /**
  114805. * Main function for light texture projection matrix computing.
  114806. */
  114807. protected _computeProjectionTextureMatrix(): void;
  114808. protected _buildUniformLayout(): void;
  114809. private _computeAngleValues;
  114810. /**
  114811. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  114812. * @param effect The effect to update
  114813. * @param lightIndex The index of the light in the effect to update
  114814. * @returns The spot light
  114815. */
  114816. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  114817. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  114818. /**
  114819. * Disposes the light and the associated resources.
  114820. */
  114821. dispose(): void;
  114822. /**
  114823. * Prepares the list of defines specific to the light type.
  114824. * @param defines the list of defines
  114825. * @param lightIndex defines the index of the light for the effect
  114826. */
  114827. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  114828. }
  114829. }
  114830. declare module BABYLON {
  114831. /**
  114832. * Gizmo that enables viewing a light
  114833. */
  114834. export class LightGizmo extends Gizmo {
  114835. private _lightMesh;
  114836. private _material;
  114837. private _cachedPosition;
  114838. private _cachedForward;
  114839. private _attachedMeshParent;
  114840. /**
  114841. * Creates a LightGizmo
  114842. * @param gizmoLayer The utility layer the gizmo will be added to
  114843. */
  114844. constructor(gizmoLayer?: UtilityLayerRenderer);
  114845. private _light;
  114846. /**
  114847. * The light that the gizmo is attached to
  114848. */
  114849. light: Nullable<Light>;
  114850. /**
  114851. * Gets the material used to render the light gizmo
  114852. */
  114853. readonly material: StandardMaterial;
  114854. /**
  114855. * @hidden
  114856. * Updates the gizmo to match the attached mesh's position/rotation
  114857. */
  114858. protected _update(): void;
  114859. private static _Scale;
  114860. /**
  114861. * Creates the lines for a light mesh
  114862. */
  114863. private static _CreateLightLines;
  114864. /**
  114865. * Disposes of the light gizmo
  114866. */
  114867. dispose(): void;
  114868. private static _CreateHemisphericLightMesh;
  114869. private static _CreatePointLightMesh;
  114870. private static _CreateSpotLightMesh;
  114871. private static _CreateDirectionalLightMesh;
  114872. }
  114873. }
  114874. declare module BABYLON {
  114875. /** @hidden */
  114876. export var backgroundFragmentDeclaration: {
  114877. name: string;
  114878. shader: string;
  114879. };
  114880. }
  114881. declare module BABYLON {
  114882. /** @hidden */
  114883. export var backgroundUboDeclaration: {
  114884. name: string;
  114885. shader: string;
  114886. };
  114887. }
  114888. declare module BABYLON {
  114889. /** @hidden */
  114890. export var backgroundPixelShader: {
  114891. name: string;
  114892. shader: string;
  114893. };
  114894. }
  114895. declare module BABYLON {
  114896. /** @hidden */
  114897. export var backgroundVertexDeclaration: {
  114898. name: string;
  114899. shader: string;
  114900. };
  114901. }
  114902. declare module BABYLON {
  114903. /** @hidden */
  114904. export var backgroundVertexShader: {
  114905. name: string;
  114906. shader: string;
  114907. };
  114908. }
  114909. declare module BABYLON {
  114910. /**
  114911. * Background material used to create an efficient environement around your scene.
  114912. */
  114913. export class BackgroundMaterial extends PushMaterial {
  114914. /**
  114915. * Standard reflectance value at parallel view angle.
  114916. */
  114917. static StandardReflectance0: number;
  114918. /**
  114919. * Standard reflectance value at grazing angle.
  114920. */
  114921. static StandardReflectance90: number;
  114922. protected _primaryColor: Color3;
  114923. /**
  114924. * Key light Color (multiply against the environement texture)
  114925. */
  114926. primaryColor: Color3;
  114927. protected __perceptualColor: Nullable<Color3>;
  114928. /**
  114929. * Experimental Internal Use Only.
  114930. *
  114931. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  114932. * This acts as a helper to set the primary color to a more "human friendly" value.
  114933. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  114934. * output color as close as possible from the chosen value.
  114935. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  114936. * part of lighting setup.)
  114937. */
  114938. _perceptualColor: Nullable<Color3>;
  114939. protected _primaryColorShadowLevel: float;
  114940. /**
  114941. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  114942. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  114943. */
  114944. primaryColorShadowLevel: float;
  114945. protected _primaryColorHighlightLevel: float;
  114946. /**
  114947. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  114948. * The primary color is used at the level chosen to define what the white area would look.
  114949. */
  114950. primaryColorHighlightLevel: float;
  114951. protected _reflectionTexture: Nullable<BaseTexture>;
  114952. /**
  114953. * Reflection Texture used in the material.
  114954. * Should be author in a specific way for the best result (refer to the documentation).
  114955. */
  114956. reflectionTexture: Nullable<BaseTexture>;
  114957. protected _reflectionBlur: float;
  114958. /**
  114959. * Reflection Texture level of blur.
  114960. *
  114961. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  114962. * texture twice.
  114963. */
  114964. reflectionBlur: float;
  114965. protected _diffuseTexture: Nullable<BaseTexture>;
  114966. /**
  114967. * Diffuse Texture used in the material.
  114968. * Should be author in a specific way for the best result (refer to the documentation).
  114969. */
  114970. diffuseTexture: Nullable<BaseTexture>;
  114971. protected _shadowLights: Nullable<IShadowLight[]>;
  114972. /**
  114973. * Specify the list of lights casting shadow on the material.
  114974. * All scene shadow lights will be included if null.
  114975. */
  114976. shadowLights: Nullable<IShadowLight[]>;
  114977. protected _shadowLevel: float;
  114978. /**
  114979. * Helps adjusting the shadow to a softer level if required.
  114980. * 0 means black shadows and 1 means no shadows.
  114981. */
  114982. shadowLevel: float;
  114983. protected _sceneCenter: Vector3;
  114984. /**
  114985. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  114986. * It is usually zero but might be interesting to modify according to your setup.
  114987. */
  114988. sceneCenter: Vector3;
  114989. protected _opacityFresnel: boolean;
  114990. /**
  114991. * This helps specifying that the material is falling off to the sky box at grazing angle.
  114992. * This helps ensuring a nice transition when the camera goes under the ground.
  114993. */
  114994. opacityFresnel: boolean;
  114995. protected _reflectionFresnel: boolean;
  114996. /**
  114997. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  114998. * This helps adding a mirror texture on the ground.
  114999. */
  115000. reflectionFresnel: boolean;
  115001. protected _reflectionFalloffDistance: number;
  115002. /**
  115003. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  115004. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  115005. */
  115006. reflectionFalloffDistance: number;
  115007. protected _reflectionAmount: number;
  115008. /**
  115009. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  115010. */
  115011. reflectionAmount: number;
  115012. protected _reflectionReflectance0: number;
  115013. /**
  115014. * This specifies the weight of the reflection at grazing angle.
  115015. */
  115016. reflectionReflectance0: number;
  115017. protected _reflectionReflectance90: number;
  115018. /**
  115019. * This specifies the weight of the reflection at a perpendicular point of view.
  115020. */
  115021. reflectionReflectance90: number;
  115022. /**
  115023. * Sets the reflection reflectance fresnel values according to the default standard
  115024. * empirically know to work well :-)
  115025. */
  115026. reflectionStandardFresnelWeight: number;
  115027. protected _useRGBColor: boolean;
  115028. /**
  115029. * Helps to directly use the maps channels instead of their level.
  115030. */
  115031. useRGBColor: boolean;
  115032. protected _enableNoise: boolean;
  115033. /**
  115034. * This helps reducing the banding effect that could occur on the background.
  115035. */
  115036. enableNoise: boolean;
  115037. /**
  115038. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115039. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  115040. * Recommended to be keep at 1.0 except for special cases.
  115041. */
  115042. fovMultiplier: number;
  115043. private _fovMultiplier;
  115044. /**
  115045. * Enable the FOV adjustment feature controlled by fovMultiplier.
  115046. */
  115047. useEquirectangularFOV: boolean;
  115048. private _maxSimultaneousLights;
  115049. /**
  115050. * Number of Simultaneous lights allowed on the material.
  115051. */
  115052. maxSimultaneousLights: int;
  115053. /**
  115054. * Default configuration related to image processing available in the Background Material.
  115055. */
  115056. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115057. /**
  115058. * Keep track of the image processing observer to allow dispose and replace.
  115059. */
  115060. private _imageProcessingObserver;
  115061. /**
  115062. * Attaches a new image processing configuration to the PBR Material.
  115063. * @param configuration (if null the scene configuration will be use)
  115064. */
  115065. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115066. /**
  115067. * Gets the image processing configuration used either in this material.
  115068. */
  115069. /**
  115070. * Sets the Default image processing configuration used either in the this material.
  115071. *
  115072. * If sets to null, the scene one is in use.
  115073. */
  115074. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  115075. /**
  115076. * Gets wether the color curves effect is enabled.
  115077. */
  115078. /**
  115079. * Sets wether the color curves effect is enabled.
  115080. */
  115081. cameraColorCurvesEnabled: boolean;
  115082. /**
  115083. * Gets wether the color grading effect is enabled.
  115084. */
  115085. /**
  115086. * Gets wether the color grading effect is enabled.
  115087. */
  115088. cameraColorGradingEnabled: boolean;
  115089. /**
  115090. * Gets wether tonemapping is enabled or not.
  115091. */
  115092. /**
  115093. * Sets wether tonemapping is enabled or not
  115094. */
  115095. cameraToneMappingEnabled: boolean;
  115096. /**
  115097. * The camera exposure used on this material.
  115098. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115099. * This corresponds to a photographic exposure.
  115100. */
  115101. /**
  115102. * The camera exposure used on this material.
  115103. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115104. * This corresponds to a photographic exposure.
  115105. */
  115106. cameraExposure: float;
  115107. /**
  115108. * Gets The camera contrast used on this material.
  115109. */
  115110. /**
  115111. * Sets The camera contrast used on this material.
  115112. */
  115113. cameraContrast: float;
  115114. /**
  115115. * Gets the Color Grading 2D Lookup Texture.
  115116. */
  115117. /**
  115118. * Sets the Color Grading 2D Lookup Texture.
  115119. */
  115120. cameraColorGradingTexture: Nullable<BaseTexture>;
  115121. /**
  115122. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115123. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115124. * 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;
  115125. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115126. */
  115127. /**
  115128. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115129. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115130. * 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;
  115131. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115132. */
  115133. cameraColorCurves: Nullable<ColorCurves>;
  115134. /**
  115135. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  115136. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  115137. */
  115138. switchToBGR: boolean;
  115139. private _renderTargets;
  115140. private _reflectionControls;
  115141. private _white;
  115142. private _primaryShadowColor;
  115143. private _primaryHighlightColor;
  115144. /**
  115145. * Instantiates a Background Material in the given scene
  115146. * @param name The friendly name of the material
  115147. * @param scene The scene to add the material to
  115148. */
  115149. constructor(name: string, scene: Scene);
  115150. /**
  115151. * Gets a boolean indicating that current material needs to register RTT
  115152. */
  115153. readonly hasRenderTargetTextures: boolean;
  115154. /**
  115155. * The entire material has been created in order to prevent overdraw.
  115156. * @returns false
  115157. */
  115158. needAlphaTesting(): boolean;
  115159. /**
  115160. * The entire material has been created in order to prevent overdraw.
  115161. * @returns true if blending is enable
  115162. */
  115163. needAlphaBlending(): boolean;
  115164. /**
  115165. * Checks wether the material is ready to be rendered for a given mesh.
  115166. * @param mesh The mesh to render
  115167. * @param subMesh The submesh to check against
  115168. * @param useInstances Specify wether or not the material is used with instances
  115169. * @returns true if all the dependencies are ready (Textures, Effects...)
  115170. */
  115171. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115172. /**
  115173. * Compute the primary color according to the chosen perceptual color.
  115174. */
  115175. private _computePrimaryColorFromPerceptualColor;
  115176. /**
  115177. * Compute the highlights and shadow colors according to their chosen levels.
  115178. */
  115179. private _computePrimaryColors;
  115180. /**
  115181. * Build the uniform buffer used in the material.
  115182. */
  115183. buildUniformLayout(): void;
  115184. /**
  115185. * Unbind the material.
  115186. */
  115187. unbind(): void;
  115188. /**
  115189. * Bind only the world matrix to the material.
  115190. * @param world The world matrix to bind.
  115191. */
  115192. bindOnlyWorldMatrix(world: Matrix): void;
  115193. /**
  115194. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  115195. * @param world The world matrix to bind.
  115196. * @param subMesh The submesh to bind for.
  115197. */
  115198. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115199. /**
  115200. * Checks to see if a texture is used in the material.
  115201. * @param texture - Base texture to use.
  115202. * @returns - Boolean specifying if a texture is used in the material.
  115203. */
  115204. hasTexture(texture: BaseTexture): boolean;
  115205. /**
  115206. * Dispose the material.
  115207. * @param forceDisposeEffect Force disposal of the associated effect.
  115208. * @param forceDisposeTextures Force disposal of the associated textures.
  115209. */
  115210. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  115211. /**
  115212. * Clones the material.
  115213. * @param name The cloned name.
  115214. * @returns The cloned material.
  115215. */
  115216. clone(name: string): BackgroundMaterial;
  115217. /**
  115218. * Serializes the current material to its JSON representation.
  115219. * @returns The JSON representation.
  115220. */
  115221. serialize(): any;
  115222. /**
  115223. * Gets the class name of the material
  115224. * @returns "BackgroundMaterial"
  115225. */
  115226. getClassName(): string;
  115227. /**
  115228. * Parse a JSON input to create back a background material.
  115229. * @param source The JSON data to parse
  115230. * @param scene The scene to create the parsed material in
  115231. * @param rootUrl The root url of the assets the material depends upon
  115232. * @returns the instantiated BackgroundMaterial.
  115233. */
  115234. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  115235. }
  115236. }
  115237. declare module BABYLON {
  115238. /**
  115239. * Represents the different options available during the creation of
  115240. * a Environment helper.
  115241. *
  115242. * This can control the default ground, skybox and image processing setup of your scene.
  115243. */
  115244. export interface IEnvironmentHelperOptions {
  115245. /**
  115246. * Specifies wether or not to create a ground.
  115247. * True by default.
  115248. */
  115249. createGround: boolean;
  115250. /**
  115251. * Specifies the ground size.
  115252. * 15 by default.
  115253. */
  115254. groundSize: number;
  115255. /**
  115256. * The texture used on the ground for the main color.
  115257. * Comes from the BabylonJS CDN by default.
  115258. *
  115259. * Remarks: Can be either a texture or a url.
  115260. */
  115261. groundTexture: string | BaseTexture;
  115262. /**
  115263. * The color mixed in the ground texture by default.
  115264. * BabylonJS clearColor by default.
  115265. */
  115266. groundColor: Color3;
  115267. /**
  115268. * Specifies the ground opacity.
  115269. * 1 by default.
  115270. */
  115271. groundOpacity: number;
  115272. /**
  115273. * Enables the ground to receive shadows.
  115274. * True by default.
  115275. */
  115276. enableGroundShadow: boolean;
  115277. /**
  115278. * Helps preventing the shadow to be fully black on the ground.
  115279. * 0.5 by default.
  115280. */
  115281. groundShadowLevel: number;
  115282. /**
  115283. * Creates a mirror texture attach to the ground.
  115284. * false by default.
  115285. */
  115286. enableGroundMirror: boolean;
  115287. /**
  115288. * Specifies the ground mirror size ratio.
  115289. * 0.3 by default as the default kernel is 64.
  115290. */
  115291. groundMirrorSizeRatio: number;
  115292. /**
  115293. * Specifies the ground mirror blur kernel size.
  115294. * 64 by default.
  115295. */
  115296. groundMirrorBlurKernel: number;
  115297. /**
  115298. * Specifies the ground mirror visibility amount.
  115299. * 1 by default
  115300. */
  115301. groundMirrorAmount: number;
  115302. /**
  115303. * Specifies the ground mirror reflectance weight.
  115304. * This uses the standard weight of the background material to setup the fresnel effect
  115305. * of the mirror.
  115306. * 1 by default.
  115307. */
  115308. groundMirrorFresnelWeight: number;
  115309. /**
  115310. * Specifies the ground mirror Falloff distance.
  115311. * This can helps reducing the size of the reflection.
  115312. * 0 by Default.
  115313. */
  115314. groundMirrorFallOffDistance: number;
  115315. /**
  115316. * Specifies the ground mirror texture type.
  115317. * Unsigned Int by Default.
  115318. */
  115319. groundMirrorTextureType: number;
  115320. /**
  115321. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  115322. * the shown objects.
  115323. */
  115324. groundYBias: number;
  115325. /**
  115326. * Specifies wether or not to create a skybox.
  115327. * True by default.
  115328. */
  115329. createSkybox: boolean;
  115330. /**
  115331. * Specifies the skybox size.
  115332. * 20 by default.
  115333. */
  115334. skyboxSize: number;
  115335. /**
  115336. * The texture used on the skybox for the main color.
  115337. * Comes from the BabylonJS CDN by default.
  115338. *
  115339. * Remarks: Can be either a texture or a url.
  115340. */
  115341. skyboxTexture: string | BaseTexture;
  115342. /**
  115343. * The color mixed in the skybox texture by default.
  115344. * BabylonJS clearColor by default.
  115345. */
  115346. skyboxColor: Color3;
  115347. /**
  115348. * The background rotation around the Y axis of the scene.
  115349. * This helps aligning the key lights of your scene with the background.
  115350. * 0 by default.
  115351. */
  115352. backgroundYRotation: number;
  115353. /**
  115354. * Compute automatically the size of the elements to best fit with the scene.
  115355. */
  115356. sizeAuto: boolean;
  115357. /**
  115358. * Default position of the rootMesh if autoSize is not true.
  115359. */
  115360. rootPosition: Vector3;
  115361. /**
  115362. * Sets up the image processing in the scene.
  115363. * true by default.
  115364. */
  115365. setupImageProcessing: boolean;
  115366. /**
  115367. * The texture used as your environment texture in the scene.
  115368. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  115369. *
  115370. * Remarks: Can be either a texture or a url.
  115371. */
  115372. environmentTexture: string | BaseTexture;
  115373. /**
  115374. * The value of the exposure to apply to the scene.
  115375. * 0.6 by default if setupImageProcessing is true.
  115376. */
  115377. cameraExposure: number;
  115378. /**
  115379. * The value of the contrast to apply to the scene.
  115380. * 1.6 by default if setupImageProcessing is true.
  115381. */
  115382. cameraContrast: number;
  115383. /**
  115384. * Specifies wether or not tonemapping should be enabled in the scene.
  115385. * true by default if setupImageProcessing is true.
  115386. */
  115387. toneMappingEnabled: boolean;
  115388. }
  115389. /**
  115390. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  115391. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  115392. * It also helps with the default setup of your imageProcessing configuration.
  115393. */
  115394. export class EnvironmentHelper {
  115395. /**
  115396. * Default ground texture URL.
  115397. */
  115398. private static _groundTextureCDNUrl;
  115399. /**
  115400. * Default skybox texture URL.
  115401. */
  115402. private static _skyboxTextureCDNUrl;
  115403. /**
  115404. * Default environment texture URL.
  115405. */
  115406. private static _environmentTextureCDNUrl;
  115407. /**
  115408. * Creates the default options for the helper.
  115409. */
  115410. private static _getDefaultOptions;
  115411. private _rootMesh;
  115412. /**
  115413. * Gets the root mesh created by the helper.
  115414. */
  115415. readonly rootMesh: Mesh;
  115416. private _skybox;
  115417. /**
  115418. * Gets the skybox created by the helper.
  115419. */
  115420. readonly skybox: Nullable<Mesh>;
  115421. private _skyboxTexture;
  115422. /**
  115423. * Gets the skybox texture created by the helper.
  115424. */
  115425. readonly skyboxTexture: Nullable<BaseTexture>;
  115426. private _skyboxMaterial;
  115427. /**
  115428. * Gets the skybox material created by the helper.
  115429. */
  115430. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  115431. private _ground;
  115432. /**
  115433. * Gets the ground mesh created by the helper.
  115434. */
  115435. readonly ground: Nullable<Mesh>;
  115436. private _groundTexture;
  115437. /**
  115438. * Gets the ground texture created by the helper.
  115439. */
  115440. readonly groundTexture: Nullable<BaseTexture>;
  115441. private _groundMirror;
  115442. /**
  115443. * Gets the ground mirror created by the helper.
  115444. */
  115445. readonly groundMirror: Nullable<MirrorTexture>;
  115446. /**
  115447. * Gets the ground mirror render list to helps pushing the meshes
  115448. * you wish in the ground reflection.
  115449. */
  115450. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  115451. private _groundMaterial;
  115452. /**
  115453. * Gets the ground material created by the helper.
  115454. */
  115455. readonly groundMaterial: Nullable<BackgroundMaterial>;
  115456. /**
  115457. * Stores the creation options.
  115458. */
  115459. private readonly _scene;
  115460. private _options;
  115461. /**
  115462. * This observable will be notified with any error during the creation of the environment,
  115463. * mainly texture creation errors.
  115464. */
  115465. onErrorObservable: Observable<{
  115466. message?: string;
  115467. exception?: any;
  115468. }>;
  115469. /**
  115470. * constructor
  115471. * @param options Defines the options we want to customize the helper
  115472. * @param scene The scene to add the material to
  115473. */
  115474. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  115475. /**
  115476. * Updates the background according to the new options
  115477. * @param options
  115478. */
  115479. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  115480. /**
  115481. * Sets the primary color of all the available elements.
  115482. * @param color the main color to affect to the ground and the background
  115483. */
  115484. setMainColor(color: Color3): void;
  115485. /**
  115486. * Setup the image processing according to the specified options.
  115487. */
  115488. private _setupImageProcessing;
  115489. /**
  115490. * Setup the environment texture according to the specified options.
  115491. */
  115492. private _setupEnvironmentTexture;
  115493. /**
  115494. * Setup the background according to the specified options.
  115495. */
  115496. private _setupBackground;
  115497. /**
  115498. * Get the scene sizes according to the setup.
  115499. */
  115500. private _getSceneSize;
  115501. /**
  115502. * Setup the ground according to the specified options.
  115503. */
  115504. private _setupGround;
  115505. /**
  115506. * Setup the ground material according to the specified options.
  115507. */
  115508. private _setupGroundMaterial;
  115509. /**
  115510. * Setup the ground diffuse texture according to the specified options.
  115511. */
  115512. private _setupGroundDiffuseTexture;
  115513. /**
  115514. * Setup the ground mirror texture according to the specified options.
  115515. */
  115516. private _setupGroundMirrorTexture;
  115517. /**
  115518. * Setup the ground to receive the mirror texture.
  115519. */
  115520. private _setupMirrorInGroundMaterial;
  115521. /**
  115522. * Setup the skybox according to the specified options.
  115523. */
  115524. private _setupSkybox;
  115525. /**
  115526. * Setup the skybox material according to the specified options.
  115527. */
  115528. private _setupSkyboxMaterial;
  115529. /**
  115530. * Setup the skybox reflection texture according to the specified options.
  115531. */
  115532. private _setupSkyboxReflectionTexture;
  115533. private _errorHandler;
  115534. /**
  115535. * Dispose all the elements created by the Helper.
  115536. */
  115537. dispose(): void;
  115538. }
  115539. }
  115540. declare module BABYLON {
  115541. /**
  115542. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  115543. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  115544. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  115545. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115546. */
  115547. export class PhotoDome extends TransformNode {
  115548. /**
  115549. * Define the image as a Monoscopic panoramic 360 image.
  115550. */
  115551. static readonly MODE_MONOSCOPIC: number;
  115552. /**
  115553. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115554. */
  115555. static readonly MODE_TOPBOTTOM: number;
  115556. /**
  115557. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115558. */
  115559. static readonly MODE_SIDEBYSIDE: number;
  115560. private _useDirectMapping;
  115561. /**
  115562. * The texture being displayed on the sphere
  115563. */
  115564. protected _photoTexture: Texture;
  115565. /**
  115566. * Gets or sets the texture being displayed on the sphere
  115567. */
  115568. photoTexture: Texture;
  115569. /**
  115570. * Observable raised when an error occured while loading the 360 image
  115571. */
  115572. onLoadErrorObservable: Observable<string>;
  115573. /**
  115574. * The skybox material
  115575. */
  115576. protected _material: BackgroundMaterial;
  115577. /**
  115578. * The surface used for the skybox
  115579. */
  115580. protected _mesh: Mesh;
  115581. /**
  115582. * Gets the mesh used for the skybox.
  115583. */
  115584. readonly mesh: Mesh;
  115585. /**
  115586. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115587. * Also see the options.resolution property.
  115588. */
  115589. fovMultiplier: number;
  115590. private _imageMode;
  115591. /**
  115592. * Gets or set the current video mode for the video. It can be:
  115593. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  115594. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  115595. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  115596. */
  115597. imageMode: number;
  115598. /**
  115599. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  115600. * @param name Element's name, child elements will append suffixes for their own names.
  115601. * @param urlsOfPhoto defines the url of the photo to display
  115602. * @param options defines an object containing optional or exposed sub element properties
  115603. * @param onError defines a callback called when an error occured while loading the texture
  115604. */
  115605. constructor(name: string, urlOfPhoto: string, options: {
  115606. resolution?: number;
  115607. size?: number;
  115608. useDirectMapping?: boolean;
  115609. faceForward?: boolean;
  115610. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  115611. private _onBeforeCameraRenderObserver;
  115612. private _changeImageMode;
  115613. /**
  115614. * Releases resources associated with this node.
  115615. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115616. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115617. */
  115618. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115619. }
  115620. }
  115621. declare module BABYLON {
  115622. /**
  115623. * Class used to host RGBD texture specific utilities
  115624. */
  115625. export class RGBDTextureTools {
  115626. /**
  115627. * Expand the RGBD Texture from RGBD to Half Float if possible.
  115628. * @param texture the texture to expand.
  115629. */
  115630. static ExpandRGBDTexture(texture: Texture): void;
  115631. }
  115632. }
  115633. declare module BABYLON {
  115634. /**
  115635. * Class used to host texture specific utilities
  115636. */
  115637. export class BRDFTextureTools {
  115638. /**
  115639. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  115640. * @param scene defines the hosting scene
  115641. * @returns the environment BRDF texture
  115642. */
  115643. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  115644. private static _environmentBRDFBase64Texture;
  115645. }
  115646. }
  115647. declare module BABYLON {
  115648. /**
  115649. * @hidden
  115650. */
  115651. export interface IMaterialClearCoatDefines {
  115652. CLEARCOAT: boolean;
  115653. CLEARCOAT_DEFAULTIOR: boolean;
  115654. CLEARCOAT_TEXTURE: boolean;
  115655. CLEARCOAT_TEXTUREDIRECTUV: number;
  115656. CLEARCOAT_BUMP: boolean;
  115657. CLEARCOAT_BUMPDIRECTUV: number;
  115658. CLEARCOAT_TINT: boolean;
  115659. CLEARCOAT_TINT_TEXTURE: boolean;
  115660. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  115661. /** @hidden */
  115662. _areTexturesDirty: boolean;
  115663. }
  115664. /**
  115665. * Define the code related to the clear coat parameters of the pbr material.
  115666. */
  115667. export class PBRClearCoatConfiguration {
  115668. /**
  115669. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115670. * The default fits with a polyurethane material.
  115671. */
  115672. private static readonly _DefaultIndexOfRefraction;
  115673. private _isEnabled;
  115674. /**
  115675. * Defines if the clear coat is enabled in the material.
  115676. */
  115677. isEnabled: boolean;
  115678. /**
  115679. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  115680. */
  115681. intensity: number;
  115682. /**
  115683. * Defines the clear coat layer roughness.
  115684. */
  115685. roughness: number;
  115686. private _indexOfRefraction;
  115687. /**
  115688. * Defines the index of refraction of the clear coat.
  115689. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  115690. * The default fits with a polyurethane material.
  115691. * Changing the default value is more performance intensive.
  115692. */
  115693. indexOfRefraction: number;
  115694. private _texture;
  115695. /**
  115696. * Stores the clear coat values in a texture.
  115697. */
  115698. texture: Nullable<BaseTexture>;
  115699. private _bumpTexture;
  115700. /**
  115701. * Define the clear coat specific bump texture.
  115702. */
  115703. bumpTexture: Nullable<BaseTexture>;
  115704. private _isTintEnabled;
  115705. /**
  115706. * Defines if the clear coat tint is enabled in the material.
  115707. */
  115708. isTintEnabled: boolean;
  115709. /**
  115710. * Defines the clear coat tint of the material.
  115711. * This is only use if tint is enabled
  115712. */
  115713. tintColor: Color3;
  115714. /**
  115715. * Defines the distance at which the tint color should be found in the
  115716. * clear coat media.
  115717. * This is only use if tint is enabled
  115718. */
  115719. tintColorAtDistance: number;
  115720. /**
  115721. * Defines the clear coat layer thickness.
  115722. * This is only use if tint is enabled
  115723. */
  115724. tintThickness: number;
  115725. private _tintTexture;
  115726. /**
  115727. * Stores the clear tint values in a texture.
  115728. * rgb is tint
  115729. * a is a thickness factor
  115730. */
  115731. tintTexture: Nullable<BaseTexture>;
  115732. /** @hidden */
  115733. private _internalMarkAllSubMeshesAsTexturesDirty;
  115734. /** @hidden */
  115735. _markAllSubMeshesAsTexturesDirty(): void;
  115736. /**
  115737. * Instantiate a new istance of clear coat configuration.
  115738. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115739. */
  115740. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115741. /**
  115742. * Gets wehter the submesh is ready to be used or not.
  115743. * @param defines the list of "defines" to update.
  115744. * @param scene defines the scene the material belongs to.
  115745. * @param engine defines the engine the material belongs to.
  115746. * @param disableBumpMap defines wether the material disables bump or not.
  115747. * @returns - boolean indicating that the submesh is ready or not.
  115748. */
  115749. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  115750. /**
  115751. * Checks to see if a texture is used in the material.
  115752. * @param defines the list of "defines" to update.
  115753. * @param scene defines the scene to the material belongs to.
  115754. */
  115755. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  115756. /**
  115757. * Binds the material data.
  115758. * @param uniformBuffer defines the Uniform buffer to fill in.
  115759. * @param scene defines the scene the material belongs to.
  115760. * @param engine defines the engine the material belongs to.
  115761. * @param disableBumpMap defines wether the material disables bump or not.
  115762. * @param isFrozen defines wether the material is frozen or not.
  115763. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  115764. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  115765. */
  115766. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  115767. /**
  115768. * Checks to see if a texture is used in the material.
  115769. * @param texture - Base texture to use.
  115770. * @returns - Boolean specifying if a texture is used in the material.
  115771. */
  115772. hasTexture(texture: BaseTexture): boolean;
  115773. /**
  115774. * Returns an array of the actively used textures.
  115775. * @param activeTextures Array of BaseTextures
  115776. */
  115777. getActiveTextures(activeTextures: BaseTexture[]): void;
  115778. /**
  115779. * Returns the animatable textures.
  115780. * @param animatables Array of animatable textures.
  115781. */
  115782. getAnimatables(animatables: IAnimatable[]): void;
  115783. /**
  115784. * Disposes the resources of the material.
  115785. * @param forceDisposeTextures - Forces the disposal of all textures.
  115786. */
  115787. dispose(forceDisposeTextures?: boolean): void;
  115788. /**
  115789. * Get the current class name of the texture useful for serialization or dynamic coding.
  115790. * @returns "PBRClearCoatConfiguration"
  115791. */
  115792. getClassName(): string;
  115793. /**
  115794. * Add fallbacks to the effect fallbacks list.
  115795. * @param defines defines the Base texture to use.
  115796. * @param fallbacks defines the current fallback list.
  115797. * @param currentRank defines the current fallback rank.
  115798. * @returns the new fallback rank.
  115799. */
  115800. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115801. /**
  115802. * Add the required uniforms to the current list.
  115803. * @param uniforms defines the current uniform list.
  115804. */
  115805. static AddUniforms(uniforms: string[]): void;
  115806. /**
  115807. * Add the required samplers to the current list.
  115808. * @param samplers defines the current sampler list.
  115809. */
  115810. static AddSamplers(samplers: string[]): void;
  115811. /**
  115812. * Add the required uniforms to the current buffer.
  115813. * @param uniformBuffer defines the current uniform buffer.
  115814. */
  115815. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115816. /**
  115817. * Makes a duplicate of the current configuration into another one.
  115818. * @param clearCoatConfiguration define the config where to copy the info
  115819. */
  115820. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  115821. /**
  115822. * Serializes this clear coat configuration.
  115823. * @returns - An object with the serialized config.
  115824. */
  115825. serialize(): any;
  115826. /**
  115827. * Parses a anisotropy Configuration from a serialized object.
  115828. * @param source - Serialized object.
  115829. * @param scene Defines the scene we are parsing for
  115830. * @param rootUrl Defines the rootUrl to load from
  115831. */
  115832. parse(source: any, scene: Scene, rootUrl: string): void;
  115833. }
  115834. }
  115835. declare module BABYLON {
  115836. /**
  115837. * @hidden
  115838. */
  115839. export interface IMaterialAnisotropicDefines {
  115840. ANISOTROPIC: boolean;
  115841. ANISOTROPIC_TEXTURE: boolean;
  115842. ANISOTROPIC_TEXTUREDIRECTUV: number;
  115843. MAINUV1: boolean;
  115844. _areTexturesDirty: boolean;
  115845. _needUVs: boolean;
  115846. }
  115847. /**
  115848. * Define the code related to the anisotropic parameters of the pbr material.
  115849. */
  115850. export class PBRAnisotropicConfiguration {
  115851. private _isEnabled;
  115852. /**
  115853. * Defines if the anisotropy is enabled in the material.
  115854. */
  115855. isEnabled: boolean;
  115856. /**
  115857. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  115858. */
  115859. intensity: number;
  115860. /**
  115861. * Defines if the effect is along the tangents, bitangents or in between.
  115862. * By default, the effect is "strectching" the highlights along the tangents.
  115863. */
  115864. direction: Vector2;
  115865. private _texture;
  115866. /**
  115867. * Stores the anisotropy values in a texture.
  115868. * rg is direction (like normal from -1 to 1)
  115869. * b is a intensity
  115870. */
  115871. texture: Nullable<BaseTexture>;
  115872. /** @hidden */
  115873. private _internalMarkAllSubMeshesAsTexturesDirty;
  115874. /** @hidden */
  115875. _markAllSubMeshesAsTexturesDirty(): void;
  115876. /**
  115877. * Instantiate a new istance of anisotropy configuration.
  115878. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  115879. */
  115880. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  115881. /**
  115882. * Specifies that the submesh is ready to be used.
  115883. * @param defines the list of "defines" to update.
  115884. * @param scene defines the scene the material belongs to.
  115885. * @returns - boolean indicating that the submesh is ready or not.
  115886. */
  115887. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  115888. /**
  115889. * Checks to see if a texture is used in the material.
  115890. * @param defines the list of "defines" to update.
  115891. * @param mesh the mesh we are preparing the defines for.
  115892. * @param scene defines the scene the material belongs to.
  115893. */
  115894. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  115895. /**
  115896. * Binds the material data.
  115897. * @param uniformBuffer defines the Uniform buffer to fill in.
  115898. * @param scene defines the scene the material belongs to.
  115899. * @param isFrozen defines wether the material is frozen or not.
  115900. */
  115901. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  115902. /**
  115903. * Checks to see if a texture is used in the material.
  115904. * @param texture - Base texture to use.
  115905. * @returns - Boolean specifying if a texture is used in the material.
  115906. */
  115907. hasTexture(texture: BaseTexture): boolean;
  115908. /**
  115909. * Returns an array of the actively used textures.
  115910. * @param activeTextures Array of BaseTextures
  115911. */
  115912. getActiveTextures(activeTextures: BaseTexture[]): void;
  115913. /**
  115914. * Returns the animatable textures.
  115915. * @param animatables Array of animatable textures.
  115916. */
  115917. getAnimatables(animatables: IAnimatable[]): void;
  115918. /**
  115919. * Disposes the resources of the material.
  115920. * @param forceDisposeTextures - Forces the disposal of all textures.
  115921. */
  115922. dispose(forceDisposeTextures?: boolean): void;
  115923. /**
  115924. * Get the current class name of the texture useful for serialization or dynamic coding.
  115925. * @returns "PBRAnisotropicConfiguration"
  115926. */
  115927. getClassName(): string;
  115928. /**
  115929. * Add fallbacks to the effect fallbacks list.
  115930. * @param defines defines the Base texture to use.
  115931. * @param fallbacks defines the current fallback list.
  115932. * @param currentRank defines the current fallback rank.
  115933. * @returns the new fallback rank.
  115934. */
  115935. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  115936. /**
  115937. * Add the required uniforms to the current list.
  115938. * @param uniforms defines the current uniform list.
  115939. */
  115940. static AddUniforms(uniforms: string[]): void;
  115941. /**
  115942. * Add the required uniforms to the current buffer.
  115943. * @param uniformBuffer defines the current uniform buffer.
  115944. */
  115945. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  115946. /**
  115947. * Add the required samplers to the current list.
  115948. * @param samplers defines the current sampler list.
  115949. */
  115950. static AddSamplers(samplers: string[]): void;
  115951. /**
  115952. * Makes a duplicate of the current configuration into another one.
  115953. * @param anisotropicConfiguration define the config where to copy the info
  115954. */
  115955. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  115956. /**
  115957. * Serializes this anisotropy configuration.
  115958. * @returns - An object with the serialized config.
  115959. */
  115960. serialize(): any;
  115961. /**
  115962. * Parses a anisotropy Configuration from a serialized object.
  115963. * @param source - Serialized object.
  115964. * @param scene Defines the scene we are parsing for
  115965. * @param rootUrl Defines the rootUrl to load from
  115966. */
  115967. parse(source: any, scene: Scene, rootUrl: string): void;
  115968. }
  115969. }
  115970. declare module BABYLON {
  115971. /**
  115972. * @hidden
  115973. */
  115974. export interface IMaterialBRDFDefines {
  115975. BRDF_V_HEIGHT_CORRELATED: boolean;
  115976. MS_BRDF_ENERGY_CONSERVATION: boolean;
  115977. SPHERICAL_HARMONICS: boolean;
  115978. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  115979. /** @hidden */
  115980. _areMiscDirty: boolean;
  115981. }
  115982. /**
  115983. * Define the code related to the BRDF parameters of the pbr material.
  115984. */
  115985. export class PBRBRDFConfiguration {
  115986. /**
  115987. * Default value used for the energy conservation.
  115988. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115989. */
  115990. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  115991. /**
  115992. * Default value used for the Smith Visibility Height Correlated mode.
  115993. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  115994. */
  115995. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  115996. /**
  115997. * Default value used for the IBL diffuse part.
  115998. * This can help switching back to the polynomials mode globally which is a tiny bit
  115999. * less GPU intensive at the drawback of a lower quality.
  116000. */
  116001. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  116002. /**
  116003. * Default value used for activating energy conservation for the specular workflow.
  116004. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116005. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116006. */
  116007. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  116008. private _useEnergyConservation;
  116009. /**
  116010. * Defines if the material uses energy conservation.
  116011. */
  116012. useEnergyConservation: boolean;
  116013. private _useSmithVisibilityHeightCorrelated;
  116014. /**
  116015. * LEGACY Mode set to false
  116016. * Defines if the material uses height smith correlated visibility term.
  116017. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  116018. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  116019. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  116020. * Not relying on height correlated will also disable energy conservation.
  116021. */
  116022. useSmithVisibilityHeightCorrelated: boolean;
  116023. private _useSphericalHarmonics;
  116024. /**
  116025. * LEGACY Mode set to false
  116026. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  116027. * diffuse part of the IBL.
  116028. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  116029. * to the ground truth.
  116030. */
  116031. useSphericalHarmonics: boolean;
  116032. private _useSpecularGlossinessInputEnergyConservation;
  116033. /**
  116034. * Defines if the material uses energy conservation, when the specular workflow is active.
  116035. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  116036. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  116037. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  116038. */
  116039. useSpecularGlossinessInputEnergyConservation: boolean;
  116040. /** @hidden */
  116041. private _internalMarkAllSubMeshesAsMiscDirty;
  116042. /** @hidden */
  116043. _markAllSubMeshesAsMiscDirty(): void;
  116044. /**
  116045. * Instantiate a new istance of clear coat configuration.
  116046. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  116047. */
  116048. constructor(markAllSubMeshesAsMiscDirty: () => void);
  116049. /**
  116050. * Checks to see if a texture is used in the material.
  116051. * @param defines the list of "defines" to update.
  116052. */
  116053. prepareDefines(defines: IMaterialBRDFDefines): void;
  116054. /**
  116055. * Get the current class name of the texture useful for serialization or dynamic coding.
  116056. * @returns "PBRClearCoatConfiguration"
  116057. */
  116058. getClassName(): string;
  116059. /**
  116060. * Makes a duplicate of the current configuration into another one.
  116061. * @param brdfConfiguration define the config where to copy the info
  116062. */
  116063. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  116064. /**
  116065. * Serializes this BRDF configuration.
  116066. * @returns - An object with the serialized config.
  116067. */
  116068. serialize(): any;
  116069. /**
  116070. * Parses a anisotropy Configuration from a serialized object.
  116071. * @param source - Serialized object.
  116072. * @param scene Defines the scene we are parsing for
  116073. * @param rootUrl Defines the rootUrl to load from
  116074. */
  116075. parse(source: any, scene: Scene, rootUrl: string): void;
  116076. }
  116077. }
  116078. declare module BABYLON {
  116079. /**
  116080. * @hidden
  116081. */
  116082. export interface IMaterialSheenDefines {
  116083. SHEEN: boolean;
  116084. SHEEN_TEXTURE: boolean;
  116085. SHEEN_TEXTUREDIRECTUV: number;
  116086. SHEEN_LINKWITHALBEDO: boolean;
  116087. /** @hidden */
  116088. _areTexturesDirty: boolean;
  116089. }
  116090. /**
  116091. * Define the code related to the Sheen parameters of the pbr material.
  116092. */
  116093. export class PBRSheenConfiguration {
  116094. private _isEnabled;
  116095. /**
  116096. * Defines if the material uses sheen.
  116097. */
  116098. isEnabled: boolean;
  116099. private _linkSheenWithAlbedo;
  116100. /**
  116101. * Defines if the sheen is linked to the sheen color.
  116102. */
  116103. linkSheenWithAlbedo: boolean;
  116104. /**
  116105. * Defines the sheen intensity.
  116106. */
  116107. intensity: number;
  116108. /**
  116109. * Defines the sheen color.
  116110. */
  116111. color: Color3;
  116112. private _texture;
  116113. /**
  116114. * Stores the sheen tint values in a texture.
  116115. * rgb is tint
  116116. * a is a intensity
  116117. */
  116118. texture: Nullable<BaseTexture>;
  116119. /** @hidden */
  116120. private _internalMarkAllSubMeshesAsTexturesDirty;
  116121. /** @hidden */
  116122. _markAllSubMeshesAsTexturesDirty(): void;
  116123. /**
  116124. * Instantiate a new istance of clear coat configuration.
  116125. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116126. */
  116127. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116128. /**
  116129. * Specifies that the submesh is ready to be used.
  116130. * @param defines the list of "defines" to update.
  116131. * @param scene defines the scene the material belongs to.
  116132. * @returns - boolean indicating that the submesh is ready or not.
  116133. */
  116134. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  116135. /**
  116136. * Checks to see if a texture is used in the material.
  116137. * @param defines the list of "defines" to update.
  116138. * @param scene defines the scene the material belongs to.
  116139. */
  116140. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  116141. /**
  116142. * Binds the material data.
  116143. * @param uniformBuffer defines the Uniform buffer to fill in.
  116144. * @param scene defines the scene the material belongs to.
  116145. * @param isFrozen defines wether the material is frozen or not.
  116146. */
  116147. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  116148. /**
  116149. * Checks to see if a texture is used in the material.
  116150. * @param texture - Base texture to use.
  116151. * @returns - Boolean specifying if a texture is used in the material.
  116152. */
  116153. hasTexture(texture: BaseTexture): boolean;
  116154. /**
  116155. * Returns an array of the actively used textures.
  116156. * @param activeTextures Array of BaseTextures
  116157. */
  116158. getActiveTextures(activeTextures: BaseTexture[]): void;
  116159. /**
  116160. * Returns the animatable textures.
  116161. * @param animatables Array of animatable textures.
  116162. */
  116163. getAnimatables(animatables: IAnimatable[]): void;
  116164. /**
  116165. * Disposes the resources of the material.
  116166. * @param forceDisposeTextures - Forces the disposal of all textures.
  116167. */
  116168. dispose(forceDisposeTextures?: boolean): void;
  116169. /**
  116170. * Get the current class name of the texture useful for serialization or dynamic coding.
  116171. * @returns "PBRSheenConfiguration"
  116172. */
  116173. getClassName(): string;
  116174. /**
  116175. * Add fallbacks to the effect fallbacks list.
  116176. * @param defines defines the Base texture to use.
  116177. * @param fallbacks defines the current fallback list.
  116178. * @param currentRank defines the current fallback rank.
  116179. * @returns the new fallback rank.
  116180. */
  116181. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116182. /**
  116183. * Add the required uniforms to the current list.
  116184. * @param uniforms defines the current uniform list.
  116185. */
  116186. static AddUniforms(uniforms: string[]): void;
  116187. /**
  116188. * Add the required uniforms to the current buffer.
  116189. * @param uniformBuffer defines the current uniform buffer.
  116190. */
  116191. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116192. /**
  116193. * Add the required samplers to the current list.
  116194. * @param samplers defines the current sampler list.
  116195. */
  116196. static AddSamplers(samplers: string[]): void;
  116197. /**
  116198. * Makes a duplicate of the current configuration into another one.
  116199. * @param sheenConfiguration define the config where to copy the info
  116200. */
  116201. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  116202. /**
  116203. * Serializes this BRDF configuration.
  116204. * @returns - An object with the serialized config.
  116205. */
  116206. serialize(): any;
  116207. /**
  116208. * Parses a anisotropy Configuration from a serialized object.
  116209. * @param source - Serialized object.
  116210. * @param scene Defines the scene we are parsing for
  116211. * @param rootUrl Defines the rootUrl to load from
  116212. */
  116213. parse(source: any, scene: Scene, rootUrl: string): void;
  116214. }
  116215. }
  116216. declare module BABYLON {
  116217. /**
  116218. * @hidden
  116219. */
  116220. export interface IMaterialSubSurfaceDefines {
  116221. SUBSURFACE: boolean;
  116222. SS_REFRACTION: boolean;
  116223. SS_TRANSLUCENCY: boolean;
  116224. SS_SCATERRING: boolean;
  116225. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116226. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116227. SS_REFRACTIONMAP_3D: boolean;
  116228. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116229. SS_LODINREFRACTIONALPHA: boolean;
  116230. SS_GAMMAREFRACTION: boolean;
  116231. SS_RGBDREFRACTION: boolean;
  116232. SS_LINEARSPECULARREFRACTION: boolean;
  116233. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116234. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116235. /** @hidden */
  116236. _areTexturesDirty: boolean;
  116237. }
  116238. /**
  116239. * Define the code related to the sub surface parameters of the pbr material.
  116240. */
  116241. export class PBRSubSurfaceConfiguration {
  116242. private _isRefractionEnabled;
  116243. /**
  116244. * Defines if the refraction is enabled in the material.
  116245. */
  116246. isRefractionEnabled: boolean;
  116247. private _isTranslucencyEnabled;
  116248. /**
  116249. * Defines if the translucency is enabled in the material.
  116250. */
  116251. isTranslucencyEnabled: boolean;
  116252. private _isScatteringEnabled;
  116253. /**
  116254. * Defines the refraction intensity of the material.
  116255. * The refraction when enabled replaces the Diffuse part of the material.
  116256. * The intensity helps transitionning between diffuse and refraction.
  116257. */
  116258. refractionIntensity: number;
  116259. /**
  116260. * Defines the translucency intensity of the material.
  116261. * When translucency has been enabled, this defines how much of the "translucency"
  116262. * is addded to the diffuse part of the material.
  116263. */
  116264. translucencyIntensity: number;
  116265. /**
  116266. * Defines the scattering intensity of the material.
  116267. * When scattering has been enabled, this defines how much of the "scattered light"
  116268. * is addded to the diffuse part of the material.
  116269. */
  116270. scatteringIntensity: number;
  116271. private _thicknessTexture;
  116272. /**
  116273. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  116274. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  116275. * 0 would mean minimumThickness
  116276. * 1 would mean maximumThickness
  116277. * The other channels might be use as a mask to vary the different effects intensity.
  116278. */
  116279. thicknessTexture: Nullable<BaseTexture>;
  116280. private _refractionTexture;
  116281. /**
  116282. * Defines the texture to use for refraction.
  116283. */
  116284. refractionTexture: Nullable<BaseTexture>;
  116285. private _indexOfRefraction;
  116286. /**
  116287. * Defines the index of refraction used in the material.
  116288. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  116289. */
  116290. indexOfRefraction: number;
  116291. private _invertRefractionY;
  116292. /**
  116293. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  116294. */
  116295. invertRefractionY: boolean;
  116296. private _linkRefractionWithTransparency;
  116297. /**
  116298. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  116299. * Materials half opaque for instance using refraction could benefit from this control.
  116300. */
  116301. linkRefractionWithTransparency: boolean;
  116302. /**
  116303. * Defines the minimum thickness stored in the thickness map.
  116304. * If no thickness map is defined, this value will be used to simulate thickness.
  116305. */
  116306. minimumThickness: number;
  116307. /**
  116308. * Defines the maximum thickness stored in the thickness map.
  116309. */
  116310. maximumThickness: number;
  116311. /**
  116312. * Defines the volume tint of the material.
  116313. * This is used for both translucency and scattering.
  116314. */
  116315. tintColor: Color3;
  116316. /**
  116317. * Defines the distance at which the tint color should be found in the media.
  116318. * This is used for refraction only.
  116319. */
  116320. tintColorAtDistance: number;
  116321. /**
  116322. * Defines how far each channel transmit through the media.
  116323. * It is defined as a color to simplify it selection.
  116324. */
  116325. diffusionDistance: Color3;
  116326. private _useMaskFromThicknessTexture;
  116327. /**
  116328. * Stores the intensity of the different subsurface effects in the thickness texture.
  116329. * * the green channel is the translucency intensity.
  116330. * * the blue channel is the scattering intensity.
  116331. * * the alpha channel is the refraction intensity.
  116332. */
  116333. useMaskFromThicknessTexture: boolean;
  116334. /** @hidden */
  116335. private _internalMarkAllSubMeshesAsTexturesDirty;
  116336. /** @hidden */
  116337. _markAllSubMeshesAsTexturesDirty(): void;
  116338. /**
  116339. * Instantiate a new istance of sub surface configuration.
  116340. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  116341. */
  116342. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  116343. /**
  116344. * Gets wehter the submesh is ready to be used or not.
  116345. * @param defines the list of "defines" to update.
  116346. * @param scene defines the scene the material belongs to.
  116347. * @returns - boolean indicating that the submesh is ready or not.
  116348. */
  116349. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  116350. /**
  116351. * Checks to see if a texture is used in the material.
  116352. * @param defines the list of "defines" to update.
  116353. * @param scene defines the scene to the material belongs to.
  116354. */
  116355. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  116356. /**
  116357. * Binds the material data.
  116358. * @param uniformBuffer defines the Uniform buffer to fill in.
  116359. * @param scene defines the scene the material belongs to.
  116360. * @param engine defines the engine the material belongs to.
  116361. * @param isFrozen defines wether the material is frozen or not.
  116362. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  116363. */
  116364. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  116365. /**
  116366. * Unbinds the material from the mesh.
  116367. * @param activeEffect defines the effect that should be unbound from.
  116368. * @returns true if unbound, otherwise false
  116369. */
  116370. unbind(activeEffect: Effect): boolean;
  116371. /**
  116372. * Returns the texture used for refraction or null if none is used.
  116373. * @param scene defines the scene the material belongs to.
  116374. * @returns - Refraction texture if present. If no refraction texture and refraction
  116375. * is linked with transparency, returns environment texture. Otherwise, returns null.
  116376. */
  116377. private _getRefractionTexture;
  116378. /**
  116379. * Returns true if alpha blending should be disabled.
  116380. */
  116381. readonly disableAlphaBlending: boolean;
  116382. /**
  116383. * Fills the list of render target textures.
  116384. * @param renderTargets the list of render targets to update
  116385. */
  116386. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  116387. /**
  116388. * Checks to see if a texture is used in the material.
  116389. * @param texture - Base texture to use.
  116390. * @returns - Boolean specifying if a texture is used in the material.
  116391. */
  116392. hasTexture(texture: BaseTexture): boolean;
  116393. /**
  116394. * Gets a boolean indicating that current material needs to register RTT
  116395. * @returns true if this uses a render target otherwise false.
  116396. */
  116397. hasRenderTargetTextures(): boolean;
  116398. /**
  116399. * Returns an array of the actively used textures.
  116400. * @param activeTextures Array of BaseTextures
  116401. */
  116402. getActiveTextures(activeTextures: BaseTexture[]): void;
  116403. /**
  116404. * Returns the animatable textures.
  116405. * @param animatables Array of animatable textures.
  116406. */
  116407. getAnimatables(animatables: IAnimatable[]): void;
  116408. /**
  116409. * Disposes the resources of the material.
  116410. * @param forceDisposeTextures - Forces the disposal of all textures.
  116411. */
  116412. dispose(forceDisposeTextures?: boolean): void;
  116413. /**
  116414. * Get the current class name of the texture useful for serialization or dynamic coding.
  116415. * @returns "PBRSubSurfaceConfiguration"
  116416. */
  116417. getClassName(): string;
  116418. /**
  116419. * Add fallbacks to the effect fallbacks list.
  116420. * @param defines defines the Base texture to use.
  116421. * @param fallbacks defines the current fallback list.
  116422. * @param currentRank defines the current fallback rank.
  116423. * @returns the new fallback rank.
  116424. */
  116425. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  116426. /**
  116427. * Add the required uniforms to the current list.
  116428. * @param uniforms defines the current uniform list.
  116429. */
  116430. static AddUniforms(uniforms: string[]): void;
  116431. /**
  116432. * Add the required samplers to the current list.
  116433. * @param samplers defines the current sampler list.
  116434. */
  116435. static AddSamplers(samplers: string[]): void;
  116436. /**
  116437. * Add the required uniforms to the current buffer.
  116438. * @param uniformBuffer defines the current uniform buffer.
  116439. */
  116440. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  116441. /**
  116442. * Makes a duplicate of the current configuration into another one.
  116443. * @param configuration define the config where to copy the info
  116444. */
  116445. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  116446. /**
  116447. * Serializes this Sub Surface configuration.
  116448. * @returns - An object with the serialized config.
  116449. */
  116450. serialize(): any;
  116451. /**
  116452. * Parses a anisotropy Configuration from a serialized object.
  116453. * @param source - Serialized object.
  116454. * @param scene Defines the scene we are parsing for
  116455. * @param rootUrl Defines the rootUrl to load from
  116456. */
  116457. parse(source: any, scene: Scene, rootUrl: string): void;
  116458. }
  116459. }
  116460. declare module BABYLON {
  116461. /** @hidden */
  116462. export var pbrFragmentDeclaration: {
  116463. name: string;
  116464. shader: string;
  116465. };
  116466. }
  116467. declare module BABYLON {
  116468. /** @hidden */
  116469. export var pbrUboDeclaration: {
  116470. name: string;
  116471. shader: string;
  116472. };
  116473. }
  116474. declare module BABYLON {
  116475. /** @hidden */
  116476. export var pbrFragmentExtraDeclaration: {
  116477. name: string;
  116478. shader: string;
  116479. };
  116480. }
  116481. declare module BABYLON {
  116482. /** @hidden */
  116483. export var pbrFragmentSamplersDeclaration: {
  116484. name: string;
  116485. shader: string;
  116486. };
  116487. }
  116488. declare module BABYLON {
  116489. /** @hidden */
  116490. export var pbrHelperFunctions: {
  116491. name: string;
  116492. shader: string;
  116493. };
  116494. }
  116495. declare module BABYLON {
  116496. /** @hidden */
  116497. export var harmonicsFunctions: {
  116498. name: string;
  116499. shader: string;
  116500. };
  116501. }
  116502. declare module BABYLON {
  116503. /** @hidden */
  116504. export var pbrDirectLightingSetupFunctions: {
  116505. name: string;
  116506. shader: string;
  116507. };
  116508. }
  116509. declare module BABYLON {
  116510. /** @hidden */
  116511. export var pbrDirectLightingFalloffFunctions: {
  116512. name: string;
  116513. shader: string;
  116514. };
  116515. }
  116516. declare module BABYLON {
  116517. /** @hidden */
  116518. export var pbrBRDFFunctions: {
  116519. name: string;
  116520. shader: string;
  116521. };
  116522. }
  116523. declare module BABYLON {
  116524. /** @hidden */
  116525. export var pbrDirectLightingFunctions: {
  116526. name: string;
  116527. shader: string;
  116528. };
  116529. }
  116530. declare module BABYLON {
  116531. /** @hidden */
  116532. export var pbrIBLFunctions: {
  116533. name: string;
  116534. shader: string;
  116535. };
  116536. }
  116537. declare module BABYLON {
  116538. /** @hidden */
  116539. export var pbrDebug: {
  116540. name: string;
  116541. shader: string;
  116542. };
  116543. }
  116544. declare module BABYLON {
  116545. /** @hidden */
  116546. export var pbrPixelShader: {
  116547. name: string;
  116548. shader: string;
  116549. };
  116550. }
  116551. declare module BABYLON {
  116552. /** @hidden */
  116553. export var pbrVertexDeclaration: {
  116554. name: string;
  116555. shader: string;
  116556. };
  116557. }
  116558. declare module BABYLON {
  116559. /** @hidden */
  116560. export var pbrVertexShader: {
  116561. name: string;
  116562. shader: string;
  116563. };
  116564. }
  116565. declare module BABYLON {
  116566. /**
  116567. * Manages the defines for the PBR Material.
  116568. * @hidden
  116569. */
  116570. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  116571. PBR: boolean;
  116572. MAINUV1: boolean;
  116573. MAINUV2: boolean;
  116574. UV1: boolean;
  116575. UV2: boolean;
  116576. ALBEDO: boolean;
  116577. ALBEDODIRECTUV: number;
  116578. VERTEXCOLOR: boolean;
  116579. AMBIENT: boolean;
  116580. AMBIENTDIRECTUV: number;
  116581. AMBIENTINGRAYSCALE: boolean;
  116582. OPACITY: boolean;
  116583. VERTEXALPHA: boolean;
  116584. OPACITYDIRECTUV: number;
  116585. OPACITYRGB: boolean;
  116586. ALPHATEST: boolean;
  116587. DEPTHPREPASS: boolean;
  116588. ALPHABLEND: boolean;
  116589. ALPHAFROMALBEDO: boolean;
  116590. ALPHATESTVALUE: string;
  116591. SPECULAROVERALPHA: boolean;
  116592. RADIANCEOVERALPHA: boolean;
  116593. ALPHAFRESNEL: boolean;
  116594. LINEARALPHAFRESNEL: boolean;
  116595. PREMULTIPLYALPHA: boolean;
  116596. EMISSIVE: boolean;
  116597. EMISSIVEDIRECTUV: number;
  116598. REFLECTIVITY: boolean;
  116599. REFLECTIVITYDIRECTUV: number;
  116600. SPECULARTERM: boolean;
  116601. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  116602. MICROSURFACEAUTOMATIC: boolean;
  116603. LODBASEDMICROSFURACE: boolean;
  116604. MICROSURFACEMAP: boolean;
  116605. MICROSURFACEMAPDIRECTUV: number;
  116606. METALLICWORKFLOW: boolean;
  116607. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  116608. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  116609. METALLNESSSTOREINMETALMAPBLUE: boolean;
  116610. AOSTOREINMETALMAPRED: boolean;
  116611. METALLICF0FACTORFROMMETALLICMAP: boolean;
  116612. ENVIRONMENTBRDF: boolean;
  116613. ENVIRONMENTBRDF_RGBD: boolean;
  116614. NORMAL: boolean;
  116615. TANGENT: boolean;
  116616. BUMP: boolean;
  116617. BUMPDIRECTUV: number;
  116618. OBJECTSPACE_NORMALMAP: boolean;
  116619. PARALLAX: boolean;
  116620. PARALLAXOCCLUSION: boolean;
  116621. NORMALXYSCALE: boolean;
  116622. LIGHTMAP: boolean;
  116623. LIGHTMAPDIRECTUV: number;
  116624. USELIGHTMAPASSHADOWMAP: boolean;
  116625. GAMMALIGHTMAP: boolean;
  116626. RGBDLIGHTMAP: boolean;
  116627. REFLECTION: boolean;
  116628. REFLECTIONMAP_3D: boolean;
  116629. REFLECTIONMAP_SPHERICAL: boolean;
  116630. REFLECTIONMAP_PLANAR: boolean;
  116631. REFLECTIONMAP_CUBIC: boolean;
  116632. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  116633. REFLECTIONMAP_PROJECTION: boolean;
  116634. REFLECTIONMAP_SKYBOX: boolean;
  116635. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  116636. REFLECTIONMAP_EXPLICIT: boolean;
  116637. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  116638. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  116639. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  116640. INVERTCUBICMAP: boolean;
  116641. USESPHERICALFROMREFLECTIONMAP: boolean;
  116642. USEIRRADIANCEMAP: boolean;
  116643. SPHERICAL_HARMONICS: boolean;
  116644. USESPHERICALINVERTEX: boolean;
  116645. REFLECTIONMAP_OPPOSITEZ: boolean;
  116646. LODINREFLECTIONALPHA: boolean;
  116647. GAMMAREFLECTION: boolean;
  116648. RGBDREFLECTION: boolean;
  116649. LINEARSPECULARREFLECTION: boolean;
  116650. RADIANCEOCCLUSION: boolean;
  116651. HORIZONOCCLUSION: boolean;
  116652. INSTANCES: boolean;
  116653. NUM_BONE_INFLUENCERS: number;
  116654. BonesPerMesh: number;
  116655. BONETEXTURE: boolean;
  116656. NONUNIFORMSCALING: boolean;
  116657. MORPHTARGETS: boolean;
  116658. MORPHTARGETS_NORMAL: boolean;
  116659. MORPHTARGETS_TANGENT: boolean;
  116660. MORPHTARGETS_UV: boolean;
  116661. NUM_MORPH_INFLUENCERS: number;
  116662. IMAGEPROCESSING: boolean;
  116663. VIGNETTE: boolean;
  116664. VIGNETTEBLENDMODEMULTIPLY: boolean;
  116665. VIGNETTEBLENDMODEOPAQUE: boolean;
  116666. TONEMAPPING: boolean;
  116667. TONEMAPPING_ACES: boolean;
  116668. CONTRAST: boolean;
  116669. COLORCURVES: boolean;
  116670. COLORGRADING: boolean;
  116671. COLORGRADING3D: boolean;
  116672. SAMPLER3DGREENDEPTH: boolean;
  116673. SAMPLER3DBGRMAP: boolean;
  116674. IMAGEPROCESSINGPOSTPROCESS: boolean;
  116675. EXPOSURE: boolean;
  116676. MULTIVIEW: boolean;
  116677. USEPHYSICALLIGHTFALLOFF: boolean;
  116678. USEGLTFLIGHTFALLOFF: boolean;
  116679. TWOSIDEDLIGHTING: boolean;
  116680. SHADOWFLOAT: boolean;
  116681. CLIPPLANE: boolean;
  116682. CLIPPLANE2: boolean;
  116683. CLIPPLANE3: boolean;
  116684. CLIPPLANE4: boolean;
  116685. POINTSIZE: boolean;
  116686. FOG: boolean;
  116687. LOGARITHMICDEPTH: boolean;
  116688. FORCENORMALFORWARD: boolean;
  116689. SPECULARAA: boolean;
  116690. CLEARCOAT: boolean;
  116691. CLEARCOAT_DEFAULTIOR: boolean;
  116692. CLEARCOAT_TEXTURE: boolean;
  116693. CLEARCOAT_TEXTUREDIRECTUV: number;
  116694. CLEARCOAT_BUMP: boolean;
  116695. CLEARCOAT_BUMPDIRECTUV: number;
  116696. CLEARCOAT_TINT: boolean;
  116697. CLEARCOAT_TINT_TEXTURE: boolean;
  116698. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  116699. ANISOTROPIC: boolean;
  116700. ANISOTROPIC_TEXTURE: boolean;
  116701. ANISOTROPIC_TEXTUREDIRECTUV: number;
  116702. BRDF_V_HEIGHT_CORRELATED: boolean;
  116703. MS_BRDF_ENERGY_CONSERVATION: boolean;
  116704. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  116705. SHEEN: boolean;
  116706. SHEEN_TEXTURE: boolean;
  116707. SHEEN_TEXTUREDIRECTUV: number;
  116708. SHEEN_LINKWITHALBEDO: boolean;
  116709. SUBSURFACE: boolean;
  116710. SS_REFRACTION: boolean;
  116711. SS_TRANSLUCENCY: boolean;
  116712. SS_SCATERRING: boolean;
  116713. SS_THICKNESSANDMASK_TEXTURE: boolean;
  116714. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  116715. SS_REFRACTIONMAP_3D: boolean;
  116716. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  116717. SS_LODINREFRACTIONALPHA: boolean;
  116718. SS_GAMMAREFRACTION: boolean;
  116719. SS_RGBDREFRACTION: boolean;
  116720. SS_LINEARSPECULARREFRACTION: boolean;
  116721. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  116722. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  116723. UNLIT: boolean;
  116724. DEBUGMODE: number;
  116725. /**
  116726. * Initializes the PBR Material defines.
  116727. */
  116728. constructor();
  116729. /**
  116730. * Resets the PBR Material defines.
  116731. */
  116732. reset(): void;
  116733. }
  116734. /**
  116735. * The Physically based material base class of BJS.
  116736. *
  116737. * This offers the main features of a standard PBR material.
  116738. * For more information, please refer to the documentation :
  116739. * https://doc.babylonjs.com/how_to/physically_based_rendering
  116740. */
  116741. export abstract class PBRBaseMaterial extends PushMaterial {
  116742. /**
  116743. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  116744. */
  116745. static readonly PBRMATERIAL_OPAQUE: number;
  116746. /**
  116747. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  116748. */
  116749. static readonly PBRMATERIAL_ALPHATEST: number;
  116750. /**
  116751. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116752. */
  116753. static readonly PBRMATERIAL_ALPHABLEND: number;
  116754. /**
  116755. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  116756. * They are also discarded below the alpha cutoff threshold to improve performances.
  116757. */
  116758. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  116759. /**
  116760. * Defines the default value of how much AO map is occluding the analytical lights
  116761. * (point spot...).
  116762. */
  116763. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  116764. /**
  116765. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  116766. */
  116767. static readonly LIGHTFALLOFF_PHYSICAL: number;
  116768. /**
  116769. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  116770. * to enhance interoperability with other engines.
  116771. */
  116772. static readonly LIGHTFALLOFF_GLTF: number;
  116773. /**
  116774. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  116775. * to enhance interoperability with other materials.
  116776. */
  116777. static readonly LIGHTFALLOFF_STANDARD: number;
  116778. /**
  116779. * Intensity of the direct lights e.g. the four lights available in your scene.
  116780. * This impacts both the direct diffuse and specular highlights.
  116781. */
  116782. protected _directIntensity: number;
  116783. /**
  116784. * Intensity of the emissive part of the material.
  116785. * This helps controlling the emissive effect without modifying the emissive color.
  116786. */
  116787. protected _emissiveIntensity: number;
  116788. /**
  116789. * Intensity of the environment e.g. how much the environment will light the object
  116790. * either through harmonics for rough material or through the refelction for shiny ones.
  116791. */
  116792. protected _environmentIntensity: number;
  116793. /**
  116794. * This is a special control allowing the reduction of the specular highlights coming from the
  116795. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  116796. */
  116797. protected _specularIntensity: number;
  116798. /**
  116799. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  116800. */
  116801. private _lightingInfos;
  116802. /**
  116803. * Debug Control allowing disabling the bump map on this material.
  116804. */
  116805. protected _disableBumpMap: boolean;
  116806. /**
  116807. * AKA Diffuse Texture in standard nomenclature.
  116808. */
  116809. protected _albedoTexture: Nullable<BaseTexture>;
  116810. /**
  116811. * AKA Occlusion Texture in other nomenclature.
  116812. */
  116813. protected _ambientTexture: Nullable<BaseTexture>;
  116814. /**
  116815. * AKA Occlusion Texture Intensity in other nomenclature.
  116816. */
  116817. protected _ambientTextureStrength: number;
  116818. /**
  116819. * Defines how much the AO map is occluding the analytical lights (point spot...).
  116820. * 1 means it completely occludes it
  116821. * 0 mean it has no impact
  116822. */
  116823. protected _ambientTextureImpactOnAnalyticalLights: number;
  116824. /**
  116825. * Stores the alpha values in a texture.
  116826. */
  116827. protected _opacityTexture: Nullable<BaseTexture>;
  116828. /**
  116829. * Stores the reflection values in a texture.
  116830. */
  116831. protected _reflectionTexture: Nullable<BaseTexture>;
  116832. /**
  116833. * Stores the emissive values in a texture.
  116834. */
  116835. protected _emissiveTexture: Nullable<BaseTexture>;
  116836. /**
  116837. * AKA Specular texture in other nomenclature.
  116838. */
  116839. protected _reflectivityTexture: Nullable<BaseTexture>;
  116840. /**
  116841. * Used to switch from specular/glossiness to metallic/roughness workflow.
  116842. */
  116843. protected _metallicTexture: Nullable<BaseTexture>;
  116844. /**
  116845. * Specifies the metallic scalar of the metallic/roughness workflow.
  116846. * Can also be used to scale the metalness values of the metallic texture.
  116847. */
  116848. protected _metallic: Nullable<number>;
  116849. /**
  116850. * Specifies the roughness scalar of the metallic/roughness workflow.
  116851. * Can also be used to scale the roughness values of the metallic texture.
  116852. */
  116853. protected _roughness: Nullable<number>;
  116854. /**
  116855. * Specifies the an F0 factor to help configuring the material F0.
  116856. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  116857. * to 0.5 the previously hard coded value stays the same.
  116858. * Can also be used to scale the F0 values of the metallic texture.
  116859. */
  116860. protected _metallicF0Factor: number;
  116861. /**
  116862. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  116863. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  116864. * your expectation as it multiplies with the texture data.
  116865. */
  116866. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  116867. /**
  116868. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  116869. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  116870. */
  116871. protected _microSurfaceTexture: Nullable<BaseTexture>;
  116872. /**
  116873. * Stores surface normal data used to displace a mesh in a texture.
  116874. */
  116875. protected _bumpTexture: Nullable<BaseTexture>;
  116876. /**
  116877. * Stores the pre-calculated light information of a mesh in a texture.
  116878. */
  116879. protected _lightmapTexture: Nullable<BaseTexture>;
  116880. /**
  116881. * The color of a material in ambient lighting.
  116882. */
  116883. protected _ambientColor: Color3;
  116884. /**
  116885. * AKA Diffuse Color in other nomenclature.
  116886. */
  116887. protected _albedoColor: Color3;
  116888. /**
  116889. * AKA Specular Color in other nomenclature.
  116890. */
  116891. protected _reflectivityColor: Color3;
  116892. /**
  116893. * The color applied when light is reflected from a material.
  116894. */
  116895. protected _reflectionColor: Color3;
  116896. /**
  116897. * The color applied when light is emitted from a material.
  116898. */
  116899. protected _emissiveColor: Color3;
  116900. /**
  116901. * AKA Glossiness in other nomenclature.
  116902. */
  116903. protected _microSurface: number;
  116904. /**
  116905. * Specifies that the material will use the light map as a show map.
  116906. */
  116907. protected _useLightmapAsShadowmap: boolean;
  116908. /**
  116909. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  116910. * makes the reflect vector face the model (under horizon).
  116911. */
  116912. protected _useHorizonOcclusion: boolean;
  116913. /**
  116914. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  116915. * too much the area relying on ambient texture to define their ambient occlusion.
  116916. */
  116917. protected _useRadianceOcclusion: boolean;
  116918. /**
  116919. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  116920. */
  116921. protected _useAlphaFromAlbedoTexture: boolean;
  116922. /**
  116923. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  116924. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  116925. */
  116926. protected _useSpecularOverAlpha: boolean;
  116927. /**
  116928. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  116929. */
  116930. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  116931. /**
  116932. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  116933. */
  116934. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  116935. /**
  116936. * Specifies if the metallic texture contains the roughness information in its green channel.
  116937. */
  116938. protected _useRoughnessFromMetallicTextureGreen: boolean;
  116939. /**
  116940. * Specifies if the metallic texture contains the metallness information in its blue channel.
  116941. */
  116942. protected _useMetallnessFromMetallicTextureBlue: boolean;
  116943. /**
  116944. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  116945. */
  116946. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  116947. /**
  116948. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  116949. */
  116950. protected _useAmbientInGrayScale: boolean;
  116951. /**
  116952. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  116953. * The material will try to infer what glossiness each pixel should be.
  116954. */
  116955. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  116956. /**
  116957. * Defines the falloff type used in this material.
  116958. * It by default is Physical.
  116959. */
  116960. protected _lightFalloff: number;
  116961. /**
  116962. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  116963. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  116964. */
  116965. protected _useRadianceOverAlpha: boolean;
  116966. /**
  116967. * Allows using an object space normal map (instead of tangent space).
  116968. */
  116969. protected _useObjectSpaceNormalMap: boolean;
  116970. /**
  116971. * Allows using the bump map in parallax mode.
  116972. */
  116973. protected _useParallax: boolean;
  116974. /**
  116975. * Allows using the bump map in parallax occlusion mode.
  116976. */
  116977. protected _useParallaxOcclusion: boolean;
  116978. /**
  116979. * Controls the scale bias of the parallax mode.
  116980. */
  116981. protected _parallaxScaleBias: number;
  116982. /**
  116983. * If sets to true, disables all the lights affecting the material.
  116984. */
  116985. protected _disableLighting: boolean;
  116986. /**
  116987. * Number of Simultaneous lights allowed on the material.
  116988. */
  116989. protected _maxSimultaneousLights: number;
  116990. /**
  116991. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  116992. */
  116993. protected _invertNormalMapX: boolean;
  116994. /**
  116995. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  116996. */
  116997. protected _invertNormalMapY: boolean;
  116998. /**
  116999. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117000. */
  117001. protected _twoSidedLighting: boolean;
  117002. /**
  117003. * Defines the alpha limits in alpha test mode.
  117004. */
  117005. protected _alphaCutOff: number;
  117006. /**
  117007. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117008. */
  117009. protected _forceAlphaTest: boolean;
  117010. /**
  117011. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117012. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117013. */
  117014. protected _useAlphaFresnel: boolean;
  117015. /**
  117016. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117017. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117018. */
  117019. protected _useLinearAlphaFresnel: boolean;
  117020. /**
  117021. * The transparency mode of the material.
  117022. */
  117023. protected _transparencyMode: Nullable<number>;
  117024. /**
  117025. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  117026. * from cos thetav and roughness:
  117027. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  117028. */
  117029. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  117030. /**
  117031. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117032. */
  117033. protected _forceIrradianceInFragment: boolean;
  117034. /**
  117035. * Force normal to face away from face.
  117036. */
  117037. protected _forceNormalForward: boolean;
  117038. /**
  117039. * Enables specular anti aliasing in the PBR shader.
  117040. * It will both interacts on the Geometry for analytical and IBL lighting.
  117041. * It also prefilter the roughness map based on the bump values.
  117042. */
  117043. protected _enableSpecularAntiAliasing: boolean;
  117044. /**
  117045. * Default configuration related to image processing available in the PBR Material.
  117046. */
  117047. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  117048. /**
  117049. * Keep track of the image processing observer to allow dispose and replace.
  117050. */
  117051. private _imageProcessingObserver;
  117052. /**
  117053. * Attaches a new image processing configuration to the PBR Material.
  117054. * @param configuration
  117055. */
  117056. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  117057. /**
  117058. * Stores the available render targets.
  117059. */
  117060. private _renderTargets;
  117061. /**
  117062. * Sets the global ambient color for the material used in lighting calculations.
  117063. */
  117064. private _globalAmbientColor;
  117065. /**
  117066. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  117067. */
  117068. private _useLogarithmicDepth;
  117069. /**
  117070. * If set to true, no lighting calculations will be applied.
  117071. */
  117072. private _unlit;
  117073. private _debugMode;
  117074. /**
  117075. * @hidden
  117076. * This is reserved for the inspector.
  117077. * Defines the material debug mode.
  117078. * It helps seeing only some components of the material while troubleshooting.
  117079. */
  117080. debugMode: number;
  117081. /**
  117082. * @hidden
  117083. * This is reserved for the inspector.
  117084. * Specify from where on screen the debug mode should start.
  117085. * The value goes from -1 (full screen) to 1 (not visible)
  117086. * It helps with side by side comparison against the final render
  117087. * This defaults to -1
  117088. */
  117089. private debugLimit;
  117090. /**
  117091. * @hidden
  117092. * This is reserved for the inspector.
  117093. * As the default viewing range might not be enough (if the ambient is really small for instance)
  117094. * You can use the factor to better multiply the final value.
  117095. */
  117096. private debugFactor;
  117097. /**
  117098. * Defines the clear coat layer parameters for the material.
  117099. */
  117100. readonly clearCoat: PBRClearCoatConfiguration;
  117101. /**
  117102. * Defines the anisotropic parameters for the material.
  117103. */
  117104. readonly anisotropy: PBRAnisotropicConfiguration;
  117105. /**
  117106. * Defines the BRDF parameters for the material.
  117107. */
  117108. readonly brdf: PBRBRDFConfiguration;
  117109. /**
  117110. * Defines the Sheen parameters for the material.
  117111. */
  117112. readonly sheen: PBRSheenConfiguration;
  117113. /**
  117114. * Defines the SubSurface parameters for the material.
  117115. */
  117116. readonly subSurface: PBRSubSurfaceConfiguration;
  117117. /**
  117118. * Custom callback helping to override the default shader used in the material.
  117119. */
  117120. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  117121. protected _rebuildInParallel: boolean;
  117122. /**
  117123. * Instantiates a new PBRMaterial instance.
  117124. *
  117125. * @param name The material name
  117126. * @param scene The scene the material will be use in.
  117127. */
  117128. constructor(name: string, scene: Scene);
  117129. /**
  117130. * Gets a boolean indicating that current material needs to register RTT
  117131. */
  117132. readonly hasRenderTargetTextures: boolean;
  117133. /**
  117134. * Gets the name of the material class.
  117135. */
  117136. getClassName(): string;
  117137. /**
  117138. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117139. */
  117140. /**
  117141. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  117142. */
  117143. useLogarithmicDepth: boolean;
  117144. /**
  117145. * Gets the current transparency mode.
  117146. */
  117147. /**
  117148. * Sets the transparency mode of the material.
  117149. *
  117150. * | Value | Type | Description |
  117151. * | ----- | ----------------------------------- | ----------- |
  117152. * | 0 | OPAQUE | |
  117153. * | 1 | ALPHATEST | |
  117154. * | 2 | ALPHABLEND | |
  117155. * | 3 | ALPHATESTANDBLEND | |
  117156. *
  117157. */
  117158. transparencyMode: Nullable<number>;
  117159. /**
  117160. * Returns true if alpha blending should be disabled.
  117161. */
  117162. private readonly _disableAlphaBlending;
  117163. /**
  117164. * Specifies whether or not this material should be rendered in alpha blend mode.
  117165. */
  117166. needAlphaBlending(): boolean;
  117167. /**
  117168. * Specifies if the mesh will require alpha blending.
  117169. * @param mesh - BJS mesh.
  117170. */
  117171. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  117172. /**
  117173. * Specifies whether or not this material should be rendered in alpha test mode.
  117174. */
  117175. needAlphaTesting(): boolean;
  117176. /**
  117177. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  117178. */
  117179. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  117180. /**
  117181. * Gets the texture used for the alpha test.
  117182. */
  117183. getAlphaTestTexture(): Nullable<BaseTexture>;
  117184. /**
  117185. * Specifies that the submesh is ready to be used.
  117186. * @param mesh - BJS mesh.
  117187. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  117188. * @param useInstances - Specifies that instances should be used.
  117189. * @returns - boolean indicating that the submesh is ready or not.
  117190. */
  117191. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  117192. /**
  117193. * Specifies if the material uses metallic roughness workflow.
  117194. * @returns boolean specifiying if the material uses metallic roughness workflow.
  117195. */
  117196. isMetallicWorkflow(): boolean;
  117197. private _prepareEffect;
  117198. private _prepareDefines;
  117199. /**
  117200. * Force shader compilation
  117201. */
  117202. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  117203. /**
  117204. * Initializes the uniform buffer layout for the shader.
  117205. */
  117206. buildUniformLayout(): void;
  117207. /**
  117208. * Unbinds the material from the mesh
  117209. */
  117210. unbind(): void;
  117211. /**
  117212. * Binds the submesh data.
  117213. * @param world - The world matrix.
  117214. * @param mesh - The BJS mesh.
  117215. * @param subMesh - A submesh of the BJS mesh.
  117216. */
  117217. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  117218. /**
  117219. * Returns the animatable textures.
  117220. * @returns - Array of animatable textures.
  117221. */
  117222. getAnimatables(): IAnimatable[];
  117223. /**
  117224. * Returns the texture used for reflections.
  117225. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  117226. */
  117227. private _getReflectionTexture;
  117228. /**
  117229. * Returns an array of the actively used textures.
  117230. * @returns - Array of BaseTextures
  117231. */
  117232. getActiveTextures(): BaseTexture[];
  117233. /**
  117234. * Checks to see if a texture is used in the material.
  117235. * @param texture - Base texture to use.
  117236. * @returns - Boolean specifying if a texture is used in the material.
  117237. */
  117238. hasTexture(texture: BaseTexture): boolean;
  117239. /**
  117240. * Disposes the resources of the material.
  117241. * @param forceDisposeEffect - Forces the disposal of effects.
  117242. * @param forceDisposeTextures - Forces the disposal of all textures.
  117243. */
  117244. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  117245. }
  117246. }
  117247. declare module BABYLON {
  117248. /**
  117249. * The Physically based material of BJS.
  117250. *
  117251. * This offers the main features of a standard PBR material.
  117252. * For more information, please refer to the documentation :
  117253. * https://doc.babylonjs.com/how_to/physically_based_rendering
  117254. */
  117255. export class PBRMaterial extends PBRBaseMaterial {
  117256. /**
  117257. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  117258. */
  117259. static readonly PBRMATERIAL_OPAQUE: number;
  117260. /**
  117261. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  117262. */
  117263. static readonly PBRMATERIAL_ALPHATEST: number;
  117264. /**
  117265. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117266. */
  117267. static readonly PBRMATERIAL_ALPHABLEND: number;
  117268. /**
  117269. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  117270. * They are also discarded below the alpha cutoff threshold to improve performances.
  117271. */
  117272. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  117273. /**
  117274. * Defines the default value of how much AO map is occluding the analytical lights
  117275. * (point spot...).
  117276. */
  117277. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  117278. /**
  117279. * Intensity of the direct lights e.g. the four lights available in your scene.
  117280. * This impacts both the direct diffuse and specular highlights.
  117281. */
  117282. directIntensity: number;
  117283. /**
  117284. * Intensity of the emissive part of the material.
  117285. * This helps controlling the emissive effect without modifying the emissive color.
  117286. */
  117287. emissiveIntensity: number;
  117288. /**
  117289. * Intensity of the environment e.g. how much the environment will light the object
  117290. * either through harmonics for rough material or through the refelction for shiny ones.
  117291. */
  117292. environmentIntensity: number;
  117293. /**
  117294. * This is a special control allowing the reduction of the specular highlights coming from the
  117295. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  117296. */
  117297. specularIntensity: number;
  117298. /**
  117299. * Debug Control allowing disabling the bump map on this material.
  117300. */
  117301. disableBumpMap: boolean;
  117302. /**
  117303. * AKA Diffuse Texture in standard nomenclature.
  117304. */
  117305. albedoTexture: BaseTexture;
  117306. /**
  117307. * AKA Occlusion Texture in other nomenclature.
  117308. */
  117309. ambientTexture: BaseTexture;
  117310. /**
  117311. * AKA Occlusion Texture Intensity in other nomenclature.
  117312. */
  117313. ambientTextureStrength: number;
  117314. /**
  117315. * Defines how much the AO map is occluding the analytical lights (point spot...).
  117316. * 1 means it completely occludes it
  117317. * 0 mean it has no impact
  117318. */
  117319. ambientTextureImpactOnAnalyticalLights: number;
  117320. /**
  117321. * Stores the alpha values in a texture.
  117322. */
  117323. opacityTexture: BaseTexture;
  117324. /**
  117325. * Stores the reflection values in a texture.
  117326. */
  117327. reflectionTexture: Nullable<BaseTexture>;
  117328. /**
  117329. * Stores the emissive values in a texture.
  117330. */
  117331. emissiveTexture: BaseTexture;
  117332. /**
  117333. * AKA Specular texture in other nomenclature.
  117334. */
  117335. reflectivityTexture: BaseTexture;
  117336. /**
  117337. * Used to switch from specular/glossiness to metallic/roughness workflow.
  117338. */
  117339. metallicTexture: BaseTexture;
  117340. /**
  117341. * Specifies the metallic scalar of the metallic/roughness workflow.
  117342. * Can also be used to scale the metalness values of the metallic texture.
  117343. */
  117344. metallic: Nullable<number>;
  117345. /**
  117346. * Specifies the roughness scalar of the metallic/roughness workflow.
  117347. * Can also be used to scale the roughness values of the metallic texture.
  117348. */
  117349. roughness: Nullable<number>;
  117350. /**
  117351. * Specifies the an F0 factor to help configuring the material F0.
  117352. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  117353. * to 0.5 the previously hard coded value stays the same.
  117354. * Can also be used to scale the F0 values of the metallic texture.
  117355. */
  117356. metallicF0Factor: number;
  117357. /**
  117358. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  117359. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  117360. * your expectation as it multiplies with the texture data.
  117361. */
  117362. useMetallicF0FactorFromMetallicTexture: boolean;
  117363. /**
  117364. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  117365. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  117366. */
  117367. microSurfaceTexture: BaseTexture;
  117368. /**
  117369. * Stores surface normal data used to displace a mesh in a texture.
  117370. */
  117371. bumpTexture: BaseTexture;
  117372. /**
  117373. * Stores the pre-calculated light information of a mesh in a texture.
  117374. */
  117375. lightmapTexture: BaseTexture;
  117376. /**
  117377. * Stores the refracted light information in a texture.
  117378. */
  117379. refractionTexture: Nullable<BaseTexture>;
  117380. /**
  117381. * The color of a material in ambient lighting.
  117382. */
  117383. ambientColor: Color3;
  117384. /**
  117385. * AKA Diffuse Color in other nomenclature.
  117386. */
  117387. albedoColor: Color3;
  117388. /**
  117389. * AKA Specular Color in other nomenclature.
  117390. */
  117391. reflectivityColor: Color3;
  117392. /**
  117393. * The color reflected from the material.
  117394. */
  117395. reflectionColor: Color3;
  117396. /**
  117397. * The color emitted from the material.
  117398. */
  117399. emissiveColor: Color3;
  117400. /**
  117401. * AKA Glossiness in other nomenclature.
  117402. */
  117403. microSurface: number;
  117404. /**
  117405. * source material index of refraction (IOR)' / 'destination material IOR.
  117406. */
  117407. indexOfRefraction: number;
  117408. /**
  117409. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  117410. */
  117411. invertRefractionY: boolean;
  117412. /**
  117413. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  117414. * Materials half opaque for instance using refraction could benefit from this control.
  117415. */
  117416. linkRefractionWithTransparency: boolean;
  117417. /**
  117418. * If true, the light map contains occlusion information instead of lighting info.
  117419. */
  117420. useLightmapAsShadowmap: boolean;
  117421. /**
  117422. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  117423. */
  117424. useAlphaFromAlbedoTexture: boolean;
  117425. /**
  117426. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  117427. */
  117428. forceAlphaTest: boolean;
  117429. /**
  117430. * Defines the alpha limits in alpha test mode.
  117431. */
  117432. alphaCutOff: number;
  117433. /**
  117434. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  117435. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  117436. */
  117437. useSpecularOverAlpha: boolean;
  117438. /**
  117439. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  117440. */
  117441. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  117442. /**
  117443. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  117444. */
  117445. useRoughnessFromMetallicTextureAlpha: boolean;
  117446. /**
  117447. * Specifies if the metallic texture contains the roughness information in its green channel.
  117448. */
  117449. useRoughnessFromMetallicTextureGreen: boolean;
  117450. /**
  117451. * Specifies if the metallic texture contains the metallness information in its blue channel.
  117452. */
  117453. useMetallnessFromMetallicTextureBlue: boolean;
  117454. /**
  117455. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  117456. */
  117457. useAmbientOcclusionFromMetallicTextureRed: boolean;
  117458. /**
  117459. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  117460. */
  117461. useAmbientInGrayScale: boolean;
  117462. /**
  117463. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  117464. * The material will try to infer what glossiness each pixel should be.
  117465. */
  117466. useAutoMicroSurfaceFromReflectivityMap: boolean;
  117467. /**
  117468. * BJS is using an harcoded light falloff based on a manually sets up range.
  117469. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117470. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117471. */
  117472. /**
  117473. * BJS is using an harcoded light falloff based on a manually sets up range.
  117474. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  117475. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  117476. */
  117477. usePhysicalLightFalloff: boolean;
  117478. /**
  117479. * In order to support the falloff compatibility with gltf, a special mode has been added
  117480. * to reproduce the gltf light falloff.
  117481. */
  117482. /**
  117483. * In order to support the falloff compatibility with gltf, a special mode has been added
  117484. * to reproduce the gltf light falloff.
  117485. */
  117486. useGLTFLightFalloff: boolean;
  117487. /**
  117488. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  117489. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  117490. */
  117491. useRadianceOverAlpha: boolean;
  117492. /**
  117493. * Allows using an object space normal map (instead of tangent space).
  117494. */
  117495. useObjectSpaceNormalMap: boolean;
  117496. /**
  117497. * Allows using the bump map in parallax mode.
  117498. */
  117499. useParallax: boolean;
  117500. /**
  117501. * Allows using the bump map in parallax occlusion mode.
  117502. */
  117503. useParallaxOcclusion: boolean;
  117504. /**
  117505. * Controls the scale bias of the parallax mode.
  117506. */
  117507. parallaxScaleBias: number;
  117508. /**
  117509. * If sets to true, disables all the lights affecting the material.
  117510. */
  117511. disableLighting: boolean;
  117512. /**
  117513. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  117514. */
  117515. forceIrradianceInFragment: boolean;
  117516. /**
  117517. * Number of Simultaneous lights allowed on the material.
  117518. */
  117519. maxSimultaneousLights: number;
  117520. /**
  117521. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  117522. */
  117523. invertNormalMapX: boolean;
  117524. /**
  117525. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  117526. */
  117527. invertNormalMapY: boolean;
  117528. /**
  117529. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117530. */
  117531. twoSidedLighting: boolean;
  117532. /**
  117533. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117534. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  117535. */
  117536. useAlphaFresnel: boolean;
  117537. /**
  117538. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  117539. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  117540. */
  117541. useLinearAlphaFresnel: boolean;
  117542. /**
  117543. * Let user defines the brdf lookup texture used for IBL.
  117544. * A default 8bit version is embedded but you could point at :
  117545. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  117546. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  117547. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  117548. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  117549. */
  117550. environmentBRDFTexture: Nullable<BaseTexture>;
  117551. /**
  117552. * Force normal to face away from face.
  117553. */
  117554. forceNormalForward: boolean;
  117555. /**
  117556. * Enables specular anti aliasing in the PBR shader.
  117557. * It will both interacts on the Geometry for analytical and IBL lighting.
  117558. * It also prefilter the roughness map based on the bump values.
  117559. */
  117560. enableSpecularAntiAliasing: boolean;
  117561. /**
  117562. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  117563. * makes the reflect vector face the model (under horizon).
  117564. */
  117565. useHorizonOcclusion: boolean;
  117566. /**
  117567. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  117568. * too much the area relying on ambient texture to define their ambient occlusion.
  117569. */
  117570. useRadianceOcclusion: boolean;
  117571. /**
  117572. * If set to true, no lighting calculations will be applied.
  117573. */
  117574. unlit: boolean;
  117575. /**
  117576. * Gets the image processing configuration used either in this material.
  117577. */
  117578. /**
  117579. * Sets the Default image processing configuration used either in the this material.
  117580. *
  117581. * If sets to null, the scene one is in use.
  117582. */
  117583. imageProcessingConfiguration: ImageProcessingConfiguration;
  117584. /**
  117585. * Gets wether the color curves effect is enabled.
  117586. */
  117587. /**
  117588. * Sets wether the color curves effect is enabled.
  117589. */
  117590. cameraColorCurvesEnabled: boolean;
  117591. /**
  117592. * Gets wether the color grading effect is enabled.
  117593. */
  117594. /**
  117595. * Gets wether the color grading effect is enabled.
  117596. */
  117597. cameraColorGradingEnabled: boolean;
  117598. /**
  117599. * Gets wether tonemapping is enabled or not.
  117600. */
  117601. /**
  117602. * Sets wether tonemapping is enabled or not
  117603. */
  117604. cameraToneMappingEnabled: boolean;
  117605. /**
  117606. * The camera exposure used on this material.
  117607. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117608. * This corresponds to a photographic exposure.
  117609. */
  117610. /**
  117611. * The camera exposure used on this material.
  117612. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  117613. * This corresponds to a photographic exposure.
  117614. */
  117615. cameraExposure: number;
  117616. /**
  117617. * Gets The camera contrast used on this material.
  117618. */
  117619. /**
  117620. * Sets The camera contrast used on this material.
  117621. */
  117622. cameraContrast: number;
  117623. /**
  117624. * Gets the Color Grading 2D Lookup Texture.
  117625. */
  117626. /**
  117627. * Sets the Color Grading 2D Lookup Texture.
  117628. */
  117629. cameraColorGradingTexture: Nullable<BaseTexture>;
  117630. /**
  117631. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117632. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117633. * 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;
  117634. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117635. */
  117636. /**
  117637. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  117638. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  117639. * 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;
  117640. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  117641. */
  117642. cameraColorCurves: Nullable<ColorCurves>;
  117643. /**
  117644. * Instantiates a new PBRMaterial instance.
  117645. *
  117646. * @param name The material name
  117647. * @param scene The scene the material will be use in.
  117648. */
  117649. constructor(name: string, scene: Scene);
  117650. /**
  117651. * Returns the name of this material class.
  117652. */
  117653. getClassName(): string;
  117654. /**
  117655. * Makes a duplicate of the current material.
  117656. * @param name - name to use for the new material.
  117657. */
  117658. clone(name: string): PBRMaterial;
  117659. /**
  117660. * Serializes this PBR Material.
  117661. * @returns - An object with the serialized material.
  117662. */
  117663. serialize(): any;
  117664. /**
  117665. * Parses a PBR Material from a serialized object.
  117666. * @param source - Serialized object.
  117667. * @param scene - BJS scene instance.
  117668. * @param rootUrl - url for the scene object
  117669. * @returns - PBRMaterial
  117670. */
  117671. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  117672. }
  117673. }
  117674. declare module BABYLON {
  117675. /**
  117676. * Direct draw surface info
  117677. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  117678. */
  117679. export interface DDSInfo {
  117680. /**
  117681. * Width of the texture
  117682. */
  117683. width: number;
  117684. /**
  117685. * Width of the texture
  117686. */
  117687. height: number;
  117688. /**
  117689. * Number of Mipmaps for the texture
  117690. * @see https://en.wikipedia.org/wiki/Mipmap
  117691. */
  117692. mipmapCount: number;
  117693. /**
  117694. * If the textures format is a known fourCC format
  117695. * @see https://www.fourcc.org/
  117696. */
  117697. isFourCC: boolean;
  117698. /**
  117699. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  117700. */
  117701. isRGB: boolean;
  117702. /**
  117703. * If the texture is a lumincance format
  117704. */
  117705. isLuminance: boolean;
  117706. /**
  117707. * If this is a cube texture
  117708. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  117709. */
  117710. isCube: boolean;
  117711. /**
  117712. * If the texture is a compressed format eg. FOURCC_DXT1
  117713. */
  117714. isCompressed: boolean;
  117715. /**
  117716. * The dxgiFormat of the texture
  117717. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  117718. */
  117719. dxgiFormat: number;
  117720. /**
  117721. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  117722. */
  117723. textureType: number;
  117724. /**
  117725. * Sphericle polynomial created for the dds texture
  117726. */
  117727. sphericalPolynomial?: SphericalPolynomial;
  117728. }
  117729. /**
  117730. * Class used to provide DDS decompression tools
  117731. */
  117732. export class DDSTools {
  117733. /**
  117734. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  117735. */
  117736. static StoreLODInAlphaChannel: boolean;
  117737. /**
  117738. * Gets DDS information from an array buffer
  117739. * @param arrayBuffer defines the array buffer to read data from
  117740. * @returns the DDS information
  117741. */
  117742. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  117743. private static _FloatView;
  117744. private static _Int32View;
  117745. private static _ToHalfFloat;
  117746. private static _FromHalfFloat;
  117747. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  117748. private static _GetHalfFloatRGBAArrayBuffer;
  117749. private static _GetFloatRGBAArrayBuffer;
  117750. private static _GetFloatAsUIntRGBAArrayBuffer;
  117751. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  117752. private static _GetRGBAArrayBuffer;
  117753. private static _ExtractLongWordOrder;
  117754. private static _GetRGBArrayBuffer;
  117755. private static _GetLuminanceArrayBuffer;
  117756. /**
  117757. * Uploads DDS Levels to a Babylon Texture
  117758. * @hidden
  117759. */
  117760. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  117761. }
  117762. interface ThinEngine {
  117763. /**
  117764. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  117765. * @param rootUrl defines the url where the file to load is located
  117766. * @param scene defines the current scene
  117767. * @param lodScale defines scale to apply to the mip map selection
  117768. * @param lodOffset defines offset to apply to the mip map selection
  117769. * @param onLoad defines an optional callback raised when the texture is loaded
  117770. * @param onError defines an optional callback raised if there is an issue to load the texture
  117771. * @param format defines the format of the data
  117772. * @param forcedExtension defines the extension to use to pick the right loader
  117773. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  117774. * @returns the cube texture as an InternalTexture
  117775. */
  117776. 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;
  117777. }
  117778. }
  117779. declare module BABYLON {
  117780. /**
  117781. * Implementation of the DDS Texture Loader.
  117782. * @hidden
  117783. */
  117784. export class _DDSTextureLoader implements IInternalTextureLoader {
  117785. /**
  117786. * Defines wether the loader supports cascade loading the different faces.
  117787. */
  117788. readonly supportCascades: boolean;
  117789. /**
  117790. * This returns if the loader support the current file information.
  117791. * @param extension defines the file extension of the file being loaded
  117792. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117793. * @param fallback defines the fallback internal texture if any
  117794. * @param isBase64 defines whether the texture is encoded as a base64
  117795. * @param isBuffer defines whether the texture data are stored as a buffer
  117796. * @returns true if the loader can load the specified file
  117797. */
  117798. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117799. /**
  117800. * Transform the url before loading if required.
  117801. * @param rootUrl the url of the texture
  117802. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117803. * @returns the transformed texture
  117804. */
  117805. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117806. /**
  117807. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117808. * @param rootUrl the url of the texture
  117809. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117810. * @returns the fallback texture
  117811. */
  117812. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117813. /**
  117814. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117815. * @param data contains the texture data
  117816. * @param texture defines the BabylonJS internal texture
  117817. * @param createPolynomials will be true if polynomials have been requested
  117818. * @param onLoad defines the callback to trigger once the texture is ready
  117819. * @param onError defines the callback to trigger in case of error
  117820. */
  117821. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117822. /**
  117823. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117824. * @param data contains the texture data
  117825. * @param texture defines the BabylonJS internal texture
  117826. * @param callback defines the method to call once ready to upload
  117827. */
  117828. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117829. }
  117830. }
  117831. declare module BABYLON {
  117832. /**
  117833. * Implementation of the ENV Texture Loader.
  117834. * @hidden
  117835. */
  117836. export class _ENVTextureLoader implements IInternalTextureLoader {
  117837. /**
  117838. * Defines wether the loader supports cascade loading the different faces.
  117839. */
  117840. readonly supportCascades: boolean;
  117841. /**
  117842. * This returns if the loader support the current file information.
  117843. * @param extension defines the file extension of the file being loaded
  117844. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117845. * @param fallback defines the fallback internal texture if any
  117846. * @param isBase64 defines whether the texture is encoded as a base64
  117847. * @param isBuffer defines whether the texture data are stored as a buffer
  117848. * @returns true if the loader can load the specified file
  117849. */
  117850. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117851. /**
  117852. * Transform the url before loading if required.
  117853. * @param rootUrl the url of the texture
  117854. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117855. * @returns the transformed texture
  117856. */
  117857. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117858. /**
  117859. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117860. * @param rootUrl the url of the texture
  117861. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117862. * @returns the fallback texture
  117863. */
  117864. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117865. /**
  117866. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117867. * @param data contains the texture data
  117868. * @param texture defines the BabylonJS internal texture
  117869. * @param createPolynomials will be true if polynomials have been requested
  117870. * @param onLoad defines the callback to trigger once the texture is ready
  117871. * @param onError defines the callback to trigger in case of error
  117872. */
  117873. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117874. /**
  117875. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117876. * @param data contains the texture data
  117877. * @param texture defines the BabylonJS internal texture
  117878. * @param callback defines the method to call once ready to upload
  117879. */
  117880. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117881. }
  117882. }
  117883. declare module BABYLON {
  117884. /**
  117885. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  117886. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  117887. */
  117888. export class KhronosTextureContainer {
  117889. /** contents of the KTX container file */
  117890. arrayBuffer: any;
  117891. private static HEADER_LEN;
  117892. private static COMPRESSED_2D;
  117893. private static COMPRESSED_3D;
  117894. private static TEX_2D;
  117895. private static TEX_3D;
  117896. /**
  117897. * Gets the openGL type
  117898. */
  117899. glType: number;
  117900. /**
  117901. * Gets the openGL type size
  117902. */
  117903. glTypeSize: number;
  117904. /**
  117905. * Gets the openGL format
  117906. */
  117907. glFormat: number;
  117908. /**
  117909. * Gets the openGL internal format
  117910. */
  117911. glInternalFormat: number;
  117912. /**
  117913. * Gets the base internal format
  117914. */
  117915. glBaseInternalFormat: number;
  117916. /**
  117917. * Gets image width in pixel
  117918. */
  117919. pixelWidth: number;
  117920. /**
  117921. * Gets image height in pixel
  117922. */
  117923. pixelHeight: number;
  117924. /**
  117925. * Gets image depth in pixels
  117926. */
  117927. pixelDepth: number;
  117928. /**
  117929. * Gets the number of array elements
  117930. */
  117931. numberOfArrayElements: number;
  117932. /**
  117933. * Gets the number of faces
  117934. */
  117935. numberOfFaces: number;
  117936. /**
  117937. * Gets the number of mipmap levels
  117938. */
  117939. numberOfMipmapLevels: number;
  117940. /**
  117941. * Gets the bytes of key value data
  117942. */
  117943. bytesOfKeyValueData: number;
  117944. /**
  117945. * Gets the load type
  117946. */
  117947. loadType: number;
  117948. /**
  117949. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  117950. */
  117951. isInvalid: boolean;
  117952. /**
  117953. * Creates a new KhronosTextureContainer
  117954. * @param arrayBuffer contents of the KTX container file
  117955. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  117956. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  117957. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  117958. */
  117959. constructor(
  117960. /** contents of the KTX container file */
  117961. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  117962. /**
  117963. * Uploads KTX content to a Babylon Texture.
  117964. * It is assumed that the texture has already been created & is currently bound
  117965. * @hidden
  117966. */
  117967. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  117968. private _upload2DCompressedLevels;
  117969. }
  117970. }
  117971. declare module BABYLON {
  117972. /**
  117973. * Implementation of the KTX Texture Loader.
  117974. * @hidden
  117975. */
  117976. export class _KTXTextureLoader implements IInternalTextureLoader {
  117977. /**
  117978. * Defines wether the loader supports cascade loading the different faces.
  117979. */
  117980. readonly supportCascades: boolean;
  117981. /**
  117982. * This returns if the loader support the current file information.
  117983. * @param extension defines the file extension of the file being loaded
  117984. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117985. * @param fallback defines the fallback internal texture if any
  117986. * @param isBase64 defines whether the texture is encoded as a base64
  117987. * @param isBuffer defines whether the texture data are stored as a buffer
  117988. * @returns true if the loader can load the specified file
  117989. */
  117990. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117991. /**
  117992. * Transform the url before loading if required.
  117993. * @param rootUrl the url of the texture
  117994. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117995. * @returns the transformed texture
  117996. */
  117997. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117998. /**
  117999. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118000. * @param rootUrl the url of the texture
  118001. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118002. * @returns the fallback texture
  118003. */
  118004. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118005. /**
  118006. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118007. * @param data contains the texture data
  118008. * @param texture defines the BabylonJS internal texture
  118009. * @param createPolynomials will be true if polynomials have been requested
  118010. * @param onLoad defines the callback to trigger once the texture is ready
  118011. * @param onError defines the callback to trigger in case of error
  118012. */
  118013. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118014. /**
  118015. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118016. * @param data contains the texture data
  118017. * @param texture defines the BabylonJS internal texture
  118018. * @param callback defines the method to call once ready to upload
  118019. */
  118020. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  118021. }
  118022. }
  118023. declare module BABYLON {
  118024. /** @hidden */
  118025. export var _forceSceneHelpersToBundle: boolean;
  118026. interface Scene {
  118027. /**
  118028. * Creates a default light for the scene.
  118029. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  118030. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  118031. */
  118032. createDefaultLight(replace?: boolean): void;
  118033. /**
  118034. * Creates a default camera for the scene.
  118035. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  118036. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118037. * @param replace has default false, when true replaces the active camera in the scene
  118038. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  118039. */
  118040. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118041. /**
  118042. * Creates a default camera and a default light.
  118043. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  118044. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  118045. * @param replace has the default false, when true replaces the active camera/light in the scene
  118046. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  118047. */
  118048. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  118049. /**
  118050. * Creates a new sky box
  118051. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  118052. * @param environmentTexture defines the texture to use as environment texture
  118053. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  118054. * @param scale defines the overall scale of the skybox
  118055. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  118056. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  118057. * @returns a new mesh holding the sky box
  118058. */
  118059. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  118060. /**
  118061. * Creates a new environment
  118062. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  118063. * @param options defines the options you can use to configure the environment
  118064. * @returns the new EnvironmentHelper
  118065. */
  118066. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  118067. /**
  118068. * Creates a new VREXperienceHelper
  118069. * @see http://doc.babylonjs.com/how_to/webvr_helper
  118070. * @param webVROptions defines the options used to create the new VREXperienceHelper
  118071. * @returns a new VREXperienceHelper
  118072. */
  118073. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  118074. /**
  118075. * Creates a new WebXRDefaultExperience
  118076. * @see http://doc.babylonjs.com/how_to/webxr
  118077. * @param options experience options
  118078. * @returns a promise for a new WebXRDefaultExperience
  118079. */
  118080. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118081. }
  118082. }
  118083. declare module BABYLON {
  118084. /**
  118085. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  118086. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  118087. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  118088. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  118089. */
  118090. export class VideoDome extends TransformNode {
  118091. /**
  118092. * Define the video source as a Monoscopic panoramic 360 video.
  118093. */
  118094. static readonly MODE_MONOSCOPIC: number;
  118095. /**
  118096. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  118097. */
  118098. static readonly MODE_TOPBOTTOM: number;
  118099. /**
  118100. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  118101. */
  118102. static readonly MODE_SIDEBYSIDE: number;
  118103. private _halfDome;
  118104. private _useDirectMapping;
  118105. /**
  118106. * The video texture being displayed on the sphere
  118107. */
  118108. protected _videoTexture: VideoTexture;
  118109. /**
  118110. * Gets the video texture being displayed on the sphere
  118111. */
  118112. readonly videoTexture: VideoTexture;
  118113. /**
  118114. * The skybox material
  118115. */
  118116. protected _material: BackgroundMaterial;
  118117. /**
  118118. * The surface used for the skybox
  118119. */
  118120. protected _mesh: Mesh;
  118121. /**
  118122. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  118123. */
  118124. private _halfDomeMask;
  118125. /**
  118126. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  118127. * Also see the options.resolution property.
  118128. */
  118129. fovMultiplier: number;
  118130. private _videoMode;
  118131. /**
  118132. * Gets or set the current video mode for the video. It can be:
  118133. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  118134. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  118135. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  118136. */
  118137. videoMode: number;
  118138. /**
  118139. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  118140. *
  118141. */
  118142. /**
  118143. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  118144. */
  118145. halfDome: boolean;
  118146. /**
  118147. * Oberserver used in Stereoscopic VR Mode.
  118148. */
  118149. private _onBeforeCameraRenderObserver;
  118150. /**
  118151. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  118152. * @param name Element's name, child elements will append suffixes for their own names.
  118153. * @param urlsOrVideo defines the url(s) or the video element to use
  118154. * @param options An object containing optional or exposed sub element properties
  118155. */
  118156. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  118157. resolution?: number;
  118158. clickToPlay?: boolean;
  118159. autoPlay?: boolean;
  118160. loop?: boolean;
  118161. size?: number;
  118162. poster?: string;
  118163. faceForward?: boolean;
  118164. useDirectMapping?: boolean;
  118165. halfDomeMode?: boolean;
  118166. }, scene: Scene);
  118167. private _changeVideoMode;
  118168. /**
  118169. * Releases resources associated with this node.
  118170. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118171. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118172. */
  118173. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118174. }
  118175. }
  118176. declare module BABYLON {
  118177. /**
  118178. * This class can be used to get instrumentation data from a Babylon engine
  118179. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118180. */
  118181. export class EngineInstrumentation implements IDisposable {
  118182. /**
  118183. * Define the instrumented engine.
  118184. */
  118185. engine: Engine;
  118186. private _captureGPUFrameTime;
  118187. private _gpuFrameTimeToken;
  118188. private _gpuFrameTime;
  118189. private _captureShaderCompilationTime;
  118190. private _shaderCompilationTime;
  118191. private _onBeginFrameObserver;
  118192. private _onEndFrameObserver;
  118193. private _onBeforeShaderCompilationObserver;
  118194. private _onAfterShaderCompilationObserver;
  118195. /**
  118196. * Gets the perf counter used for GPU frame time
  118197. */
  118198. readonly gpuFrameTimeCounter: PerfCounter;
  118199. /**
  118200. * Gets the GPU frame time capture status
  118201. */
  118202. /**
  118203. * Enable or disable the GPU frame time capture
  118204. */
  118205. captureGPUFrameTime: boolean;
  118206. /**
  118207. * Gets the perf counter used for shader compilation time
  118208. */
  118209. readonly shaderCompilationTimeCounter: PerfCounter;
  118210. /**
  118211. * Gets the shader compilation time capture status
  118212. */
  118213. /**
  118214. * Enable or disable the shader compilation time capture
  118215. */
  118216. captureShaderCompilationTime: boolean;
  118217. /**
  118218. * Instantiates a new engine instrumentation.
  118219. * This class can be used to get instrumentation data from a Babylon engine
  118220. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118221. * @param engine Defines the engine to instrument
  118222. */
  118223. constructor(
  118224. /**
  118225. * Define the instrumented engine.
  118226. */
  118227. engine: Engine);
  118228. /**
  118229. * Dispose and release associated resources.
  118230. */
  118231. dispose(): void;
  118232. }
  118233. }
  118234. declare module BABYLON {
  118235. /**
  118236. * This class can be used to get instrumentation data from a Babylon engine
  118237. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118238. */
  118239. export class SceneInstrumentation implements IDisposable {
  118240. /**
  118241. * Defines the scene to instrument
  118242. */
  118243. scene: Scene;
  118244. private _captureActiveMeshesEvaluationTime;
  118245. private _activeMeshesEvaluationTime;
  118246. private _captureRenderTargetsRenderTime;
  118247. private _renderTargetsRenderTime;
  118248. private _captureFrameTime;
  118249. private _frameTime;
  118250. private _captureRenderTime;
  118251. private _renderTime;
  118252. private _captureInterFrameTime;
  118253. private _interFrameTime;
  118254. private _captureParticlesRenderTime;
  118255. private _particlesRenderTime;
  118256. private _captureSpritesRenderTime;
  118257. private _spritesRenderTime;
  118258. private _capturePhysicsTime;
  118259. private _physicsTime;
  118260. private _captureAnimationsTime;
  118261. private _animationsTime;
  118262. private _captureCameraRenderTime;
  118263. private _cameraRenderTime;
  118264. private _onBeforeActiveMeshesEvaluationObserver;
  118265. private _onAfterActiveMeshesEvaluationObserver;
  118266. private _onBeforeRenderTargetsRenderObserver;
  118267. private _onAfterRenderTargetsRenderObserver;
  118268. private _onAfterRenderObserver;
  118269. private _onBeforeDrawPhaseObserver;
  118270. private _onAfterDrawPhaseObserver;
  118271. private _onBeforeAnimationsObserver;
  118272. private _onBeforeParticlesRenderingObserver;
  118273. private _onAfterParticlesRenderingObserver;
  118274. private _onBeforeSpritesRenderingObserver;
  118275. private _onAfterSpritesRenderingObserver;
  118276. private _onBeforePhysicsObserver;
  118277. private _onAfterPhysicsObserver;
  118278. private _onAfterAnimationsObserver;
  118279. private _onBeforeCameraRenderObserver;
  118280. private _onAfterCameraRenderObserver;
  118281. /**
  118282. * Gets the perf counter used for active meshes evaluation time
  118283. */
  118284. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  118285. /**
  118286. * Gets the active meshes evaluation time capture status
  118287. */
  118288. /**
  118289. * Enable or disable the active meshes evaluation time capture
  118290. */
  118291. captureActiveMeshesEvaluationTime: boolean;
  118292. /**
  118293. * Gets the perf counter used for render targets render time
  118294. */
  118295. readonly renderTargetsRenderTimeCounter: PerfCounter;
  118296. /**
  118297. * Gets the render targets render time capture status
  118298. */
  118299. /**
  118300. * Enable or disable the render targets render time capture
  118301. */
  118302. captureRenderTargetsRenderTime: boolean;
  118303. /**
  118304. * Gets the perf counter used for particles render time
  118305. */
  118306. readonly particlesRenderTimeCounter: PerfCounter;
  118307. /**
  118308. * Gets the particles render time capture status
  118309. */
  118310. /**
  118311. * Enable or disable the particles render time capture
  118312. */
  118313. captureParticlesRenderTime: boolean;
  118314. /**
  118315. * Gets the perf counter used for sprites render time
  118316. */
  118317. readonly spritesRenderTimeCounter: PerfCounter;
  118318. /**
  118319. * Gets the sprites render time capture status
  118320. */
  118321. /**
  118322. * Enable or disable the sprites render time capture
  118323. */
  118324. captureSpritesRenderTime: boolean;
  118325. /**
  118326. * Gets the perf counter used for physics time
  118327. */
  118328. readonly physicsTimeCounter: PerfCounter;
  118329. /**
  118330. * Gets the physics time capture status
  118331. */
  118332. /**
  118333. * Enable or disable the physics time capture
  118334. */
  118335. capturePhysicsTime: boolean;
  118336. /**
  118337. * Gets the perf counter used for animations time
  118338. */
  118339. readonly animationsTimeCounter: PerfCounter;
  118340. /**
  118341. * Gets the animations time capture status
  118342. */
  118343. /**
  118344. * Enable or disable the animations time capture
  118345. */
  118346. captureAnimationsTime: boolean;
  118347. /**
  118348. * Gets the perf counter used for frame time capture
  118349. */
  118350. readonly frameTimeCounter: PerfCounter;
  118351. /**
  118352. * Gets the frame time capture status
  118353. */
  118354. /**
  118355. * Enable or disable the frame time capture
  118356. */
  118357. captureFrameTime: boolean;
  118358. /**
  118359. * Gets the perf counter used for inter-frames time capture
  118360. */
  118361. readonly interFrameTimeCounter: PerfCounter;
  118362. /**
  118363. * Gets the inter-frames time capture status
  118364. */
  118365. /**
  118366. * Enable or disable the inter-frames time capture
  118367. */
  118368. captureInterFrameTime: boolean;
  118369. /**
  118370. * Gets the perf counter used for render time capture
  118371. */
  118372. readonly renderTimeCounter: PerfCounter;
  118373. /**
  118374. * Gets the render time capture status
  118375. */
  118376. /**
  118377. * Enable or disable the render time capture
  118378. */
  118379. captureRenderTime: boolean;
  118380. /**
  118381. * Gets the perf counter used for camera render time capture
  118382. */
  118383. readonly cameraRenderTimeCounter: PerfCounter;
  118384. /**
  118385. * Gets the camera render time capture status
  118386. */
  118387. /**
  118388. * Enable or disable the camera render time capture
  118389. */
  118390. captureCameraRenderTime: boolean;
  118391. /**
  118392. * Gets the perf counter used for draw calls
  118393. */
  118394. readonly drawCallsCounter: PerfCounter;
  118395. /**
  118396. * Instantiates a new scene instrumentation.
  118397. * This class can be used to get instrumentation data from a Babylon engine
  118398. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  118399. * @param scene Defines the scene to instrument
  118400. */
  118401. constructor(
  118402. /**
  118403. * Defines the scene to instrument
  118404. */
  118405. scene: Scene);
  118406. /**
  118407. * Dispose and release associated resources.
  118408. */
  118409. dispose(): void;
  118410. }
  118411. }
  118412. declare module BABYLON {
  118413. /** @hidden */
  118414. export var glowMapGenerationPixelShader: {
  118415. name: string;
  118416. shader: string;
  118417. };
  118418. }
  118419. declare module BABYLON {
  118420. /** @hidden */
  118421. export var glowMapGenerationVertexShader: {
  118422. name: string;
  118423. shader: string;
  118424. };
  118425. }
  118426. declare module BABYLON {
  118427. /**
  118428. * Effect layer options. This helps customizing the behaviour
  118429. * of the effect layer.
  118430. */
  118431. export interface IEffectLayerOptions {
  118432. /**
  118433. * Multiplication factor apply to the canvas size to compute the render target size
  118434. * used to generated the objects (the smaller the faster).
  118435. */
  118436. mainTextureRatio: number;
  118437. /**
  118438. * Enforces a fixed size texture to ensure effect stability across devices.
  118439. */
  118440. mainTextureFixedSize?: number;
  118441. /**
  118442. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  118443. */
  118444. alphaBlendingMode: number;
  118445. /**
  118446. * The camera attached to the layer.
  118447. */
  118448. camera: Nullable<Camera>;
  118449. /**
  118450. * The rendering group to draw the layer in.
  118451. */
  118452. renderingGroupId: number;
  118453. }
  118454. /**
  118455. * The effect layer Helps adding post process effect blended with the main pass.
  118456. *
  118457. * This can be for instance use to generate glow or higlight effects on the scene.
  118458. *
  118459. * The effect layer class can not be used directly and is intented to inherited from to be
  118460. * customized per effects.
  118461. */
  118462. export abstract class EffectLayer {
  118463. private _vertexBuffers;
  118464. private _indexBuffer;
  118465. private _cachedDefines;
  118466. private _effectLayerMapGenerationEffect;
  118467. private _effectLayerOptions;
  118468. private _mergeEffect;
  118469. protected _scene: Scene;
  118470. protected _engine: Engine;
  118471. protected _maxSize: number;
  118472. protected _mainTextureDesiredSize: ISize;
  118473. protected _mainTexture: RenderTargetTexture;
  118474. protected _shouldRender: boolean;
  118475. protected _postProcesses: PostProcess[];
  118476. protected _textures: BaseTexture[];
  118477. protected _emissiveTextureAndColor: {
  118478. texture: Nullable<BaseTexture>;
  118479. color: Color4;
  118480. };
  118481. /**
  118482. * The name of the layer
  118483. */
  118484. name: string;
  118485. /**
  118486. * The clear color of the texture used to generate the glow map.
  118487. */
  118488. neutralColor: Color4;
  118489. /**
  118490. * Specifies wether the highlight layer is enabled or not.
  118491. */
  118492. isEnabled: boolean;
  118493. /**
  118494. * Gets the camera attached to the layer.
  118495. */
  118496. readonly camera: Nullable<Camera>;
  118497. /**
  118498. * Gets the rendering group id the layer should render in.
  118499. */
  118500. renderingGroupId: number;
  118501. /**
  118502. * An event triggered when the effect layer has been disposed.
  118503. */
  118504. onDisposeObservable: Observable<EffectLayer>;
  118505. /**
  118506. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  118507. */
  118508. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  118509. /**
  118510. * An event triggered when the generated texture is being merged in the scene.
  118511. */
  118512. onBeforeComposeObservable: Observable<EffectLayer>;
  118513. /**
  118514. * An event triggered when the mesh is rendered into the effect render target.
  118515. */
  118516. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  118517. /**
  118518. * An event triggered after the mesh has been rendered into the effect render target.
  118519. */
  118520. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  118521. /**
  118522. * An event triggered when the generated texture has been merged in the scene.
  118523. */
  118524. onAfterComposeObservable: Observable<EffectLayer>;
  118525. /**
  118526. * An event triggered when the efffect layer changes its size.
  118527. */
  118528. onSizeChangedObservable: Observable<EffectLayer>;
  118529. /** @hidden */
  118530. static _SceneComponentInitialization: (scene: Scene) => void;
  118531. /**
  118532. * Instantiates a new effect Layer and references it in the scene.
  118533. * @param name The name of the layer
  118534. * @param scene The scene to use the layer in
  118535. */
  118536. constructor(
  118537. /** The Friendly of the effect in the scene */
  118538. name: string, scene: Scene);
  118539. /**
  118540. * Get the effect name of the layer.
  118541. * @return The effect name
  118542. */
  118543. abstract getEffectName(): string;
  118544. /**
  118545. * Checks for the readiness of the element composing the layer.
  118546. * @param subMesh the mesh to check for
  118547. * @param useInstances specify wether or not to use instances to render the mesh
  118548. * @return true if ready otherwise, false
  118549. */
  118550. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118551. /**
  118552. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118553. * @returns true if the effect requires stencil during the main canvas render pass.
  118554. */
  118555. abstract needStencil(): boolean;
  118556. /**
  118557. * Create the merge effect. This is the shader use to blit the information back
  118558. * to the main canvas at the end of the scene rendering.
  118559. * @returns The effect containing the shader used to merge the effect on the main canvas
  118560. */
  118561. protected abstract _createMergeEffect(): Effect;
  118562. /**
  118563. * Creates the render target textures and post processes used in the effect layer.
  118564. */
  118565. protected abstract _createTextureAndPostProcesses(): void;
  118566. /**
  118567. * Implementation specific of rendering the generating effect on the main canvas.
  118568. * @param effect The effect used to render through
  118569. */
  118570. protected abstract _internalRender(effect: Effect): void;
  118571. /**
  118572. * Sets the required values for both the emissive texture and and the main color.
  118573. */
  118574. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118575. /**
  118576. * Free any resources and references associated to a mesh.
  118577. * Internal use
  118578. * @param mesh The mesh to free.
  118579. */
  118580. abstract _disposeMesh(mesh: Mesh): void;
  118581. /**
  118582. * Serializes this layer (Glow or Highlight for example)
  118583. * @returns a serialized layer object
  118584. */
  118585. abstract serialize?(): any;
  118586. /**
  118587. * Initializes the effect layer with the required options.
  118588. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  118589. */
  118590. protected _init(options: Partial<IEffectLayerOptions>): void;
  118591. /**
  118592. * Generates the index buffer of the full screen quad blending to the main canvas.
  118593. */
  118594. private _generateIndexBuffer;
  118595. /**
  118596. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  118597. */
  118598. private _generateVertexBuffer;
  118599. /**
  118600. * Sets the main texture desired size which is the closest power of two
  118601. * of the engine canvas size.
  118602. */
  118603. private _setMainTextureSize;
  118604. /**
  118605. * Creates the main texture for the effect layer.
  118606. */
  118607. protected _createMainTexture(): void;
  118608. /**
  118609. * Adds specific effects defines.
  118610. * @param defines The defines to add specifics to.
  118611. */
  118612. protected _addCustomEffectDefines(defines: string[]): void;
  118613. /**
  118614. * Checks for the readiness of the element composing the layer.
  118615. * @param subMesh the mesh to check for
  118616. * @param useInstances specify wether or not to use instances to render the mesh
  118617. * @param emissiveTexture the associated emissive texture used to generate the glow
  118618. * @return true if ready otherwise, false
  118619. */
  118620. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  118621. /**
  118622. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  118623. */
  118624. render(): void;
  118625. /**
  118626. * Determine if a given mesh will be used in the current effect.
  118627. * @param mesh mesh to test
  118628. * @returns true if the mesh will be used
  118629. */
  118630. hasMesh(mesh: AbstractMesh): boolean;
  118631. /**
  118632. * Returns true if the layer contains information to display, otherwise false.
  118633. * @returns true if the glow layer should be rendered
  118634. */
  118635. shouldRender(): boolean;
  118636. /**
  118637. * Returns true if the mesh should render, otherwise false.
  118638. * @param mesh The mesh to render
  118639. * @returns true if it should render otherwise false
  118640. */
  118641. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  118642. /**
  118643. * Returns true if the mesh can be rendered, otherwise false.
  118644. * @param mesh The mesh to render
  118645. * @param material The material used on the mesh
  118646. * @returns true if it can be rendered otherwise false
  118647. */
  118648. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118649. /**
  118650. * Returns true if the mesh should render, otherwise false.
  118651. * @param mesh The mesh to render
  118652. * @returns true if it should render otherwise false
  118653. */
  118654. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  118655. /**
  118656. * Renders the submesh passed in parameter to the generation map.
  118657. */
  118658. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  118659. /**
  118660. * Defines wether the current material of the mesh should be use to render the effect.
  118661. * @param mesh defines the current mesh to render
  118662. */
  118663. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118664. /**
  118665. * Rebuild the required buffers.
  118666. * @hidden Internal use only.
  118667. */
  118668. _rebuild(): void;
  118669. /**
  118670. * Dispose only the render target textures and post process.
  118671. */
  118672. private _disposeTextureAndPostProcesses;
  118673. /**
  118674. * Dispose the highlight layer and free resources.
  118675. */
  118676. dispose(): void;
  118677. /**
  118678. * Gets the class name of the effect layer
  118679. * @returns the string with the class name of the effect layer
  118680. */
  118681. getClassName(): string;
  118682. /**
  118683. * Creates an effect layer from parsed effect layer data
  118684. * @param parsedEffectLayer defines effect layer data
  118685. * @param scene defines the current scene
  118686. * @param rootUrl defines the root URL containing the effect layer information
  118687. * @returns a parsed effect Layer
  118688. */
  118689. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  118690. }
  118691. }
  118692. declare module BABYLON {
  118693. interface AbstractScene {
  118694. /**
  118695. * The list of effect layers (highlights/glow) added to the scene
  118696. * @see http://doc.babylonjs.com/how_to/highlight_layer
  118697. * @see http://doc.babylonjs.com/how_to/glow_layer
  118698. */
  118699. effectLayers: Array<EffectLayer>;
  118700. /**
  118701. * Removes the given effect layer from this scene.
  118702. * @param toRemove defines the effect layer to remove
  118703. * @returns the index of the removed effect layer
  118704. */
  118705. removeEffectLayer(toRemove: EffectLayer): number;
  118706. /**
  118707. * Adds the given effect layer to this scene
  118708. * @param newEffectLayer defines the effect layer to add
  118709. */
  118710. addEffectLayer(newEffectLayer: EffectLayer): void;
  118711. }
  118712. /**
  118713. * Defines the layer scene component responsible to manage any effect layers
  118714. * in a given scene.
  118715. */
  118716. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  118717. /**
  118718. * The component name helpfull to identify the component in the list of scene components.
  118719. */
  118720. readonly name: string;
  118721. /**
  118722. * The scene the component belongs to.
  118723. */
  118724. scene: Scene;
  118725. private _engine;
  118726. private _renderEffects;
  118727. private _needStencil;
  118728. private _previousStencilState;
  118729. /**
  118730. * Creates a new instance of the component for the given scene
  118731. * @param scene Defines the scene to register the component in
  118732. */
  118733. constructor(scene: Scene);
  118734. /**
  118735. * Registers the component in a given scene
  118736. */
  118737. register(): void;
  118738. /**
  118739. * Rebuilds the elements related to this component in case of
  118740. * context lost for instance.
  118741. */
  118742. rebuild(): void;
  118743. /**
  118744. * Serializes the component data to the specified json object
  118745. * @param serializationObject The object to serialize to
  118746. */
  118747. serialize(serializationObject: any): void;
  118748. /**
  118749. * Adds all the elements from the container to the scene
  118750. * @param container the container holding the elements
  118751. */
  118752. addFromContainer(container: AbstractScene): void;
  118753. /**
  118754. * Removes all the elements in the container from the scene
  118755. * @param container contains the elements to remove
  118756. * @param dispose if the removed element should be disposed (default: false)
  118757. */
  118758. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118759. /**
  118760. * Disposes the component and the associated ressources.
  118761. */
  118762. dispose(): void;
  118763. private _isReadyForMesh;
  118764. private _renderMainTexture;
  118765. private _setStencil;
  118766. private _setStencilBack;
  118767. private _draw;
  118768. private _drawCamera;
  118769. private _drawRenderingGroup;
  118770. }
  118771. }
  118772. declare module BABYLON {
  118773. /** @hidden */
  118774. export var glowMapMergePixelShader: {
  118775. name: string;
  118776. shader: string;
  118777. };
  118778. }
  118779. declare module BABYLON {
  118780. /** @hidden */
  118781. export var glowMapMergeVertexShader: {
  118782. name: string;
  118783. shader: string;
  118784. };
  118785. }
  118786. declare module BABYLON {
  118787. interface AbstractScene {
  118788. /**
  118789. * Return a the first highlight layer of the scene with a given name.
  118790. * @param name The name of the highlight layer to look for.
  118791. * @return The highlight layer if found otherwise null.
  118792. */
  118793. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  118794. }
  118795. /**
  118796. * Glow layer options. This helps customizing the behaviour
  118797. * of the glow layer.
  118798. */
  118799. export interface IGlowLayerOptions {
  118800. /**
  118801. * Multiplication factor apply to the canvas size to compute the render target size
  118802. * used to generated the glowing objects (the smaller the faster).
  118803. */
  118804. mainTextureRatio: number;
  118805. /**
  118806. * Enforces a fixed size texture to ensure resize independant blur.
  118807. */
  118808. mainTextureFixedSize?: number;
  118809. /**
  118810. * How big is the kernel of the blur texture.
  118811. */
  118812. blurKernelSize: number;
  118813. /**
  118814. * The camera attached to the layer.
  118815. */
  118816. camera: Nullable<Camera>;
  118817. /**
  118818. * Enable MSAA by chosing the number of samples.
  118819. */
  118820. mainTextureSamples?: number;
  118821. /**
  118822. * The rendering group to draw the layer in.
  118823. */
  118824. renderingGroupId: number;
  118825. }
  118826. /**
  118827. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  118828. *
  118829. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  118830. *
  118831. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  118832. */
  118833. export class GlowLayer extends EffectLayer {
  118834. /**
  118835. * Effect Name of the layer.
  118836. */
  118837. static readonly EffectName: string;
  118838. /**
  118839. * The default blur kernel size used for the glow.
  118840. */
  118841. static DefaultBlurKernelSize: number;
  118842. /**
  118843. * The default texture size ratio used for the glow.
  118844. */
  118845. static DefaultTextureRatio: number;
  118846. /**
  118847. * Sets the kernel size of the blur.
  118848. */
  118849. /**
  118850. * Gets the kernel size of the blur.
  118851. */
  118852. blurKernelSize: number;
  118853. /**
  118854. * Sets the glow intensity.
  118855. */
  118856. /**
  118857. * Gets the glow intensity.
  118858. */
  118859. intensity: number;
  118860. private _options;
  118861. private _intensity;
  118862. private _horizontalBlurPostprocess1;
  118863. private _verticalBlurPostprocess1;
  118864. private _horizontalBlurPostprocess2;
  118865. private _verticalBlurPostprocess2;
  118866. private _blurTexture1;
  118867. private _blurTexture2;
  118868. private _postProcesses1;
  118869. private _postProcesses2;
  118870. private _includedOnlyMeshes;
  118871. private _excludedMeshes;
  118872. private _meshesUsingTheirOwnMaterials;
  118873. /**
  118874. * Callback used to let the user override the color selection on a per mesh basis
  118875. */
  118876. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  118877. /**
  118878. * Callback used to let the user override the texture selection on a per mesh basis
  118879. */
  118880. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  118881. /**
  118882. * Instantiates a new glow Layer and references it to the scene.
  118883. * @param name The name of the layer
  118884. * @param scene The scene to use the layer in
  118885. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  118886. */
  118887. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  118888. /**
  118889. * Get the effect name of the layer.
  118890. * @return The effect name
  118891. */
  118892. getEffectName(): string;
  118893. /**
  118894. * Create the merge effect. This is the shader use to blit the information back
  118895. * to the main canvas at the end of the scene rendering.
  118896. */
  118897. protected _createMergeEffect(): Effect;
  118898. /**
  118899. * Creates the render target textures and post processes used in the glow layer.
  118900. */
  118901. protected _createTextureAndPostProcesses(): void;
  118902. /**
  118903. * Checks for the readiness of the element composing the layer.
  118904. * @param subMesh the mesh to check for
  118905. * @param useInstances specify wether or not to use instances to render the mesh
  118906. * @param emissiveTexture the associated emissive texture used to generate the glow
  118907. * @return true if ready otherwise, false
  118908. */
  118909. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118910. /**
  118911. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  118912. */
  118913. needStencil(): boolean;
  118914. /**
  118915. * Returns true if the mesh can be rendered, otherwise false.
  118916. * @param mesh The mesh to render
  118917. * @param material The material used on the mesh
  118918. * @returns true if it can be rendered otherwise false
  118919. */
  118920. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  118921. /**
  118922. * Implementation specific of rendering the generating effect on the main canvas.
  118923. * @param effect The effect used to render through
  118924. */
  118925. protected _internalRender(effect: Effect): void;
  118926. /**
  118927. * Sets the required values for both the emissive texture and and the main color.
  118928. */
  118929. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  118930. /**
  118931. * Returns true if the mesh should render, otherwise false.
  118932. * @param mesh The mesh to render
  118933. * @returns true if it should render otherwise false
  118934. */
  118935. protected _shouldRenderMesh(mesh: Mesh): boolean;
  118936. /**
  118937. * Adds specific effects defines.
  118938. * @param defines The defines to add specifics to.
  118939. */
  118940. protected _addCustomEffectDefines(defines: string[]): void;
  118941. /**
  118942. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  118943. * @param mesh The mesh to exclude from the glow layer
  118944. */
  118945. addExcludedMesh(mesh: Mesh): void;
  118946. /**
  118947. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  118948. * @param mesh The mesh to remove
  118949. */
  118950. removeExcludedMesh(mesh: Mesh): void;
  118951. /**
  118952. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  118953. * @param mesh The mesh to include in the glow layer
  118954. */
  118955. addIncludedOnlyMesh(mesh: Mesh): void;
  118956. /**
  118957. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  118958. * @param mesh The mesh to remove
  118959. */
  118960. removeIncludedOnlyMesh(mesh: Mesh): void;
  118961. /**
  118962. * Determine if a given mesh will be used in the glow layer
  118963. * @param mesh The mesh to test
  118964. * @returns true if the mesh will be highlighted by the current glow layer
  118965. */
  118966. hasMesh(mesh: AbstractMesh): boolean;
  118967. /**
  118968. * Defines wether the current material of the mesh should be use to render the effect.
  118969. * @param mesh defines the current mesh to render
  118970. */
  118971. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  118972. /**
  118973. * Add a mesh to be rendered through its own material and not with emissive only.
  118974. * @param mesh The mesh for which we need to use its material
  118975. */
  118976. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  118977. /**
  118978. * Remove a mesh from being rendered through its own material and not with emissive only.
  118979. * @param mesh The mesh for which we need to not use its material
  118980. */
  118981. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  118982. /**
  118983. * Free any resources and references associated to a mesh.
  118984. * Internal use
  118985. * @param mesh The mesh to free.
  118986. * @hidden
  118987. */
  118988. _disposeMesh(mesh: Mesh): void;
  118989. /**
  118990. * Gets the class name of the effect layer
  118991. * @returns the string with the class name of the effect layer
  118992. */
  118993. getClassName(): string;
  118994. /**
  118995. * Serializes this glow layer
  118996. * @returns a serialized glow layer object
  118997. */
  118998. serialize(): any;
  118999. /**
  119000. * Creates a Glow Layer from parsed glow layer data
  119001. * @param parsedGlowLayer defines glow layer data
  119002. * @param scene defines the current scene
  119003. * @param rootUrl defines the root URL containing the glow layer information
  119004. * @returns a parsed Glow Layer
  119005. */
  119006. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  119007. }
  119008. }
  119009. declare module BABYLON {
  119010. /** @hidden */
  119011. export var glowBlurPostProcessPixelShader: {
  119012. name: string;
  119013. shader: string;
  119014. };
  119015. }
  119016. declare module BABYLON {
  119017. interface AbstractScene {
  119018. /**
  119019. * Return a the first highlight layer of the scene with a given name.
  119020. * @param name The name of the highlight layer to look for.
  119021. * @return The highlight layer if found otherwise null.
  119022. */
  119023. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  119024. }
  119025. /**
  119026. * Highlight layer options. This helps customizing the behaviour
  119027. * of the highlight layer.
  119028. */
  119029. export interface IHighlightLayerOptions {
  119030. /**
  119031. * Multiplication factor apply to the canvas size to compute the render target size
  119032. * used to generated the glowing objects (the smaller the faster).
  119033. */
  119034. mainTextureRatio: number;
  119035. /**
  119036. * Enforces a fixed size texture to ensure resize independant blur.
  119037. */
  119038. mainTextureFixedSize?: number;
  119039. /**
  119040. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  119041. * of the picture to blur (the smaller the faster).
  119042. */
  119043. blurTextureSizeRatio: number;
  119044. /**
  119045. * How big in texel of the blur texture is the vertical blur.
  119046. */
  119047. blurVerticalSize: number;
  119048. /**
  119049. * How big in texel of the blur texture is the horizontal blur.
  119050. */
  119051. blurHorizontalSize: number;
  119052. /**
  119053. * Alpha blending mode used to apply the blur. Default is combine.
  119054. */
  119055. alphaBlendingMode: number;
  119056. /**
  119057. * The camera attached to the layer.
  119058. */
  119059. camera: Nullable<Camera>;
  119060. /**
  119061. * Should we display highlight as a solid stroke?
  119062. */
  119063. isStroke?: boolean;
  119064. /**
  119065. * The rendering group to draw the layer in.
  119066. */
  119067. renderingGroupId: number;
  119068. }
  119069. /**
  119070. * The highlight layer Helps adding a glow effect around a mesh.
  119071. *
  119072. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  119073. * glowy meshes to your scene.
  119074. *
  119075. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  119076. */
  119077. export class HighlightLayer extends EffectLayer {
  119078. name: string;
  119079. /**
  119080. * Effect Name of the highlight layer.
  119081. */
  119082. static readonly EffectName: string;
  119083. /**
  119084. * The neutral color used during the preparation of the glow effect.
  119085. * This is black by default as the blend operation is a blend operation.
  119086. */
  119087. static NeutralColor: Color4;
  119088. /**
  119089. * Stencil value used for glowing meshes.
  119090. */
  119091. static GlowingMeshStencilReference: number;
  119092. /**
  119093. * Stencil value used for the other meshes in the scene.
  119094. */
  119095. static NormalMeshStencilReference: number;
  119096. /**
  119097. * Specifies whether or not the inner glow is ACTIVE in the layer.
  119098. */
  119099. innerGlow: boolean;
  119100. /**
  119101. * Specifies whether or not the outer glow is ACTIVE in the layer.
  119102. */
  119103. outerGlow: boolean;
  119104. /**
  119105. * Specifies the horizontal size of the blur.
  119106. */
  119107. /**
  119108. * Gets the horizontal size of the blur.
  119109. */
  119110. blurHorizontalSize: number;
  119111. /**
  119112. * Specifies the vertical size of the blur.
  119113. */
  119114. /**
  119115. * Gets the vertical size of the blur.
  119116. */
  119117. blurVerticalSize: number;
  119118. /**
  119119. * An event triggered when the highlight layer is being blurred.
  119120. */
  119121. onBeforeBlurObservable: Observable<HighlightLayer>;
  119122. /**
  119123. * An event triggered when the highlight layer has been blurred.
  119124. */
  119125. onAfterBlurObservable: Observable<HighlightLayer>;
  119126. private _instanceGlowingMeshStencilReference;
  119127. private _options;
  119128. private _downSamplePostprocess;
  119129. private _horizontalBlurPostprocess;
  119130. private _verticalBlurPostprocess;
  119131. private _blurTexture;
  119132. private _meshes;
  119133. private _excludedMeshes;
  119134. /**
  119135. * Instantiates a new highlight Layer and references it to the scene..
  119136. * @param name The name of the layer
  119137. * @param scene The scene to use the layer in
  119138. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  119139. */
  119140. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  119141. /**
  119142. * Get the effect name of the layer.
  119143. * @return The effect name
  119144. */
  119145. getEffectName(): string;
  119146. /**
  119147. * Create the merge effect. This is the shader use to blit the information back
  119148. * to the main canvas at the end of the scene rendering.
  119149. */
  119150. protected _createMergeEffect(): Effect;
  119151. /**
  119152. * Creates the render target textures and post processes used in the highlight layer.
  119153. */
  119154. protected _createTextureAndPostProcesses(): void;
  119155. /**
  119156. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  119157. */
  119158. needStencil(): boolean;
  119159. /**
  119160. * Checks for the readiness of the element composing the layer.
  119161. * @param subMesh the mesh to check for
  119162. * @param useInstances specify wether or not to use instances to render the mesh
  119163. * @param emissiveTexture the associated emissive texture used to generate the glow
  119164. * @return true if ready otherwise, false
  119165. */
  119166. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119167. /**
  119168. * Implementation specific of rendering the generating effect on the main canvas.
  119169. * @param effect The effect used to render through
  119170. */
  119171. protected _internalRender(effect: Effect): void;
  119172. /**
  119173. * Returns true if the layer contains information to display, otherwise false.
  119174. */
  119175. shouldRender(): boolean;
  119176. /**
  119177. * Returns true if the mesh should render, otherwise false.
  119178. * @param mesh The mesh to render
  119179. * @returns true if it should render otherwise false
  119180. */
  119181. protected _shouldRenderMesh(mesh: Mesh): boolean;
  119182. /**
  119183. * Sets the required values for both the emissive texture and and the main color.
  119184. */
  119185. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  119186. /**
  119187. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  119188. * @param mesh The mesh to exclude from the highlight layer
  119189. */
  119190. addExcludedMesh(mesh: Mesh): void;
  119191. /**
  119192. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  119193. * @param mesh The mesh to highlight
  119194. */
  119195. removeExcludedMesh(mesh: Mesh): void;
  119196. /**
  119197. * Determine if a given mesh will be highlighted by the current HighlightLayer
  119198. * @param mesh mesh to test
  119199. * @returns true if the mesh will be highlighted by the current HighlightLayer
  119200. */
  119201. hasMesh(mesh: AbstractMesh): boolean;
  119202. /**
  119203. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  119204. * @param mesh The mesh to highlight
  119205. * @param color The color of the highlight
  119206. * @param glowEmissiveOnly Extract the glow from the emissive texture
  119207. */
  119208. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  119209. /**
  119210. * Remove a mesh from the highlight layer in order to make it stop glowing.
  119211. * @param mesh The mesh to highlight
  119212. */
  119213. removeMesh(mesh: Mesh): void;
  119214. /**
  119215. * Force the stencil to the normal expected value for none glowing parts
  119216. */
  119217. private _defaultStencilReference;
  119218. /**
  119219. * Free any resources and references associated to a mesh.
  119220. * Internal use
  119221. * @param mesh The mesh to free.
  119222. * @hidden
  119223. */
  119224. _disposeMesh(mesh: Mesh): void;
  119225. /**
  119226. * Dispose the highlight layer and free resources.
  119227. */
  119228. dispose(): void;
  119229. /**
  119230. * Gets the class name of the effect layer
  119231. * @returns the string with the class name of the effect layer
  119232. */
  119233. getClassName(): string;
  119234. /**
  119235. * Serializes this Highlight layer
  119236. * @returns a serialized Highlight layer object
  119237. */
  119238. serialize(): any;
  119239. /**
  119240. * Creates a Highlight layer from parsed Highlight layer data
  119241. * @param parsedHightlightLayer defines the Highlight layer data
  119242. * @param scene defines the current scene
  119243. * @param rootUrl defines the root URL containing the Highlight layer information
  119244. * @returns a parsed Highlight layer
  119245. */
  119246. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  119247. }
  119248. }
  119249. declare module BABYLON {
  119250. interface AbstractScene {
  119251. /**
  119252. * The list of layers (background and foreground) of the scene
  119253. */
  119254. layers: Array<Layer>;
  119255. }
  119256. /**
  119257. * Defines the layer scene component responsible to manage any layers
  119258. * in a given scene.
  119259. */
  119260. export class LayerSceneComponent implements ISceneComponent {
  119261. /**
  119262. * The component name helpfull to identify the component in the list of scene components.
  119263. */
  119264. readonly name: string;
  119265. /**
  119266. * The scene the component belongs to.
  119267. */
  119268. scene: Scene;
  119269. private _engine;
  119270. /**
  119271. * Creates a new instance of the component for the given scene
  119272. * @param scene Defines the scene to register the component in
  119273. */
  119274. constructor(scene: Scene);
  119275. /**
  119276. * Registers the component in a given scene
  119277. */
  119278. register(): void;
  119279. /**
  119280. * Rebuilds the elements related to this component in case of
  119281. * context lost for instance.
  119282. */
  119283. rebuild(): void;
  119284. /**
  119285. * Disposes the component and the associated ressources.
  119286. */
  119287. dispose(): void;
  119288. private _draw;
  119289. private _drawCameraPredicate;
  119290. private _drawCameraBackground;
  119291. private _drawCameraForeground;
  119292. private _drawRenderTargetPredicate;
  119293. private _drawRenderTargetBackground;
  119294. private _drawRenderTargetForeground;
  119295. /**
  119296. * Adds all the elements from the container to the scene
  119297. * @param container the container holding the elements
  119298. */
  119299. addFromContainer(container: AbstractScene): void;
  119300. /**
  119301. * Removes all the elements in the container from the scene
  119302. * @param container contains the elements to remove
  119303. * @param dispose if the removed element should be disposed (default: false)
  119304. */
  119305. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119306. }
  119307. }
  119308. declare module BABYLON {
  119309. /** @hidden */
  119310. export var layerPixelShader: {
  119311. name: string;
  119312. shader: string;
  119313. };
  119314. }
  119315. declare module BABYLON {
  119316. /** @hidden */
  119317. export var layerVertexShader: {
  119318. name: string;
  119319. shader: string;
  119320. };
  119321. }
  119322. declare module BABYLON {
  119323. /**
  119324. * This represents a full screen 2d layer.
  119325. * This can be useful to display a picture in the background of your scene for instance.
  119326. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119327. */
  119328. export class Layer {
  119329. /**
  119330. * Define the name of the layer.
  119331. */
  119332. name: string;
  119333. /**
  119334. * Define the texture the layer should display.
  119335. */
  119336. texture: Nullable<Texture>;
  119337. /**
  119338. * Is the layer in background or foreground.
  119339. */
  119340. isBackground: boolean;
  119341. /**
  119342. * Define the color of the layer (instead of texture).
  119343. */
  119344. color: Color4;
  119345. /**
  119346. * Define the scale of the layer in order to zoom in out of the texture.
  119347. */
  119348. scale: Vector2;
  119349. /**
  119350. * Define an offset for the layer in order to shift the texture.
  119351. */
  119352. offset: Vector2;
  119353. /**
  119354. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  119355. */
  119356. alphaBlendingMode: number;
  119357. /**
  119358. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  119359. * Alpha test will not mix with the background color in case of transparency.
  119360. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  119361. */
  119362. alphaTest: boolean;
  119363. /**
  119364. * Define a mask to restrict the layer to only some of the scene cameras.
  119365. */
  119366. layerMask: number;
  119367. /**
  119368. * Define the list of render target the layer is visible into.
  119369. */
  119370. renderTargetTextures: RenderTargetTexture[];
  119371. /**
  119372. * Define if the layer is only used in renderTarget or if it also
  119373. * renders in the main frame buffer of the canvas.
  119374. */
  119375. renderOnlyInRenderTargetTextures: boolean;
  119376. private _scene;
  119377. private _vertexBuffers;
  119378. private _indexBuffer;
  119379. private _effect;
  119380. private _alphaTestEffect;
  119381. /**
  119382. * An event triggered when the layer is disposed.
  119383. */
  119384. onDisposeObservable: Observable<Layer>;
  119385. private _onDisposeObserver;
  119386. /**
  119387. * Back compatibility with callback before the onDisposeObservable existed.
  119388. * The set callback will be triggered when the layer has been disposed.
  119389. */
  119390. onDispose: () => void;
  119391. /**
  119392. * An event triggered before rendering the scene
  119393. */
  119394. onBeforeRenderObservable: Observable<Layer>;
  119395. private _onBeforeRenderObserver;
  119396. /**
  119397. * Back compatibility with callback before the onBeforeRenderObservable existed.
  119398. * The set callback will be triggered just before rendering the layer.
  119399. */
  119400. onBeforeRender: () => void;
  119401. /**
  119402. * An event triggered after rendering the scene
  119403. */
  119404. onAfterRenderObservable: Observable<Layer>;
  119405. private _onAfterRenderObserver;
  119406. /**
  119407. * Back compatibility with callback before the onAfterRenderObservable existed.
  119408. * The set callback will be triggered just after rendering the layer.
  119409. */
  119410. onAfterRender: () => void;
  119411. /**
  119412. * Instantiates a new layer.
  119413. * This represents a full screen 2d layer.
  119414. * This can be useful to display a picture in the background of your scene for instance.
  119415. * @see https://www.babylonjs-playground.com/#08A2BS#1
  119416. * @param name Define the name of the layer in the scene
  119417. * @param imgUrl Define the url of the texture to display in the layer
  119418. * @param scene Define the scene the layer belongs to
  119419. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  119420. * @param color Defines a color for the layer
  119421. */
  119422. constructor(
  119423. /**
  119424. * Define the name of the layer.
  119425. */
  119426. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  119427. private _createIndexBuffer;
  119428. /** @hidden */
  119429. _rebuild(): void;
  119430. /**
  119431. * Renders the layer in the scene.
  119432. */
  119433. render(): void;
  119434. /**
  119435. * Disposes and releases the associated ressources.
  119436. */
  119437. dispose(): void;
  119438. }
  119439. }
  119440. declare module BABYLON {
  119441. /** @hidden */
  119442. export var lensFlarePixelShader: {
  119443. name: string;
  119444. shader: string;
  119445. };
  119446. }
  119447. declare module BABYLON {
  119448. /** @hidden */
  119449. export var lensFlareVertexShader: {
  119450. name: string;
  119451. shader: string;
  119452. };
  119453. }
  119454. declare module BABYLON {
  119455. /**
  119456. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119457. * It is usually composed of several `lensFlare`.
  119458. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119459. */
  119460. export class LensFlareSystem {
  119461. /**
  119462. * Define the name of the lens flare system
  119463. */
  119464. name: string;
  119465. /**
  119466. * List of lens flares used in this system.
  119467. */
  119468. lensFlares: LensFlare[];
  119469. /**
  119470. * Define a limit from the border the lens flare can be visible.
  119471. */
  119472. borderLimit: number;
  119473. /**
  119474. * Define a viewport border we do not want to see the lens flare in.
  119475. */
  119476. viewportBorder: number;
  119477. /**
  119478. * Define a predicate which could limit the list of meshes able to occlude the effect.
  119479. */
  119480. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119481. /**
  119482. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  119483. */
  119484. layerMask: number;
  119485. /**
  119486. * Define the id of the lens flare system in the scene.
  119487. * (equal to name by default)
  119488. */
  119489. id: string;
  119490. private _scene;
  119491. private _emitter;
  119492. private _vertexBuffers;
  119493. private _indexBuffer;
  119494. private _effect;
  119495. private _positionX;
  119496. private _positionY;
  119497. private _isEnabled;
  119498. /** @hidden */
  119499. static _SceneComponentInitialization: (scene: Scene) => void;
  119500. /**
  119501. * Instantiates a lens flare system.
  119502. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  119503. * It is usually composed of several `lensFlare`.
  119504. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119505. * @param name Define the name of the lens flare system in the scene
  119506. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  119507. * @param scene Define the scene the lens flare system belongs to
  119508. */
  119509. constructor(
  119510. /**
  119511. * Define the name of the lens flare system
  119512. */
  119513. name: string, emitter: any, scene: Scene);
  119514. /**
  119515. * Define if the lens flare system is enabled.
  119516. */
  119517. isEnabled: boolean;
  119518. /**
  119519. * Get the scene the effects belongs to.
  119520. * @returns the scene holding the lens flare system
  119521. */
  119522. getScene(): Scene;
  119523. /**
  119524. * Get the emitter of the lens flare system.
  119525. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119526. * @returns the emitter of the lens flare system
  119527. */
  119528. getEmitter(): any;
  119529. /**
  119530. * Set the emitter of the lens flare system.
  119531. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  119532. * @param newEmitter Define the new emitter of the system
  119533. */
  119534. setEmitter(newEmitter: any): void;
  119535. /**
  119536. * Get the lens flare system emitter position.
  119537. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  119538. * @returns the position
  119539. */
  119540. getEmitterPosition(): Vector3;
  119541. /**
  119542. * @hidden
  119543. */
  119544. computeEffectivePosition(globalViewport: Viewport): boolean;
  119545. /** @hidden */
  119546. _isVisible(): boolean;
  119547. /**
  119548. * @hidden
  119549. */
  119550. render(): boolean;
  119551. /**
  119552. * Dispose and release the lens flare with its associated resources.
  119553. */
  119554. dispose(): void;
  119555. /**
  119556. * Parse a lens flare system from a JSON repressentation
  119557. * @param parsedLensFlareSystem Define the JSON to parse
  119558. * @param scene Define the scene the parsed system should be instantiated in
  119559. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  119560. * @returns the parsed system
  119561. */
  119562. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  119563. /**
  119564. * Serialize the current Lens Flare System into a JSON representation.
  119565. * @returns the serialized JSON
  119566. */
  119567. serialize(): any;
  119568. }
  119569. }
  119570. declare module BABYLON {
  119571. /**
  119572. * This represents one of the lens effect in a `lensFlareSystem`.
  119573. * It controls one of the indiviual texture used in the effect.
  119574. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119575. */
  119576. export class LensFlare {
  119577. /**
  119578. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119579. */
  119580. size: number;
  119581. /**
  119582. * 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.
  119583. */
  119584. position: number;
  119585. /**
  119586. * Define the lens color.
  119587. */
  119588. color: Color3;
  119589. /**
  119590. * Define the lens texture.
  119591. */
  119592. texture: Nullable<Texture>;
  119593. /**
  119594. * Define the alpha mode to render this particular lens.
  119595. */
  119596. alphaMode: number;
  119597. private _system;
  119598. /**
  119599. * Creates a new Lens Flare.
  119600. * This represents one of the lens effect in a `lensFlareSystem`.
  119601. * It controls one of the indiviual texture used in the effect.
  119602. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119603. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  119604. * @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.
  119605. * @param color Define the lens color
  119606. * @param imgUrl Define the lens texture url
  119607. * @param system Define the `lensFlareSystem` this flare is part of
  119608. * @returns The newly created Lens Flare
  119609. */
  119610. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  119611. /**
  119612. * Instantiates a new Lens Flare.
  119613. * This represents one of the lens effect in a `lensFlareSystem`.
  119614. * It controls one of the indiviual texture used in the effect.
  119615. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119616. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  119617. * @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.
  119618. * @param color Define the lens color
  119619. * @param imgUrl Define the lens texture url
  119620. * @param system Define the `lensFlareSystem` this flare is part of
  119621. */
  119622. constructor(
  119623. /**
  119624. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  119625. */
  119626. size: number,
  119627. /**
  119628. * 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.
  119629. */
  119630. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  119631. /**
  119632. * Dispose and release the lens flare with its associated resources.
  119633. */
  119634. dispose(): void;
  119635. }
  119636. }
  119637. declare module BABYLON {
  119638. interface AbstractScene {
  119639. /**
  119640. * The list of lens flare system added to the scene
  119641. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  119642. */
  119643. lensFlareSystems: Array<LensFlareSystem>;
  119644. /**
  119645. * Removes the given lens flare system from this scene.
  119646. * @param toRemove The lens flare system to remove
  119647. * @returns The index of the removed lens flare system
  119648. */
  119649. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  119650. /**
  119651. * Adds the given lens flare system to this scene
  119652. * @param newLensFlareSystem The lens flare system to add
  119653. */
  119654. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  119655. /**
  119656. * Gets a lens flare system using its name
  119657. * @param name defines the name to look for
  119658. * @returns the lens flare system or null if not found
  119659. */
  119660. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  119661. /**
  119662. * Gets a lens flare system using its id
  119663. * @param id defines the id to look for
  119664. * @returns the lens flare system or null if not found
  119665. */
  119666. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  119667. }
  119668. /**
  119669. * Defines the lens flare scene component responsible to manage any lens flares
  119670. * in a given scene.
  119671. */
  119672. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  119673. /**
  119674. * The component name helpfull to identify the component in the list of scene components.
  119675. */
  119676. readonly name: string;
  119677. /**
  119678. * The scene the component belongs to.
  119679. */
  119680. scene: Scene;
  119681. /**
  119682. * Creates a new instance of the component for the given scene
  119683. * @param scene Defines the scene to register the component in
  119684. */
  119685. constructor(scene: Scene);
  119686. /**
  119687. * Registers the component in a given scene
  119688. */
  119689. register(): void;
  119690. /**
  119691. * Rebuilds the elements related to this component in case of
  119692. * context lost for instance.
  119693. */
  119694. rebuild(): void;
  119695. /**
  119696. * Adds all the elements from the container to the scene
  119697. * @param container the container holding the elements
  119698. */
  119699. addFromContainer(container: AbstractScene): void;
  119700. /**
  119701. * Removes all the elements in the container from the scene
  119702. * @param container contains the elements to remove
  119703. * @param dispose if the removed element should be disposed (default: false)
  119704. */
  119705. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119706. /**
  119707. * Serializes the component data to the specified json object
  119708. * @param serializationObject The object to serialize to
  119709. */
  119710. serialize(serializationObject: any): void;
  119711. /**
  119712. * Disposes the component and the associated ressources.
  119713. */
  119714. dispose(): void;
  119715. private _draw;
  119716. }
  119717. }
  119718. declare module BABYLON {
  119719. /**
  119720. * Defines the shadow generator component responsible to manage any shadow generators
  119721. * in a given scene.
  119722. */
  119723. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  119724. /**
  119725. * The component name helpfull to identify the component in the list of scene components.
  119726. */
  119727. readonly name: string;
  119728. /**
  119729. * The scene the component belongs to.
  119730. */
  119731. scene: Scene;
  119732. /**
  119733. * Creates a new instance of the component for the given scene
  119734. * @param scene Defines the scene to register the component in
  119735. */
  119736. constructor(scene: Scene);
  119737. /**
  119738. * Registers the component in a given scene
  119739. */
  119740. register(): void;
  119741. /**
  119742. * Rebuilds the elements related to this component in case of
  119743. * context lost for instance.
  119744. */
  119745. rebuild(): void;
  119746. /**
  119747. * Serializes the component data to the specified json object
  119748. * @param serializationObject The object to serialize to
  119749. */
  119750. serialize(serializationObject: any): void;
  119751. /**
  119752. * Adds all the elements from the container to the scene
  119753. * @param container the container holding the elements
  119754. */
  119755. addFromContainer(container: AbstractScene): void;
  119756. /**
  119757. * Removes all the elements in the container from the scene
  119758. * @param container contains the elements to remove
  119759. * @param dispose if the removed element should be disposed (default: false)
  119760. */
  119761. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119762. /**
  119763. * Rebuilds the elements related to this component in case of
  119764. * context lost for instance.
  119765. */
  119766. dispose(): void;
  119767. private _gatherRenderTargets;
  119768. }
  119769. }
  119770. declare module BABYLON {
  119771. /**
  119772. * A point light is a light defined by an unique point in world space.
  119773. * The light is emitted in every direction from this point.
  119774. * A good example of a point light is a standard light bulb.
  119775. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119776. */
  119777. export class PointLight extends ShadowLight {
  119778. private _shadowAngle;
  119779. /**
  119780. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119781. * This specifies what angle the shadow will use to be created.
  119782. *
  119783. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119784. */
  119785. /**
  119786. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119787. * This specifies what angle the shadow will use to be created.
  119788. *
  119789. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  119790. */
  119791. shadowAngle: number;
  119792. /**
  119793. * Gets the direction if it has been set.
  119794. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119795. */
  119796. /**
  119797. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  119798. */
  119799. direction: Vector3;
  119800. /**
  119801. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  119802. * A PointLight emits the light in every direction.
  119803. * It can cast shadows.
  119804. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  119805. * ```javascript
  119806. * var pointLight = new PointLight("pl", camera.position, scene);
  119807. * ```
  119808. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119809. * @param name The light friendly name
  119810. * @param position The position of the point light in the scene
  119811. * @param scene The scene the lights belongs to
  119812. */
  119813. constructor(name: string, position: Vector3, scene: Scene);
  119814. /**
  119815. * Returns the string "PointLight"
  119816. * @returns the class name
  119817. */
  119818. getClassName(): string;
  119819. /**
  119820. * Returns the integer 0.
  119821. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  119822. */
  119823. getTypeID(): number;
  119824. /**
  119825. * Specifies wether or not the shadowmap should be a cube texture.
  119826. * @returns true if the shadowmap needs to be a cube texture.
  119827. */
  119828. needCube(): boolean;
  119829. /**
  119830. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  119831. * @param faceIndex The index of the face we are computed the direction to generate shadow
  119832. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  119833. */
  119834. getShadowDirection(faceIndex?: number): Vector3;
  119835. /**
  119836. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  119837. * - fov = PI / 2
  119838. * - aspect ratio : 1.0
  119839. * - z-near and far equal to the active camera minZ and maxZ.
  119840. * Returns the PointLight.
  119841. */
  119842. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119843. protected _buildUniformLayout(): void;
  119844. /**
  119845. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  119846. * @param effect The effect to update
  119847. * @param lightIndex The index of the light in the effect to update
  119848. * @returns The point light
  119849. */
  119850. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  119851. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  119852. /**
  119853. * Prepares the list of defines specific to the light type.
  119854. * @param defines the list of defines
  119855. * @param lightIndex defines the index of the light for the effect
  119856. */
  119857. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119858. }
  119859. }
  119860. declare module BABYLON {
  119861. /**
  119862. * Header information of HDR texture files.
  119863. */
  119864. export interface HDRInfo {
  119865. /**
  119866. * The height of the texture in pixels.
  119867. */
  119868. height: number;
  119869. /**
  119870. * The width of the texture in pixels.
  119871. */
  119872. width: number;
  119873. /**
  119874. * The index of the beginning of the data in the binary file.
  119875. */
  119876. dataPosition: number;
  119877. }
  119878. /**
  119879. * This groups tools to convert HDR texture to native colors array.
  119880. */
  119881. export class HDRTools {
  119882. private static Ldexp;
  119883. private static Rgbe2float;
  119884. private static readStringLine;
  119885. /**
  119886. * Reads header information from an RGBE texture stored in a native array.
  119887. * More information on this format are available here:
  119888. * https://en.wikipedia.org/wiki/RGBE_image_format
  119889. *
  119890. * @param uint8array The binary file stored in native array.
  119891. * @return The header information.
  119892. */
  119893. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  119894. /**
  119895. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  119896. * This RGBE texture needs to store the information as a panorama.
  119897. *
  119898. * More information on this format are available here:
  119899. * https://en.wikipedia.org/wiki/RGBE_image_format
  119900. *
  119901. * @param buffer The binary file stored in an array buffer.
  119902. * @param size The expected size of the extracted cubemap.
  119903. * @return The Cube Map information.
  119904. */
  119905. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  119906. /**
  119907. * Returns the pixels data extracted from an RGBE texture.
  119908. * This pixels will be stored left to right up to down in the R G B order in one array.
  119909. *
  119910. * More information on this format are available here:
  119911. * https://en.wikipedia.org/wiki/RGBE_image_format
  119912. *
  119913. * @param uint8array The binary file stored in an array buffer.
  119914. * @param hdrInfo The header information of the file.
  119915. * @return The pixels data in RGB right to left up to down order.
  119916. */
  119917. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  119918. private static RGBE_ReadPixels_RLE;
  119919. }
  119920. }
  119921. declare module BABYLON {
  119922. /**
  119923. * This represents a texture coming from an HDR input.
  119924. *
  119925. * The only supported format is currently panorama picture stored in RGBE format.
  119926. * Example of such files can be found on HDRLib: http://hdrlib.com/
  119927. */
  119928. export class HDRCubeTexture extends BaseTexture {
  119929. private static _facesMapping;
  119930. private _generateHarmonics;
  119931. private _noMipmap;
  119932. private _textureMatrix;
  119933. private _size;
  119934. private _onLoad;
  119935. private _onError;
  119936. /**
  119937. * The texture URL.
  119938. */
  119939. url: string;
  119940. /**
  119941. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  119942. */
  119943. coordinatesMode: number;
  119944. protected _isBlocking: boolean;
  119945. /**
  119946. * Sets wether or not the texture is blocking during loading.
  119947. */
  119948. /**
  119949. * Gets wether or not the texture is blocking during loading.
  119950. */
  119951. isBlocking: boolean;
  119952. protected _rotationY: number;
  119953. /**
  119954. * Sets texture matrix rotation angle around Y axis in radians.
  119955. */
  119956. /**
  119957. * Gets texture matrix rotation angle around Y axis radians.
  119958. */
  119959. rotationY: number;
  119960. /**
  119961. * Gets or sets the center of the bounding box associated with the cube texture
  119962. * It must define where the camera used to render the texture was set
  119963. */
  119964. boundingBoxPosition: Vector3;
  119965. private _boundingBoxSize;
  119966. /**
  119967. * Gets or sets the size of the bounding box associated with the cube texture
  119968. * When defined, the cubemap will switch to local mode
  119969. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119970. * @example https://www.babylonjs-playground.com/#RNASML
  119971. */
  119972. boundingBoxSize: Vector3;
  119973. /**
  119974. * Instantiates an HDRTexture from the following parameters.
  119975. *
  119976. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  119977. * @param scene The scene the texture will be used in
  119978. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  119979. * @param noMipmap Forces to not generate the mipmap if true
  119980. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  119981. * @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)
  119982. * @param reserved Reserved flag for internal use.
  119983. */
  119984. 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>);
  119985. /**
  119986. * Get the current class name of the texture useful for serialization or dynamic coding.
  119987. * @returns "HDRCubeTexture"
  119988. */
  119989. getClassName(): string;
  119990. /**
  119991. * Occurs when the file is raw .hdr file.
  119992. */
  119993. private loadTexture;
  119994. clone(): HDRCubeTexture;
  119995. delayLoad(): void;
  119996. /**
  119997. * Get the texture reflection matrix used to rotate/transform the reflection.
  119998. * @returns the reflection matrix
  119999. */
  120000. getReflectionTextureMatrix(): Matrix;
  120001. /**
  120002. * Set the texture reflection matrix used to rotate/transform the reflection.
  120003. * @param value Define the reflection matrix to set
  120004. */
  120005. setReflectionTextureMatrix(value: Matrix): void;
  120006. /**
  120007. * Parses a JSON representation of an HDR Texture in order to create the texture
  120008. * @param parsedTexture Define the JSON representation
  120009. * @param scene Define the scene the texture should be created in
  120010. * @param rootUrl Define the root url in case we need to load relative dependencies
  120011. * @returns the newly created texture after parsing
  120012. */
  120013. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  120014. serialize(): any;
  120015. }
  120016. }
  120017. declare module BABYLON {
  120018. /**
  120019. * Class used to control physics engine
  120020. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  120021. */
  120022. export class PhysicsEngine implements IPhysicsEngine {
  120023. private _physicsPlugin;
  120024. /**
  120025. * Global value used to control the smallest number supported by the simulation
  120026. */
  120027. static Epsilon: number;
  120028. private _impostors;
  120029. private _joints;
  120030. /**
  120031. * Gets the gravity vector used by the simulation
  120032. */
  120033. gravity: Vector3;
  120034. /**
  120035. * Factory used to create the default physics plugin.
  120036. * @returns The default physics plugin
  120037. */
  120038. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  120039. /**
  120040. * Creates a new Physics Engine
  120041. * @param gravity defines the gravity vector used by the simulation
  120042. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  120043. */
  120044. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  120045. /**
  120046. * Sets the gravity vector used by the simulation
  120047. * @param gravity defines the gravity vector to use
  120048. */
  120049. setGravity(gravity: Vector3): void;
  120050. /**
  120051. * Set the time step of the physics engine.
  120052. * Default is 1/60.
  120053. * To slow it down, enter 1/600 for example.
  120054. * To speed it up, 1/30
  120055. * @param newTimeStep defines the new timestep to apply to this world.
  120056. */
  120057. setTimeStep(newTimeStep?: number): void;
  120058. /**
  120059. * Get the time step of the physics engine.
  120060. * @returns the current time step
  120061. */
  120062. getTimeStep(): number;
  120063. /**
  120064. * Release all resources
  120065. */
  120066. dispose(): void;
  120067. /**
  120068. * Gets the name of the current physics plugin
  120069. * @returns the name of the plugin
  120070. */
  120071. getPhysicsPluginName(): string;
  120072. /**
  120073. * Adding a new impostor for the impostor tracking.
  120074. * This will be done by the impostor itself.
  120075. * @param impostor the impostor to add
  120076. */
  120077. addImpostor(impostor: PhysicsImpostor): void;
  120078. /**
  120079. * Remove an impostor from the engine.
  120080. * This impostor and its mesh will not longer be updated by the physics engine.
  120081. * @param impostor the impostor to remove
  120082. */
  120083. removeImpostor(impostor: PhysicsImpostor): void;
  120084. /**
  120085. * Add a joint to the physics engine
  120086. * @param mainImpostor defines the main impostor to which the joint is added.
  120087. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  120088. * @param joint defines the joint that will connect both impostors.
  120089. */
  120090. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  120091. /**
  120092. * Removes a joint from the simulation
  120093. * @param mainImpostor defines the impostor used with the joint
  120094. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  120095. * @param joint defines the joint to remove
  120096. */
  120097. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  120098. /**
  120099. * Called by the scene. No need to call it.
  120100. * @param delta defines the timespam between frames
  120101. */
  120102. _step(delta: number): void;
  120103. /**
  120104. * Gets the current plugin used to run the simulation
  120105. * @returns current plugin
  120106. */
  120107. getPhysicsPlugin(): IPhysicsEnginePlugin;
  120108. /**
  120109. * Gets the list of physic impostors
  120110. * @returns an array of PhysicsImpostor
  120111. */
  120112. getImpostors(): Array<PhysicsImpostor>;
  120113. /**
  120114. * Gets the impostor for a physics enabled object
  120115. * @param object defines the object impersonated by the impostor
  120116. * @returns the PhysicsImpostor or null if not found
  120117. */
  120118. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  120119. /**
  120120. * Gets the impostor for a physics body object
  120121. * @param body defines physics body used by the impostor
  120122. * @returns the PhysicsImpostor or null if not found
  120123. */
  120124. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  120125. /**
  120126. * Does a raycast in the physics world
  120127. * @param from when should the ray start?
  120128. * @param to when should the ray end?
  120129. * @returns PhysicsRaycastResult
  120130. */
  120131. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120132. }
  120133. }
  120134. declare module BABYLON {
  120135. /** @hidden */
  120136. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  120137. private _useDeltaForWorldStep;
  120138. world: any;
  120139. name: string;
  120140. private _physicsMaterials;
  120141. private _fixedTimeStep;
  120142. private _cannonRaycastResult;
  120143. private _raycastResult;
  120144. private _physicsBodysToRemoveAfterStep;
  120145. BJSCANNON: any;
  120146. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  120147. setGravity(gravity: Vector3): void;
  120148. setTimeStep(timeStep: number): void;
  120149. getTimeStep(): number;
  120150. executeStep(delta: number): void;
  120151. private _removeMarkedPhysicsBodiesFromWorld;
  120152. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120153. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120154. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120155. private _processChildMeshes;
  120156. removePhysicsBody(impostor: PhysicsImpostor): void;
  120157. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120158. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120159. private _addMaterial;
  120160. private _checkWithEpsilon;
  120161. private _createShape;
  120162. private _createHeightmap;
  120163. private _minus90X;
  120164. private _plus90X;
  120165. private _tmpPosition;
  120166. private _tmpDeltaPosition;
  120167. private _tmpUnityRotation;
  120168. private _updatePhysicsBodyTransformation;
  120169. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120170. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120171. isSupported(): boolean;
  120172. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120173. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120174. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120175. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120176. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120177. getBodyMass(impostor: PhysicsImpostor): number;
  120178. getBodyFriction(impostor: PhysicsImpostor): number;
  120179. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120180. getBodyRestitution(impostor: PhysicsImpostor): number;
  120181. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120182. sleepBody(impostor: PhysicsImpostor): void;
  120183. wakeUpBody(impostor: PhysicsImpostor): void;
  120184. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  120185. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120186. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120187. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120188. getRadius(impostor: PhysicsImpostor): number;
  120189. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120190. dispose(): void;
  120191. private _extendNamespace;
  120192. /**
  120193. * Does a raycast in the physics world
  120194. * @param from when should the ray start?
  120195. * @param to when should the ray end?
  120196. * @returns PhysicsRaycastResult
  120197. */
  120198. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120199. }
  120200. }
  120201. declare module BABYLON {
  120202. /** @hidden */
  120203. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  120204. world: any;
  120205. name: string;
  120206. BJSOIMO: any;
  120207. private _raycastResult;
  120208. constructor(iterations?: number, oimoInjection?: any);
  120209. setGravity(gravity: Vector3): void;
  120210. setTimeStep(timeStep: number): void;
  120211. getTimeStep(): number;
  120212. private _tmpImpostorsArray;
  120213. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120214. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120215. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120216. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120217. private _tmpPositionVector;
  120218. removePhysicsBody(impostor: PhysicsImpostor): void;
  120219. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120220. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120221. isSupported(): boolean;
  120222. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120223. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120224. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120225. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120226. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120227. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120228. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120229. getBodyMass(impostor: PhysicsImpostor): number;
  120230. getBodyFriction(impostor: PhysicsImpostor): number;
  120231. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120232. getBodyRestitution(impostor: PhysicsImpostor): number;
  120233. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120234. sleepBody(impostor: PhysicsImpostor): void;
  120235. wakeUpBody(impostor: PhysicsImpostor): void;
  120236. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120237. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  120238. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  120239. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120240. getRadius(impostor: PhysicsImpostor): number;
  120241. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120242. dispose(): void;
  120243. /**
  120244. * Does a raycast in the physics world
  120245. * @param from when should the ray start?
  120246. * @param to when should the ray end?
  120247. * @returns PhysicsRaycastResult
  120248. */
  120249. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120250. }
  120251. }
  120252. declare module BABYLON {
  120253. /**
  120254. * Class containing static functions to help procedurally build meshes
  120255. */
  120256. export class RibbonBuilder {
  120257. /**
  120258. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  120259. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  120260. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  120261. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  120262. * * 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
  120263. * * 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
  120264. * * 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
  120265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120267. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120268. * * 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
  120269. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  120270. * * 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
  120271. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  120272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120273. * @param name defines the name of the mesh
  120274. * @param options defines the options used to create the mesh
  120275. * @param scene defines the hosting scene
  120276. * @returns the ribbon mesh
  120277. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  120278. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120279. */
  120280. static CreateRibbon(name: string, options: {
  120281. pathArray: Vector3[][];
  120282. closeArray?: boolean;
  120283. closePath?: boolean;
  120284. offset?: number;
  120285. updatable?: boolean;
  120286. sideOrientation?: number;
  120287. frontUVs?: Vector4;
  120288. backUVs?: Vector4;
  120289. instance?: Mesh;
  120290. invertUV?: boolean;
  120291. uvs?: Vector2[];
  120292. colors?: Color4[];
  120293. }, scene?: Nullable<Scene>): Mesh;
  120294. }
  120295. }
  120296. declare module BABYLON {
  120297. /**
  120298. * Class containing static functions to help procedurally build meshes
  120299. */
  120300. export class ShapeBuilder {
  120301. /**
  120302. * 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.
  120303. * * 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.
  120304. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120305. * * 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.
  120306. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  120307. * * 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
  120308. * * 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
  120309. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  120310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120311. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120312. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  120313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120314. * @param name defines the name of the mesh
  120315. * @param options defines the options used to create the mesh
  120316. * @param scene defines the hosting scene
  120317. * @returns the extruded shape mesh
  120318. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120320. */
  120321. static ExtrudeShape(name: string, options: {
  120322. shape: Vector3[];
  120323. path: Vector3[];
  120324. scale?: number;
  120325. rotation?: number;
  120326. cap?: number;
  120327. updatable?: boolean;
  120328. sideOrientation?: number;
  120329. frontUVs?: Vector4;
  120330. backUVs?: Vector4;
  120331. instance?: Mesh;
  120332. invertUV?: boolean;
  120333. }, scene?: Nullable<Scene>): Mesh;
  120334. /**
  120335. * Creates an custom extruded shape mesh.
  120336. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  120337. * * 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.
  120338. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  120339. * * 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
  120340. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  120341. * * 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
  120342. * * It must returns a float value that will be the scale value applied to the shape on each path point
  120343. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  120344. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  120345. * * 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
  120346. * * 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
  120347. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  120348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120349. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120350. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  120351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120352. * @param name defines the name of the mesh
  120353. * @param options defines the options used to create the mesh
  120354. * @param scene defines the hosting scene
  120355. * @returns the custom extruded shape mesh
  120356. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  120357. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  120358. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  120359. */
  120360. static ExtrudeShapeCustom(name: string, options: {
  120361. shape: Vector3[];
  120362. path: Vector3[];
  120363. scaleFunction?: any;
  120364. rotationFunction?: any;
  120365. ribbonCloseArray?: boolean;
  120366. ribbonClosePath?: boolean;
  120367. cap?: number;
  120368. updatable?: boolean;
  120369. sideOrientation?: number;
  120370. frontUVs?: Vector4;
  120371. backUVs?: Vector4;
  120372. instance?: Mesh;
  120373. invertUV?: boolean;
  120374. }, scene?: Nullable<Scene>): Mesh;
  120375. private static _ExtrudeShapeGeneric;
  120376. }
  120377. }
  120378. declare module BABYLON {
  120379. /**
  120380. * AmmoJS Physics plugin
  120381. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  120382. * @see https://github.com/kripken/ammo.js/
  120383. */
  120384. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  120385. private _useDeltaForWorldStep;
  120386. /**
  120387. * Reference to the Ammo library
  120388. */
  120389. bjsAMMO: any;
  120390. /**
  120391. * Created ammoJS world which physics bodies are added to
  120392. */
  120393. world: any;
  120394. /**
  120395. * Name of the plugin
  120396. */
  120397. name: string;
  120398. private _timeStep;
  120399. private _fixedTimeStep;
  120400. private _maxSteps;
  120401. private _tmpQuaternion;
  120402. private _tmpAmmoTransform;
  120403. private _tmpAmmoQuaternion;
  120404. private _tmpAmmoConcreteContactResultCallback;
  120405. private _collisionConfiguration;
  120406. private _dispatcher;
  120407. private _overlappingPairCache;
  120408. private _solver;
  120409. private _softBodySolver;
  120410. private _tmpAmmoVectorA;
  120411. private _tmpAmmoVectorB;
  120412. private _tmpAmmoVectorC;
  120413. private _tmpAmmoVectorD;
  120414. private _tmpContactCallbackResult;
  120415. private _tmpAmmoVectorRCA;
  120416. private _tmpAmmoVectorRCB;
  120417. private _raycastResult;
  120418. private static readonly DISABLE_COLLISION_FLAG;
  120419. private static readonly KINEMATIC_FLAG;
  120420. private static readonly DISABLE_DEACTIVATION_FLAG;
  120421. /**
  120422. * Initializes the ammoJS plugin
  120423. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  120424. * @param ammoInjection can be used to inject your own ammo reference
  120425. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  120426. */
  120427. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  120428. /**
  120429. * Sets the gravity of the physics world (m/(s^2))
  120430. * @param gravity Gravity to set
  120431. */
  120432. setGravity(gravity: Vector3): void;
  120433. /**
  120434. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  120435. * @param timeStep timestep to use in seconds
  120436. */
  120437. setTimeStep(timeStep: number): void;
  120438. /**
  120439. * 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)
  120440. * @param fixedTimeStep fixedTimeStep to use in seconds
  120441. */
  120442. setFixedTimeStep(fixedTimeStep: number): void;
  120443. /**
  120444. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  120445. * @param maxSteps the maximum number of steps by the physics engine per frame
  120446. */
  120447. setMaxSteps(maxSteps: number): void;
  120448. /**
  120449. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  120450. * @returns the current timestep in seconds
  120451. */
  120452. getTimeStep(): number;
  120453. private _isImpostorInContact;
  120454. private _isImpostorPairInContact;
  120455. private _stepSimulation;
  120456. /**
  120457. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  120458. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  120459. * After the step the babylon meshes are set to the position of the physics imposters
  120460. * @param delta amount of time to step forward
  120461. * @param impostors array of imposters to update before/after the step
  120462. */
  120463. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  120464. /**
  120465. * Update babylon mesh to match physics world object
  120466. * @param impostor imposter to match
  120467. */
  120468. private _afterSoftStep;
  120469. /**
  120470. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120471. * @param impostor imposter to match
  120472. */
  120473. private _ropeStep;
  120474. /**
  120475. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  120476. * @param impostor imposter to match
  120477. */
  120478. private _softbodyOrClothStep;
  120479. private _tmpVector;
  120480. private _tmpMatrix;
  120481. /**
  120482. * Applies an impulse on the imposter
  120483. * @param impostor imposter to apply impulse to
  120484. * @param force amount of force to be applied to the imposter
  120485. * @param contactPoint the location to apply the impulse on the imposter
  120486. */
  120487. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120488. /**
  120489. * Applies a force on the imposter
  120490. * @param impostor imposter to apply force
  120491. * @param force amount of force to be applied to the imposter
  120492. * @param contactPoint the location to apply the force on the imposter
  120493. */
  120494. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  120495. /**
  120496. * Creates a physics body using the plugin
  120497. * @param impostor the imposter to create the physics body on
  120498. */
  120499. generatePhysicsBody(impostor: PhysicsImpostor): void;
  120500. /**
  120501. * Removes the physics body from the imposter and disposes of the body's memory
  120502. * @param impostor imposter to remove the physics body from
  120503. */
  120504. removePhysicsBody(impostor: PhysicsImpostor): void;
  120505. /**
  120506. * Generates a joint
  120507. * @param impostorJoint the imposter joint to create the joint with
  120508. */
  120509. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  120510. /**
  120511. * Removes a joint
  120512. * @param impostorJoint the imposter joint to remove the joint from
  120513. */
  120514. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  120515. private _addMeshVerts;
  120516. /**
  120517. * Initialise the soft body vertices to match its object's (mesh) vertices
  120518. * Softbody vertices (nodes) are in world space and to match this
  120519. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  120520. * @param impostor to create the softbody for
  120521. */
  120522. private _softVertexData;
  120523. /**
  120524. * Create an impostor's soft body
  120525. * @param impostor to create the softbody for
  120526. */
  120527. private _createSoftbody;
  120528. /**
  120529. * Create cloth for an impostor
  120530. * @param impostor to create the softbody for
  120531. */
  120532. private _createCloth;
  120533. /**
  120534. * Create rope for an impostor
  120535. * @param impostor to create the softbody for
  120536. */
  120537. private _createRope;
  120538. private _addHullVerts;
  120539. private _createShape;
  120540. /**
  120541. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  120542. * @param impostor imposter containing the physics body and babylon object
  120543. */
  120544. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  120545. /**
  120546. * Sets the babylon object's position/rotation from the physics body's position/rotation
  120547. * @param impostor imposter containing the physics body and babylon object
  120548. * @param newPosition new position
  120549. * @param newRotation new rotation
  120550. */
  120551. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  120552. /**
  120553. * If this plugin is supported
  120554. * @returns true if its supported
  120555. */
  120556. isSupported(): boolean;
  120557. /**
  120558. * Sets the linear velocity of the physics body
  120559. * @param impostor imposter to set the velocity on
  120560. * @param velocity velocity to set
  120561. */
  120562. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120563. /**
  120564. * Sets the angular velocity of the physics body
  120565. * @param impostor imposter to set the velocity on
  120566. * @param velocity velocity to set
  120567. */
  120568. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  120569. /**
  120570. * gets the linear velocity
  120571. * @param impostor imposter to get linear velocity from
  120572. * @returns linear velocity
  120573. */
  120574. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120575. /**
  120576. * gets the angular velocity
  120577. * @param impostor imposter to get angular velocity from
  120578. * @returns angular velocity
  120579. */
  120580. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  120581. /**
  120582. * Sets the mass of physics body
  120583. * @param impostor imposter to set the mass on
  120584. * @param mass mass to set
  120585. */
  120586. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  120587. /**
  120588. * Gets the mass of the physics body
  120589. * @param impostor imposter to get the mass from
  120590. * @returns mass
  120591. */
  120592. getBodyMass(impostor: PhysicsImpostor): number;
  120593. /**
  120594. * Gets friction of the impostor
  120595. * @param impostor impostor to get friction from
  120596. * @returns friction value
  120597. */
  120598. getBodyFriction(impostor: PhysicsImpostor): number;
  120599. /**
  120600. * Sets friction of the impostor
  120601. * @param impostor impostor to set friction on
  120602. * @param friction friction value
  120603. */
  120604. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  120605. /**
  120606. * Gets restitution of the impostor
  120607. * @param impostor impostor to get restitution from
  120608. * @returns restitution value
  120609. */
  120610. getBodyRestitution(impostor: PhysicsImpostor): number;
  120611. /**
  120612. * Sets resitution of the impostor
  120613. * @param impostor impostor to set resitution on
  120614. * @param restitution resitution value
  120615. */
  120616. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  120617. /**
  120618. * Gets pressure inside the impostor
  120619. * @param impostor impostor to get pressure from
  120620. * @returns pressure value
  120621. */
  120622. getBodyPressure(impostor: PhysicsImpostor): number;
  120623. /**
  120624. * Sets pressure inside a soft body impostor
  120625. * Cloth and rope must remain 0 pressure
  120626. * @param impostor impostor to set pressure on
  120627. * @param pressure pressure value
  120628. */
  120629. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  120630. /**
  120631. * Gets stiffness of the impostor
  120632. * @param impostor impostor to get stiffness from
  120633. * @returns pressure value
  120634. */
  120635. getBodyStiffness(impostor: PhysicsImpostor): number;
  120636. /**
  120637. * Sets stiffness of the impostor
  120638. * @param impostor impostor to set stiffness on
  120639. * @param stiffness stiffness value from 0 to 1
  120640. */
  120641. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  120642. /**
  120643. * Gets velocityIterations of the impostor
  120644. * @param impostor impostor to get velocity iterations from
  120645. * @returns velocityIterations value
  120646. */
  120647. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  120648. /**
  120649. * Sets velocityIterations of the impostor
  120650. * @param impostor impostor to set velocity iterations on
  120651. * @param velocityIterations velocityIterations value
  120652. */
  120653. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  120654. /**
  120655. * Gets positionIterations of the impostor
  120656. * @param impostor impostor to get position iterations from
  120657. * @returns positionIterations value
  120658. */
  120659. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  120660. /**
  120661. * Sets positionIterations of the impostor
  120662. * @param impostor impostor to set position on
  120663. * @param positionIterations positionIterations value
  120664. */
  120665. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  120666. /**
  120667. * Append an anchor to a cloth object
  120668. * @param impostor is the cloth impostor to add anchor to
  120669. * @param otherImpostor is the rigid impostor to anchor to
  120670. * @param width ratio across width from 0 to 1
  120671. * @param height ratio up height from 0 to 1
  120672. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  120673. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120674. */
  120675. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120676. /**
  120677. * Append an hook to a rope object
  120678. * @param impostor is the rope impostor to add hook to
  120679. * @param otherImpostor is the rigid impostor to hook to
  120680. * @param length ratio along the rope from 0 to 1
  120681. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  120682. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  120683. */
  120684. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  120685. /**
  120686. * Sleeps the physics body and stops it from being active
  120687. * @param impostor impostor to sleep
  120688. */
  120689. sleepBody(impostor: PhysicsImpostor): void;
  120690. /**
  120691. * Activates the physics body
  120692. * @param impostor impostor to activate
  120693. */
  120694. wakeUpBody(impostor: PhysicsImpostor): void;
  120695. /**
  120696. * Updates the distance parameters of the joint
  120697. * @param joint joint to update
  120698. * @param maxDistance maximum distance of the joint
  120699. * @param minDistance minimum distance of the joint
  120700. */
  120701. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  120702. /**
  120703. * Sets a motor on the joint
  120704. * @param joint joint to set motor on
  120705. * @param speed speed of the motor
  120706. * @param maxForce maximum force of the motor
  120707. * @param motorIndex index of the motor
  120708. */
  120709. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  120710. /**
  120711. * Sets the motors limit
  120712. * @param joint joint to set limit on
  120713. * @param upperLimit upper limit
  120714. * @param lowerLimit lower limit
  120715. */
  120716. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  120717. /**
  120718. * Syncs the position and rotation of a mesh with the impostor
  120719. * @param mesh mesh to sync
  120720. * @param impostor impostor to update the mesh with
  120721. */
  120722. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  120723. /**
  120724. * Gets the radius of the impostor
  120725. * @param impostor impostor to get radius from
  120726. * @returns the radius
  120727. */
  120728. getRadius(impostor: PhysicsImpostor): number;
  120729. /**
  120730. * Gets the box size of the impostor
  120731. * @param impostor impostor to get box size from
  120732. * @param result the resulting box size
  120733. */
  120734. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  120735. /**
  120736. * Disposes of the impostor
  120737. */
  120738. dispose(): void;
  120739. /**
  120740. * Does a raycast in the physics world
  120741. * @param from when should the ray start?
  120742. * @param to when should the ray end?
  120743. * @returns PhysicsRaycastResult
  120744. */
  120745. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  120746. }
  120747. }
  120748. declare module BABYLON {
  120749. interface AbstractScene {
  120750. /**
  120751. * The list of reflection probes added to the scene
  120752. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120753. */
  120754. reflectionProbes: Array<ReflectionProbe>;
  120755. /**
  120756. * Removes the given reflection probe from this scene.
  120757. * @param toRemove The reflection probe to remove
  120758. * @returns The index of the removed reflection probe
  120759. */
  120760. removeReflectionProbe(toRemove: ReflectionProbe): number;
  120761. /**
  120762. * Adds the given reflection probe to this scene.
  120763. * @param newReflectionProbe The reflection probe to add
  120764. */
  120765. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  120766. }
  120767. /**
  120768. * Class used to generate realtime reflection / refraction cube textures
  120769. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120770. */
  120771. export class ReflectionProbe {
  120772. /** defines the name of the probe */
  120773. name: string;
  120774. private _scene;
  120775. private _renderTargetTexture;
  120776. private _projectionMatrix;
  120777. private _viewMatrix;
  120778. private _target;
  120779. private _add;
  120780. private _attachedMesh;
  120781. private _invertYAxis;
  120782. /** Gets or sets probe position (center of the cube map) */
  120783. position: Vector3;
  120784. /**
  120785. * Creates a new reflection probe
  120786. * @param name defines the name of the probe
  120787. * @param size defines the texture resolution (for each face)
  120788. * @param scene defines the hosting scene
  120789. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  120790. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  120791. */
  120792. constructor(
  120793. /** defines the name of the probe */
  120794. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  120795. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  120796. samples: number;
  120797. /** Gets or sets the refresh rate to use (on every frame by default) */
  120798. refreshRate: number;
  120799. /**
  120800. * Gets the hosting scene
  120801. * @returns a Scene
  120802. */
  120803. getScene(): Scene;
  120804. /** Gets the internal CubeTexture used to render to */
  120805. readonly cubeTexture: RenderTargetTexture;
  120806. /** Gets the list of meshes to render */
  120807. readonly renderList: Nullable<AbstractMesh[]>;
  120808. /**
  120809. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120810. * @param mesh defines the mesh to attach to
  120811. */
  120812. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  120813. /**
  120814. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120815. * @param renderingGroupId The rendering group id corresponding to its index
  120816. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120817. */
  120818. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  120819. /**
  120820. * Clean all associated resources
  120821. */
  120822. dispose(): void;
  120823. /**
  120824. * Converts the reflection probe information to a readable string for debug purpose.
  120825. * @param fullDetails Supports for multiple levels of logging within scene loading
  120826. * @returns the human readable reflection probe info
  120827. */
  120828. toString(fullDetails?: boolean): string;
  120829. /**
  120830. * Get the class name of the relfection probe.
  120831. * @returns "ReflectionProbe"
  120832. */
  120833. getClassName(): string;
  120834. /**
  120835. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120836. * @returns The JSON representation of the texture
  120837. */
  120838. serialize(): any;
  120839. /**
  120840. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120841. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120842. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120843. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120844. * @returns The parsed reflection probe if successful
  120845. */
  120846. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  120847. }
  120848. }
  120849. declare module BABYLON {
  120850. /** @hidden */
  120851. export var _BabylonLoaderRegistered: boolean;
  120852. /**
  120853. * Helps setting up some configuration for the babylon file loader.
  120854. */
  120855. export class BabylonFileLoaderConfiguration {
  120856. /**
  120857. * The loader does not allow injecting custom physix engine into the plugins.
  120858. * Unfortunately in ES6, we need to manually inject them into the plugin.
  120859. * So you could set this variable to your engine import to make it work.
  120860. */
  120861. static LoaderInjectedPhysicsEngine: any;
  120862. }
  120863. }
  120864. declare module BABYLON {
  120865. /**
  120866. * The Physically based simple base material of BJS.
  120867. *
  120868. * This enables better naming and convention enforcements on top of the pbrMaterial.
  120869. * It is used as the base class for both the specGloss and metalRough conventions.
  120870. */
  120871. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  120872. /**
  120873. * Number of Simultaneous lights allowed on the material.
  120874. */
  120875. maxSimultaneousLights: number;
  120876. /**
  120877. * If sets to true, disables all the lights affecting the material.
  120878. */
  120879. disableLighting: boolean;
  120880. /**
  120881. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  120882. */
  120883. environmentTexture: BaseTexture;
  120884. /**
  120885. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  120886. */
  120887. invertNormalMapX: boolean;
  120888. /**
  120889. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  120890. */
  120891. invertNormalMapY: boolean;
  120892. /**
  120893. * Normal map used in the model.
  120894. */
  120895. normalTexture: BaseTexture;
  120896. /**
  120897. * Emissivie color used to self-illuminate the model.
  120898. */
  120899. emissiveColor: Color3;
  120900. /**
  120901. * Emissivie texture used to self-illuminate the model.
  120902. */
  120903. emissiveTexture: BaseTexture;
  120904. /**
  120905. * Occlusion Channel Strenght.
  120906. */
  120907. occlusionStrength: number;
  120908. /**
  120909. * Occlusion Texture of the material (adding extra occlusion effects).
  120910. */
  120911. occlusionTexture: BaseTexture;
  120912. /**
  120913. * Defines the alpha limits in alpha test mode.
  120914. */
  120915. alphaCutOff: number;
  120916. /**
  120917. * Gets the current double sided mode.
  120918. */
  120919. /**
  120920. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  120921. */
  120922. doubleSided: boolean;
  120923. /**
  120924. * Stores the pre-calculated light information of a mesh in a texture.
  120925. */
  120926. lightmapTexture: BaseTexture;
  120927. /**
  120928. * If true, the light map contains occlusion information instead of lighting info.
  120929. */
  120930. useLightmapAsShadowmap: boolean;
  120931. /**
  120932. * Instantiates a new PBRMaterial instance.
  120933. *
  120934. * @param name The material name
  120935. * @param scene The scene the material will be use in.
  120936. */
  120937. constructor(name: string, scene: Scene);
  120938. getClassName(): string;
  120939. }
  120940. }
  120941. declare module BABYLON {
  120942. /**
  120943. * The PBR material of BJS following the metal roughness convention.
  120944. *
  120945. * This fits to the PBR convention in the GLTF definition:
  120946. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  120947. */
  120948. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  120949. /**
  120950. * The base color has two different interpretations depending on the value of metalness.
  120951. * When the material is a metal, the base color is the specific measured reflectance value
  120952. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  120953. * of the material.
  120954. */
  120955. baseColor: Color3;
  120956. /**
  120957. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  120958. * well as opacity information in the alpha channel.
  120959. */
  120960. baseTexture: BaseTexture;
  120961. /**
  120962. * Specifies the metallic scalar value of the material.
  120963. * Can also be used to scale the metalness values of the metallic texture.
  120964. */
  120965. metallic: number;
  120966. /**
  120967. * Specifies the roughness scalar value of the material.
  120968. * Can also be used to scale the roughness values of the metallic texture.
  120969. */
  120970. roughness: number;
  120971. /**
  120972. * Texture containing both the metallic value in the B channel and the
  120973. * roughness value in the G channel to keep better precision.
  120974. */
  120975. metallicRoughnessTexture: BaseTexture;
  120976. /**
  120977. * Instantiates a new PBRMetalRoughnessMaterial instance.
  120978. *
  120979. * @param name The material name
  120980. * @param scene The scene the material will be use in.
  120981. */
  120982. constructor(name: string, scene: Scene);
  120983. /**
  120984. * Return the currrent class name of the material.
  120985. */
  120986. getClassName(): string;
  120987. /**
  120988. * Makes a duplicate of the current material.
  120989. * @param name - name to use for the new material.
  120990. */
  120991. clone(name: string): PBRMetallicRoughnessMaterial;
  120992. /**
  120993. * Serialize the material to a parsable JSON object.
  120994. */
  120995. serialize(): any;
  120996. /**
  120997. * Parses a JSON object correponding to the serialize function.
  120998. */
  120999. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  121000. }
  121001. }
  121002. declare module BABYLON {
  121003. /**
  121004. * The PBR material of BJS following the specular glossiness convention.
  121005. *
  121006. * This fits to the PBR convention in the GLTF definition:
  121007. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  121008. */
  121009. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  121010. /**
  121011. * Specifies the diffuse color of the material.
  121012. */
  121013. diffuseColor: Color3;
  121014. /**
  121015. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  121016. * channel.
  121017. */
  121018. diffuseTexture: BaseTexture;
  121019. /**
  121020. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  121021. */
  121022. specularColor: Color3;
  121023. /**
  121024. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  121025. */
  121026. glossiness: number;
  121027. /**
  121028. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  121029. */
  121030. specularGlossinessTexture: BaseTexture;
  121031. /**
  121032. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  121033. *
  121034. * @param name The material name
  121035. * @param scene The scene the material will be use in.
  121036. */
  121037. constructor(name: string, scene: Scene);
  121038. /**
  121039. * Return the currrent class name of the material.
  121040. */
  121041. getClassName(): string;
  121042. /**
  121043. * Makes a duplicate of the current material.
  121044. * @param name - name to use for the new material.
  121045. */
  121046. clone(name: string): PBRSpecularGlossinessMaterial;
  121047. /**
  121048. * Serialize the material to a parsable JSON object.
  121049. */
  121050. serialize(): any;
  121051. /**
  121052. * Parses a JSON object correponding to the serialize function.
  121053. */
  121054. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  121055. }
  121056. }
  121057. declare module BABYLON {
  121058. /**
  121059. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  121060. * It can help converting any input color in a desired output one. This can then be used to create effects
  121061. * from sepia, black and white to sixties or futuristic rendering...
  121062. *
  121063. * The only supported format is currently 3dl.
  121064. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  121065. */
  121066. export class ColorGradingTexture extends BaseTexture {
  121067. /**
  121068. * The current texture matrix. (will always be identity in color grading texture)
  121069. */
  121070. private _textureMatrix;
  121071. /**
  121072. * The texture URL.
  121073. */
  121074. url: string;
  121075. /**
  121076. * Empty line regex stored for GC.
  121077. */
  121078. private static _noneEmptyLineRegex;
  121079. private _engine;
  121080. /**
  121081. * Instantiates a ColorGradingTexture from the following parameters.
  121082. *
  121083. * @param url The location of the color gradind data (currently only supporting 3dl)
  121084. * @param scene The scene the texture will be used in
  121085. */
  121086. constructor(url: string, scene: Scene);
  121087. /**
  121088. * Returns the texture matrix used in most of the material.
  121089. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  121090. */
  121091. getTextureMatrix(): Matrix;
  121092. /**
  121093. * Occurs when the file being loaded is a .3dl LUT file.
  121094. */
  121095. private load3dlTexture;
  121096. /**
  121097. * Starts the loading process of the texture.
  121098. */
  121099. private loadTexture;
  121100. /**
  121101. * Clones the color gradind texture.
  121102. */
  121103. clone(): ColorGradingTexture;
  121104. /**
  121105. * Called during delayed load for textures.
  121106. */
  121107. delayLoad(): void;
  121108. /**
  121109. * Parses a color grading texture serialized by Babylon.
  121110. * @param parsedTexture The texture information being parsedTexture
  121111. * @param scene The scene to load the texture in
  121112. * @param rootUrl The root url of the data assets to load
  121113. * @return A color gradind texture
  121114. */
  121115. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  121116. /**
  121117. * Serializes the LUT texture to json format.
  121118. */
  121119. serialize(): any;
  121120. }
  121121. }
  121122. declare module BABYLON {
  121123. /**
  121124. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  121125. */
  121126. export class EquiRectangularCubeTexture extends BaseTexture {
  121127. /** The six faces of the cube. */
  121128. private static _FacesMapping;
  121129. private _noMipmap;
  121130. private _onLoad;
  121131. private _onError;
  121132. /** The size of the cubemap. */
  121133. private _size;
  121134. /** The buffer of the image. */
  121135. private _buffer;
  121136. /** The width of the input image. */
  121137. private _width;
  121138. /** The height of the input image. */
  121139. private _height;
  121140. /** The URL to the image. */
  121141. url: string;
  121142. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  121143. coordinatesMode: number;
  121144. /**
  121145. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  121146. * @param url The location of the image
  121147. * @param scene The scene the texture will be used in
  121148. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  121149. * @param noMipmap Forces to not generate the mipmap if true
  121150. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121151. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121152. * @param onLoad — defines a callback called when texture is loaded
  121153. * @param onError — defines a callback called if there is an error
  121154. */
  121155. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  121156. /**
  121157. * Load the image data, by putting the image on a canvas and extracting its buffer.
  121158. */
  121159. private loadImage;
  121160. /**
  121161. * Convert the image buffer into a cubemap and create a CubeTexture.
  121162. */
  121163. private loadTexture;
  121164. /**
  121165. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  121166. * @param buffer The ArrayBuffer that should be converted.
  121167. * @returns The buffer as Float32Array.
  121168. */
  121169. private getFloat32ArrayFromArrayBuffer;
  121170. /**
  121171. * Get the current class name of the texture useful for serialization or dynamic coding.
  121172. * @returns "EquiRectangularCubeTexture"
  121173. */
  121174. getClassName(): string;
  121175. /**
  121176. * Create a clone of the current EquiRectangularCubeTexture and return it.
  121177. * @returns A clone of the current EquiRectangularCubeTexture.
  121178. */
  121179. clone(): EquiRectangularCubeTexture;
  121180. }
  121181. }
  121182. declare module BABYLON {
  121183. /**
  121184. * Based on jsTGALoader - Javascript loader for TGA file
  121185. * By Vincent Thibault
  121186. * @see http://blog.robrowser.com/javascript-tga-loader.html
  121187. */
  121188. export class TGATools {
  121189. private static _TYPE_INDEXED;
  121190. private static _TYPE_RGB;
  121191. private static _TYPE_GREY;
  121192. private static _TYPE_RLE_INDEXED;
  121193. private static _TYPE_RLE_RGB;
  121194. private static _TYPE_RLE_GREY;
  121195. private static _ORIGIN_MASK;
  121196. private static _ORIGIN_SHIFT;
  121197. private static _ORIGIN_BL;
  121198. private static _ORIGIN_BR;
  121199. private static _ORIGIN_UL;
  121200. private static _ORIGIN_UR;
  121201. /**
  121202. * Gets the header of a TGA file
  121203. * @param data defines the TGA data
  121204. * @returns the header
  121205. */
  121206. static GetTGAHeader(data: Uint8Array): any;
  121207. /**
  121208. * Uploads TGA content to a Babylon Texture
  121209. * @hidden
  121210. */
  121211. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  121212. /** @hidden */
  121213. 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;
  121214. /** @hidden */
  121215. 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;
  121216. /** @hidden */
  121217. 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;
  121218. /** @hidden */
  121219. 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;
  121220. /** @hidden */
  121221. 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;
  121222. /** @hidden */
  121223. 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;
  121224. }
  121225. }
  121226. declare module BABYLON {
  121227. /**
  121228. * Implementation of the TGA Texture Loader.
  121229. * @hidden
  121230. */
  121231. export class _TGATextureLoader implements IInternalTextureLoader {
  121232. /**
  121233. * Defines wether the loader supports cascade loading the different faces.
  121234. */
  121235. readonly supportCascades: boolean;
  121236. /**
  121237. * This returns if the loader support the current file information.
  121238. * @param extension defines the file extension of the file being loaded
  121239. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121240. * @param fallback defines the fallback internal texture if any
  121241. * @param isBase64 defines whether the texture is encoded as a base64
  121242. * @param isBuffer defines whether the texture data are stored as a buffer
  121243. * @returns true if the loader can load the specified file
  121244. */
  121245. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121246. /**
  121247. * Transform the url before loading if required.
  121248. * @param rootUrl the url of the texture
  121249. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121250. * @returns the transformed texture
  121251. */
  121252. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121253. /**
  121254. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121255. * @param rootUrl the url of the texture
  121256. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121257. * @returns the fallback texture
  121258. */
  121259. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121260. /**
  121261. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  121262. * @param data contains the texture data
  121263. * @param texture defines the BabylonJS internal texture
  121264. * @param createPolynomials will be true if polynomials have been requested
  121265. * @param onLoad defines the callback to trigger once the texture is ready
  121266. * @param onError defines the callback to trigger in case of error
  121267. */
  121268. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121269. /**
  121270. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121271. * @param data contains the texture data
  121272. * @param texture defines the BabylonJS internal texture
  121273. * @param callback defines the method to call once ready to upload
  121274. */
  121275. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121276. }
  121277. }
  121278. declare module BABYLON {
  121279. /**
  121280. * Info about the .basis files
  121281. */
  121282. class BasisFileInfo {
  121283. /**
  121284. * If the file has alpha
  121285. */
  121286. hasAlpha: boolean;
  121287. /**
  121288. * Info about each image of the basis file
  121289. */
  121290. images: Array<{
  121291. levels: Array<{
  121292. width: number;
  121293. height: number;
  121294. transcodedPixels: ArrayBufferView;
  121295. }>;
  121296. }>;
  121297. }
  121298. /**
  121299. * Result of transcoding a basis file
  121300. */
  121301. class TranscodeResult {
  121302. /**
  121303. * Info about the .basis file
  121304. */
  121305. fileInfo: BasisFileInfo;
  121306. /**
  121307. * Format to use when loading the file
  121308. */
  121309. format: number;
  121310. }
  121311. /**
  121312. * Configuration options for the Basis transcoder
  121313. */
  121314. export class BasisTranscodeConfiguration {
  121315. /**
  121316. * Supported compression formats used to determine the supported output format of the transcoder
  121317. */
  121318. supportedCompressionFormats?: {
  121319. /**
  121320. * etc1 compression format
  121321. */
  121322. etc1?: boolean;
  121323. /**
  121324. * s3tc compression format
  121325. */
  121326. s3tc?: boolean;
  121327. /**
  121328. * pvrtc compression format
  121329. */
  121330. pvrtc?: boolean;
  121331. /**
  121332. * etc2 compression format
  121333. */
  121334. etc2?: boolean;
  121335. };
  121336. /**
  121337. * If mipmap levels should be loaded for transcoded images (Default: true)
  121338. */
  121339. loadMipmapLevels?: boolean;
  121340. /**
  121341. * Index of a single image to load (Default: all images)
  121342. */
  121343. loadSingleImage?: number;
  121344. }
  121345. /**
  121346. * Used to load .Basis files
  121347. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  121348. */
  121349. export class BasisTools {
  121350. private static _IgnoreSupportedFormats;
  121351. /**
  121352. * URL to use when loading the basis transcoder
  121353. */
  121354. static JSModuleURL: string;
  121355. /**
  121356. * URL to use when loading the wasm module for the transcoder
  121357. */
  121358. static WasmModuleURL: string;
  121359. /**
  121360. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  121361. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  121362. * @returns internal format corresponding to the Basis format
  121363. */
  121364. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  121365. private static _WorkerPromise;
  121366. private static _Worker;
  121367. private static _actionId;
  121368. private static _CreateWorkerAsync;
  121369. /**
  121370. * Transcodes a loaded image file to compressed pixel data
  121371. * @param imageData image data to transcode
  121372. * @param config configuration options for the transcoding
  121373. * @returns a promise resulting in the transcoded image
  121374. */
  121375. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  121376. /**
  121377. * Loads a texture from the transcode result
  121378. * @param texture texture load to
  121379. * @param transcodeResult the result of transcoding the basis file to load from
  121380. */
  121381. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  121382. }
  121383. }
  121384. declare module BABYLON {
  121385. /**
  121386. * Loader for .basis file format
  121387. */
  121388. export class _BasisTextureLoader implements IInternalTextureLoader {
  121389. /**
  121390. * Defines whether the loader supports cascade loading the different faces.
  121391. */
  121392. readonly supportCascades: boolean;
  121393. /**
  121394. * This returns if the loader support the current file information.
  121395. * @param extension defines the file extension of the file being loaded
  121396. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121397. * @param fallback defines the fallback internal texture if any
  121398. * @param isBase64 defines whether the texture is encoded as a base64
  121399. * @param isBuffer defines whether the texture data are stored as a buffer
  121400. * @returns true if the loader can load the specified file
  121401. */
  121402. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  121403. /**
  121404. * Transform the url before loading if required.
  121405. * @param rootUrl the url of the texture
  121406. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121407. * @returns the transformed texture
  121408. */
  121409. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  121410. /**
  121411. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  121412. * @param rootUrl the url of the texture
  121413. * @param textureFormatInUse defines the current compressed format in use iun the engine
  121414. * @returns the fallback texture
  121415. */
  121416. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  121417. /**
  121418. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  121419. * @param data contains the texture data
  121420. * @param texture defines the BabylonJS internal texture
  121421. * @param createPolynomials will be true if polynomials have been requested
  121422. * @param onLoad defines the callback to trigger once the texture is ready
  121423. * @param onError defines the callback to trigger in case of error
  121424. */
  121425. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  121426. /**
  121427. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  121428. * @param data contains the texture data
  121429. * @param texture defines the BabylonJS internal texture
  121430. * @param callback defines the method to call once ready to upload
  121431. */
  121432. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  121433. }
  121434. }
  121435. declare module BABYLON {
  121436. /**
  121437. * 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.
  121438. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121439. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121440. */
  121441. export class CustomProceduralTexture extends ProceduralTexture {
  121442. private _animate;
  121443. private _time;
  121444. private _config;
  121445. private _texturePath;
  121446. /**
  121447. * Instantiates a new Custom Procedural Texture.
  121448. * 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.
  121449. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  121450. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  121451. * @param name Define the name of the texture
  121452. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  121453. * @param size Define the size of the texture to create
  121454. * @param scene Define the scene the texture belongs to
  121455. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  121456. * @param generateMipMaps Define if the texture should creates mip maps or not
  121457. */
  121458. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121459. private _loadJson;
  121460. /**
  121461. * Is the texture ready to be used ? (rendered at least once)
  121462. * @returns true if ready, otherwise, false.
  121463. */
  121464. isReady(): boolean;
  121465. /**
  121466. * Render the texture to its associated render target.
  121467. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  121468. */
  121469. render(useCameraPostProcess?: boolean): void;
  121470. /**
  121471. * Update the list of dependant textures samplers in the shader.
  121472. */
  121473. updateTextures(): void;
  121474. /**
  121475. * Update the uniform values of the procedural texture in the shader.
  121476. */
  121477. updateShaderUniforms(): void;
  121478. /**
  121479. * Define if the texture animates or not.
  121480. */
  121481. animate: boolean;
  121482. }
  121483. }
  121484. declare module BABYLON {
  121485. /** @hidden */
  121486. export var noisePixelShader: {
  121487. name: string;
  121488. shader: string;
  121489. };
  121490. }
  121491. declare module BABYLON {
  121492. /**
  121493. * Class used to generate noise procedural textures
  121494. */
  121495. export class NoiseProceduralTexture extends ProceduralTexture {
  121496. private _time;
  121497. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  121498. brightness: number;
  121499. /** Defines the number of octaves to process */
  121500. octaves: number;
  121501. /** Defines the level of persistence (0.8 by default) */
  121502. persistence: number;
  121503. /** Gets or sets animation speed factor (default is 1) */
  121504. animationSpeedFactor: number;
  121505. /**
  121506. * Creates a new NoiseProceduralTexture
  121507. * @param name defines the name fo the texture
  121508. * @param size defines the size of the texture (default is 256)
  121509. * @param scene defines the hosting scene
  121510. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  121511. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  121512. */
  121513. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  121514. private _updateShaderUniforms;
  121515. protected _getDefines(): string;
  121516. /** Generate the current state of the procedural texture */
  121517. render(useCameraPostProcess?: boolean): void;
  121518. /**
  121519. * Serializes this noise procedural texture
  121520. * @returns a serialized noise procedural texture object
  121521. */
  121522. serialize(): any;
  121523. /**
  121524. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  121525. * @param parsedTexture defines parsed texture data
  121526. * @param scene defines the current scene
  121527. * @param rootUrl defines the root URL containing noise procedural texture information
  121528. * @returns a parsed NoiseProceduralTexture
  121529. */
  121530. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  121531. }
  121532. }
  121533. declare module BABYLON {
  121534. /**
  121535. * Raw cube texture where the raw buffers are passed in
  121536. */
  121537. export class RawCubeTexture extends CubeTexture {
  121538. /**
  121539. * Creates a cube texture where the raw buffers are passed in.
  121540. * @param scene defines the scene the texture is attached to
  121541. * @param data defines the array of data to use to create each face
  121542. * @param size defines the size of the textures
  121543. * @param format defines the format of the data
  121544. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  121545. * @param generateMipMaps defines if the engine should generate the mip levels
  121546. * @param invertY defines if data must be stored with Y axis inverted
  121547. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  121548. * @param compression defines the compression used (null by default)
  121549. */
  121550. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  121551. /**
  121552. * Updates the raw cube texture.
  121553. * @param data defines the data to store
  121554. * @param format defines the data format
  121555. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  121556. * @param invertY defines if data must be stored with Y axis inverted
  121557. * @param compression defines the compression used (null by default)
  121558. * @param level defines which level of the texture to update
  121559. */
  121560. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  121561. /**
  121562. * Updates a raw cube texture with RGBD encoded data.
  121563. * @param data defines the array of data [mipmap][face] to use to create each face
  121564. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  121565. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121566. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121567. * @returns a promsie that resolves when the operation is complete
  121568. */
  121569. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  121570. /**
  121571. * Clones the raw cube texture.
  121572. * @return a new cube texture
  121573. */
  121574. clone(): CubeTexture;
  121575. /** @hidden */
  121576. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  121577. }
  121578. }
  121579. declare module BABYLON {
  121580. /**
  121581. * Class used to store 3D textures containing user data
  121582. */
  121583. export class RawTexture3D extends Texture {
  121584. /** Gets or sets the texture format to use */
  121585. format: number;
  121586. private _engine;
  121587. /**
  121588. * Create a new RawTexture3D
  121589. * @param data defines the data of the texture
  121590. * @param width defines the width of the texture
  121591. * @param height defines the height of the texture
  121592. * @param depth defines the depth of the texture
  121593. * @param format defines the texture format to use
  121594. * @param scene defines the hosting scene
  121595. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121596. * @param invertY defines if texture must be stored with Y axis inverted
  121597. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121598. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121599. */
  121600. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121601. /** Gets or sets the texture format to use */
  121602. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121603. /**
  121604. * Update the texture with new data
  121605. * @param data defines the data to store in the texture
  121606. */
  121607. update(data: ArrayBufferView): void;
  121608. }
  121609. }
  121610. declare module BABYLON {
  121611. /**
  121612. * Class used to store 2D array textures containing user data
  121613. */
  121614. export class RawTexture2DArray extends Texture {
  121615. /** Gets or sets the texture format to use */
  121616. format: number;
  121617. private _engine;
  121618. /**
  121619. * Create a new RawTexture2DArray
  121620. * @param data defines the data of the texture
  121621. * @param width defines the width of the texture
  121622. * @param height defines the height of the texture
  121623. * @param depth defines the number of layers of the texture
  121624. * @param format defines the texture format to use
  121625. * @param scene defines the hosting scene
  121626. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  121627. * @param invertY defines if texture must be stored with Y axis inverted
  121628. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121629. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  121630. */
  121631. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  121632. /** Gets or sets the texture format to use */
  121633. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  121634. /**
  121635. * Update the texture with new data
  121636. * @param data defines the data to store in the texture
  121637. */
  121638. update(data: ArrayBufferView): void;
  121639. }
  121640. }
  121641. declare module BABYLON {
  121642. /**
  121643. * Creates a refraction texture used by refraction channel of the standard material.
  121644. * It is like a mirror but to see through a material.
  121645. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121646. */
  121647. export class RefractionTexture extends RenderTargetTexture {
  121648. /**
  121649. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  121650. * 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.
  121651. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121652. */
  121653. refractionPlane: Plane;
  121654. /**
  121655. * Define how deep under the surface we should see.
  121656. */
  121657. depth: number;
  121658. /**
  121659. * Creates a refraction texture used by refraction channel of the standard material.
  121660. * It is like a mirror but to see through a material.
  121661. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  121662. * @param name Define the texture name
  121663. * @param size Define the size of the underlying texture
  121664. * @param scene Define the scene the refraction belongs to
  121665. * @param generateMipMaps Define if we need to generate mips level for the refraction
  121666. */
  121667. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  121668. /**
  121669. * Clone the refraction texture.
  121670. * @returns the cloned texture
  121671. */
  121672. clone(): RefractionTexture;
  121673. /**
  121674. * Serialize the texture to a JSON representation you could use in Parse later on
  121675. * @returns the serialized JSON representation
  121676. */
  121677. serialize(): any;
  121678. }
  121679. }
  121680. declare module BABYLON {
  121681. /**
  121682. * Defines the options related to the creation of an HtmlElementTexture
  121683. */
  121684. export interface IHtmlElementTextureOptions {
  121685. /**
  121686. * Defines wether mip maps should be created or not.
  121687. */
  121688. generateMipMaps?: boolean;
  121689. /**
  121690. * Defines the sampling mode of the texture.
  121691. */
  121692. samplingMode?: number;
  121693. /**
  121694. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  121695. */
  121696. engine: Nullable<ThinEngine>;
  121697. /**
  121698. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  121699. */
  121700. scene: Nullable<Scene>;
  121701. }
  121702. /**
  121703. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  121704. * To be as efficient as possible depending on your constraints nothing aside the first upload
  121705. * is automatically managed.
  121706. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  121707. * in your application.
  121708. *
  121709. * As the update is not automatic, you need to call them manually.
  121710. */
  121711. export class HtmlElementTexture extends BaseTexture {
  121712. /**
  121713. * The texture URL.
  121714. */
  121715. element: HTMLVideoElement | HTMLCanvasElement;
  121716. private static readonly DefaultOptions;
  121717. private _textureMatrix;
  121718. private _engine;
  121719. private _isVideo;
  121720. private _generateMipMaps;
  121721. private _samplingMode;
  121722. /**
  121723. * Instantiates a HtmlElementTexture from the following parameters.
  121724. *
  121725. * @param name Defines the name of the texture
  121726. * @param element Defines the video or canvas the texture is filled with
  121727. * @param options Defines the other none mandatory texture creation options
  121728. */
  121729. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  121730. private _createInternalTexture;
  121731. /**
  121732. * Returns the texture matrix used in most of the material.
  121733. */
  121734. getTextureMatrix(): Matrix;
  121735. /**
  121736. * Updates the content of the texture.
  121737. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  121738. */
  121739. update(invertY?: Nullable<boolean>): void;
  121740. }
  121741. }
  121742. declare module BABYLON {
  121743. /**
  121744. * Enum used to define the target of a block
  121745. */
  121746. export enum NodeMaterialBlockTargets {
  121747. /** Vertex shader */
  121748. Vertex = 1,
  121749. /** Fragment shader */
  121750. Fragment = 2,
  121751. /** Neutral */
  121752. Neutral = 4,
  121753. /** Vertex and Fragment */
  121754. VertexAndFragment = 3
  121755. }
  121756. }
  121757. declare module BABYLON {
  121758. /**
  121759. * Defines the kind of connection point for node based material
  121760. */
  121761. export enum NodeMaterialBlockConnectionPointTypes {
  121762. /** Float */
  121763. Float = 1,
  121764. /** Int */
  121765. Int = 2,
  121766. /** Vector2 */
  121767. Vector2 = 4,
  121768. /** Vector3 */
  121769. Vector3 = 8,
  121770. /** Vector4 */
  121771. Vector4 = 16,
  121772. /** Color3 */
  121773. Color3 = 32,
  121774. /** Color4 */
  121775. Color4 = 64,
  121776. /** Matrix */
  121777. Matrix = 128,
  121778. /** Detect type based on connection */
  121779. AutoDetect = 1024,
  121780. /** Output type that will be defined by input type */
  121781. BasedOnInput = 2048
  121782. }
  121783. }
  121784. declare module BABYLON {
  121785. /**
  121786. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  121787. */
  121788. export enum NodeMaterialBlockConnectionPointMode {
  121789. /** Value is an uniform */
  121790. Uniform = 0,
  121791. /** Value is a mesh attribute */
  121792. Attribute = 1,
  121793. /** Value is a varying between vertex and fragment shaders */
  121794. Varying = 2,
  121795. /** Mode is undefined */
  121796. Undefined = 3
  121797. }
  121798. }
  121799. declare module BABYLON {
  121800. /**
  121801. * Enum used to define system values e.g. values automatically provided by the system
  121802. */
  121803. export enum NodeMaterialSystemValues {
  121804. /** World */
  121805. World = 1,
  121806. /** View */
  121807. View = 2,
  121808. /** Projection */
  121809. Projection = 3,
  121810. /** ViewProjection */
  121811. ViewProjection = 4,
  121812. /** WorldView */
  121813. WorldView = 5,
  121814. /** WorldViewProjection */
  121815. WorldViewProjection = 6,
  121816. /** CameraPosition */
  121817. CameraPosition = 7,
  121818. /** Fog Color */
  121819. FogColor = 8,
  121820. /** Delta time */
  121821. DeltaTime = 9
  121822. }
  121823. }
  121824. declare module BABYLON {
  121825. /**
  121826. * Root class for all node material optimizers
  121827. */
  121828. export class NodeMaterialOptimizer {
  121829. /**
  121830. * Function used to optimize a NodeMaterial graph
  121831. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  121832. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  121833. */
  121834. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  121835. }
  121836. }
  121837. declare module BABYLON {
  121838. /**
  121839. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  121840. */
  121841. export class TransformBlock extends NodeMaterialBlock {
  121842. /**
  121843. * Defines the value to use to complement W value to transform it to a Vector4
  121844. */
  121845. complementW: number;
  121846. /**
  121847. * Defines the value to use to complement z value to transform it to a Vector4
  121848. */
  121849. complementZ: number;
  121850. /**
  121851. * Creates a new TransformBlock
  121852. * @param name defines the block name
  121853. */
  121854. constructor(name: string);
  121855. /**
  121856. * Gets the current class name
  121857. * @returns the class name
  121858. */
  121859. getClassName(): string;
  121860. /**
  121861. * Gets the vector input
  121862. */
  121863. readonly vector: NodeMaterialConnectionPoint;
  121864. /**
  121865. * Gets the output component
  121866. */
  121867. readonly output: NodeMaterialConnectionPoint;
  121868. /**
  121869. * Gets the matrix transform input
  121870. */
  121871. readonly transform: NodeMaterialConnectionPoint;
  121872. protected _buildBlock(state: NodeMaterialBuildState): this;
  121873. serialize(): any;
  121874. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121875. protected _dumpPropertiesCode(): string;
  121876. }
  121877. }
  121878. declare module BABYLON {
  121879. /**
  121880. * Block used to output the vertex position
  121881. */
  121882. export class VertexOutputBlock extends NodeMaterialBlock {
  121883. /**
  121884. * Creates a new VertexOutputBlock
  121885. * @param name defines the block name
  121886. */
  121887. constructor(name: string);
  121888. /**
  121889. * Gets the current class name
  121890. * @returns the class name
  121891. */
  121892. getClassName(): string;
  121893. /**
  121894. * Gets the vector input component
  121895. */
  121896. readonly vector: NodeMaterialConnectionPoint;
  121897. protected _buildBlock(state: NodeMaterialBuildState): this;
  121898. }
  121899. }
  121900. declare module BABYLON {
  121901. /**
  121902. * Block used to output the final color
  121903. */
  121904. export class FragmentOutputBlock extends NodeMaterialBlock {
  121905. /**
  121906. * Create a new FragmentOutputBlock
  121907. * @param name defines the block name
  121908. */
  121909. constructor(name: string);
  121910. /**
  121911. * Gets the current class name
  121912. * @returns the class name
  121913. */
  121914. getClassName(): string;
  121915. /**
  121916. * Gets the rgba input component
  121917. */
  121918. readonly rgba: NodeMaterialConnectionPoint;
  121919. /**
  121920. * Gets the rgb input component
  121921. */
  121922. readonly rgb: NodeMaterialConnectionPoint;
  121923. /**
  121924. * Gets the a input component
  121925. */
  121926. readonly a: NodeMaterialConnectionPoint;
  121927. protected _buildBlock(state: NodeMaterialBuildState): this;
  121928. }
  121929. }
  121930. declare module BABYLON {
  121931. /**
  121932. * Block used to read a reflection texture from a sampler
  121933. */
  121934. export class ReflectionTextureBlock extends NodeMaterialBlock {
  121935. private _define3DName;
  121936. private _defineCubicName;
  121937. private _defineExplicitName;
  121938. private _defineProjectionName;
  121939. private _defineLocalCubicName;
  121940. private _defineSphericalName;
  121941. private _definePlanarName;
  121942. private _defineEquirectangularName;
  121943. private _defineMirroredEquirectangularFixedName;
  121944. private _defineEquirectangularFixedName;
  121945. private _defineSkyboxName;
  121946. private _cubeSamplerName;
  121947. private _2DSamplerName;
  121948. private _positionUVWName;
  121949. private _directionWName;
  121950. private _reflectionCoordsName;
  121951. private _reflection2DCoordsName;
  121952. private _reflectionColorName;
  121953. private _reflectionMatrixName;
  121954. /**
  121955. * Gets or sets the texture associated with the node
  121956. */
  121957. texture: Nullable<BaseTexture>;
  121958. /**
  121959. * Create a new TextureBlock
  121960. * @param name defines the block name
  121961. */
  121962. constructor(name: string);
  121963. /**
  121964. * Gets the current class name
  121965. * @returns the class name
  121966. */
  121967. getClassName(): string;
  121968. /**
  121969. * Gets the world position input component
  121970. */
  121971. readonly position: NodeMaterialConnectionPoint;
  121972. /**
  121973. * Gets the world position input component
  121974. */
  121975. readonly worldPosition: NodeMaterialConnectionPoint;
  121976. /**
  121977. * Gets the world normal input component
  121978. */
  121979. readonly worldNormal: NodeMaterialConnectionPoint;
  121980. /**
  121981. * Gets the world input component
  121982. */
  121983. readonly world: NodeMaterialConnectionPoint;
  121984. /**
  121985. * Gets the camera (or eye) position component
  121986. */
  121987. readonly cameraPosition: NodeMaterialConnectionPoint;
  121988. /**
  121989. * Gets the view input component
  121990. */
  121991. readonly view: NodeMaterialConnectionPoint;
  121992. /**
  121993. * Gets the rgb output component
  121994. */
  121995. readonly rgb: NodeMaterialConnectionPoint;
  121996. /**
  121997. * Gets the r output component
  121998. */
  121999. readonly r: NodeMaterialConnectionPoint;
  122000. /**
  122001. * Gets the g output component
  122002. */
  122003. readonly g: NodeMaterialConnectionPoint;
  122004. /**
  122005. * Gets the b output component
  122006. */
  122007. readonly b: NodeMaterialConnectionPoint;
  122008. autoConfigure(material: NodeMaterial): void;
  122009. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122010. isReady(): boolean;
  122011. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122012. private _injectVertexCode;
  122013. private _writeOutput;
  122014. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122015. protected _dumpPropertiesCode(): string;
  122016. serialize(): any;
  122017. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122018. }
  122019. }
  122020. declare module BABYLON {
  122021. /**
  122022. * Interface used to configure the node material editor
  122023. */
  122024. export interface INodeMaterialEditorOptions {
  122025. /** Define the URl to load node editor script */
  122026. editorURL?: string;
  122027. }
  122028. /** @hidden */
  122029. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  122030. /** BONES */
  122031. NUM_BONE_INFLUENCERS: number;
  122032. BonesPerMesh: number;
  122033. BONETEXTURE: boolean;
  122034. /** MORPH TARGETS */
  122035. MORPHTARGETS: boolean;
  122036. MORPHTARGETS_NORMAL: boolean;
  122037. MORPHTARGETS_TANGENT: boolean;
  122038. MORPHTARGETS_UV: boolean;
  122039. NUM_MORPH_INFLUENCERS: number;
  122040. /** IMAGE PROCESSING */
  122041. IMAGEPROCESSING: boolean;
  122042. VIGNETTE: boolean;
  122043. VIGNETTEBLENDMODEMULTIPLY: boolean;
  122044. VIGNETTEBLENDMODEOPAQUE: boolean;
  122045. TONEMAPPING: boolean;
  122046. TONEMAPPING_ACES: boolean;
  122047. CONTRAST: boolean;
  122048. EXPOSURE: boolean;
  122049. COLORCURVES: boolean;
  122050. COLORGRADING: boolean;
  122051. COLORGRADING3D: boolean;
  122052. SAMPLER3DGREENDEPTH: boolean;
  122053. SAMPLER3DBGRMAP: boolean;
  122054. IMAGEPROCESSINGPOSTPROCESS: boolean;
  122055. /** MISC. */
  122056. BUMPDIRECTUV: number;
  122057. constructor();
  122058. setValue(name: string, value: boolean): void;
  122059. }
  122060. /**
  122061. * Class used to configure NodeMaterial
  122062. */
  122063. export interface INodeMaterialOptions {
  122064. /**
  122065. * Defines if blocks should emit comments
  122066. */
  122067. emitComments: boolean;
  122068. }
  122069. /**
  122070. * Class used to create a node based material built by assembling shader blocks
  122071. */
  122072. export class NodeMaterial extends PushMaterial {
  122073. private static _BuildIdGenerator;
  122074. private _options;
  122075. private _vertexCompilationState;
  122076. private _fragmentCompilationState;
  122077. private _sharedData;
  122078. private _buildId;
  122079. private _buildWasSuccessful;
  122080. private _cachedWorldViewMatrix;
  122081. private _cachedWorldViewProjectionMatrix;
  122082. private _optimizers;
  122083. private _animationFrame;
  122084. /** Define the URl to load node editor script */
  122085. static EditorURL: string;
  122086. private BJSNODEMATERIALEDITOR;
  122087. /** Get the inspector from bundle or global */
  122088. private _getGlobalNodeMaterialEditor;
  122089. /**
  122090. * Gets or sets data used by visual editor
  122091. * @see https://nme.babylonjs.com
  122092. */
  122093. editorData: any;
  122094. /**
  122095. * 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)
  122096. */
  122097. ignoreAlpha: boolean;
  122098. /**
  122099. * Defines the maximum number of lights that can be used in the material
  122100. */
  122101. maxSimultaneousLights: number;
  122102. /**
  122103. * Observable raised when the material is built
  122104. */
  122105. onBuildObservable: Observable<NodeMaterial>;
  122106. /**
  122107. * Gets or sets the root nodes of the material vertex shader
  122108. */
  122109. _vertexOutputNodes: NodeMaterialBlock[];
  122110. /**
  122111. * Gets or sets the root nodes of the material fragment (pixel) shader
  122112. */
  122113. _fragmentOutputNodes: NodeMaterialBlock[];
  122114. /** Gets or sets options to control the node material overall behavior */
  122115. options: INodeMaterialOptions;
  122116. /**
  122117. * Default configuration related to image processing available in the standard Material.
  122118. */
  122119. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122120. /**
  122121. * Gets the image processing configuration used either in this material.
  122122. */
  122123. /**
  122124. * Sets the Default image processing configuration used either in the this material.
  122125. *
  122126. * If sets to null, the scene one is in use.
  122127. */
  122128. imageProcessingConfiguration: ImageProcessingConfiguration;
  122129. /**
  122130. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  122131. */
  122132. attachedBlocks: NodeMaterialBlock[];
  122133. /**
  122134. * Create a new node based material
  122135. * @param name defines the material name
  122136. * @param scene defines the hosting scene
  122137. * @param options defines creation option
  122138. */
  122139. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  122140. /**
  122141. * Gets the current class name of the material e.g. "NodeMaterial"
  122142. * @returns the class name
  122143. */
  122144. getClassName(): string;
  122145. /**
  122146. * Keep track of the image processing observer to allow dispose and replace.
  122147. */
  122148. private _imageProcessingObserver;
  122149. /**
  122150. * Attaches a new image processing configuration to the Standard Material.
  122151. * @param configuration
  122152. */
  122153. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122154. /**
  122155. * Get a block by its name
  122156. * @param name defines the name of the block to retrieve
  122157. * @returns the required block or null if not found
  122158. */
  122159. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  122160. /**
  122161. * Get a block by its name
  122162. * @param predicate defines the predicate used to find the good candidate
  122163. * @returns the required block or null if not found
  122164. */
  122165. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  122166. /**
  122167. * Get an input block by its name
  122168. * @param predicate defines the predicate used to find the good candidate
  122169. * @returns the required input block or null if not found
  122170. */
  122171. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  122172. /**
  122173. * Gets the list of input blocks attached to this material
  122174. * @returns an array of InputBlocks
  122175. */
  122176. getInputBlocks(): InputBlock[];
  122177. /**
  122178. * Adds a new optimizer to the list of optimizers
  122179. * @param optimizer defines the optimizers to add
  122180. * @returns the current material
  122181. */
  122182. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  122183. /**
  122184. * Remove an optimizer from the list of optimizers
  122185. * @param optimizer defines the optimizers to remove
  122186. * @returns the current material
  122187. */
  122188. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  122189. /**
  122190. * Add a new block to the list of output nodes
  122191. * @param node defines the node to add
  122192. * @returns the current material
  122193. */
  122194. addOutputNode(node: NodeMaterialBlock): this;
  122195. /**
  122196. * Remove a block from the list of root nodes
  122197. * @param node defines the node to remove
  122198. * @returns the current material
  122199. */
  122200. removeOutputNode(node: NodeMaterialBlock): this;
  122201. private _addVertexOutputNode;
  122202. private _removeVertexOutputNode;
  122203. private _addFragmentOutputNode;
  122204. private _removeFragmentOutputNode;
  122205. /**
  122206. * Specifies if the material will require alpha blending
  122207. * @returns a boolean specifying if alpha blending is needed
  122208. */
  122209. needAlphaBlending(): boolean;
  122210. /**
  122211. * Specifies if this material should be rendered in alpha test mode
  122212. * @returns a boolean specifying if an alpha test is needed.
  122213. */
  122214. needAlphaTesting(): boolean;
  122215. private _initializeBlock;
  122216. private _resetDualBlocks;
  122217. /**
  122218. * Build the material and generates the inner effect
  122219. * @param verbose defines if the build should log activity
  122220. */
  122221. build(verbose?: boolean): void;
  122222. /**
  122223. * Runs an otpimization phase to try to improve the shader code
  122224. */
  122225. optimize(): void;
  122226. private _prepareDefinesForAttributes;
  122227. /**
  122228. * Get if the submesh is ready to be used and all its information available.
  122229. * Child classes can use it to update shaders
  122230. * @param mesh defines the mesh to check
  122231. * @param subMesh defines which submesh to check
  122232. * @param useInstances specifies that instances should be used
  122233. * @returns a boolean indicating that the submesh is ready or not
  122234. */
  122235. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122236. /**
  122237. * Get a string representing the shaders built by the current node graph
  122238. */
  122239. readonly compiledShaders: string;
  122240. /**
  122241. * Binds the world matrix to the material
  122242. * @param world defines the world transformation matrix
  122243. */
  122244. bindOnlyWorldMatrix(world: Matrix): void;
  122245. /**
  122246. * Binds the submesh to this material by preparing the effect and shader to draw
  122247. * @param world defines the world transformation matrix
  122248. * @param mesh defines the mesh containing the submesh
  122249. * @param subMesh defines the submesh to bind the material to
  122250. */
  122251. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122252. /**
  122253. * Gets the active textures from the material
  122254. * @returns an array of textures
  122255. */
  122256. getActiveTextures(): BaseTexture[];
  122257. /**
  122258. * Gets the list of texture blocks
  122259. * @returns an array of texture blocks
  122260. */
  122261. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  122262. /**
  122263. * Specifies if the material uses a texture
  122264. * @param texture defines the texture to check against the material
  122265. * @returns a boolean specifying if the material uses the texture
  122266. */
  122267. hasTexture(texture: BaseTexture): boolean;
  122268. /**
  122269. * Disposes the material
  122270. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  122271. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  122272. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  122273. */
  122274. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  122275. /** Creates the node editor window. */
  122276. private _createNodeEditor;
  122277. /**
  122278. * Launch the node material editor
  122279. * @param config Define the configuration of the editor
  122280. * @return a promise fulfilled when the node editor is visible
  122281. */
  122282. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  122283. /**
  122284. * Clear the current material
  122285. */
  122286. clear(): void;
  122287. /**
  122288. * Clear the current material and set it to a default state
  122289. */
  122290. setToDefault(): void;
  122291. /**
  122292. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  122293. * @param url defines the url to load from
  122294. * @returns a promise that will fullfil when the material is fully loaded
  122295. */
  122296. loadAsync(url: string): Promise<void>;
  122297. private _gatherBlocks;
  122298. /**
  122299. * Generate a string containing the code declaration required to create an equivalent of this material
  122300. * @returns a string
  122301. */
  122302. generateCode(): string;
  122303. /**
  122304. * Serializes this material in a JSON representation
  122305. * @returns the serialized material object
  122306. */
  122307. serialize(): any;
  122308. private _restoreConnections;
  122309. /**
  122310. * Clear the current graph and load a new one from a serialization object
  122311. * @param source defines the JSON representation of the material
  122312. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122313. */
  122314. loadFromSerialization(source: any, rootUrl?: string): void;
  122315. /**
  122316. * Creates a node material from parsed material data
  122317. * @param source defines the JSON representation of the material
  122318. * @param scene defines the hosting scene
  122319. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122320. * @returns a new node material
  122321. */
  122322. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  122323. /**
  122324. * Creates a new node material set to default basic configuration
  122325. * @param name defines the name of the material
  122326. * @param scene defines the hosting scene
  122327. * @returns a new NodeMaterial
  122328. */
  122329. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  122330. }
  122331. }
  122332. declare module BABYLON {
  122333. /**
  122334. * Block used to read a texture from a sampler
  122335. */
  122336. export class TextureBlock extends NodeMaterialBlock {
  122337. private _defineName;
  122338. private _linearDefineName;
  122339. private _tempTextureRead;
  122340. private _samplerName;
  122341. private _transformedUVName;
  122342. private _textureTransformName;
  122343. private _textureInfoName;
  122344. private _mainUVName;
  122345. private _mainUVDefineName;
  122346. /**
  122347. * Gets or sets the texture associated with the node
  122348. */
  122349. texture: Nullable<Texture>;
  122350. /**
  122351. * Create a new TextureBlock
  122352. * @param name defines the block name
  122353. */
  122354. constructor(name: string);
  122355. /**
  122356. * Gets the current class name
  122357. * @returns the class name
  122358. */
  122359. getClassName(): string;
  122360. /**
  122361. * Gets the uv input component
  122362. */
  122363. readonly uv: NodeMaterialConnectionPoint;
  122364. /**
  122365. * Gets the rgba output component
  122366. */
  122367. readonly rgba: NodeMaterialConnectionPoint;
  122368. /**
  122369. * Gets the rgb output component
  122370. */
  122371. readonly rgb: NodeMaterialConnectionPoint;
  122372. /**
  122373. * Gets the r output component
  122374. */
  122375. readonly r: NodeMaterialConnectionPoint;
  122376. /**
  122377. * Gets the g output component
  122378. */
  122379. readonly g: NodeMaterialConnectionPoint;
  122380. /**
  122381. * Gets the b output component
  122382. */
  122383. readonly b: NodeMaterialConnectionPoint;
  122384. /**
  122385. * Gets the a output component
  122386. */
  122387. readonly a: NodeMaterialConnectionPoint;
  122388. readonly target: NodeMaterialBlockTargets;
  122389. autoConfigure(material: NodeMaterial): void;
  122390. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  122392. isReady(): boolean;
  122393. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122394. private readonly _isMixed;
  122395. private _injectVertexCode;
  122396. private _writeTextureRead;
  122397. private _writeOutput;
  122398. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122399. protected _dumpPropertiesCode(): string;
  122400. serialize(): any;
  122401. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122402. }
  122403. }
  122404. declare module BABYLON {
  122405. /**
  122406. * Class used to store shared data between 2 NodeMaterialBuildState
  122407. */
  122408. export class NodeMaterialBuildStateSharedData {
  122409. /**
  122410. * Gets the list of emitted varyings
  122411. */
  122412. temps: string[];
  122413. /**
  122414. * Gets the list of emitted varyings
  122415. */
  122416. varyings: string[];
  122417. /**
  122418. * Gets the varying declaration string
  122419. */
  122420. varyingDeclaration: string;
  122421. /**
  122422. * Input blocks
  122423. */
  122424. inputBlocks: InputBlock[];
  122425. /**
  122426. * Input blocks
  122427. */
  122428. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  122429. /**
  122430. * Bindable blocks (Blocks that need to set data to the effect)
  122431. */
  122432. bindableBlocks: NodeMaterialBlock[];
  122433. /**
  122434. * List of blocks that can provide a compilation fallback
  122435. */
  122436. blocksWithFallbacks: NodeMaterialBlock[];
  122437. /**
  122438. * List of blocks that can provide a define update
  122439. */
  122440. blocksWithDefines: NodeMaterialBlock[];
  122441. /**
  122442. * List of blocks that can provide a repeatable content
  122443. */
  122444. repeatableContentBlocks: NodeMaterialBlock[];
  122445. /**
  122446. * List of blocks that can provide a dynamic list of uniforms
  122447. */
  122448. dynamicUniformBlocks: NodeMaterialBlock[];
  122449. /**
  122450. * List of blocks that can block the isReady function for the material
  122451. */
  122452. blockingBlocks: NodeMaterialBlock[];
  122453. /**
  122454. * Gets the list of animated inputs
  122455. */
  122456. animatedInputs: InputBlock[];
  122457. /**
  122458. * Build Id used to avoid multiple recompilations
  122459. */
  122460. buildId: number;
  122461. /** List of emitted variables */
  122462. variableNames: {
  122463. [key: string]: number;
  122464. };
  122465. /** List of emitted defines */
  122466. defineNames: {
  122467. [key: string]: number;
  122468. };
  122469. /** Should emit comments? */
  122470. emitComments: boolean;
  122471. /** Emit build activity */
  122472. verbose: boolean;
  122473. /** Gets or sets the hosting scene */
  122474. scene: Scene;
  122475. /**
  122476. * Gets the compilation hints emitted at compilation time
  122477. */
  122478. hints: {
  122479. needWorldViewMatrix: boolean;
  122480. needWorldViewProjectionMatrix: boolean;
  122481. needAlphaBlending: boolean;
  122482. needAlphaTesting: boolean;
  122483. };
  122484. /**
  122485. * List of compilation checks
  122486. */
  122487. checks: {
  122488. emitVertex: boolean;
  122489. emitFragment: boolean;
  122490. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  122491. };
  122492. /** Creates a new shared data */
  122493. constructor();
  122494. /**
  122495. * Emits console errors and exceptions if there is a failing check
  122496. */
  122497. emitErrors(): void;
  122498. }
  122499. }
  122500. declare module BABYLON {
  122501. /**
  122502. * Class used to store node based material build state
  122503. */
  122504. export class NodeMaterialBuildState {
  122505. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  122506. supportUniformBuffers: boolean;
  122507. /**
  122508. * Gets the list of emitted attributes
  122509. */
  122510. attributes: string[];
  122511. /**
  122512. * Gets the list of emitted uniforms
  122513. */
  122514. uniforms: string[];
  122515. /**
  122516. * Gets the list of emitted constants
  122517. */
  122518. constants: string[];
  122519. /**
  122520. * Gets the list of emitted samplers
  122521. */
  122522. samplers: string[];
  122523. /**
  122524. * Gets the list of emitted functions
  122525. */
  122526. functions: {
  122527. [key: string]: string;
  122528. };
  122529. /**
  122530. * Gets the list of emitted extensions
  122531. */
  122532. extensions: {
  122533. [key: string]: string;
  122534. };
  122535. /**
  122536. * Gets the target of the compilation state
  122537. */
  122538. target: NodeMaterialBlockTargets;
  122539. /**
  122540. * Gets the list of emitted counters
  122541. */
  122542. counters: {
  122543. [key: string]: number;
  122544. };
  122545. /**
  122546. * Shared data between multiple NodeMaterialBuildState instances
  122547. */
  122548. sharedData: NodeMaterialBuildStateSharedData;
  122549. /** @hidden */
  122550. _vertexState: NodeMaterialBuildState;
  122551. /** @hidden */
  122552. _attributeDeclaration: string;
  122553. /** @hidden */
  122554. _uniformDeclaration: string;
  122555. /** @hidden */
  122556. _constantDeclaration: string;
  122557. /** @hidden */
  122558. _samplerDeclaration: string;
  122559. /** @hidden */
  122560. _varyingTransfer: string;
  122561. private _repeatableContentAnchorIndex;
  122562. /** @hidden */
  122563. _builtCompilationString: string;
  122564. /**
  122565. * Gets the emitted compilation strings
  122566. */
  122567. compilationString: string;
  122568. /**
  122569. * Finalize the compilation strings
  122570. * @param state defines the current compilation state
  122571. */
  122572. finalize(state: NodeMaterialBuildState): void;
  122573. /** @hidden */
  122574. readonly _repeatableContentAnchor: string;
  122575. /** @hidden */
  122576. _getFreeVariableName(prefix: string): string;
  122577. /** @hidden */
  122578. _getFreeDefineName(prefix: string): string;
  122579. /** @hidden */
  122580. _excludeVariableName(name: string): void;
  122581. /** @hidden */
  122582. _emit2DSampler(name: string): void;
  122583. /** @hidden */
  122584. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  122585. /** @hidden */
  122586. _emitExtension(name: string, extension: string): void;
  122587. /** @hidden */
  122588. _emitFunction(name: string, code: string, comments: string): void;
  122589. /** @hidden */
  122590. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  122591. replaceStrings?: {
  122592. search: RegExp;
  122593. replace: string;
  122594. }[];
  122595. repeatKey?: string;
  122596. }): string;
  122597. /** @hidden */
  122598. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  122599. repeatKey?: string;
  122600. removeAttributes?: boolean;
  122601. removeUniforms?: boolean;
  122602. removeVaryings?: boolean;
  122603. removeIfDef?: boolean;
  122604. replaceStrings?: {
  122605. search: RegExp;
  122606. replace: string;
  122607. }[];
  122608. }, storeKey?: string): void;
  122609. /** @hidden */
  122610. _registerTempVariable(name: string): boolean;
  122611. /** @hidden */
  122612. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  122613. /** @hidden */
  122614. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  122615. /** @hidden */
  122616. _emitFloat(value: number): string;
  122617. }
  122618. }
  122619. declare module BABYLON {
  122620. /**
  122621. * Defines a block that can be used inside a node based material
  122622. */
  122623. export class NodeMaterialBlock {
  122624. private _buildId;
  122625. private _buildTarget;
  122626. private _target;
  122627. private _isFinalMerger;
  122628. private _isInput;
  122629. protected _isUnique: boolean;
  122630. /** @hidden */
  122631. _codeVariableName: string;
  122632. /** @hidden */
  122633. _inputs: NodeMaterialConnectionPoint[];
  122634. /** @hidden */
  122635. _outputs: NodeMaterialConnectionPoint[];
  122636. /** @hidden */
  122637. _preparationId: number;
  122638. /**
  122639. * Gets or sets the name of the block
  122640. */
  122641. name: string;
  122642. /**
  122643. * Gets or sets the unique id of the node
  122644. */
  122645. uniqueId: number;
  122646. /**
  122647. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  122648. */
  122649. readonly isUnique: boolean;
  122650. /**
  122651. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  122652. */
  122653. readonly isFinalMerger: boolean;
  122654. /**
  122655. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  122656. */
  122657. readonly isInput: boolean;
  122658. /**
  122659. * Gets or sets the build Id
  122660. */
  122661. buildId: number;
  122662. /**
  122663. * Gets or sets the target of the block
  122664. */
  122665. target: NodeMaterialBlockTargets;
  122666. /**
  122667. * Gets the list of input points
  122668. */
  122669. readonly inputs: NodeMaterialConnectionPoint[];
  122670. /** Gets the list of output points */
  122671. readonly outputs: NodeMaterialConnectionPoint[];
  122672. /**
  122673. * Find an input by its name
  122674. * @param name defines the name of the input to look for
  122675. * @returns the input or null if not found
  122676. */
  122677. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122678. /**
  122679. * Find an output by its name
  122680. * @param name defines the name of the outputto look for
  122681. * @returns the output or null if not found
  122682. */
  122683. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  122684. /**
  122685. * Creates a new NodeMaterialBlock
  122686. * @param name defines the block name
  122687. * @param target defines the target of that block (Vertex by default)
  122688. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  122689. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  122690. */
  122691. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  122692. /**
  122693. * Initialize the block and prepare the context for build
  122694. * @param state defines the state that will be used for the build
  122695. */
  122696. initialize(state: NodeMaterialBuildState): void;
  122697. /**
  122698. * Bind data to effect. Will only be called for blocks with isBindable === true
  122699. * @param effect defines the effect to bind data to
  122700. * @param nodeMaterial defines the hosting NodeMaterial
  122701. * @param mesh defines the mesh that will be rendered
  122702. */
  122703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  122704. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  122705. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  122706. protected _writeFloat(value: number): string;
  122707. /**
  122708. * Gets the current class name e.g. "NodeMaterialBlock"
  122709. * @returns the class name
  122710. */
  122711. getClassName(): string;
  122712. /**
  122713. * Register a new input. Must be called inside a block constructor
  122714. * @param name defines the connection point name
  122715. * @param type defines the connection point type
  122716. * @param isOptional defines a boolean indicating that this input can be omitted
  122717. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122718. * @returns the current block
  122719. */
  122720. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  122721. /**
  122722. * Register a new output. Must be called inside a block constructor
  122723. * @param name defines the connection point name
  122724. * @param type defines the connection point type
  122725. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  122726. * @returns the current block
  122727. */
  122728. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  122729. /**
  122730. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  122731. * @param forOutput defines an optional connection point to check compatibility with
  122732. * @returns the first available input or null
  122733. */
  122734. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  122735. /**
  122736. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  122737. * @param forBlock defines an optional block to check compatibility with
  122738. * @returns the first available input or null
  122739. */
  122740. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  122741. /**
  122742. * Gets the sibling of the given output
  122743. * @param current defines the current output
  122744. * @returns the next output in the list or null
  122745. */
  122746. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  122747. /**
  122748. * Connect current block with another block
  122749. * @param other defines the block to connect with
  122750. * @param options define the various options to help pick the right connections
  122751. * @returns the current block
  122752. */
  122753. connectTo(other: NodeMaterialBlock, options?: {
  122754. input?: string;
  122755. output?: string;
  122756. outputSwizzle?: string;
  122757. }): this | undefined;
  122758. protected _buildBlock(state: NodeMaterialBuildState): void;
  122759. /**
  122760. * Add uniforms, samplers and uniform buffers at compilation time
  122761. * @param state defines the state to update
  122762. * @param nodeMaterial defines the node material requesting the update
  122763. * @param defines defines the material defines to update
  122764. * @param uniformBuffers defines the list of uniform buffer names
  122765. */
  122766. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  122767. /**
  122768. * Add potential fallbacks if shader compilation fails
  122769. * @param mesh defines the mesh to be rendered
  122770. * @param fallbacks defines the current prioritized list of fallbacks
  122771. */
  122772. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  122773. /**
  122774. * Initialize defines for shader compilation
  122775. * @param mesh defines the mesh to be rendered
  122776. * @param nodeMaterial defines the node material requesting the update
  122777. * @param defines defines the material defines to update
  122778. * @param useInstances specifies that instances should be used
  122779. */
  122780. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122781. /**
  122782. * Update defines for shader compilation
  122783. * @param mesh defines the mesh to be rendered
  122784. * @param nodeMaterial defines the node material requesting the update
  122785. * @param defines defines the material defines to update
  122786. * @param useInstances specifies that instances should be used
  122787. */
  122788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  122789. /**
  122790. * Lets the block try to connect some inputs automatically
  122791. * @param material defines the hosting NodeMaterial
  122792. */
  122793. autoConfigure(material: NodeMaterial): void;
  122794. /**
  122795. * Function called when a block is declared as repeatable content generator
  122796. * @param vertexShaderState defines the current compilation state for the vertex shader
  122797. * @param fragmentShaderState defines the current compilation state for the fragment shader
  122798. * @param mesh defines the mesh to be rendered
  122799. * @param defines defines the material defines to update
  122800. */
  122801. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  122802. /**
  122803. * Checks if the block is ready
  122804. * @param mesh defines the mesh to be rendered
  122805. * @param nodeMaterial defines the node material requesting the update
  122806. * @param defines defines the material defines to update
  122807. * @param useInstances specifies that instances should be used
  122808. * @returns true if the block is ready
  122809. */
  122810. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  122811. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  122812. private _processBuild;
  122813. /**
  122814. * Compile the current node and generate the shader code
  122815. * @param state defines the current compilation state (uniforms, samplers, current string)
  122816. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  122817. * @returns true if already built
  122818. */
  122819. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  122820. protected _inputRename(name: string): string;
  122821. protected _outputRename(name: string): string;
  122822. protected _dumpPropertiesCode(): string;
  122823. /** @hidden */
  122824. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  122825. /** @hidden */
  122826. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  122827. /**
  122828. * Clone the current block to a new identical block
  122829. * @param scene defines the hosting scene
  122830. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  122831. * @returns a copy of the current block
  122832. */
  122833. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  122834. /**
  122835. * Serializes this block in a JSON representation
  122836. * @returns the serialized block object
  122837. */
  122838. serialize(): any;
  122839. /** @hidden */
  122840. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122841. /**
  122842. * Release resources
  122843. */
  122844. dispose(): void;
  122845. }
  122846. }
  122847. declare module BABYLON {
  122848. /**
  122849. * Enum defining the type of animations supported by InputBlock
  122850. */
  122851. export enum AnimatedInputBlockTypes {
  122852. /** No animation */
  122853. None = 0,
  122854. /** Time based animation. Will only work for floats */
  122855. Time = 1
  122856. }
  122857. }
  122858. declare module BABYLON {
  122859. /**
  122860. * Block used to expose an input value
  122861. */
  122862. export class InputBlock extends NodeMaterialBlock {
  122863. private _mode;
  122864. private _associatedVariableName;
  122865. private _storedValue;
  122866. private _valueCallback;
  122867. private _type;
  122868. private _animationType;
  122869. /** Gets or set a value used to limit the range of float values */
  122870. min: number;
  122871. /** Gets or set a value used to limit the range of float values */
  122872. max: number;
  122873. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  122874. matrixMode: number;
  122875. /** @hidden */
  122876. _systemValue: Nullable<NodeMaterialSystemValues>;
  122877. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  122878. visibleInInspector: boolean;
  122879. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  122880. isConstant: boolean;
  122881. /**
  122882. * Gets or sets the connection point type (default is float)
  122883. */
  122884. readonly type: NodeMaterialBlockConnectionPointTypes;
  122885. /**
  122886. * Creates a new InputBlock
  122887. * @param name defines the block name
  122888. * @param target defines the target of that block (Vertex by default)
  122889. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  122890. */
  122891. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  122892. /**
  122893. * Gets the output component
  122894. */
  122895. readonly output: NodeMaterialConnectionPoint;
  122896. /**
  122897. * Set the source of this connection point to a vertex attribute
  122898. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  122899. * @returns the current connection point
  122900. */
  122901. setAsAttribute(attributeName?: string): InputBlock;
  122902. /**
  122903. * Set the source of this connection point to a system value
  122904. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  122905. * @returns the current connection point
  122906. */
  122907. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  122908. /**
  122909. * Gets or sets the value of that point.
  122910. * Please note that this value will be ignored if valueCallback is defined
  122911. */
  122912. value: any;
  122913. /**
  122914. * Gets or sets a callback used to get the value of that point.
  122915. * Please note that setting this value will force the connection point to ignore the value property
  122916. */
  122917. valueCallback: () => any;
  122918. /**
  122919. * Gets or sets the associated variable name in the shader
  122920. */
  122921. associatedVariableName: string;
  122922. /** Gets or sets the type of animation applied to the input */
  122923. animationType: AnimatedInputBlockTypes;
  122924. /**
  122925. * Gets a boolean indicating that this connection point not defined yet
  122926. */
  122927. readonly isUndefined: boolean;
  122928. /**
  122929. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  122930. * In this case the connection point name must be the name of the uniform to use.
  122931. * Can only be set on inputs
  122932. */
  122933. isUniform: boolean;
  122934. /**
  122935. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  122936. * In this case the connection point name must be the name of the attribute to use
  122937. * Can only be set on inputs
  122938. */
  122939. isAttribute: boolean;
  122940. /**
  122941. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  122942. * Can only be set on exit points
  122943. */
  122944. isVarying: boolean;
  122945. /**
  122946. * Gets a boolean indicating that the current connection point is a system value
  122947. */
  122948. readonly isSystemValue: boolean;
  122949. /**
  122950. * Gets or sets the current well known value or null if not defined as a system value
  122951. */
  122952. systemValue: Nullable<NodeMaterialSystemValues>;
  122953. /**
  122954. * Gets the current class name
  122955. * @returns the class name
  122956. */
  122957. getClassName(): string;
  122958. /**
  122959. * Animate the input if animationType !== None
  122960. * @param scene defines the rendering scene
  122961. */
  122962. animate(scene: Scene): void;
  122963. private _emitDefine;
  122964. initialize(state: NodeMaterialBuildState): void;
  122965. /**
  122966. * Set the input block to its default value (based on its type)
  122967. */
  122968. setDefaultValue(): void;
  122969. private _emitConstant;
  122970. private _emit;
  122971. /** @hidden */
  122972. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  122973. /** @hidden */
  122974. _transmit(effect: Effect, scene: Scene): void;
  122975. protected _buildBlock(state: NodeMaterialBuildState): void;
  122976. protected _dumpPropertiesCode(): string;
  122977. serialize(): any;
  122978. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122979. }
  122980. }
  122981. declare module BABYLON {
  122982. /**
  122983. * Enum used to define the compatibility state between two connection points
  122984. */
  122985. export enum NodeMaterialConnectionPointCompatibilityStates {
  122986. /** Points are compatibles */
  122987. Compatible = 0,
  122988. /** Points are incompatible because of their types */
  122989. TypeIncompatible = 1,
  122990. /** Points are incompatible because of their targets (vertex vs fragment) */
  122991. TargetIncompatible = 2
  122992. }
  122993. /**
  122994. * Defines a connection point for a block
  122995. */
  122996. export class NodeMaterialConnectionPoint {
  122997. /** @hidden */
  122998. _ownerBlock: NodeMaterialBlock;
  122999. /** @hidden */
  123000. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123001. private _endpoints;
  123002. private _associatedVariableName;
  123003. /** @hidden */
  123004. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123005. /** @hidden */
  123006. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  123007. private _type;
  123008. /** @hidden */
  123009. _enforceAssociatedVariableName: boolean;
  123010. /**
  123011. * Gets or sets the additional types supported by this connection point
  123012. */
  123013. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123014. /**
  123015. * Gets or sets the additional types excluded by this connection point
  123016. */
  123017. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  123018. /**
  123019. * Observable triggered when this point is connected
  123020. */
  123021. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  123022. /**
  123023. * Gets or sets the associated variable name in the shader
  123024. */
  123025. associatedVariableName: string;
  123026. /**
  123027. * Gets or sets the connection point type (default is float)
  123028. */
  123029. type: NodeMaterialBlockConnectionPointTypes;
  123030. /**
  123031. * Gets or sets the connection point name
  123032. */
  123033. name: string;
  123034. /**
  123035. * Gets or sets a boolean indicating that this connection point can be omitted
  123036. */
  123037. isOptional: boolean;
  123038. /**
  123039. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  123040. */
  123041. define: string;
  123042. /** @hidden */
  123043. _prioritizeVertex: boolean;
  123044. private _target;
  123045. /** Gets or sets the target of that connection point */
  123046. target: NodeMaterialBlockTargets;
  123047. /**
  123048. * Gets a boolean indicating that the current point is connected
  123049. */
  123050. readonly isConnected: boolean;
  123051. /**
  123052. * Gets a boolean indicating that the current point is connected to an input block
  123053. */
  123054. readonly isConnectedToInputBlock: boolean;
  123055. /**
  123056. * Gets a the connected input block (if any)
  123057. */
  123058. readonly connectInputBlock: Nullable<InputBlock>;
  123059. /** Get the other side of the connection (if any) */
  123060. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  123061. /** Get the block that owns this connection point */
  123062. readonly ownerBlock: NodeMaterialBlock;
  123063. /** Get the block connected on the other side of this connection (if any) */
  123064. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  123065. /** Get the block connected on the endpoints of this connection (if any) */
  123066. readonly connectedBlocks: Array<NodeMaterialBlock>;
  123067. /** Gets the list of connected endpoints */
  123068. readonly endpoints: NodeMaterialConnectionPoint[];
  123069. /** Gets a boolean indicating if that output point is connected to at least one input */
  123070. readonly hasEndpoints: boolean;
  123071. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  123072. readonly isConnectedInVertexShader: boolean;
  123073. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  123074. readonly isConnectedInFragmentShader: boolean;
  123075. /**
  123076. * Creates a new connection point
  123077. * @param name defines the connection point name
  123078. * @param ownerBlock defines the block hosting this connection point
  123079. */
  123080. constructor(name: string, ownerBlock: NodeMaterialBlock);
  123081. /**
  123082. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  123083. * @returns the class name
  123084. */
  123085. getClassName(): string;
  123086. /**
  123087. * Gets a boolean indicating if the current point can be connected to another point
  123088. * @param connectionPoint defines the other connection point
  123089. * @returns a boolean
  123090. */
  123091. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  123092. /**
  123093. * Gets a number indicating if the current point can be connected to another point
  123094. * @param connectionPoint defines the other connection point
  123095. * @returns a number defining the compatibility state
  123096. */
  123097. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  123098. /**
  123099. * Connect this point to another connection point
  123100. * @param connectionPoint defines the other connection point
  123101. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  123102. * @returns the current connection point
  123103. */
  123104. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  123105. /**
  123106. * Disconnect this point from one of his endpoint
  123107. * @param endpoint defines the other connection point
  123108. * @returns the current connection point
  123109. */
  123110. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  123111. /**
  123112. * Serializes this point in a JSON representation
  123113. * @returns the serialized point object
  123114. */
  123115. serialize(): any;
  123116. /**
  123117. * Release resources
  123118. */
  123119. dispose(): void;
  123120. }
  123121. }
  123122. declare module BABYLON {
  123123. /**
  123124. * Block used to add support for vertex skinning (bones)
  123125. */
  123126. export class BonesBlock extends NodeMaterialBlock {
  123127. /**
  123128. * Creates a new BonesBlock
  123129. * @param name defines the block name
  123130. */
  123131. constructor(name: string);
  123132. /**
  123133. * Initialize the block and prepare the context for build
  123134. * @param state defines the state that will be used for the build
  123135. */
  123136. initialize(state: NodeMaterialBuildState): void;
  123137. /**
  123138. * Gets the current class name
  123139. * @returns the class name
  123140. */
  123141. getClassName(): string;
  123142. /**
  123143. * Gets the matrix indices input component
  123144. */
  123145. readonly matricesIndices: NodeMaterialConnectionPoint;
  123146. /**
  123147. * Gets the matrix weights input component
  123148. */
  123149. readonly matricesWeights: NodeMaterialConnectionPoint;
  123150. /**
  123151. * Gets the extra matrix indices input component
  123152. */
  123153. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  123154. /**
  123155. * Gets the extra matrix weights input component
  123156. */
  123157. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  123158. /**
  123159. * Gets the world input component
  123160. */
  123161. readonly world: NodeMaterialConnectionPoint;
  123162. /**
  123163. * Gets the output component
  123164. */
  123165. readonly output: NodeMaterialConnectionPoint;
  123166. autoConfigure(material: NodeMaterial): void;
  123167. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  123168. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123169. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123170. protected _buildBlock(state: NodeMaterialBuildState): this;
  123171. }
  123172. }
  123173. declare module BABYLON {
  123174. /**
  123175. * Block used to add support for instances
  123176. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  123177. */
  123178. export class InstancesBlock extends NodeMaterialBlock {
  123179. /**
  123180. * Creates a new InstancesBlock
  123181. * @param name defines the block name
  123182. */
  123183. constructor(name: string);
  123184. /**
  123185. * Gets the current class name
  123186. * @returns the class name
  123187. */
  123188. getClassName(): string;
  123189. /**
  123190. * Gets the first world row input component
  123191. */
  123192. readonly world0: NodeMaterialConnectionPoint;
  123193. /**
  123194. * Gets the second world row input component
  123195. */
  123196. readonly world1: NodeMaterialConnectionPoint;
  123197. /**
  123198. * Gets the third world row input component
  123199. */
  123200. readonly world2: NodeMaterialConnectionPoint;
  123201. /**
  123202. * Gets the forth world row input component
  123203. */
  123204. readonly world3: NodeMaterialConnectionPoint;
  123205. /**
  123206. * Gets the world input component
  123207. */
  123208. readonly world: NodeMaterialConnectionPoint;
  123209. /**
  123210. * Gets the output component
  123211. */
  123212. readonly output: NodeMaterialConnectionPoint;
  123213. autoConfigure(material: NodeMaterial): void;
  123214. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  123215. protected _buildBlock(state: NodeMaterialBuildState): this;
  123216. }
  123217. }
  123218. declare module BABYLON {
  123219. /**
  123220. * Block used to add morph targets support to vertex shader
  123221. */
  123222. export class MorphTargetsBlock extends NodeMaterialBlock {
  123223. private _repeatableContentAnchor;
  123224. private _repeatebleContentGenerated;
  123225. /**
  123226. * Create a new MorphTargetsBlock
  123227. * @param name defines the block name
  123228. */
  123229. constructor(name: string);
  123230. /**
  123231. * Gets the current class name
  123232. * @returns the class name
  123233. */
  123234. getClassName(): string;
  123235. /**
  123236. * Gets the position input component
  123237. */
  123238. readonly position: NodeMaterialConnectionPoint;
  123239. /**
  123240. * Gets the normal input component
  123241. */
  123242. readonly normal: NodeMaterialConnectionPoint;
  123243. /**
  123244. * Gets the tangent input component
  123245. */
  123246. readonly tangent: NodeMaterialConnectionPoint;
  123247. /**
  123248. * Gets the tangent input component
  123249. */
  123250. readonly uv: NodeMaterialConnectionPoint;
  123251. /**
  123252. * Gets the position output component
  123253. */
  123254. readonly positionOutput: NodeMaterialConnectionPoint;
  123255. /**
  123256. * Gets the normal output component
  123257. */
  123258. readonly normalOutput: NodeMaterialConnectionPoint;
  123259. /**
  123260. * Gets the tangent output component
  123261. */
  123262. readonly tangentOutput: NodeMaterialConnectionPoint;
  123263. /**
  123264. * Gets the tangent output component
  123265. */
  123266. readonly uvOutput: NodeMaterialConnectionPoint;
  123267. initialize(state: NodeMaterialBuildState): void;
  123268. autoConfigure(material: NodeMaterial): void;
  123269. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123270. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123271. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  123272. protected _buildBlock(state: NodeMaterialBuildState): this;
  123273. }
  123274. }
  123275. declare module BABYLON {
  123276. /**
  123277. * Block used to get data information from a light
  123278. */
  123279. export class LightInformationBlock extends NodeMaterialBlock {
  123280. private _lightDataUniformName;
  123281. private _lightColorUniformName;
  123282. private _lightTypeDefineName;
  123283. /**
  123284. * Gets or sets the light associated with this block
  123285. */
  123286. light: Nullable<Light>;
  123287. /**
  123288. * Creates a new LightInformationBlock
  123289. * @param name defines the block name
  123290. */
  123291. constructor(name: string);
  123292. /**
  123293. * Gets the current class name
  123294. * @returns the class name
  123295. */
  123296. getClassName(): string;
  123297. /**
  123298. * Gets the world position input component
  123299. */
  123300. readonly worldPosition: NodeMaterialConnectionPoint;
  123301. /**
  123302. * Gets the direction output component
  123303. */
  123304. readonly direction: NodeMaterialConnectionPoint;
  123305. /**
  123306. * Gets the direction output component
  123307. */
  123308. readonly color: NodeMaterialConnectionPoint;
  123309. /**
  123310. * Gets the direction output component
  123311. */
  123312. readonly intensity: NodeMaterialConnectionPoint;
  123313. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123314. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123315. protected _buildBlock(state: NodeMaterialBuildState): this;
  123316. serialize(): any;
  123317. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123318. }
  123319. }
  123320. declare module BABYLON {
  123321. /**
  123322. * Block used to add image processing support to fragment shader
  123323. */
  123324. export class ImageProcessingBlock extends NodeMaterialBlock {
  123325. /**
  123326. * Create a new ImageProcessingBlock
  123327. * @param name defines the block name
  123328. */
  123329. constructor(name: string);
  123330. /**
  123331. * Gets the current class name
  123332. * @returns the class name
  123333. */
  123334. getClassName(): string;
  123335. /**
  123336. * Gets the color input component
  123337. */
  123338. readonly color: NodeMaterialConnectionPoint;
  123339. /**
  123340. * Gets the output component
  123341. */
  123342. readonly output: NodeMaterialConnectionPoint;
  123343. /**
  123344. * Initialize the block and prepare the context for build
  123345. * @param state defines the state that will be used for the build
  123346. */
  123347. initialize(state: NodeMaterialBuildState): void;
  123348. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  123349. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123350. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123351. protected _buildBlock(state: NodeMaterialBuildState): this;
  123352. }
  123353. }
  123354. declare module BABYLON {
  123355. /**
  123356. * Block used to pertub normals based on a normal map
  123357. */
  123358. export class PerturbNormalBlock extends NodeMaterialBlock {
  123359. private _tangentSpaceParameterName;
  123360. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  123361. invertX: boolean;
  123362. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  123363. invertY: boolean;
  123364. /**
  123365. * Create a new PerturbNormalBlock
  123366. * @param name defines the block name
  123367. */
  123368. constructor(name: string);
  123369. /**
  123370. * Gets the current class name
  123371. * @returns the class name
  123372. */
  123373. getClassName(): string;
  123374. /**
  123375. * Gets the world position input component
  123376. */
  123377. readonly worldPosition: NodeMaterialConnectionPoint;
  123378. /**
  123379. * Gets the world normal input component
  123380. */
  123381. readonly worldNormal: NodeMaterialConnectionPoint;
  123382. /**
  123383. * Gets the uv input component
  123384. */
  123385. readonly uv: NodeMaterialConnectionPoint;
  123386. /**
  123387. * Gets the normal map color input component
  123388. */
  123389. readonly normalMapColor: NodeMaterialConnectionPoint;
  123390. /**
  123391. * Gets the strength input component
  123392. */
  123393. readonly strength: NodeMaterialConnectionPoint;
  123394. /**
  123395. * Gets the output component
  123396. */
  123397. readonly output: NodeMaterialConnectionPoint;
  123398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123399. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123400. autoConfigure(material: NodeMaterial): void;
  123401. protected _buildBlock(state: NodeMaterialBuildState): this;
  123402. protected _dumpPropertiesCode(): string;
  123403. serialize(): any;
  123404. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123405. }
  123406. }
  123407. declare module BABYLON {
  123408. /**
  123409. * Block used to discard a pixel if a value is smaller than a cutoff
  123410. */
  123411. export class DiscardBlock extends NodeMaterialBlock {
  123412. /**
  123413. * Create a new DiscardBlock
  123414. * @param name defines the block name
  123415. */
  123416. constructor(name: string);
  123417. /**
  123418. * Gets the current class name
  123419. * @returns the class name
  123420. */
  123421. getClassName(): string;
  123422. /**
  123423. * Gets the color input component
  123424. */
  123425. readonly value: NodeMaterialConnectionPoint;
  123426. /**
  123427. * Gets the cutoff input component
  123428. */
  123429. readonly cutoff: NodeMaterialConnectionPoint;
  123430. protected _buildBlock(state: NodeMaterialBuildState): this;
  123431. }
  123432. }
  123433. declare module BABYLON {
  123434. /**
  123435. * Block used to test if the fragment shader is front facing
  123436. */
  123437. export class FrontFacingBlock extends NodeMaterialBlock {
  123438. /**
  123439. * Creates a new FrontFacingBlock
  123440. * @param name defines the block name
  123441. */
  123442. constructor(name: string);
  123443. /**
  123444. * Gets the current class name
  123445. * @returns the class name
  123446. */
  123447. getClassName(): string;
  123448. /**
  123449. * Gets the output component
  123450. */
  123451. readonly output: NodeMaterialConnectionPoint;
  123452. protected _buildBlock(state: NodeMaterialBuildState): this;
  123453. }
  123454. }
  123455. declare module BABYLON {
  123456. /**
  123457. * Block used to add support for scene fog
  123458. */
  123459. export class FogBlock extends NodeMaterialBlock {
  123460. private _fogDistanceName;
  123461. private _fogParameters;
  123462. /**
  123463. * Create a new FogBlock
  123464. * @param name defines the block name
  123465. */
  123466. constructor(name: string);
  123467. /**
  123468. * Gets the current class name
  123469. * @returns the class name
  123470. */
  123471. getClassName(): string;
  123472. /**
  123473. * Gets the world position input component
  123474. */
  123475. readonly worldPosition: NodeMaterialConnectionPoint;
  123476. /**
  123477. * Gets the view input component
  123478. */
  123479. readonly view: NodeMaterialConnectionPoint;
  123480. /**
  123481. * Gets the color input component
  123482. */
  123483. readonly input: NodeMaterialConnectionPoint;
  123484. /**
  123485. * Gets the fog color input component
  123486. */
  123487. readonly fogColor: NodeMaterialConnectionPoint;
  123488. /**
  123489. * Gets the output component
  123490. */
  123491. readonly output: NodeMaterialConnectionPoint;
  123492. autoConfigure(material: NodeMaterial): void;
  123493. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123494. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123495. protected _buildBlock(state: NodeMaterialBuildState): this;
  123496. }
  123497. }
  123498. declare module BABYLON {
  123499. /**
  123500. * Block used to add light in the fragment shader
  123501. */
  123502. export class LightBlock extends NodeMaterialBlock {
  123503. private _lightId;
  123504. /**
  123505. * Gets or sets the light associated with this block
  123506. */
  123507. light: Nullable<Light>;
  123508. /**
  123509. * Create a new LightBlock
  123510. * @param name defines the block name
  123511. */
  123512. constructor(name: string);
  123513. /**
  123514. * Gets the current class name
  123515. * @returns the class name
  123516. */
  123517. getClassName(): string;
  123518. /**
  123519. * Gets the world position input component
  123520. */
  123521. readonly worldPosition: NodeMaterialConnectionPoint;
  123522. /**
  123523. * Gets the world normal input component
  123524. */
  123525. readonly worldNormal: NodeMaterialConnectionPoint;
  123526. /**
  123527. * Gets the camera (or eye) position component
  123528. */
  123529. readonly cameraPosition: NodeMaterialConnectionPoint;
  123530. /**
  123531. * Gets the glossiness component
  123532. */
  123533. readonly glossiness: NodeMaterialConnectionPoint;
  123534. /**
  123535. * Gets the glossinness power component
  123536. */
  123537. readonly glossPower: NodeMaterialConnectionPoint;
  123538. /**
  123539. * Gets the diffuse color component
  123540. */
  123541. readonly diffuseColor: NodeMaterialConnectionPoint;
  123542. /**
  123543. * Gets the specular color component
  123544. */
  123545. readonly specularColor: NodeMaterialConnectionPoint;
  123546. /**
  123547. * Gets the diffuse output component
  123548. */
  123549. readonly diffuseOutput: NodeMaterialConnectionPoint;
  123550. /**
  123551. * Gets the specular output component
  123552. */
  123553. readonly specularOutput: NodeMaterialConnectionPoint;
  123554. autoConfigure(material: NodeMaterial): void;
  123555. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  123556. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  123557. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  123558. private _injectVertexCode;
  123559. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  123560. serialize(): any;
  123561. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123562. }
  123563. }
  123564. declare module BABYLON {
  123565. /**
  123566. * Block used to multiply 2 values
  123567. */
  123568. export class MultiplyBlock extends NodeMaterialBlock {
  123569. /**
  123570. * Creates a new MultiplyBlock
  123571. * @param name defines the block name
  123572. */
  123573. constructor(name: string);
  123574. /**
  123575. * Gets the current class name
  123576. * @returns the class name
  123577. */
  123578. getClassName(): string;
  123579. /**
  123580. * Gets the left operand input component
  123581. */
  123582. readonly left: NodeMaterialConnectionPoint;
  123583. /**
  123584. * Gets the right operand input component
  123585. */
  123586. readonly right: NodeMaterialConnectionPoint;
  123587. /**
  123588. * Gets the output component
  123589. */
  123590. readonly output: NodeMaterialConnectionPoint;
  123591. protected _buildBlock(state: NodeMaterialBuildState): this;
  123592. }
  123593. }
  123594. declare module BABYLON {
  123595. /**
  123596. * Block used to add 2 vectors
  123597. */
  123598. export class AddBlock extends NodeMaterialBlock {
  123599. /**
  123600. * Creates a new AddBlock
  123601. * @param name defines the block name
  123602. */
  123603. constructor(name: string);
  123604. /**
  123605. * Gets the current class name
  123606. * @returns the class name
  123607. */
  123608. getClassName(): string;
  123609. /**
  123610. * Gets the left operand input component
  123611. */
  123612. readonly left: NodeMaterialConnectionPoint;
  123613. /**
  123614. * Gets the right operand input component
  123615. */
  123616. readonly right: NodeMaterialConnectionPoint;
  123617. /**
  123618. * Gets the output component
  123619. */
  123620. readonly output: NodeMaterialConnectionPoint;
  123621. protected _buildBlock(state: NodeMaterialBuildState): this;
  123622. }
  123623. }
  123624. declare module BABYLON {
  123625. /**
  123626. * Block used to scale a vector by a float
  123627. */
  123628. export class ScaleBlock extends NodeMaterialBlock {
  123629. /**
  123630. * Creates a new ScaleBlock
  123631. * @param name defines the block name
  123632. */
  123633. constructor(name: string);
  123634. /**
  123635. * Gets the current class name
  123636. * @returns the class name
  123637. */
  123638. getClassName(): string;
  123639. /**
  123640. * Gets the input component
  123641. */
  123642. readonly input: NodeMaterialConnectionPoint;
  123643. /**
  123644. * Gets the factor input component
  123645. */
  123646. readonly factor: NodeMaterialConnectionPoint;
  123647. /**
  123648. * Gets the output component
  123649. */
  123650. readonly output: NodeMaterialConnectionPoint;
  123651. protected _buildBlock(state: NodeMaterialBuildState): this;
  123652. }
  123653. }
  123654. declare module BABYLON {
  123655. /**
  123656. * Block used to clamp a float
  123657. */
  123658. export class ClampBlock extends NodeMaterialBlock {
  123659. /** Gets or sets the minimum range */
  123660. minimum: number;
  123661. /** Gets or sets the maximum range */
  123662. maximum: number;
  123663. /**
  123664. * Creates a new ClampBlock
  123665. * @param name defines the block name
  123666. */
  123667. constructor(name: string);
  123668. /**
  123669. * Gets the current class name
  123670. * @returns the class name
  123671. */
  123672. getClassName(): string;
  123673. /**
  123674. * Gets the value input component
  123675. */
  123676. readonly value: NodeMaterialConnectionPoint;
  123677. /**
  123678. * Gets the output component
  123679. */
  123680. readonly output: NodeMaterialConnectionPoint;
  123681. protected _buildBlock(state: NodeMaterialBuildState): this;
  123682. protected _dumpPropertiesCode(): string;
  123683. serialize(): any;
  123684. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123685. }
  123686. }
  123687. declare module BABYLON {
  123688. /**
  123689. * Block used to apply a cross product between 2 vectors
  123690. */
  123691. export class CrossBlock extends NodeMaterialBlock {
  123692. /**
  123693. * Creates a new CrossBlock
  123694. * @param name defines the block name
  123695. */
  123696. constructor(name: string);
  123697. /**
  123698. * Gets the current class name
  123699. * @returns the class name
  123700. */
  123701. getClassName(): string;
  123702. /**
  123703. * Gets the left operand input component
  123704. */
  123705. readonly left: NodeMaterialConnectionPoint;
  123706. /**
  123707. * Gets the right operand input component
  123708. */
  123709. readonly right: NodeMaterialConnectionPoint;
  123710. /**
  123711. * Gets the output component
  123712. */
  123713. readonly output: NodeMaterialConnectionPoint;
  123714. protected _buildBlock(state: NodeMaterialBuildState): this;
  123715. }
  123716. }
  123717. declare module BABYLON {
  123718. /**
  123719. * Block used to apply a dot product between 2 vectors
  123720. */
  123721. export class DotBlock extends NodeMaterialBlock {
  123722. /**
  123723. * Creates a new DotBlock
  123724. * @param name defines the block name
  123725. */
  123726. constructor(name: string);
  123727. /**
  123728. * Gets the current class name
  123729. * @returns the class name
  123730. */
  123731. getClassName(): string;
  123732. /**
  123733. * Gets the left operand input component
  123734. */
  123735. readonly left: NodeMaterialConnectionPoint;
  123736. /**
  123737. * Gets the right operand input component
  123738. */
  123739. readonly right: NodeMaterialConnectionPoint;
  123740. /**
  123741. * Gets the output component
  123742. */
  123743. readonly output: NodeMaterialConnectionPoint;
  123744. protected _buildBlock(state: NodeMaterialBuildState): this;
  123745. }
  123746. }
  123747. declare module BABYLON {
  123748. /**
  123749. * Block used to remap a float from a range to a new one
  123750. */
  123751. export class RemapBlock extends NodeMaterialBlock {
  123752. /**
  123753. * Gets or sets the source range
  123754. */
  123755. sourceRange: Vector2;
  123756. /**
  123757. * Gets or sets the target range
  123758. */
  123759. targetRange: Vector2;
  123760. /**
  123761. * Creates a new RemapBlock
  123762. * @param name defines the block name
  123763. */
  123764. constructor(name: string);
  123765. /**
  123766. * Gets the current class name
  123767. * @returns the class name
  123768. */
  123769. getClassName(): string;
  123770. /**
  123771. * Gets the input component
  123772. */
  123773. readonly input: NodeMaterialConnectionPoint;
  123774. /**
  123775. * Gets the source min input component
  123776. */
  123777. readonly sourceMin: NodeMaterialConnectionPoint;
  123778. /**
  123779. * Gets the source max input component
  123780. */
  123781. readonly sourceMax: NodeMaterialConnectionPoint;
  123782. /**
  123783. * Gets the target min input component
  123784. */
  123785. readonly targetMin: NodeMaterialConnectionPoint;
  123786. /**
  123787. * Gets the target max input component
  123788. */
  123789. readonly targetMax: NodeMaterialConnectionPoint;
  123790. /**
  123791. * Gets the output component
  123792. */
  123793. readonly output: NodeMaterialConnectionPoint;
  123794. protected _buildBlock(state: NodeMaterialBuildState): this;
  123795. protected _dumpPropertiesCode(): string;
  123796. serialize(): any;
  123797. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123798. }
  123799. }
  123800. declare module BABYLON {
  123801. /**
  123802. * Block used to normalize a vector
  123803. */
  123804. export class NormalizeBlock extends NodeMaterialBlock {
  123805. /**
  123806. * Creates a new NormalizeBlock
  123807. * @param name defines the block name
  123808. */
  123809. constructor(name: string);
  123810. /**
  123811. * Gets the current class name
  123812. * @returns the class name
  123813. */
  123814. getClassName(): string;
  123815. /**
  123816. * Gets the input component
  123817. */
  123818. readonly input: NodeMaterialConnectionPoint;
  123819. /**
  123820. * Gets the output component
  123821. */
  123822. readonly output: NodeMaterialConnectionPoint;
  123823. protected _buildBlock(state: NodeMaterialBuildState): this;
  123824. }
  123825. }
  123826. declare module BABYLON {
  123827. /**
  123828. * Operations supported by the Trigonometry block
  123829. */
  123830. export enum TrigonometryBlockOperations {
  123831. /** Cos */
  123832. Cos = 0,
  123833. /** Sin */
  123834. Sin = 1,
  123835. /** Abs */
  123836. Abs = 2,
  123837. /** Exp */
  123838. Exp = 3,
  123839. /** Exp2 */
  123840. Exp2 = 4,
  123841. /** Round */
  123842. Round = 5,
  123843. /** Floor */
  123844. Floor = 6,
  123845. /** Ceiling */
  123846. Ceiling = 7,
  123847. /** Square root */
  123848. Sqrt = 8,
  123849. /** Log */
  123850. Log = 9,
  123851. /** Tangent */
  123852. Tan = 10,
  123853. /** Arc tangent */
  123854. ArcTan = 11,
  123855. /** Arc cosinus */
  123856. ArcCos = 12,
  123857. /** Arc sinus */
  123858. ArcSin = 13,
  123859. /** Fraction */
  123860. Fract = 14,
  123861. /** Sign */
  123862. Sign = 15,
  123863. /** To radians (from degrees) */
  123864. Radians = 16,
  123865. /** To degrees (from radians) */
  123866. Degrees = 17
  123867. }
  123868. /**
  123869. * Block used to apply trigonometry operation to floats
  123870. */
  123871. export class TrigonometryBlock extends NodeMaterialBlock {
  123872. /**
  123873. * Gets or sets the operation applied by the block
  123874. */
  123875. operation: TrigonometryBlockOperations;
  123876. /**
  123877. * Creates a new TrigonometryBlock
  123878. * @param name defines the block name
  123879. */
  123880. constructor(name: string);
  123881. /**
  123882. * Gets the current class name
  123883. * @returns the class name
  123884. */
  123885. getClassName(): string;
  123886. /**
  123887. * Gets the input component
  123888. */
  123889. readonly input: NodeMaterialConnectionPoint;
  123890. /**
  123891. * Gets the output component
  123892. */
  123893. readonly output: NodeMaterialConnectionPoint;
  123894. protected _buildBlock(state: NodeMaterialBuildState): this;
  123895. serialize(): any;
  123896. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  123897. protected _dumpPropertiesCode(): string;
  123898. }
  123899. }
  123900. declare module BABYLON {
  123901. /**
  123902. * Block used to create a Color3/4 out of individual inputs (one for each component)
  123903. */
  123904. export class ColorMergerBlock extends NodeMaterialBlock {
  123905. /**
  123906. * Create a new ColorMergerBlock
  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 r component (input)
  123917. */
  123918. readonly r: NodeMaterialConnectionPoint;
  123919. /**
  123920. * Gets the g component (input)
  123921. */
  123922. readonly g: NodeMaterialConnectionPoint;
  123923. /**
  123924. * Gets the b component (input)
  123925. */
  123926. readonly b: NodeMaterialConnectionPoint;
  123927. /**
  123928. * Gets the a component (input)
  123929. */
  123930. readonly a: NodeMaterialConnectionPoint;
  123931. /**
  123932. * Gets the rgba component (output)
  123933. */
  123934. readonly rgba: NodeMaterialConnectionPoint;
  123935. /**
  123936. * Gets the rgb component (output)
  123937. */
  123938. readonly rgb: NodeMaterialConnectionPoint;
  123939. protected _buildBlock(state: NodeMaterialBuildState): this;
  123940. }
  123941. }
  123942. declare module BABYLON {
  123943. /**
  123944. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  123945. */
  123946. export class VectorMergerBlock extends NodeMaterialBlock {
  123947. /**
  123948. * Create a new VectorMergerBlock
  123949. * @param name defines the block name
  123950. */
  123951. constructor(name: string);
  123952. /**
  123953. * Gets the current class name
  123954. * @returns the class name
  123955. */
  123956. getClassName(): string;
  123957. /**
  123958. * Gets the x component (input)
  123959. */
  123960. readonly x: NodeMaterialConnectionPoint;
  123961. /**
  123962. * Gets the y component (input)
  123963. */
  123964. readonly y: NodeMaterialConnectionPoint;
  123965. /**
  123966. * Gets the z component (input)
  123967. */
  123968. readonly z: NodeMaterialConnectionPoint;
  123969. /**
  123970. * Gets the w component (input)
  123971. */
  123972. readonly w: NodeMaterialConnectionPoint;
  123973. /**
  123974. * Gets the xyzw component (output)
  123975. */
  123976. readonly xyzw: NodeMaterialConnectionPoint;
  123977. /**
  123978. * Gets the xyz component (output)
  123979. */
  123980. readonly xyz: NodeMaterialConnectionPoint;
  123981. /**
  123982. * Gets the xy component (output)
  123983. */
  123984. readonly xy: NodeMaterialConnectionPoint;
  123985. protected _buildBlock(state: NodeMaterialBuildState): this;
  123986. }
  123987. }
  123988. declare module BABYLON {
  123989. /**
  123990. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  123991. */
  123992. export class ColorSplitterBlock extends NodeMaterialBlock {
  123993. /**
  123994. * Create a new ColorSplitterBlock
  123995. * @param name defines the block name
  123996. */
  123997. constructor(name: string);
  123998. /**
  123999. * Gets the current class name
  124000. * @returns the class name
  124001. */
  124002. getClassName(): string;
  124003. /**
  124004. * Gets the rgba component (input)
  124005. */
  124006. readonly rgba: NodeMaterialConnectionPoint;
  124007. /**
  124008. * Gets the rgb component (input)
  124009. */
  124010. readonly rgbIn: NodeMaterialConnectionPoint;
  124011. /**
  124012. * Gets the rgb component (output)
  124013. */
  124014. readonly rgbOut: NodeMaterialConnectionPoint;
  124015. /**
  124016. * Gets the r component (output)
  124017. */
  124018. readonly r: NodeMaterialConnectionPoint;
  124019. /**
  124020. * Gets the g component (output)
  124021. */
  124022. readonly g: NodeMaterialConnectionPoint;
  124023. /**
  124024. * Gets the b component (output)
  124025. */
  124026. readonly b: NodeMaterialConnectionPoint;
  124027. /**
  124028. * Gets the a component (output)
  124029. */
  124030. readonly a: NodeMaterialConnectionPoint;
  124031. protected _inputRename(name: string): string;
  124032. protected _outputRename(name: string): string;
  124033. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124034. }
  124035. }
  124036. declare module BABYLON {
  124037. /**
  124038. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  124039. */
  124040. export class VectorSplitterBlock extends NodeMaterialBlock {
  124041. /**
  124042. * Create a new VectorSplitterBlock
  124043. * @param name defines the block name
  124044. */
  124045. constructor(name: string);
  124046. /**
  124047. * Gets the current class name
  124048. * @returns the class name
  124049. */
  124050. getClassName(): string;
  124051. /**
  124052. * Gets the xyzw component (input)
  124053. */
  124054. readonly xyzw: NodeMaterialConnectionPoint;
  124055. /**
  124056. * Gets the xyz component (input)
  124057. */
  124058. readonly xyzIn: NodeMaterialConnectionPoint;
  124059. /**
  124060. * Gets the xy component (input)
  124061. */
  124062. readonly xyIn: NodeMaterialConnectionPoint;
  124063. /**
  124064. * Gets the xyz component (output)
  124065. */
  124066. readonly xyzOut: NodeMaterialConnectionPoint;
  124067. /**
  124068. * Gets the xy component (output)
  124069. */
  124070. readonly xyOut: NodeMaterialConnectionPoint;
  124071. /**
  124072. * Gets the x component (output)
  124073. */
  124074. readonly x: NodeMaterialConnectionPoint;
  124075. /**
  124076. * Gets the y component (output)
  124077. */
  124078. readonly y: NodeMaterialConnectionPoint;
  124079. /**
  124080. * Gets the z component (output)
  124081. */
  124082. readonly z: NodeMaterialConnectionPoint;
  124083. /**
  124084. * Gets the w component (output)
  124085. */
  124086. readonly w: NodeMaterialConnectionPoint;
  124087. protected _inputRename(name: string): string;
  124088. protected _outputRename(name: string): string;
  124089. protected _buildBlock(state: NodeMaterialBuildState): this;
  124090. }
  124091. }
  124092. declare module BABYLON {
  124093. /**
  124094. * Block used to lerp between 2 values
  124095. */
  124096. export class LerpBlock extends NodeMaterialBlock {
  124097. /**
  124098. * Creates a new LerpBlock
  124099. * @param name defines the block name
  124100. */
  124101. constructor(name: string);
  124102. /**
  124103. * Gets the current class name
  124104. * @returns the class name
  124105. */
  124106. getClassName(): string;
  124107. /**
  124108. * Gets the left operand input component
  124109. */
  124110. readonly left: NodeMaterialConnectionPoint;
  124111. /**
  124112. * Gets the right operand input component
  124113. */
  124114. readonly right: NodeMaterialConnectionPoint;
  124115. /**
  124116. * Gets the gradient operand input component
  124117. */
  124118. readonly gradient: NodeMaterialConnectionPoint;
  124119. /**
  124120. * Gets the output component
  124121. */
  124122. readonly output: NodeMaterialConnectionPoint;
  124123. protected _buildBlock(state: NodeMaterialBuildState): this;
  124124. }
  124125. }
  124126. declare module BABYLON {
  124127. /**
  124128. * Block used to divide 2 vectors
  124129. */
  124130. export class DivideBlock extends NodeMaterialBlock {
  124131. /**
  124132. * Creates a new DivideBlock
  124133. * @param name defines the block name
  124134. */
  124135. constructor(name: string);
  124136. /**
  124137. * Gets the current class name
  124138. * @returns the class name
  124139. */
  124140. getClassName(): string;
  124141. /**
  124142. * Gets the left operand input component
  124143. */
  124144. readonly left: NodeMaterialConnectionPoint;
  124145. /**
  124146. * Gets the right operand input component
  124147. */
  124148. readonly right: NodeMaterialConnectionPoint;
  124149. /**
  124150. * Gets the output component
  124151. */
  124152. readonly output: NodeMaterialConnectionPoint;
  124153. protected _buildBlock(state: NodeMaterialBuildState): this;
  124154. }
  124155. }
  124156. declare module BABYLON {
  124157. /**
  124158. * Block used to subtract 2 vectors
  124159. */
  124160. export class SubtractBlock extends NodeMaterialBlock {
  124161. /**
  124162. * Creates a new SubtractBlock
  124163. * @param name defines the block name
  124164. */
  124165. constructor(name: string);
  124166. /**
  124167. * Gets the current class name
  124168. * @returns the class name
  124169. */
  124170. getClassName(): string;
  124171. /**
  124172. * Gets the left operand input component
  124173. */
  124174. readonly left: NodeMaterialConnectionPoint;
  124175. /**
  124176. * Gets the right operand input component
  124177. */
  124178. readonly right: NodeMaterialConnectionPoint;
  124179. /**
  124180. * Gets the output component
  124181. */
  124182. readonly output: NodeMaterialConnectionPoint;
  124183. protected _buildBlock(state: NodeMaterialBuildState): this;
  124184. }
  124185. }
  124186. declare module BABYLON {
  124187. /**
  124188. * Block used to step a value
  124189. */
  124190. export class StepBlock extends NodeMaterialBlock {
  124191. /**
  124192. * Creates a new StepBlock
  124193. * @param name defines the block name
  124194. */
  124195. constructor(name: string);
  124196. /**
  124197. * Gets the current class name
  124198. * @returns the class name
  124199. */
  124200. getClassName(): string;
  124201. /**
  124202. * Gets the value operand input component
  124203. */
  124204. readonly value: NodeMaterialConnectionPoint;
  124205. /**
  124206. * Gets the edge operand input component
  124207. */
  124208. readonly edge: NodeMaterialConnectionPoint;
  124209. /**
  124210. * Gets the output component
  124211. */
  124212. readonly output: NodeMaterialConnectionPoint;
  124213. protected _buildBlock(state: NodeMaterialBuildState): this;
  124214. }
  124215. }
  124216. declare module BABYLON {
  124217. /**
  124218. * Block used to get the opposite (1 - x) of a value
  124219. */
  124220. export class OneMinusBlock extends NodeMaterialBlock {
  124221. /**
  124222. * Creates a new OneMinusBlock
  124223. * @param name defines the block name
  124224. */
  124225. constructor(name: string);
  124226. /**
  124227. * Gets the current class name
  124228. * @returns the class name
  124229. */
  124230. getClassName(): string;
  124231. /**
  124232. * Gets the input component
  124233. */
  124234. readonly input: NodeMaterialConnectionPoint;
  124235. /**
  124236. * Gets the output component
  124237. */
  124238. readonly output: NodeMaterialConnectionPoint;
  124239. protected _buildBlock(state: NodeMaterialBuildState): this;
  124240. }
  124241. }
  124242. declare module BABYLON {
  124243. /**
  124244. * Block used to get the view direction
  124245. */
  124246. export class ViewDirectionBlock extends NodeMaterialBlock {
  124247. /**
  124248. * Creates a new ViewDirectionBlock
  124249. * @param name defines the block name
  124250. */
  124251. constructor(name: string);
  124252. /**
  124253. * Gets the current class name
  124254. * @returns the class name
  124255. */
  124256. getClassName(): string;
  124257. /**
  124258. * Gets the world position component
  124259. */
  124260. readonly worldPosition: NodeMaterialConnectionPoint;
  124261. /**
  124262. * Gets the camera position component
  124263. */
  124264. readonly cameraPosition: NodeMaterialConnectionPoint;
  124265. /**
  124266. * Gets the output component
  124267. */
  124268. readonly output: NodeMaterialConnectionPoint;
  124269. autoConfigure(material: NodeMaterial): void;
  124270. protected _buildBlock(state: NodeMaterialBuildState): this;
  124271. }
  124272. }
  124273. declare module BABYLON {
  124274. /**
  124275. * Block used to compute fresnel value
  124276. */
  124277. export class FresnelBlock extends NodeMaterialBlock {
  124278. /**
  124279. * Create a new FresnelBlock
  124280. * @param name defines the block name
  124281. */
  124282. constructor(name: string);
  124283. /**
  124284. * Gets the current class name
  124285. * @returns the class name
  124286. */
  124287. getClassName(): string;
  124288. /**
  124289. * Gets the world normal input component
  124290. */
  124291. readonly worldNormal: NodeMaterialConnectionPoint;
  124292. /**
  124293. * Gets the view direction input component
  124294. */
  124295. readonly viewDirection: NodeMaterialConnectionPoint;
  124296. /**
  124297. * Gets the bias input component
  124298. */
  124299. readonly bias: NodeMaterialConnectionPoint;
  124300. /**
  124301. * Gets the camera (or eye) position component
  124302. */
  124303. readonly power: NodeMaterialConnectionPoint;
  124304. /**
  124305. * Gets the fresnel output component
  124306. */
  124307. readonly fresnel: NodeMaterialConnectionPoint;
  124308. autoConfigure(material: NodeMaterial): void;
  124309. protected _buildBlock(state: NodeMaterialBuildState): this;
  124310. }
  124311. }
  124312. declare module BABYLON {
  124313. /**
  124314. * Block used to get the max of 2 values
  124315. */
  124316. export class MaxBlock extends NodeMaterialBlock {
  124317. /**
  124318. * Creates a new MaxBlock
  124319. * @param name defines the block name
  124320. */
  124321. constructor(name: string);
  124322. /**
  124323. * Gets the current class name
  124324. * @returns the class name
  124325. */
  124326. getClassName(): string;
  124327. /**
  124328. * Gets the left operand input component
  124329. */
  124330. readonly left: NodeMaterialConnectionPoint;
  124331. /**
  124332. * Gets the right operand input component
  124333. */
  124334. readonly right: NodeMaterialConnectionPoint;
  124335. /**
  124336. * Gets the output component
  124337. */
  124338. readonly output: NodeMaterialConnectionPoint;
  124339. protected _buildBlock(state: NodeMaterialBuildState): this;
  124340. }
  124341. }
  124342. declare module BABYLON {
  124343. /**
  124344. * Block used to get the min of 2 values
  124345. */
  124346. export class MinBlock extends NodeMaterialBlock {
  124347. /**
  124348. * Creates a new MinBlock
  124349. * @param name defines the block name
  124350. */
  124351. constructor(name: string);
  124352. /**
  124353. * Gets the current class name
  124354. * @returns the class name
  124355. */
  124356. getClassName(): string;
  124357. /**
  124358. * Gets the left operand input component
  124359. */
  124360. readonly left: NodeMaterialConnectionPoint;
  124361. /**
  124362. * Gets the right operand input component
  124363. */
  124364. readonly right: NodeMaterialConnectionPoint;
  124365. /**
  124366. * Gets the output component
  124367. */
  124368. readonly output: NodeMaterialConnectionPoint;
  124369. protected _buildBlock(state: NodeMaterialBuildState): this;
  124370. }
  124371. }
  124372. declare module BABYLON {
  124373. /**
  124374. * Block used to get the distance between 2 values
  124375. */
  124376. export class DistanceBlock extends NodeMaterialBlock {
  124377. /**
  124378. * Creates a new DistanceBlock
  124379. * @param name defines the block name
  124380. */
  124381. constructor(name: string);
  124382. /**
  124383. * Gets the current class name
  124384. * @returns the class name
  124385. */
  124386. getClassName(): string;
  124387. /**
  124388. * Gets the left operand input component
  124389. */
  124390. readonly left: NodeMaterialConnectionPoint;
  124391. /**
  124392. * Gets the right operand input component
  124393. */
  124394. readonly right: NodeMaterialConnectionPoint;
  124395. /**
  124396. * Gets the output component
  124397. */
  124398. readonly output: NodeMaterialConnectionPoint;
  124399. protected _buildBlock(state: NodeMaterialBuildState): this;
  124400. }
  124401. }
  124402. declare module BABYLON {
  124403. /**
  124404. * Block used to get the length of a vector
  124405. */
  124406. export class LengthBlock extends NodeMaterialBlock {
  124407. /**
  124408. * Creates a new LengthBlock
  124409. * @param name defines the block name
  124410. */
  124411. constructor(name: string);
  124412. /**
  124413. * Gets the current class name
  124414. * @returns the class name
  124415. */
  124416. getClassName(): string;
  124417. /**
  124418. * Gets the value input component
  124419. */
  124420. readonly value: NodeMaterialConnectionPoint;
  124421. /**
  124422. * Gets the output component
  124423. */
  124424. readonly output: NodeMaterialConnectionPoint;
  124425. protected _buildBlock(state: NodeMaterialBuildState): this;
  124426. }
  124427. }
  124428. declare module BABYLON {
  124429. /**
  124430. * Block used to get negative version of a value (i.e. x * -1)
  124431. */
  124432. export class NegateBlock extends NodeMaterialBlock {
  124433. /**
  124434. * Creates a new NegateBlock
  124435. * @param name defines the block name
  124436. */
  124437. constructor(name: string);
  124438. /**
  124439. * Gets the current class name
  124440. * @returns the class name
  124441. */
  124442. getClassName(): string;
  124443. /**
  124444. * Gets the value input component
  124445. */
  124446. readonly value: NodeMaterialConnectionPoint;
  124447. /**
  124448. * Gets the output component
  124449. */
  124450. readonly output: NodeMaterialConnectionPoint;
  124451. protected _buildBlock(state: NodeMaterialBuildState): this;
  124452. }
  124453. }
  124454. declare module BABYLON {
  124455. /**
  124456. * Block used to get the value of the first parameter raised to the power of the second
  124457. */
  124458. export class PowBlock extends NodeMaterialBlock {
  124459. /**
  124460. * Creates a new PowBlock
  124461. * @param name defines the block name
  124462. */
  124463. constructor(name: string);
  124464. /**
  124465. * Gets the current class name
  124466. * @returns the class name
  124467. */
  124468. getClassName(): string;
  124469. /**
  124470. * Gets the value operand input component
  124471. */
  124472. readonly value: NodeMaterialConnectionPoint;
  124473. /**
  124474. * Gets the power operand input component
  124475. */
  124476. readonly power: NodeMaterialConnectionPoint;
  124477. /**
  124478. * Gets the output component
  124479. */
  124480. readonly output: NodeMaterialConnectionPoint;
  124481. protected _buildBlock(state: NodeMaterialBuildState): this;
  124482. }
  124483. }
  124484. declare module BABYLON {
  124485. /**
  124486. * Block used to get a random number
  124487. */
  124488. export class RandomNumberBlock extends NodeMaterialBlock {
  124489. /**
  124490. * Creates a new RandomNumberBlock
  124491. * @param name defines the block name
  124492. */
  124493. constructor(name: string);
  124494. /**
  124495. * Gets the current class name
  124496. * @returns the class name
  124497. */
  124498. getClassName(): string;
  124499. /**
  124500. * Gets the seed input component
  124501. */
  124502. readonly seed: NodeMaterialConnectionPoint;
  124503. /**
  124504. * Gets the output component
  124505. */
  124506. readonly output: NodeMaterialConnectionPoint;
  124507. protected _buildBlock(state: NodeMaterialBuildState): this;
  124508. }
  124509. }
  124510. declare module BABYLON {
  124511. /**
  124512. * Block used to compute arc tangent of 2 values
  124513. */
  124514. export class ArcTan2Block extends NodeMaterialBlock {
  124515. /**
  124516. * Creates a new ArcTan2Block
  124517. * @param name defines the block name
  124518. */
  124519. constructor(name: string);
  124520. /**
  124521. * Gets the current class name
  124522. * @returns the class name
  124523. */
  124524. getClassName(): string;
  124525. /**
  124526. * Gets the x operand input component
  124527. */
  124528. readonly x: NodeMaterialConnectionPoint;
  124529. /**
  124530. * Gets the y operand input component
  124531. */
  124532. readonly y: NodeMaterialConnectionPoint;
  124533. /**
  124534. * Gets the output component
  124535. */
  124536. readonly output: NodeMaterialConnectionPoint;
  124537. protected _buildBlock(state: NodeMaterialBuildState): this;
  124538. }
  124539. }
  124540. declare module BABYLON {
  124541. /**
  124542. * Block used to smooth step a value
  124543. */
  124544. export class SmoothStepBlock extends NodeMaterialBlock {
  124545. /**
  124546. * Creates a new SmoothStepBlock
  124547. * @param name defines the block name
  124548. */
  124549. constructor(name: string);
  124550. /**
  124551. * Gets the current class name
  124552. * @returns the class name
  124553. */
  124554. getClassName(): string;
  124555. /**
  124556. * Gets the value operand input component
  124557. */
  124558. readonly value: NodeMaterialConnectionPoint;
  124559. /**
  124560. * Gets the first edge operand input component
  124561. */
  124562. readonly edge0: NodeMaterialConnectionPoint;
  124563. /**
  124564. * Gets the second edge operand input component
  124565. */
  124566. readonly edge1: NodeMaterialConnectionPoint;
  124567. /**
  124568. * Gets the output component
  124569. */
  124570. readonly output: NodeMaterialConnectionPoint;
  124571. protected _buildBlock(state: NodeMaterialBuildState): this;
  124572. }
  124573. }
  124574. declare module BABYLON {
  124575. /**
  124576. * Block used to get the reciprocal (1 / x) of a value
  124577. */
  124578. export class ReciprocalBlock extends NodeMaterialBlock {
  124579. /**
  124580. * Creates a new ReciprocalBlock
  124581. * @param name defines the block name
  124582. */
  124583. constructor(name: string);
  124584. /**
  124585. * Gets the current class name
  124586. * @returns the class name
  124587. */
  124588. getClassName(): string;
  124589. /**
  124590. * Gets the input component
  124591. */
  124592. readonly input: NodeMaterialConnectionPoint;
  124593. /**
  124594. * Gets the output component
  124595. */
  124596. readonly output: NodeMaterialConnectionPoint;
  124597. protected _buildBlock(state: NodeMaterialBuildState): this;
  124598. }
  124599. }
  124600. declare module BABYLON {
  124601. /**
  124602. * Block used to replace a color by another one
  124603. */
  124604. export class ReplaceColorBlock extends NodeMaterialBlock {
  124605. /**
  124606. * Creates a new ReplaceColorBlock
  124607. * @param name defines the block name
  124608. */
  124609. constructor(name: string);
  124610. /**
  124611. * Gets the current class name
  124612. * @returns the class name
  124613. */
  124614. getClassName(): string;
  124615. /**
  124616. * Gets the value input component
  124617. */
  124618. readonly value: NodeMaterialConnectionPoint;
  124619. /**
  124620. * Gets the reference input component
  124621. */
  124622. readonly reference: NodeMaterialConnectionPoint;
  124623. /**
  124624. * Gets the distance input component
  124625. */
  124626. readonly distance: NodeMaterialConnectionPoint;
  124627. /**
  124628. * Gets the replacement input component
  124629. */
  124630. readonly replacement: NodeMaterialConnectionPoint;
  124631. /**
  124632. * Gets the output component
  124633. */
  124634. readonly output: NodeMaterialConnectionPoint;
  124635. protected _buildBlock(state: NodeMaterialBuildState): this;
  124636. }
  124637. }
  124638. declare module BABYLON {
  124639. /**
  124640. * Block used to posterize a value
  124641. * @see https://en.wikipedia.org/wiki/Posterization
  124642. */
  124643. export class PosterizeBlock extends NodeMaterialBlock {
  124644. /**
  124645. * Creates a new PosterizeBlock
  124646. * @param name defines the block name
  124647. */
  124648. constructor(name: string);
  124649. /**
  124650. * Gets the current class name
  124651. * @returns the class name
  124652. */
  124653. getClassName(): string;
  124654. /**
  124655. * Gets the value input component
  124656. */
  124657. readonly value: NodeMaterialConnectionPoint;
  124658. /**
  124659. * Gets the steps input component
  124660. */
  124661. readonly steps: NodeMaterialConnectionPoint;
  124662. /**
  124663. * Gets the output component
  124664. */
  124665. readonly output: NodeMaterialConnectionPoint;
  124666. protected _buildBlock(state: NodeMaterialBuildState): this;
  124667. }
  124668. }
  124669. declare module BABYLON {
  124670. /**
  124671. * Operations supported by the Wave block
  124672. */
  124673. export enum WaveBlockKind {
  124674. /** SawTooth */
  124675. SawTooth = 0,
  124676. /** Square */
  124677. Square = 1,
  124678. /** Triangle */
  124679. Triangle = 2
  124680. }
  124681. /**
  124682. * Block used to apply wave operation to floats
  124683. */
  124684. export class WaveBlock extends NodeMaterialBlock {
  124685. /**
  124686. * Gets or sets the kibnd of wave to be applied by the block
  124687. */
  124688. kind: WaveBlockKind;
  124689. /**
  124690. * Creates a new WaveBlock
  124691. * @param name defines the block name
  124692. */
  124693. constructor(name: string);
  124694. /**
  124695. * Gets the current class name
  124696. * @returns the class name
  124697. */
  124698. getClassName(): string;
  124699. /**
  124700. * Gets the input component
  124701. */
  124702. readonly input: NodeMaterialConnectionPoint;
  124703. /**
  124704. * Gets the output component
  124705. */
  124706. readonly output: NodeMaterialConnectionPoint;
  124707. protected _buildBlock(state: NodeMaterialBuildState): this;
  124708. serialize(): any;
  124709. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124710. }
  124711. }
  124712. declare module BABYLON {
  124713. /**
  124714. * Class used to store a color step for the GradientBlock
  124715. */
  124716. export class GradientBlockColorStep {
  124717. /**
  124718. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124719. */
  124720. step: number;
  124721. /**
  124722. * Gets or sets the color associated with this step
  124723. */
  124724. color: Color3;
  124725. /**
  124726. * Creates a new GradientBlockColorStep
  124727. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  124728. * @param color defines the color associated with this step
  124729. */
  124730. constructor(
  124731. /**
  124732. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  124733. */
  124734. step: number,
  124735. /**
  124736. * Gets or sets the color associated with this step
  124737. */
  124738. color: Color3);
  124739. }
  124740. /**
  124741. * Block used to return a color from a gradient based on an input value between 0 and 1
  124742. */
  124743. export class GradientBlock extends NodeMaterialBlock {
  124744. /**
  124745. * Gets or sets the list of color steps
  124746. */
  124747. colorSteps: GradientBlockColorStep[];
  124748. /**
  124749. * Creates a new GradientBlock
  124750. * @param name defines the block name
  124751. */
  124752. constructor(name: string);
  124753. /**
  124754. * Gets the current class name
  124755. * @returns the class name
  124756. */
  124757. getClassName(): string;
  124758. /**
  124759. * Gets the gradient input component
  124760. */
  124761. readonly gradient: NodeMaterialConnectionPoint;
  124762. /**
  124763. * Gets the output component
  124764. */
  124765. readonly output: NodeMaterialConnectionPoint;
  124766. private _writeColorConstant;
  124767. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124768. serialize(): any;
  124769. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124770. protected _dumpPropertiesCode(): string;
  124771. }
  124772. }
  124773. declare module BABYLON {
  124774. /**
  124775. * Block used to normalize lerp between 2 values
  124776. */
  124777. export class NLerpBlock extends NodeMaterialBlock {
  124778. /**
  124779. * Creates a new NLerpBlock
  124780. * @param name defines the block name
  124781. */
  124782. constructor(name: string);
  124783. /**
  124784. * Gets the current class name
  124785. * @returns the class name
  124786. */
  124787. getClassName(): string;
  124788. /**
  124789. * Gets the left operand input component
  124790. */
  124791. readonly left: NodeMaterialConnectionPoint;
  124792. /**
  124793. * Gets the right operand input component
  124794. */
  124795. readonly right: NodeMaterialConnectionPoint;
  124796. /**
  124797. * Gets the gradient operand input component
  124798. */
  124799. readonly gradient: NodeMaterialConnectionPoint;
  124800. /**
  124801. * Gets the output component
  124802. */
  124803. readonly output: NodeMaterialConnectionPoint;
  124804. protected _buildBlock(state: NodeMaterialBuildState): this;
  124805. }
  124806. }
  124807. declare module BABYLON {
  124808. /**
  124809. * block used to Generate a Worley Noise 3D Noise Pattern
  124810. */
  124811. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  124812. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  124813. manhattanDistance: boolean;
  124814. /**
  124815. * Creates a new WorleyNoise3DBlock
  124816. * @param name defines the block name
  124817. */
  124818. constructor(name: string);
  124819. /**
  124820. * Gets the current class name
  124821. * @returns the class name
  124822. */
  124823. getClassName(): string;
  124824. /**
  124825. * Gets the seed input component
  124826. */
  124827. readonly seed: NodeMaterialConnectionPoint;
  124828. /**
  124829. * Gets the jitter input component
  124830. */
  124831. readonly jitter: NodeMaterialConnectionPoint;
  124832. /**
  124833. * Gets the output component
  124834. */
  124835. readonly output: NodeMaterialConnectionPoint;
  124836. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124837. /**
  124838. * Exposes the properties to the UI?
  124839. */
  124840. protected _dumpPropertiesCode(): string;
  124841. /**
  124842. * Exposes the properties to the Seralize?
  124843. */
  124844. serialize(): any;
  124845. /**
  124846. * Exposes the properties to the deseralize?
  124847. */
  124848. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  124849. }
  124850. }
  124851. declare module BABYLON {
  124852. /**
  124853. * block used to Generate a Simplex Perlin 3d Noise Pattern
  124854. */
  124855. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  124856. /**
  124857. * Creates a new SimplexPerlin3DBlock
  124858. * @param name defines the block name
  124859. */
  124860. constructor(name: string);
  124861. /**
  124862. * Gets the current class name
  124863. * @returns the class name
  124864. */
  124865. getClassName(): string;
  124866. /**
  124867. * Gets the seed operand input component
  124868. */
  124869. readonly seed: NodeMaterialConnectionPoint;
  124870. /**
  124871. * Gets the output component
  124872. */
  124873. readonly output: NodeMaterialConnectionPoint;
  124874. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  124875. }
  124876. }
  124877. declare module BABYLON {
  124878. /**
  124879. * Block used to blend normals
  124880. */
  124881. export class NormalBlendBlock extends NodeMaterialBlock {
  124882. /**
  124883. * Creates a new NormalBlendBlock
  124884. * @param name defines the block name
  124885. */
  124886. constructor(name: string);
  124887. /**
  124888. * Gets the current class name
  124889. * @returns the class name
  124890. */
  124891. getClassName(): string;
  124892. /**
  124893. * Gets the first input component
  124894. */
  124895. readonly input0: NodeMaterialConnectionPoint;
  124896. /**
  124897. * Gets the second input component
  124898. */
  124899. readonly input1: NodeMaterialConnectionPoint;
  124900. /**
  124901. * Gets the output component
  124902. */
  124903. readonly output: NodeMaterialConnectionPoint;
  124904. protected _buildBlock(state: NodeMaterialBuildState): this;
  124905. }
  124906. }
  124907. declare module BABYLON {
  124908. /**
  124909. * Block used to rotate a 2d vector by a given angle
  124910. */
  124911. export class Rotate2dBlock extends NodeMaterialBlock {
  124912. /**
  124913. * Creates a new Rotate2dBlock
  124914. * @param name defines the block name
  124915. */
  124916. constructor(name: string);
  124917. /**
  124918. * Gets the current class name
  124919. * @returns the class name
  124920. */
  124921. getClassName(): string;
  124922. /**
  124923. * Gets the input vector
  124924. */
  124925. readonly input: NodeMaterialConnectionPoint;
  124926. /**
  124927. * Gets the input angle
  124928. */
  124929. readonly angle: NodeMaterialConnectionPoint;
  124930. /**
  124931. * Gets the output component
  124932. */
  124933. readonly output: NodeMaterialConnectionPoint;
  124934. autoConfigure(material: NodeMaterial): void;
  124935. protected _buildBlock(state: NodeMaterialBuildState): this;
  124936. }
  124937. }
  124938. declare module BABYLON {
  124939. /**
  124940. * Effect Render Options
  124941. */
  124942. export interface IEffectRendererOptions {
  124943. /**
  124944. * Defines the vertices positions.
  124945. */
  124946. positions?: number[];
  124947. /**
  124948. * Defines the indices.
  124949. */
  124950. indices?: number[];
  124951. }
  124952. /**
  124953. * Helper class to render one or more effects
  124954. */
  124955. export class EffectRenderer {
  124956. private engine;
  124957. private static _DefaultOptions;
  124958. private _vertexBuffers;
  124959. private _indexBuffer;
  124960. private _ringBufferIndex;
  124961. private _ringScreenBuffer;
  124962. private _fullscreenViewport;
  124963. private _getNextFrameBuffer;
  124964. /**
  124965. * Creates an effect renderer
  124966. * @param engine the engine to use for rendering
  124967. * @param options defines the options of the effect renderer
  124968. */
  124969. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  124970. /**
  124971. * Sets the current viewport in normalized coordinates 0-1
  124972. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  124973. */
  124974. setViewport(viewport?: Viewport): void;
  124975. /**
  124976. * Binds the embedded attributes buffer to the effect.
  124977. * @param effect Defines the effect to bind the attributes for
  124978. */
  124979. bindBuffers(effect: Effect): void;
  124980. /**
  124981. * Sets the current effect wrapper to use during draw.
  124982. * The effect needs to be ready before calling this api.
  124983. * This also sets the default full screen position attribute.
  124984. * @param effectWrapper Defines the effect to draw with
  124985. */
  124986. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  124987. /**
  124988. * Draws a full screen quad.
  124989. */
  124990. draw(): void;
  124991. /**
  124992. * renders one or more effects to a specified texture
  124993. * @param effectWrappers list of effects to renderer
  124994. * @param outputTexture texture to draw to, if null it will render to the screen
  124995. */
  124996. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  124997. /**
  124998. * Disposes of the effect renderer
  124999. */
  125000. dispose(): void;
  125001. }
  125002. /**
  125003. * Options to create an EffectWrapper
  125004. */
  125005. interface EffectWrapperCreationOptions {
  125006. /**
  125007. * Engine to use to create the effect
  125008. */
  125009. engine: ThinEngine;
  125010. /**
  125011. * Fragment shader for the effect
  125012. */
  125013. fragmentShader: string;
  125014. /**
  125015. * Vertex shader for the effect
  125016. */
  125017. vertexShader?: string;
  125018. /**
  125019. * Attributes to use in the shader
  125020. */
  125021. attributeNames?: Array<string>;
  125022. /**
  125023. * Uniforms to use in the shader
  125024. */
  125025. uniformNames?: Array<string>;
  125026. /**
  125027. * Texture sampler names to use in the shader
  125028. */
  125029. samplerNames?: Array<string>;
  125030. /**
  125031. * The friendly name of the effect displayed in Spector.
  125032. */
  125033. name?: string;
  125034. }
  125035. /**
  125036. * Wraps an effect to be used for rendering
  125037. */
  125038. export class EffectWrapper {
  125039. /**
  125040. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  125041. */
  125042. onApplyObservable: Observable<{}>;
  125043. /**
  125044. * The underlying effect
  125045. */
  125046. effect: Effect;
  125047. /**
  125048. * Creates an effect to be renderer
  125049. * @param creationOptions options to create the effect
  125050. */
  125051. constructor(creationOptions: EffectWrapperCreationOptions);
  125052. /**
  125053. * Disposes of the effect wrapper
  125054. */
  125055. dispose(): void;
  125056. }
  125057. }
  125058. declare module BABYLON {
  125059. /**
  125060. * Helper class to push actions to a pool of workers.
  125061. */
  125062. export class WorkerPool implements IDisposable {
  125063. private _workerInfos;
  125064. private _pendingActions;
  125065. /**
  125066. * Constructor
  125067. * @param workers Array of workers to use for actions
  125068. */
  125069. constructor(workers: Array<Worker>);
  125070. /**
  125071. * Terminates all workers and clears any pending actions.
  125072. */
  125073. dispose(): void;
  125074. /**
  125075. * Pushes an action to the worker pool. If all the workers are active, the action will be
  125076. * pended until a worker has completed its action.
  125077. * @param action The action to perform. Call onComplete when the action is complete.
  125078. */
  125079. push(action: (worker: Worker, onComplete: () => void) => void): void;
  125080. private _execute;
  125081. }
  125082. }
  125083. declare module BABYLON {
  125084. /**
  125085. * Configuration for Draco compression
  125086. */
  125087. export interface IDracoCompressionConfiguration {
  125088. /**
  125089. * Configuration for the decoder.
  125090. */
  125091. decoder: {
  125092. /**
  125093. * The url to the WebAssembly module.
  125094. */
  125095. wasmUrl?: string;
  125096. /**
  125097. * The url to the WebAssembly binary.
  125098. */
  125099. wasmBinaryUrl?: string;
  125100. /**
  125101. * The url to the fallback JavaScript module.
  125102. */
  125103. fallbackUrl?: string;
  125104. };
  125105. }
  125106. /**
  125107. * Draco compression (https://google.github.io/draco/)
  125108. *
  125109. * This class wraps the Draco module.
  125110. *
  125111. * **Encoder**
  125112. *
  125113. * The encoder is not currently implemented.
  125114. *
  125115. * **Decoder**
  125116. *
  125117. * 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.
  125118. *
  125119. * To update the configuration, use the following code:
  125120. * ```javascript
  125121. * DracoCompression.Configuration = {
  125122. * decoder: {
  125123. * wasmUrl: "<url to the WebAssembly library>",
  125124. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  125125. * fallbackUrl: "<url to the fallback JavaScript library>",
  125126. * }
  125127. * };
  125128. * ```
  125129. *
  125130. * 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.
  125131. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  125132. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  125133. *
  125134. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  125135. * ```javascript
  125136. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  125137. * ```
  125138. *
  125139. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  125140. */
  125141. export class DracoCompression implements IDisposable {
  125142. private _workerPoolPromise?;
  125143. private _decoderModulePromise?;
  125144. /**
  125145. * The configuration. Defaults to the following urls:
  125146. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  125147. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  125148. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  125149. */
  125150. static Configuration: IDracoCompressionConfiguration;
  125151. /**
  125152. * Returns true if the decoder configuration is available.
  125153. */
  125154. static readonly DecoderAvailable: boolean;
  125155. /**
  125156. * Default number of workers to create when creating the draco compression object.
  125157. */
  125158. static DefaultNumWorkers: number;
  125159. private static GetDefaultNumWorkers;
  125160. private static _Default;
  125161. /**
  125162. * Default instance for the draco compression object.
  125163. */
  125164. static readonly Default: DracoCompression;
  125165. /**
  125166. * Constructor
  125167. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  125168. */
  125169. constructor(numWorkers?: number);
  125170. /**
  125171. * Stop all async operations and release resources.
  125172. */
  125173. dispose(): void;
  125174. /**
  125175. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  125176. * @returns a promise that resolves when ready
  125177. */
  125178. whenReadyAsync(): Promise<void>;
  125179. /**
  125180. * Decode Draco compressed mesh data to vertex data.
  125181. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  125182. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  125183. * @returns A promise that resolves with the decoded vertex data
  125184. */
  125185. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  125186. [kind: string]: number;
  125187. }): Promise<VertexData>;
  125188. }
  125189. }
  125190. declare module BABYLON {
  125191. /**
  125192. * Class for building Constructive Solid Geometry
  125193. */
  125194. export class CSG {
  125195. private polygons;
  125196. /**
  125197. * The world matrix
  125198. */
  125199. matrix: Matrix;
  125200. /**
  125201. * Stores the position
  125202. */
  125203. position: Vector3;
  125204. /**
  125205. * Stores the rotation
  125206. */
  125207. rotation: Vector3;
  125208. /**
  125209. * Stores the rotation quaternion
  125210. */
  125211. rotationQuaternion: Nullable<Quaternion>;
  125212. /**
  125213. * Stores the scaling vector
  125214. */
  125215. scaling: Vector3;
  125216. /**
  125217. * Convert the Mesh to CSG
  125218. * @param mesh The Mesh to convert to CSG
  125219. * @returns A new CSG from the Mesh
  125220. */
  125221. static FromMesh(mesh: Mesh): CSG;
  125222. /**
  125223. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  125224. * @param polygons Polygons used to construct a CSG solid
  125225. */
  125226. private static FromPolygons;
  125227. /**
  125228. * Clones, or makes a deep copy, of the CSG
  125229. * @returns A new CSG
  125230. */
  125231. clone(): CSG;
  125232. /**
  125233. * Unions this CSG with another CSG
  125234. * @param csg The CSG to union against this CSG
  125235. * @returns The unioned CSG
  125236. */
  125237. union(csg: CSG): CSG;
  125238. /**
  125239. * Unions this CSG with another CSG in place
  125240. * @param csg The CSG to union against this CSG
  125241. */
  125242. unionInPlace(csg: CSG): void;
  125243. /**
  125244. * Subtracts this CSG with another CSG
  125245. * @param csg The CSG to subtract against this CSG
  125246. * @returns A new CSG
  125247. */
  125248. subtract(csg: CSG): CSG;
  125249. /**
  125250. * Subtracts this CSG with another CSG in place
  125251. * @param csg The CSG to subtact against this CSG
  125252. */
  125253. subtractInPlace(csg: CSG): void;
  125254. /**
  125255. * Intersect this CSG with another CSG
  125256. * @param csg The CSG to intersect against this CSG
  125257. * @returns A new CSG
  125258. */
  125259. intersect(csg: CSG): CSG;
  125260. /**
  125261. * Intersects this CSG with another CSG in place
  125262. * @param csg The CSG to intersect against this CSG
  125263. */
  125264. intersectInPlace(csg: CSG): void;
  125265. /**
  125266. * Return a new CSG solid with solid and empty space switched. This solid is
  125267. * not modified.
  125268. * @returns A new CSG solid with solid and empty space switched
  125269. */
  125270. inverse(): CSG;
  125271. /**
  125272. * Inverses the CSG in place
  125273. */
  125274. inverseInPlace(): void;
  125275. /**
  125276. * This is used to keep meshes transformations so they can be restored
  125277. * when we build back a Babylon Mesh
  125278. * NB : All CSG operations are performed in world coordinates
  125279. * @param csg The CSG to copy the transform attributes from
  125280. * @returns This CSG
  125281. */
  125282. copyTransformAttributes(csg: CSG): CSG;
  125283. /**
  125284. * Build Raw mesh from CSG
  125285. * Coordinates here are in world space
  125286. * @param name The name of the mesh geometry
  125287. * @param scene The Scene
  125288. * @param keepSubMeshes Specifies if the submeshes should be kept
  125289. * @returns A new Mesh
  125290. */
  125291. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  125292. /**
  125293. * Build Mesh from CSG taking material and transforms into account
  125294. * @param name The name of the Mesh
  125295. * @param material The material of the Mesh
  125296. * @param scene The Scene
  125297. * @param keepSubMeshes Specifies if submeshes should be kept
  125298. * @returns The new Mesh
  125299. */
  125300. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  125301. }
  125302. }
  125303. declare module BABYLON {
  125304. /**
  125305. * Class used to create a trail following a mesh
  125306. */
  125307. export class TrailMesh extends Mesh {
  125308. private _generator;
  125309. private _autoStart;
  125310. private _running;
  125311. private _diameter;
  125312. private _length;
  125313. private _sectionPolygonPointsCount;
  125314. private _sectionVectors;
  125315. private _sectionNormalVectors;
  125316. private _beforeRenderObserver;
  125317. /**
  125318. * @constructor
  125319. * @param name The value used by scene.getMeshByName() to do a lookup.
  125320. * @param generator The mesh to generate a trail.
  125321. * @param scene The scene to add this mesh to.
  125322. * @param diameter Diameter of trailing mesh. Default is 1.
  125323. * @param length Length of trailing mesh. Default is 60.
  125324. * @param autoStart Automatically start trailing mesh. Default true.
  125325. */
  125326. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  125327. /**
  125328. * "TrailMesh"
  125329. * @returns "TrailMesh"
  125330. */
  125331. getClassName(): string;
  125332. private _createMesh;
  125333. /**
  125334. * Start trailing mesh.
  125335. */
  125336. start(): void;
  125337. /**
  125338. * Stop trailing mesh.
  125339. */
  125340. stop(): void;
  125341. /**
  125342. * Update trailing mesh geometry.
  125343. */
  125344. update(): void;
  125345. /**
  125346. * Returns a new TrailMesh object.
  125347. * @param name is a string, the name given to the new mesh
  125348. * @param newGenerator use new generator object for cloned trail mesh
  125349. * @returns a new mesh
  125350. */
  125351. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  125352. /**
  125353. * Serializes this trail mesh
  125354. * @param serializationObject object to write serialization to
  125355. */
  125356. serialize(serializationObject: any): void;
  125357. /**
  125358. * Parses a serialized trail mesh
  125359. * @param parsedMesh the serialized mesh
  125360. * @param scene the scene to create the trail mesh in
  125361. * @returns the created trail mesh
  125362. */
  125363. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  125364. }
  125365. }
  125366. declare module BABYLON {
  125367. /**
  125368. * Class containing static functions to help procedurally build meshes
  125369. */
  125370. export class TiledBoxBuilder {
  125371. /**
  125372. * Creates a box mesh
  125373. * 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)
  125374. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125376. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125378. * @param name defines the name of the mesh
  125379. * @param options defines the options used to create the mesh
  125380. * @param scene defines the hosting scene
  125381. * @returns the box mesh
  125382. */
  125383. static CreateTiledBox(name: string, options: {
  125384. pattern?: number;
  125385. width?: number;
  125386. height?: number;
  125387. depth?: number;
  125388. tileSize?: number;
  125389. tileWidth?: number;
  125390. tileHeight?: number;
  125391. alignHorizontal?: number;
  125392. alignVertical?: number;
  125393. faceUV?: Vector4[];
  125394. faceColors?: Color4[];
  125395. sideOrientation?: number;
  125396. updatable?: boolean;
  125397. }, scene?: Nullable<Scene>): Mesh;
  125398. }
  125399. }
  125400. declare module BABYLON {
  125401. /**
  125402. * Class containing static functions to help procedurally build meshes
  125403. */
  125404. export class TorusKnotBuilder {
  125405. /**
  125406. * Creates a torus knot mesh
  125407. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  125408. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  125409. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  125410. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  125411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125414. * @param name defines the name of the mesh
  125415. * @param options defines the options used to create the mesh
  125416. * @param scene defines the hosting scene
  125417. * @returns the torus knot mesh
  125418. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  125419. */
  125420. static CreateTorusKnot(name: string, options: {
  125421. radius?: number;
  125422. tube?: number;
  125423. radialSegments?: number;
  125424. tubularSegments?: number;
  125425. p?: number;
  125426. q?: number;
  125427. updatable?: boolean;
  125428. sideOrientation?: number;
  125429. frontUVs?: Vector4;
  125430. backUVs?: Vector4;
  125431. }, scene: any): Mesh;
  125432. }
  125433. }
  125434. declare module BABYLON {
  125435. /**
  125436. * Polygon
  125437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  125438. */
  125439. export class Polygon {
  125440. /**
  125441. * Creates a rectangle
  125442. * @param xmin bottom X coord
  125443. * @param ymin bottom Y coord
  125444. * @param xmax top X coord
  125445. * @param ymax top Y coord
  125446. * @returns points that make the resulting rectation
  125447. */
  125448. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  125449. /**
  125450. * Creates a circle
  125451. * @param radius radius of circle
  125452. * @param cx scale in x
  125453. * @param cy scale in y
  125454. * @param numberOfSides number of sides that make up the circle
  125455. * @returns points that make the resulting circle
  125456. */
  125457. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  125458. /**
  125459. * Creates a polygon from input string
  125460. * @param input Input polygon data
  125461. * @returns the parsed points
  125462. */
  125463. static Parse(input: string): Vector2[];
  125464. /**
  125465. * Starts building a polygon from x and y coordinates
  125466. * @param x x coordinate
  125467. * @param y y coordinate
  125468. * @returns the started path2
  125469. */
  125470. static StartingAt(x: number, y: number): Path2;
  125471. }
  125472. /**
  125473. * Builds a polygon
  125474. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  125475. */
  125476. export class PolygonMeshBuilder {
  125477. private _points;
  125478. private _outlinepoints;
  125479. private _holes;
  125480. private _name;
  125481. private _scene;
  125482. private _epoints;
  125483. private _eholes;
  125484. private _addToepoint;
  125485. /**
  125486. * Babylon reference to the earcut plugin.
  125487. */
  125488. bjsEarcut: any;
  125489. /**
  125490. * Creates a PolygonMeshBuilder
  125491. * @param name name of the builder
  125492. * @param contours Path of the polygon
  125493. * @param scene scene to add to when creating the mesh
  125494. * @param earcutInjection can be used to inject your own earcut reference
  125495. */
  125496. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  125497. /**
  125498. * Adds a whole within the polygon
  125499. * @param hole Array of points defining the hole
  125500. * @returns this
  125501. */
  125502. addHole(hole: Vector2[]): PolygonMeshBuilder;
  125503. /**
  125504. * Creates the polygon
  125505. * @param updatable If the mesh should be updatable
  125506. * @param depth The depth of the mesh created
  125507. * @returns the created mesh
  125508. */
  125509. build(updatable?: boolean, depth?: number): Mesh;
  125510. /**
  125511. * Creates the polygon
  125512. * @param depth The depth of the mesh created
  125513. * @returns the created VertexData
  125514. */
  125515. buildVertexData(depth?: number): VertexData;
  125516. /**
  125517. * Adds a side to the polygon
  125518. * @param positions points that make the polygon
  125519. * @param normals normals of the polygon
  125520. * @param uvs uvs of the polygon
  125521. * @param indices indices of the polygon
  125522. * @param bounds bounds of the polygon
  125523. * @param points points of the polygon
  125524. * @param depth depth of the polygon
  125525. * @param flip flip of the polygon
  125526. */
  125527. private addSide;
  125528. }
  125529. }
  125530. declare module BABYLON {
  125531. /**
  125532. * Class containing static functions to help procedurally build meshes
  125533. */
  125534. export class PolygonBuilder {
  125535. /**
  125536. * Creates a polygon mesh
  125537. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  125538. * * 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
  125539. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  125542. * * Remember you can only change the shape positions, not their number when updating a polygon
  125543. * @param name defines the name of the mesh
  125544. * @param options defines the options used to create the mesh
  125545. * @param scene defines the hosting scene
  125546. * @param earcutInjection can be used to inject your own earcut reference
  125547. * @returns the polygon mesh
  125548. */
  125549. static CreatePolygon(name: string, options: {
  125550. shape: Vector3[];
  125551. holes?: Vector3[][];
  125552. depth?: number;
  125553. faceUV?: Vector4[];
  125554. faceColors?: Color4[];
  125555. updatable?: boolean;
  125556. sideOrientation?: number;
  125557. frontUVs?: Vector4;
  125558. backUVs?: Vector4;
  125559. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125560. /**
  125561. * Creates an extruded polygon mesh, with depth in the Y direction.
  125562. * * 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)
  125563. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125564. * @param name defines the name of the mesh
  125565. * @param options defines the options used to create the mesh
  125566. * @param scene defines the hosting scene
  125567. * @param earcutInjection can be used to inject your own earcut reference
  125568. * @returns the polygon mesh
  125569. */
  125570. static ExtrudePolygon(name: string, options: {
  125571. shape: Vector3[];
  125572. holes?: Vector3[][];
  125573. depth?: number;
  125574. faceUV?: Vector4[];
  125575. faceColors?: Color4[];
  125576. updatable?: boolean;
  125577. sideOrientation?: number;
  125578. frontUVs?: Vector4;
  125579. backUVs?: Vector4;
  125580. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  125581. }
  125582. }
  125583. declare module BABYLON {
  125584. /**
  125585. * Class containing static functions to help procedurally build meshes
  125586. */
  125587. export class LatheBuilder {
  125588. /**
  125589. * Creates lathe mesh.
  125590. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  125591. * * 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
  125592. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  125593. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  125594. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  125595. * * 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
  125596. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  125597. * * 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
  125598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125600. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125602. * @param name defines the name of the mesh
  125603. * @param options defines the options used to create the mesh
  125604. * @param scene defines the hosting scene
  125605. * @returns the lathe mesh
  125606. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  125607. */
  125608. static CreateLathe(name: string, options: {
  125609. shape: Vector3[];
  125610. radius?: number;
  125611. tessellation?: number;
  125612. clip?: number;
  125613. arc?: number;
  125614. closed?: boolean;
  125615. updatable?: boolean;
  125616. sideOrientation?: number;
  125617. frontUVs?: Vector4;
  125618. backUVs?: Vector4;
  125619. cap?: number;
  125620. invertUV?: boolean;
  125621. }, scene?: Nullable<Scene>): Mesh;
  125622. }
  125623. }
  125624. declare module BABYLON {
  125625. /**
  125626. * Class containing static functions to help procedurally build meshes
  125627. */
  125628. export class TiledPlaneBuilder {
  125629. /**
  125630. * Creates a tiled plane mesh
  125631. * * The parameter `pattern` will, depending on value, do nothing or
  125632. * * * flip (reflect about central vertical) alternate tiles across and up
  125633. * * * flip every tile on alternate rows
  125634. * * * rotate (180 degs) alternate tiles across and up
  125635. * * * rotate every tile on alternate rows
  125636. * * * flip and rotate alternate tiles across and up
  125637. * * * flip and rotate every tile on alternate rows
  125638. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  125639. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  125640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125641. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  125642. * * 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)
  125643. * * 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)
  125644. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125645. * @param name defines the name of the mesh
  125646. * @param options defines the options used to create the mesh
  125647. * @param scene defines the hosting scene
  125648. * @returns the box mesh
  125649. */
  125650. static CreateTiledPlane(name: string, options: {
  125651. pattern?: number;
  125652. tileSize?: number;
  125653. tileWidth?: number;
  125654. tileHeight?: number;
  125655. size?: number;
  125656. width?: number;
  125657. height?: number;
  125658. alignHorizontal?: number;
  125659. alignVertical?: number;
  125660. sideOrientation?: number;
  125661. frontUVs?: Vector4;
  125662. backUVs?: Vector4;
  125663. updatable?: boolean;
  125664. }, scene?: Nullable<Scene>): Mesh;
  125665. }
  125666. }
  125667. declare module BABYLON {
  125668. /**
  125669. * Class containing static functions to help procedurally build meshes
  125670. */
  125671. export class TubeBuilder {
  125672. /**
  125673. * Creates a tube mesh.
  125674. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125675. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  125676. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  125677. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  125678. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  125679. * * 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)
  125680. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  125681. * * 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
  125682. * * 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
  125683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125685. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125687. * @param name defines the name of the mesh
  125688. * @param options defines the options used to create the mesh
  125689. * @param scene defines the hosting scene
  125690. * @returns the tube mesh
  125691. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125692. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  125693. */
  125694. static CreateTube(name: string, options: {
  125695. path: Vector3[];
  125696. radius?: number;
  125697. tessellation?: number;
  125698. radiusFunction?: {
  125699. (i: number, distance: number): number;
  125700. };
  125701. cap?: number;
  125702. arc?: number;
  125703. updatable?: boolean;
  125704. sideOrientation?: number;
  125705. frontUVs?: Vector4;
  125706. backUVs?: Vector4;
  125707. instance?: Mesh;
  125708. invertUV?: boolean;
  125709. }, scene?: Nullable<Scene>): Mesh;
  125710. }
  125711. }
  125712. declare module BABYLON {
  125713. /**
  125714. * Class containing static functions to help procedurally build meshes
  125715. */
  125716. export class IcoSphereBuilder {
  125717. /**
  125718. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125719. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125720. * * 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`)
  125721. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125722. * * 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
  125723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125726. * @param name defines the name of the mesh
  125727. * @param options defines the options used to create the mesh
  125728. * @param scene defines the hosting scene
  125729. * @returns the icosahedron mesh
  125730. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125731. */
  125732. static CreateIcoSphere(name: string, options: {
  125733. radius?: number;
  125734. radiusX?: number;
  125735. radiusY?: number;
  125736. radiusZ?: number;
  125737. flat?: boolean;
  125738. subdivisions?: number;
  125739. sideOrientation?: number;
  125740. frontUVs?: Vector4;
  125741. backUVs?: Vector4;
  125742. updatable?: boolean;
  125743. }, scene?: Nullable<Scene>): Mesh;
  125744. }
  125745. }
  125746. declare module BABYLON {
  125747. /**
  125748. * Class containing static functions to help procedurally build meshes
  125749. */
  125750. export class DecalBuilder {
  125751. /**
  125752. * Creates a decal mesh.
  125753. * 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
  125754. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  125755. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  125756. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  125757. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  125758. * @param name defines the name of the mesh
  125759. * @param sourceMesh defines the mesh where the decal must be applied
  125760. * @param options defines the options used to create the mesh
  125761. * @param scene defines the hosting scene
  125762. * @returns the decal mesh
  125763. * @see https://doc.babylonjs.com/how_to/decals
  125764. */
  125765. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  125766. position?: Vector3;
  125767. normal?: Vector3;
  125768. size?: Vector3;
  125769. angle?: number;
  125770. }): Mesh;
  125771. }
  125772. }
  125773. declare module BABYLON {
  125774. /**
  125775. * Class containing static functions to help procedurally build meshes
  125776. */
  125777. export class MeshBuilder {
  125778. /**
  125779. * Creates a box mesh
  125780. * * The parameter `size` sets the size (float) of each box side (default 1)
  125781. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  125782. * * 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)
  125783. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  125784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125787. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  125788. * @param name defines the name of the mesh
  125789. * @param options defines the options used to create the mesh
  125790. * @param scene defines the hosting scene
  125791. * @returns the box mesh
  125792. */
  125793. static CreateBox(name: string, options: {
  125794. size?: number;
  125795. width?: number;
  125796. height?: number;
  125797. depth?: number;
  125798. faceUV?: Vector4[];
  125799. faceColors?: Color4[];
  125800. sideOrientation?: number;
  125801. frontUVs?: Vector4;
  125802. backUVs?: Vector4;
  125803. updatable?: boolean;
  125804. }, scene?: Nullable<Scene>): Mesh;
  125805. /**
  125806. * Creates a tiled box mesh
  125807. * * faceTiles sets the pattern, tile size and number of tiles for a face
  125808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125809. * @param name defines the name of the mesh
  125810. * @param options defines the options used to create the mesh
  125811. * @param scene defines the hosting scene
  125812. * @returns the tiled box mesh
  125813. */
  125814. static CreateTiledBox(name: string, options: {
  125815. pattern?: number;
  125816. size?: number;
  125817. width?: number;
  125818. height?: number;
  125819. depth: number;
  125820. tileSize?: number;
  125821. tileWidth?: number;
  125822. tileHeight?: number;
  125823. faceUV?: Vector4[];
  125824. faceColors?: Color4[];
  125825. alignHorizontal?: number;
  125826. alignVertical?: number;
  125827. sideOrientation?: number;
  125828. updatable?: boolean;
  125829. }, scene?: Nullable<Scene>): Mesh;
  125830. /**
  125831. * Creates a sphere mesh
  125832. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125833. * * 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`)
  125834. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125835. * * 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
  125836. * * 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)
  125837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125840. * @param name defines the name of the mesh
  125841. * @param options defines the options used to create the mesh
  125842. * @param scene defines the hosting scene
  125843. * @returns the sphere mesh
  125844. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125845. */
  125846. static CreateSphere(name: string, options: {
  125847. segments?: number;
  125848. diameter?: number;
  125849. diameterX?: number;
  125850. diameterY?: number;
  125851. diameterZ?: number;
  125852. arc?: number;
  125853. slice?: number;
  125854. sideOrientation?: number;
  125855. frontUVs?: Vector4;
  125856. backUVs?: Vector4;
  125857. updatable?: boolean;
  125858. }, scene?: Nullable<Scene>): Mesh;
  125859. /**
  125860. * Creates a plane polygonal mesh. By default, this is a disc
  125861. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  125862. * * 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
  125863. * * 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
  125864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125865. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125867. * @param name defines the name of the mesh
  125868. * @param options defines the options used to create the mesh
  125869. * @param scene defines the hosting scene
  125870. * @returns the plane polygonal mesh
  125871. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  125872. */
  125873. static CreateDisc(name: string, options: {
  125874. radius?: number;
  125875. tessellation?: number;
  125876. arc?: number;
  125877. updatable?: boolean;
  125878. sideOrientation?: number;
  125879. frontUVs?: Vector4;
  125880. backUVs?: Vector4;
  125881. }, scene?: Nullable<Scene>): Mesh;
  125882. /**
  125883. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  125884. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  125885. * * 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`)
  125886. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  125887. * * 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
  125888. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125889. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125890. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125891. * @param name defines the name of the mesh
  125892. * @param options defines the options used to create the mesh
  125893. * @param scene defines the hosting scene
  125894. * @returns the icosahedron mesh
  125895. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  125896. */
  125897. static CreateIcoSphere(name: string, options: {
  125898. radius?: number;
  125899. radiusX?: number;
  125900. radiusY?: number;
  125901. radiusZ?: number;
  125902. flat?: boolean;
  125903. subdivisions?: number;
  125904. sideOrientation?: number;
  125905. frontUVs?: Vector4;
  125906. backUVs?: Vector4;
  125907. updatable?: boolean;
  125908. }, scene?: Nullable<Scene>): Mesh;
  125909. /**
  125910. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125911. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  125912. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  125913. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  125914. * * 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
  125915. * * 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
  125916. * * 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
  125917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125920. * * 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
  125921. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  125922. * * 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
  125923. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  125924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125925. * @param name defines the name of the mesh
  125926. * @param options defines the options used to create the mesh
  125927. * @param scene defines the hosting scene
  125928. * @returns the ribbon mesh
  125929. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  125930. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125931. */
  125932. static CreateRibbon(name: string, options: {
  125933. pathArray: Vector3[][];
  125934. closeArray?: boolean;
  125935. closePath?: boolean;
  125936. offset?: number;
  125937. updatable?: boolean;
  125938. sideOrientation?: number;
  125939. frontUVs?: Vector4;
  125940. backUVs?: Vector4;
  125941. instance?: Mesh;
  125942. invertUV?: boolean;
  125943. uvs?: Vector2[];
  125944. colors?: Color4[];
  125945. }, scene?: Nullable<Scene>): Mesh;
  125946. /**
  125947. * Creates a cylinder or a cone mesh
  125948. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  125949. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  125950. * * 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.
  125951. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  125952. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  125953. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  125954. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  125955. * * 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).
  125956. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  125957. * * 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).
  125958. * * 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
  125959. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  125960. * * 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
  125961. * * 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.
  125962. * * If `enclose` is false, a ring surface is one element.
  125963. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  125964. * * 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
  125965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125968. * @param name defines the name of the mesh
  125969. * @param options defines the options used to create the mesh
  125970. * @param scene defines the hosting scene
  125971. * @returns the cylinder mesh
  125972. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  125973. */
  125974. static CreateCylinder(name: string, options: {
  125975. height?: number;
  125976. diameterTop?: number;
  125977. diameterBottom?: number;
  125978. diameter?: number;
  125979. tessellation?: number;
  125980. subdivisions?: number;
  125981. arc?: number;
  125982. faceColors?: Color4[];
  125983. faceUV?: Vector4[];
  125984. updatable?: boolean;
  125985. hasRings?: boolean;
  125986. enclose?: boolean;
  125987. cap?: number;
  125988. sideOrientation?: number;
  125989. frontUVs?: Vector4;
  125990. backUVs?: Vector4;
  125991. }, scene?: Nullable<Scene>): Mesh;
  125992. /**
  125993. * Creates a torus mesh
  125994. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  125995. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  125996. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  125997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125998. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126000. * @param name defines the name of the mesh
  126001. * @param options defines the options used to create the mesh
  126002. * @param scene defines the hosting scene
  126003. * @returns the torus mesh
  126004. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  126005. */
  126006. static CreateTorus(name: string, options: {
  126007. diameter?: number;
  126008. thickness?: number;
  126009. tessellation?: number;
  126010. updatable?: boolean;
  126011. sideOrientation?: number;
  126012. frontUVs?: Vector4;
  126013. backUVs?: Vector4;
  126014. }, scene?: Nullable<Scene>): Mesh;
  126015. /**
  126016. * Creates a torus knot mesh
  126017. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  126018. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  126019. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  126020. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  126021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126024. * @param name defines the name of the mesh
  126025. * @param options defines the options used to create the mesh
  126026. * @param scene defines the hosting scene
  126027. * @returns the torus knot mesh
  126028. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  126029. */
  126030. static CreateTorusKnot(name: string, options: {
  126031. radius?: number;
  126032. tube?: number;
  126033. radialSegments?: number;
  126034. tubularSegments?: number;
  126035. p?: number;
  126036. q?: number;
  126037. updatable?: boolean;
  126038. sideOrientation?: number;
  126039. frontUVs?: Vector4;
  126040. backUVs?: Vector4;
  126041. }, scene?: Nullable<Scene>): Mesh;
  126042. /**
  126043. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  126044. * * 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
  126045. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  126046. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  126047. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  126048. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  126049. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126050. * * 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
  126051. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  126052. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126053. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  126054. * @param name defines the name of the new line system
  126055. * @param options defines the options used to create the line system
  126056. * @param scene defines the hosting scene
  126057. * @returns a new line system mesh
  126058. */
  126059. static CreateLineSystem(name: string, options: {
  126060. lines: Vector3[][];
  126061. updatable?: boolean;
  126062. instance?: Nullable<LinesMesh>;
  126063. colors?: Nullable<Color4[][]>;
  126064. useVertexAlpha?: boolean;
  126065. }, scene: Nullable<Scene>): LinesMesh;
  126066. /**
  126067. * Creates a line mesh
  126068. * 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
  126069. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126070. * * The parameter `points` is an array successive Vector3
  126071. * * 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
  126072. * * The optional parameter `colors` is an array of successive Color4, one per line point
  126073. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  126074. * * When updating an instance, remember that only point positions can change, not the number of points
  126075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  126077. * @param name defines the name of the new line system
  126078. * @param options defines the options used to create the line system
  126079. * @param scene defines the hosting scene
  126080. * @returns a new line mesh
  126081. */
  126082. static CreateLines(name: string, options: {
  126083. points: Vector3[];
  126084. updatable?: boolean;
  126085. instance?: Nullable<LinesMesh>;
  126086. colors?: Color4[];
  126087. useVertexAlpha?: boolean;
  126088. }, scene?: Nullable<Scene>): LinesMesh;
  126089. /**
  126090. * Creates a dashed line mesh
  126091. * * 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
  126092. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126093. * * The parameter `points` is an array successive Vector3
  126094. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  126095. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  126096. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  126097. * * 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
  126098. * * When updating an instance, remember that only point positions can change, not the number of points
  126099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126100. * @param name defines the name of the mesh
  126101. * @param options defines the options used to create the mesh
  126102. * @param scene defines the hosting scene
  126103. * @returns the dashed line mesh
  126104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  126105. */
  126106. static CreateDashedLines(name: string, options: {
  126107. points: Vector3[];
  126108. dashSize?: number;
  126109. gapSize?: number;
  126110. dashNb?: number;
  126111. updatable?: boolean;
  126112. instance?: LinesMesh;
  126113. }, scene?: Nullable<Scene>): LinesMesh;
  126114. /**
  126115. * 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.
  126116. * * 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.
  126117. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  126118. * * 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.
  126119. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  126120. * * 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
  126121. * * 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
  126122. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  126123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126125. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  126126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126127. * @param name defines the name of the mesh
  126128. * @param options defines the options used to create the mesh
  126129. * @param scene defines the hosting scene
  126130. * @returns the extruded shape mesh
  126131. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126132. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  126133. */
  126134. static ExtrudeShape(name: string, options: {
  126135. shape: Vector3[];
  126136. path: Vector3[];
  126137. scale?: number;
  126138. rotation?: number;
  126139. cap?: number;
  126140. updatable?: boolean;
  126141. sideOrientation?: number;
  126142. frontUVs?: Vector4;
  126143. backUVs?: Vector4;
  126144. instance?: Mesh;
  126145. invertUV?: boolean;
  126146. }, scene?: Nullable<Scene>): Mesh;
  126147. /**
  126148. * Creates an custom extruded shape mesh.
  126149. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  126150. * * 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.
  126151. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  126152. * * 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
  126153. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  126154. * * 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
  126155. * * It must returns a float value that will be the scale value applied to the shape on each path point
  126156. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  126157. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  126158. * * 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
  126159. * * 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
  126160. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  126161. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126162. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126163. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126165. * @param name defines the name of the mesh
  126166. * @param options defines the options used to create the mesh
  126167. * @param scene defines the hosting scene
  126168. * @returns the custom extruded shape mesh
  126169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  126170. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126171. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  126172. */
  126173. static ExtrudeShapeCustom(name: string, options: {
  126174. shape: Vector3[];
  126175. path: Vector3[];
  126176. scaleFunction?: any;
  126177. rotationFunction?: any;
  126178. ribbonCloseArray?: boolean;
  126179. ribbonClosePath?: boolean;
  126180. cap?: number;
  126181. updatable?: boolean;
  126182. sideOrientation?: number;
  126183. frontUVs?: Vector4;
  126184. backUVs?: Vector4;
  126185. instance?: Mesh;
  126186. invertUV?: boolean;
  126187. }, scene?: Nullable<Scene>): Mesh;
  126188. /**
  126189. * Creates lathe mesh.
  126190. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  126191. * * 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
  126192. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  126193. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  126194. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  126195. * * 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
  126196. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  126197. * * 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
  126198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126199. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126200. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126202. * @param name defines the name of the mesh
  126203. * @param options defines the options used to create the mesh
  126204. * @param scene defines the hosting scene
  126205. * @returns the lathe mesh
  126206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  126207. */
  126208. static CreateLathe(name: string, options: {
  126209. shape: Vector3[];
  126210. radius?: number;
  126211. tessellation?: number;
  126212. clip?: number;
  126213. arc?: number;
  126214. closed?: boolean;
  126215. updatable?: boolean;
  126216. sideOrientation?: number;
  126217. frontUVs?: Vector4;
  126218. backUVs?: Vector4;
  126219. cap?: number;
  126220. invertUV?: boolean;
  126221. }, scene?: Nullable<Scene>): Mesh;
  126222. /**
  126223. * Creates a tiled plane mesh
  126224. * * You can set a limited pattern arrangement with the tiles
  126225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126228. * @param name defines the name of the mesh
  126229. * @param options defines the options used to create the mesh
  126230. * @param scene defines the hosting scene
  126231. * @returns the plane mesh
  126232. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  126233. */
  126234. static CreateTiledPlane(name: string, options: {
  126235. pattern?: number;
  126236. tileSize?: number;
  126237. tileWidth?: number;
  126238. tileHeight?: number;
  126239. size?: number;
  126240. width?: number;
  126241. height?: number;
  126242. alignHorizontal?: number;
  126243. alignVertical?: number;
  126244. sideOrientation?: number;
  126245. frontUVs?: Vector4;
  126246. backUVs?: Vector4;
  126247. updatable?: boolean;
  126248. }, scene?: Nullable<Scene>): Mesh;
  126249. /**
  126250. * Creates a plane mesh
  126251. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  126252. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  126253. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  126254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126255. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126257. * @param name defines the name of the mesh
  126258. * @param options defines the options used to create the mesh
  126259. * @param scene defines the hosting scene
  126260. * @returns the plane mesh
  126261. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  126262. */
  126263. static CreatePlane(name: string, options: {
  126264. size?: number;
  126265. width?: number;
  126266. height?: number;
  126267. sideOrientation?: number;
  126268. frontUVs?: Vector4;
  126269. backUVs?: Vector4;
  126270. updatable?: boolean;
  126271. sourcePlane?: Plane;
  126272. }, scene?: Nullable<Scene>): Mesh;
  126273. /**
  126274. * Creates a ground mesh
  126275. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126276. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126278. * @param name defines the name of the mesh
  126279. * @param options defines the options used to create the mesh
  126280. * @param scene defines the hosting scene
  126281. * @returns the ground mesh
  126282. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126283. */
  126284. static CreateGround(name: string, options: {
  126285. width?: number;
  126286. height?: number;
  126287. subdivisions?: number;
  126288. subdivisionsX?: number;
  126289. subdivisionsY?: number;
  126290. updatable?: boolean;
  126291. }, scene?: Nullable<Scene>): Mesh;
  126292. /**
  126293. * Creates a tiled ground mesh
  126294. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  126295. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  126296. * * 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
  126297. * * 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
  126298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126299. * @param name defines the name of the mesh
  126300. * @param options defines the options used to create the mesh
  126301. * @param scene defines the hosting scene
  126302. * @returns the tiled ground mesh
  126303. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  126304. */
  126305. static CreateTiledGround(name: string, options: {
  126306. xmin: number;
  126307. zmin: number;
  126308. xmax: number;
  126309. zmax: number;
  126310. subdivisions?: {
  126311. w: number;
  126312. h: number;
  126313. };
  126314. precision?: {
  126315. w: number;
  126316. h: number;
  126317. };
  126318. updatable?: boolean;
  126319. }, scene?: Nullable<Scene>): Mesh;
  126320. /**
  126321. * Creates a ground mesh from a height map
  126322. * * The parameter `url` sets the URL of the height map image resource.
  126323. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  126324. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  126325. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  126326. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  126327. * * 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.
  126328. * * 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).
  126329. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  126330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  126331. * @param name defines the name of the mesh
  126332. * @param url defines the url to the height map
  126333. * @param options defines the options used to create the mesh
  126334. * @param scene defines the hosting scene
  126335. * @returns the ground mesh
  126336. * @see https://doc.babylonjs.com/babylon101/height_map
  126337. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  126338. */
  126339. static CreateGroundFromHeightMap(name: string, url: string, options: {
  126340. width?: number;
  126341. height?: number;
  126342. subdivisions?: number;
  126343. minHeight?: number;
  126344. maxHeight?: number;
  126345. colorFilter?: Color3;
  126346. alphaFilter?: number;
  126347. updatable?: boolean;
  126348. onReady?: (mesh: GroundMesh) => void;
  126349. }, scene?: Nullable<Scene>): GroundMesh;
  126350. /**
  126351. * Creates a polygon mesh
  126352. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  126353. * * 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
  126354. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  126355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126356. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  126357. * * Remember you can only change the shape positions, not their number when updating a polygon
  126358. * @param name defines the name of the mesh
  126359. * @param options defines the options used to create the mesh
  126360. * @param scene defines the hosting scene
  126361. * @param earcutInjection can be used to inject your own earcut reference
  126362. * @returns the polygon mesh
  126363. */
  126364. static CreatePolygon(name: string, options: {
  126365. shape: Vector3[];
  126366. holes?: Vector3[][];
  126367. depth?: number;
  126368. faceUV?: Vector4[];
  126369. faceColors?: Color4[];
  126370. updatable?: boolean;
  126371. sideOrientation?: number;
  126372. frontUVs?: Vector4;
  126373. backUVs?: Vector4;
  126374. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126375. /**
  126376. * Creates an extruded polygon mesh, with depth in the Y direction.
  126377. * * 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)
  126378. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  126379. * @param name defines the name of the mesh
  126380. * @param options defines the options used to create the mesh
  126381. * @param scene defines the hosting scene
  126382. * @param earcutInjection can be used to inject your own earcut reference
  126383. * @returns the polygon mesh
  126384. */
  126385. static ExtrudePolygon(name: string, options: {
  126386. shape: Vector3[];
  126387. holes?: Vector3[][];
  126388. depth?: number;
  126389. faceUV?: Vector4[];
  126390. faceColors?: Color4[];
  126391. updatable?: boolean;
  126392. sideOrientation?: number;
  126393. frontUVs?: Vector4;
  126394. backUVs?: Vector4;
  126395. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  126396. /**
  126397. * Creates a tube mesh.
  126398. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  126399. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  126400. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  126401. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  126402. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  126403. * * 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)
  126404. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  126405. * * 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
  126406. * * 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
  126407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126409. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  126410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126411. * @param name defines the name of the mesh
  126412. * @param options defines the options used to create the mesh
  126413. * @param scene defines the hosting scene
  126414. * @returns the tube mesh
  126415. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  126416. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  126417. */
  126418. static CreateTube(name: string, options: {
  126419. path: Vector3[];
  126420. radius?: number;
  126421. tessellation?: number;
  126422. radiusFunction?: {
  126423. (i: number, distance: number): number;
  126424. };
  126425. cap?: number;
  126426. arc?: number;
  126427. updatable?: boolean;
  126428. sideOrientation?: number;
  126429. frontUVs?: Vector4;
  126430. backUVs?: Vector4;
  126431. instance?: Mesh;
  126432. invertUV?: boolean;
  126433. }, scene?: Nullable<Scene>): Mesh;
  126434. /**
  126435. * Creates a polyhedron mesh
  126436. * * 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
  126437. * * The parameter `size` (positive float, default 1) sets the polygon size
  126438. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  126439. * * 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`
  126440. * * 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
  126441. * * 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)`)
  126442. * * 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
  126443. * * 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
  126444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  126445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  126446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126447. * @param name defines the name of the mesh
  126448. * @param options defines the options used to create the mesh
  126449. * @param scene defines the hosting scene
  126450. * @returns the polyhedron mesh
  126451. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  126452. */
  126453. static CreatePolyhedron(name: string, options: {
  126454. type?: number;
  126455. size?: number;
  126456. sizeX?: number;
  126457. sizeY?: number;
  126458. sizeZ?: number;
  126459. custom?: any;
  126460. faceUV?: Vector4[];
  126461. faceColors?: Color4[];
  126462. flat?: boolean;
  126463. updatable?: boolean;
  126464. sideOrientation?: number;
  126465. frontUVs?: Vector4;
  126466. backUVs?: Vector4;
  126467. }, scene?: Nullable<Scene>): Mesh;
  126468. /**
  126469. * Creates a decal mesh.
  126470. * 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
  126471. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  126472. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  126473. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  126474. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  126475. * @param name defines the name of the mesh
  126476. * @param sourceMesh defines the mesh where the decal must be applied
  126477. * @param options defines the options used to create the mesh
  126478. * @param scene defines the hosting scene
  126479. * @returns the decal mesh
  126480. * @see https://doc.babylonjs.com/how_to/decals
  126481. */
  126482. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  126483. position?: Vector3;
  126484. normal?: Vector3;
  126485. size?: Vector3;
  126486. angle?: number;
  126487. }): Mesh;
  126488. }
  126489. }
  126490. declare module BABYLON {
  126491. /**
  126492. * A simplifier interface for future simplification implementations
  126493. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126494. */
  126495. export interface ISimplifier {
  126496. /**
  126497. * Simplification of a given mesh according to the given settings.
  126498. * Since this requires computation, it is assumed that the function runs async.
  126499. * @param settings The settings of the simplification, including quality and distance
  126500. * @param successCallback A callback that will be called after the mesh was simplified.
  126501. * @param errorCallback in case of an error, this callback will be called. optional.
  126502. */
  126503. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  126504. }
  126505. /**
  126506. * Expected simplification settings.
  126507. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  126508. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126509. */
  126510. export interface ISimplificationSettings {
  126511. /**
  126512. * Gets or sets the expected quality
  126513. */
  126514. quality: number;
  126515. /**
  126516. * Gets or sets the distance when this optimized version should be used
  126517. */
  126518. distance: number;
  126519. /**
  126520. * Gets an already optimized mesh
  126521. */
  126522. optimizeMesh?: boolean;
  126523. }
  126524. /**
  126525. * Class used to specify simplification options
  126526. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126527. */
  126528. export class SimplificationSettings implements ISimplificationSettings {
  126529. /** expected quality */
  126530. quality: number;
  126531. /** distance when this optimized version should be used */
  126532. distance: number;
  126533. /** already optimized mesh */
  126534. optimizeMesh?: boolean | undefined;
  126535. /**
  126536. * Creates a SimplificationSettings
  126537. * @param quality expected quality
  126538. * @param distance distance when this optimized version should be used
  126539. * @param optimizeMesh already optimized mesh
  126540. */
  126541. constructor(
  126542. /** expected quality */
  126543. quality: number,
  126544. /** distance when this optimized version should be used */
  126545. distance: number,
  126546. /** already optimized mesh */
  126547. optimizeMesh?: boolean | undefined);
  126548. }
  126549. /**
  126550. * Interface used to define a simplification task
  126551. */
  126552. export interface ISimplificationTask {
  126553. /**
  126554. * Array of settings
  126555. */
  126556. settings: Array<ISimplificationSettings>;
  126557. /**
  126558. * Simplification type
  126559. */
  126560. simplificationType: SimplificationType;
  126561. /**
  126562. * Mesh to simplify
  126563. */
  126564. mesh: Mesh;
  126565. /**
  126566. * Callback called on success
  126567. */
  126568. successCallback?: () => void;
  126569. /**
  126570. * Defines if parallel processing can be used
  126571. */
  126572. parallelProcessing: boolean;
  126573. }
  126574. /**
  126575. * Queue used to order the simplification tasks
  126576. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126577. */
  126578. export class SimplificationQueue {
  126579. private _simplificationArray;
  126580. /**
  126581. * Gets a boolean indicating that the process is still running
  126582. */
  126583. running: boolean;
  126584. /**
  126585. * Creates a new queue
  126586. */
  126587. constructor();
  126588. /**
  126589. * Adds a new simplification task
  126590. * @param task defines a task to add
  126591. */
  126592. addTask(task: ISimplificationTask): void;
  126593. /**
  126594. * Execute next task
  126595. */
  126596. executeNext(): void;
  126597. /**
  126598. * Execute a simplification task
  126599. * @param task defines the task to run
  126600. */
  126601. runSimplification(task: ISimplificationTask): void;
  126602. private getSimplifier;
  126603. }
  126604. /**
  126605. * The implemented types of simplification
  126606. * At the moment only Quadratic Error Decimation is implemented
  126607. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126608. */
  126609. export enum SimplificationType {
  126610. /** Quadratic error decimation */
  126611. QUADRATIC = 0
  126612. }
  126613. }
  126614. declare module BABYLON {
  126615. interface Scene {
  126616. /** @hidden (Backing field) */
  126617. _simplificationQueue: SimplificationQueue;
  126618. /**
  126619. * Gets or sets the simplification queue attached to the scene
  126620. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  126621. */
  126622. simplificationQueue: SimplificationQueue;
  126623. }
  126624. interface Mesh {
  126625. /**
  126626. * Simplify the mesh according to the given array of settings.
  126627. * Function will return immediately and will simplify async
  126628. * @param settings a collection of simplification settings
  126629. * @param parallelProcessing should all levels calculate parallel or one after the other
  126630. * @param simplificationType the type of simplification to run
  126631. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  126632. * @returns the current mesh
  126633. */
  126634. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  126635. }
  126636. /**
  126637. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  126638. * created in a scene
  126639. */
  126640. export class SimplicationQueueSceneComponent implements ISceneComponent {
  126641. /**
  126642. * The component name helpfull to identify the component in the list of scene components.
  126643. */
  126644. readonly name: string;
  126645. /**
  126646. * The scene the component belongs to.
  126647. */
  126648. scene: Scene;
  126649. /**
  126650. * Creates a new instance of the component for the given scene
  126651. * @param scene Defines the scene to register the component in
  126652. */
  126653. constructor(scene: Scene);
  126654. /**
  126655. * Registers the component in a given scene
  126656. */
  126657. register(): void;
  126658. /**
  126659. * Rebuilds the elements related to this component in case of
  126660. * context lost for instance.
  126661. */
  126662. rebuild(): void;
  126663. /**
  126664. * Disposes the component and the associated ressources
  126665. */
  126666. dispose(): void;
  126667. private _beforeCameraUpdate;
  126668. }
  126669. }
  126670. declare module BABYLON {
  126671. /**
  126672. * Navigation plugin interface to add navigation constrained by a navigation mesh
  126673. */
  126674. export interface INavigationEnginePlugin {
  126675. /**
  126676. * plugin name
  126677. */
  126678. name: string;
  126679. /**
  126680. * Creates a navigation mesh
  126681. * @param meshes array of all the geometry used to compute the navigatio mesh
  126682. * @param parameters bunch of parameters used to filter geometry
  126683. */
  126684. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126685. /**
  126686. * Create a navigation mesh debug mesh
  126687. * @param scene is where the mesh will be added
  126688. * @returns debug display mesh
  126689. */
  126690. createDebugNavMesh(scene: Scene): Mesh;
  126691. /**
  126692. * Get a navigation mesh constrained position, closest to the parameter position
  126693. * @param position world position
  126694. * @returns the closest point to position constrained by the navigation mesh
  126695. */
  126696. getClosestPoint(position: Vector3): Vector3;
  126697. /**
  126698. * Get a navigation mesh constrained position, within a particular radius
  126699. * @param position world position
  126700. * @param maxRadius the maximum distance to the constrained world position
  126701. * @returns the closest point to position constrained by the navigation mesh
  126702. */
  126703. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126704. /**
  126705. * Compute the final position from a segment made of destination-position
  126706. * @param position world position
  126707. * @param destination world position
  126708. * @returns the resulting point along the navmesh
  126709. */
  126710. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126711. /**
  126712. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126713. * @param start world position
  126714. * @param end world position
  126715. * @returns array containing world position composing the path
  126716. */
  126717. computePath(start: Vector3, end: Vector3): Vector3[];
  126718. /**
  126719. * If this plugin is supported
  126720. * @returns true if plugin is supported
  126721. */
  126722. isSupported(): boolean;
  126723. /**
  126724. * Create a new Crowd so you can add agents
  126725. * @param maxAgents the maximum agent count in the crowd
  126726. * @param maxAgentRadius the maximum radius an agent can have
  126727. * @param scene to attach the crowd to
  126728. * @returns the crowd you can add agents to
  126729. */
  126730. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126731. /**
  126732. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126733. * The queries will try to find a solution within those bounds
  126734. * default is (1,1,1)
  126735. * @param extent x,y,z value that define the extent around the queries point of reference
  126736. */
  126737. setDefaultQueryExtent(extent: Vector3): void;
  126738. /**
  126739. * Get the Bounding box extent specified by setDefaultQueryExtent
  126740. * @returns the box extent values
  126741. */
  126742. getDefaultQueryExtent(): Vector3;
  126743. /**
  126744. * Release all resources
  126745. */
  126746. dispose(): void;
  126747. }
  126748. /**
  126749. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  126750. */
  126751. export interface ICrowd {
  126752. /**
  126753. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  126754. * You can attach anything to that node. The node position is updated in the scene update tick.
  126755. * @param pos world position that will be constrained by the navigation mesh
  126756. * @param parameters agent parameters
  126757. * @param transform hooked to the agent that will be update by the scene
  126758. * @returns agent index
  126759. */
  126760. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  126761. /**
  126762. * Returns the agent position in world space
  126763. * @param index agent index returned by addAgent
  126764. * @returns world space position
  126765. */
  126766. getAgentPosition(index: number): Vector3;
  126767. /**
  126768. * Gets the agent velocity in world space
  126769. * @param index agent index returned by addAgent
  126770. * @returns world space velocity
  126771. */
  126772. getAgentVelocity(index: number): Vector3;
  126773. /**
  126774. * remove a particular agent previously created
  126775. * @param index agent index returned by addAgent
  126776. */
  126777. removeAgent(index: number): void;
  126778. /**
  126779. * get the list of all agents attached to this crowd
  126780. * @returns list of agent indices
  126781. */
  126782. getAgents(): number[];
  126783. /**
  126784. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  126785. * @param deltaTime in seconds
  126786. */
  126787. update(deltaTime: number): void;
  126788. /**
  126789. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  126790. * @param index agent index returned by addAgent
  126791. * @param destination targeted world position
  126792. */
  126793. agentGoto(index: number, destination: Vector3): void;
  126794. /**
  126795. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126796. * The queries will try to find a solution within those bounds
  126797. * default is (1,1,1)
  126798. * @param extent x,y,z value that define the extent around the queries point of reference
  126799. */
  126800. setDefaultQueryExtent(extent: Vector3): void;
  126801. /**
  126802. * Get the Bounding box extent specified by setDefaultQueryExtent
  126803. * @returns the box extent values
  126804. */
  126805. getDefaultQueryExtent(): Vector3;
  126806. /**
  126807. * Release all resources
  126808. */
  126809. dispose(): void;
  126810. }
  126811. /**
  126812. * Configures an agent
  126813. */
  126814. export interface IAgentParameters {
  126815. /**
  126816. * Agent radius. [Limit: >= 0]
  126817. */
  126818. radius: number;
  126819. /**
  126820. * Agent height. [Limit: > 0]
  126821. */
  126822. height: number;
  126823. /**
  126824. * Maximum allowed acceleration. [Limit: >= 0]
  126825. */
  126826. maxAcceleration: number;
  126827. /**
  126828. * Maximum allowed speed. [Limit: >= 0]
  126829. */
  126830. maxSpeed: number;
  126831. /**
  126832. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  126833. */
  126834. collisionQueryRange: number;
  126835. /**
  126836. * The path visibility optimization range. [Limit: > 0]
  126837. */
  126838. pathOptimizationRange: number;
  126839. /**
  126840. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  126841. */
  126842. separationWeight: number;
  126843. }
  126844. /**
  126845. * Configures the navigation mesh creation
  126846. */
  126847. export interface INavMeshParameters {
  126848. /**
  126849. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  126850. */
  126851. cs: number;
  126852. /**
  126853. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  126854. */
  126855. ch: number;
  126856. /**
  126857. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  126858. */
  126859. walkableSlopeAngle: number;
  126860. /**
  126861. * Minimum floor to 'ceiling' height that will still allow the floor area to
  126862. * be considered walkable. [Limit: >= 3] [Units: vx]
  126863. */
  126864. walkableHeight: number;
  126865. /**
  126866. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  126867. */
  126868. walkableClimb: number;
  126869. /**
  126870. * The distance to erode/shrink the walkable area of the heightfield away from
  126871. * obstructions. [Limit: >=0] [Units: vx]
  126872. */
  126873. walkableRadius: number;
  126874. /**
  126875. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  126876. */
  126877. maxEdgeLen: number;
  126878. /**
  126879. * The maximum distance a simplfied contour's border edges should deviate
  126880. * the original raw contour. [Limit: >=0] [Units: vx]
  126881. */
  126882. maxSimplificationError: number;
  126883. /**
  126884. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  126885. */
  126886. minRegionArea: number;
  126887. /**
  126888. * Any regions with a span count smaller than this value will, if possible,
  126889. * be merged with larger regions. [Limit: >=0] [Units: vx]
  126890. */
  126891. mergeRegionArea: number;
  126892. /**
  126893. * The maximum number of vertices allowed for polygons generated during the
  126894. * contour to polygon conversion process. [Limit: >= 3]
  126895. */
  126896. maxVertsPerPoly: number;
  126897. /**
  126898. * Sets the sampling distance to use when generating the detail mesh.
  126899. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  126900. */
  126901. detailSampleDist: number;
  126902. /**
  126903. * The maximum distance the detail mesh surface should deviate from heightfield
  126904. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  126905. */
  126906. detailSampleMaxError: number;
  126907. }
  126908. }
  126909. declare module BABYLON {
  126910. /**
  126911. * RecastJS navigation plugin
  126912. */
  126913. export class RecastJSPlugin implements INavigationEnginePlugin {
  126914. /**
  126915. * Reference to the Recast library
  126916. */
  126917. bjsRECAST: any;
  126918. /**
  126919. * plugin name
  126920. */
  126921. name: string;
  126922. /**
  126923. * the first navmesh created. We might extend this to support multiple navmeshes
  126924. */
  126925. navMesh: any;
  126926. /**
  126927. * Initializes the recastJS plugin
  126928. * @param recastInjection can be used to inject your own recast reference
  126929. */
  126930. constructor(recastInjection?: any);
  126931. /**
  126932. * Creates a navigation mesh
  126933. * @param meshes array of all the geometry used to compute the navigatio mesh
  126934. * @param parameters bunch of parameters used to filter geometry
  126935. */
  126936. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  126937. /**
  126938. * Create a navigation mesh debug mesh
  126939. * @param scene is where the mesh will be added
  126940. * @returns debug display mesh
  126941. */
  126942. createDebugNavMesh(scene: Scene): Mesh;
  126943. /**
  126944. * Get a navigation mesh constrained position, closest to the parameter position
  126945. * @param position world position
  126946. * @returns the closest point to position constrained by the navigation mesh
  126947. */
  126948. getClosestPoint(position: Vector3): Vector3;
  126949. /**
  126950. * Get a navigation mesh constrained position, within a particular radius
  126951. * @param position world position
  126952. * @param maxRadius the maximum distance to the constrained world position
  126953. * @returns the closest point to position constrained by the navigation mesh
  126954. */
  126955. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  126956. /**
  126957. * Compute the final position from a segment made of destination-position
  126958. * @param position world position
  126959. * @param destination world position
  126960. * @returns the resulting point along the navmesh
  126961. */
  126962. moveAlong(position: Vector3, destination: Vector3): Vector3;
  126963. /**
  126964. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  126965. * @param start world position
  126966. * @param end world position
  126967. * @returns array containing world position composing the path
  126968. */
  126969. computePath(start: Vector3, end: Vector3): Vector3[];
  126970. /**
  126971. * Create a new Crowd so you can add agents
  126972. * @param maxAgents the maximum agent count in the crowd
  126973. * @param maxAgentRadius the maximum radius an agent can have
  126974. * @param scene to attach the crowd to
  126975. * @returns the crowd you can add agents to
  126976. */
  126977. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  126978. /**
  126979. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  126980. * The queries will try to find a solution within those bounds
  126981. * default is (1,1,1)
  126982. * @param extent x,y,z value that define the extent around the queries point of reference
  126983. */
  126984. setDefaultQueryExtent(extent: Vector3): void;
  126985. /**
  126986. * Get the Bounding box extent specified by setDefaultQueryExtent
  126987. * @returns the box extent values
  126988. */
  126989. getDefaultQueryExtent(): Vector3;
  126990. /**
  126991. * Disposes
  126992. */
  126993. dispose(): void;
  126994. /**
  126995. * If this plugin is supported
  126996. * @returns true if plugin is supported
  126997. */
  126998. isSupported(): boolean;
  126999. }
  127000. /**
  127001. * Recast detour crowd implementation
  127002. */
  127003. export class RecastJSCrowd implements ICrowd {
  127004. /**
  127005. * Recast/detour plugin
  127006. */
  127007. bjsRECASTPlugin: RecastJSPlugin;
  127008. /**
  127009. * Link to the detour crowd
  127010. */
  127011. recastCrowd: any;
  127012. /**
  127013. * One transform per agent
  127014. */
  127015. transforms: TransformNode[];
  127016. /**
  127017. * All agents created
  127018. */
  127019. agents: number[];
  127020. /**
  127021. * Link to the scene is kept to unregister the crowd from the scene
  127022. */
  127023. private _scene;
  127024. /**
  127025. * Observer for crowd updates
  127026. */
  127027. private _onBeforeAnimationsObserver;
  127028. /**
  127029. * Constructor
  127030. * @param plugin recastJS plugin
  127031. * @param maxAgents the maximum agent count in the crowd
  127032. * @param maxAgentRadius the maximum radius an agent can have
  127033. * @param scene to attach the crowd to
  127034. * @returns the crowd you can add agents to
  127035. */
  127036. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  127037. /**
  127038. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  127039. * You can attach anything to that node. The node position is updated in the scene update tick.
  127040. * @param pos world position that will be constrained by the navigation mesh
  127041. * @param parameters agent parameters
  127042. * @param transform hooked to the agent that will be update by the scene
  127043. * @returns agent index
  127044. */
  127045. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  127046. /**
  127047. * Returns the agent position in world space
  127048. * @param index agent index returned by addAgent
  127049. * @returns world space position
  127050. */
  127051. getAgentPosition(index: number): Vector3;
  127052. /**
  127053. * Returns the agent velocity in world space
  127054. * @param index agent index returned by addAgent
  127055. * @returns world space velocity
  127056. */
  127057. getAgentVelocity(index: number): Vector3;
  127058. /**
  127059. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  127060. * @param index agent index returned by addAgent
  127061. * @param destination targeted world position
  127062. */
  127063. agentGoto(index: number, destination: Vector3): void;
  127064. /**
  127065. * remove a particular agent previously created
  127066. * @param index agent index returned by addAgent
  127067. */
  127068. removeAgent(index: number): void;
  127069. /**
  127070. * get the list of all agents attached to this crowd
  127071. * @returns list of agent indices
  127072. */
  127073. getAgents(): number[];
  127074. /**
  127075. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  127076. * @param deltaTime in seconds
  127077. */
  127078. update(deltaTime: number): void;
  127079. /**
  127080. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  127081. * The queries will try to find a solution within those bounds
  127082. * default is (1,1,1)
  127083. * @param extent x,y,z value that define the extent around the queries point of reference
  127084. */
  127085. setDefaultQueryExtent(extent: Vector3): void;
  127086. /**
  127087. * Get the Bounding box extent specified by setDefaultQueryExtent
  127088. * @returns the box extent values
  127089. */
  127090. getDefaultQueryExtent(): Vector3;
  127091. /**
  127092. * Release all resources
  127093. */
  127094. dispose(): void;
  127095. }
  127096. }
  127097. declare module BABYLON {
  127098. /**
  127099. * Class used to enable access to IndexedDB
  127100. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  127101. */
  127102. export class Database implements IOfflineProvider {
  127103. private _callbackManifestChecked;
  127104. private _currentSceneUrl;
  127105. private _db;
  127106. private _enableSceneOffline;
  127107. private _enableTexturesOffline;
  127108. private _manifestVersionFound;
  127109. private _mustUpdateRessources;
  127110. private _hasReachedQuota;
  127111. private _isSupported;
  127112. private _idbFactory;
  127113. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  127114. private static IsUASupportingBlobStorage;
  127115. /**
  127116. * Gets a boolean indicating if Database storate is enabled (off by default)
  127117. */
  127118. static IDBStorageEnabled: boolean;
  127119. /**
  127120. * Gets a boolean indicating if scene must be saved in the database
  127121. */
  127122. readonly enableSceneOffline: boolean;
  127123. /**
  127124. * Gets a boolean indicating if textures must be saved in the database
  127125. */
  127126. readonly enableTexturesOffline: boolean;
  127127. /**
  127128. * Creates a new Database
  127129. * @param urlToScene defines the url to load the scene
  127130. * @param callbackManifestChecked defines the callback to use when manifest is checked
  127131. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  127132. */
  127133. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  127134. private static _ParseURL;
  127135. private static _ReturnFullUrlLocation;
  127136. private _checkManifestFile;
  127137. /**
  127138. * Open the database and make it available
  127139. * @param successCallback defines the callback to call on success
  127140. * @param errorCallback defines the callback to call on error
  127141. */
  127142. open(successCallback: () => void, errorCallback: () => void): void;
  127143. /**
  127144. * Loads an image from the database
  127145. * @param url defines the url to load from
  127146. * @param image defines the target DOM image
  127147. */
  127148. loadImage(url: string, image: HTMLImageElement): void;
  127149. private _loadImageFromDBAsync;
  127150. private _saveImageIntoDBAsync;
  127151. private _checkVersionFromDB;
  127152. private _loadVersionFromDBAsync;
  127153. private _saveVersionIntoDBAsync;
  127154. /**
  127155. * Loads a file from database
  127156. * @param url defines the URL to load from
  127157. * @param sceneLoaded defines a callback to call on success
  127158. * @param progressCallBack defines a callback to call when progress changed
  127159. * @param errorCallback defines a callback to call on error
  127160. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  127161. */
  127162. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  127163. private _loadFileAsync;
  127164. private _saveFileAsync;
  127165. /**
  127166. * Validates if xhr data is correct
  127167. * @param xhr defines the request to validate
  127168. * @param dataType defines the expected data type
  127169. * @returns true if data is correct
  127170. */
  127171. private static _ValidateXHRData;
  127172. }
  127173. }
  127174. declare module BABYLON {
  127175. /** @hidden */
  127176. export var gpuUpdateParticlesPixelShader: {
  127177. name: string;
  127178. shader: string;
  127179. };
  127180. }
  127181. declare module BABYLON {
  127182. /** @hidden */
  127183. export var gpuUpdateParticlesVertexShader: {
  127184. name: string;
  127185. shader: string;
  127186. };
  127187. }
  127188. declare module BABYLON {
  127189. /** @hidden */
  127190. export var clipPlaneFragmentDeclaration2: {
  127191. name: string;
  127192. shader: string;
  127193. };
  127194. }
  127195. declare module BABYLON {
  127196. /** @hidden */
  127197. export var gpuRenderParticlesPixelShader: {
  127198. name: string;
  127199. shader: string;
  127200. };
  127201. }
  127202. declare module BABYLON {
  127203. /** @hidden */
  127204. export var clipPlaneVertexDeclaration2: {
  127205. name: string;
  127206. shader: string;
  127207. };
  127208. }
  127209. declare module BABYLON {
  127210. /** @hidden */
  127211. export var gpuRenderParticlesVertexShader: {
  127212. name: string;
  127213. shader: string;
  127214. };
  127215. }
  127216. declare module BABYLON {
  127217. /**
  127218. * This represents a GPU particle system in Babylon
  127219. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  127220. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  127221. */
  127222. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  127223. /**
  127224. * The layer mask we are rendering the particles through.
  127225. */
  127226. layerMask: number;
  127227. private _capacity;
  127228. private _activeCount;
  127229. private _currentActiveCount;
  127230. private _accumulatedCount;
  127231. private _renderEffect;
  127232. private _updateEffect;
  127233. private _buffer0;
  127234. private _buffer1;
  127235. private _spriteBuffer;
  127236. private _updateVAO;
  127237. private _renderVAO;
  127238. private _targetIndex;
  127239. private _sourceBuffer;
  127240. private _targetBuffer;
  127241. private _engine;
  127242. private _currentRenderId;
  127243. private _started;
  127244. private _stopped;
  127245. private _timeDelta;
  127246. private _randomTexture;
  127247. private _randomTexture2;
  127248. private _attributesStrideSize;
  127249. private _updateEffectOptions;
  127250. private _randomTextureSize;
  127251. private _actualFrame;
  127252. private readonly _rawTextureWidth;
  127253. /**
  127254. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  127255. */
  127256. static readonly IsSupported: boolean;
  127257. /**
  127258. * An event triggered when the system is disposed.
  127259. */
  127260. onDisposeObservable: Observable<GPUParticleSystem>;
  127261. /**
  127262. * Gets the maximum number of particles active at the same time.
  127263. * @returns The max number of active particles.
  127264. */
  127265. getCapacity(): number;
  127266. /**
  127267. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  127268. * to override the particles.
  127269. */
  127270. forceDepthWrite: boolean;
  127271. /**
  127272. * Gets or set the number of active particles
  127273. */
  127274. activeParticleCount: number;
  127275. private _preWarmDone;
  127276. /**
  127277. * Is this system ready to be used/rendered
  127278. * @return true if the system is ready
  127279. */
  127280. isReady(): boolean;
  127281. /**
  127282. * Gets if the system has been started. (Note: this will still be true after stop is called)
  127283. * @returns True if it has been started, otherwise false.
  127284. */
  127285. isStarted(): boolean;
  127286. /**
  127287. * Starts the particle system and begins to emit
  127288. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  127289. */
  127290. start(delay?: number): void;
  127291. /**
  127292. * Stops the particle system.
  127293. */
  127294. stop(): void;
  127295. /**
  127296. * Remove all active particles
  127297. */
  127298. reset(): void;
  127299. /**
  127300. * Returns the string "GPUParticleSystem"
  127301. * @returns a string containing the class name
  127302. */
  127303. getClassName(): string;
  127304. private _colorGradientsTexture;
  127305. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  127306. /**
  127307. * Adds a new color gradient
  127308. * @param gradient defines the gradient to use (between 0 and 1)
  127309. * @param color1 defines the color to affect to the specified gradient
  127310. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  127311. * @returns the current particle system
  127312. */
  127313. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  127314. /**
  127315. * Remove a specific color gradient
  127316. * @param gradient defines the gradient to remove
  127317. * @returns the current particle system
  127318. */
  127319. removeColorGradient(gradient: number): GPUParticleSystem;
  127320. private _angularSpeedGradientsTexture;
  127321. private _sizeGradientsTexture;
  127322. private _velocityGradientsTexture;
  127323. private _limitVelocityGradientsTexture;
  127324. private _dragGradientsTexture;
  127325. private _addFactorGradient;
  127326. /**
  127327. * Adds a new size gradient
  127328. * @param gradient defines the gradient to use (between 0 and 1)
  127329. * @param factor defines the size factor to affect to the specified gradient
  127330. * @returns the current particle system
  127331. */
  127332. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  127333. /**
  127334. * Remove a specific size gradient
  127335. * @param gradient defines the gradient to remove
  127336. * @returns the current particle system
  127337. */
  127338. removeSizeGradient(gradient: number): GPUParticleSystem;
  127339. /**
  127340. * Adds a new angular speed gradient
  127341. * @param gradient defines the gradient to use (between 0 and 1)
  127342. * @param factor defines the angular speed to affect to the specified gradient
  127343. * @returns the current particle system
  127344. */
  127345. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  127346. /**
  127347. * Remove a specific angular speed gradient
  127348. * @param gradient defines the gradient to remove
  127349. * @returns the current particle system
  127350. */
  127351. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  127352. /**
  127353. * Adds a new velocity gradient
  127354. * @param gradient defines the gradient to use (between 0 and 1)
  127355. * @param factor defines the velocity to affect to the specified gradient
  127356. * @returns the current particle system
  127357. */
  127358. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  127359. /**
  127360. * Remove a specific velocity gradient
  127361. * @param gradient defines the gradient to remove
  127362. * @returns the current particle system
  127363. */
  127364. removeVelocityGradient(gradient: number): GPUParticleSystem;
  127365. /**
  127366. * Adds a new limit velocity gradient
  127367. * @param gradient defines the gradient to use (between 0 and 1)
  127368. * @param factor defines the limit velocity value to affect to the specified gradient
  127369. * @returns the current particle system
  127370. */
  127371. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  127372. /**
  127373. * Remove a specific limit velocity gradient
  127374. * @param gradient defines the gradient to remove
  127375. * @returns the current particle system
  127376. */
  127377. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  127378. /**
  127379. * Adds a new drag gradient
  127380. * @param gradient defines the gradient to use (between 0 and 1)
  127381. * @param factor defines the drag value to affect to the specified gradient
  127382. * @returns the current particle system
  127383. */
  127384. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  127385. /**
  127386. * Remove a specific drag gradient
  127387. * @param gradient defines the gradient to remove
  127388. * @returns the current particle system
  127389. */
  127390. removeDragGradient(gradient: number): GPUParticleSystem;
  127391. /**
  127392. * Not supported by GPUParticleSystem
  127393. * @param gradient defines the gradient to use (between 0 and 1)
  127394. * @param factor defines the emit rate value to affect to the specified gradient
  127395. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127396. * @returns the current particle system
  127397. */
  127398. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127399. /**
  127400. * Not supported by GPUParticleSystem
  127401. * @param gradient defines the gradient to remove
  127402. * @returns the current particle system
  127403. */
  127404. removeEmitRateGradient(gradient: number): IParticleSystem;
  127405. /**
  127406. * Not supported by GPUParticleSystem
  127407. * @param gradient defines the gradient to use (between 0 and 1)
  127408. * @param factor defines the start size value to affect to the specified gradient
  127409. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127410. * @returns the current particle system
  127411. */
  127412. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127413. /**
  127414. * Not supported by GPUParticleSystem
  127415. * @param gradient defines the gradient to remove
  127416. * @returns the current particle system
  127417. */
  127418. removeStartSizeGradient(gradient: number): IParticleSystem;
  127419. /**
  127420. * Not supported by GPUParticleSystem
  127421. * @param gradient defines the gradient to use (between 0 and 1)
  127422. * @param min defines the color remap minimal range
  127423. * @param max defines the color remap maximal range
  127424. * @returns the current particle system
  127425. */
  127426. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  127427. /**
  127428. * Not supported by GPUParticleSystem
  127429. * @param gradient defines the gradient to remove
  127430. * @returns the current particle system
  127431. */
  127432. removeColorRemapGradient(): IParticleSystem;
  127433. /**
  127434. * Not supported by GPUParticleSystem
  127435. * @param gradient defines the gradient to use (between 0 and 1)
  127436. * @param min defines the alpha remap minimal range
  127437. * @param max defines the alpha remap maximal range
  127438. * @returns the current particle system
  127439. */
  127440. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  127441. /**
  127442. * Not supported by GPUParticleSystem
  127443. * @param gradient defines the gradient to remove
  127444. * @returns the current particle system
  127445. */
  127446. removeAlphaRemapGradient(): IParticleSystem;
  127447. /**
  127448. * Not supported by GPUParticleSystem
  127449. * @param gradient defines the gradient to use (between 0 and 1)
  127450. * @param color defines the color to affect to the specified gradient
  127451. * @returns the current particle system
  127452. */
  127453. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  127454. /**
  127455. * Not supported by GPUParticleSystem
  127456. * @param gradient defines the gradient to remove
  127457. * @returns the current particle system
  127458. */
  127459. removeRampGradient(): IParticleSystem;
  127460. /**
  127461. * Not supported by GPUParticleSystem
  127462. * @returns the list of ramp gradients
  127463. */
  127464. getRampGradients(): Nullable<Array<Color3Gradient>>;
  127465. /**
  127466. * Not supported by GPUParticleSystem
  127467. * Gets or sets a boolean indicating that ramp gradients must be used
  127468. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  127469. */
  127470. useRampGradients: boolean;
  127471. /**
  127472. * Not supported by GPUParticleSystem
  127473. * @param gradient defines the gradient to use (between 0 and 1)
  127474. * @param factor defines the life time factor to affect to the specified gradient
  127475. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  127476. * @returns the current particle system
  127477. */
  127478. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  127479. /**
  127480. * Not supported by GPUParticleSystem
  127481. * @param gradient defines the gradient to remove
  127482. * @returns the current particle system
  127483. */
  127484. removeLifeTimeGradient(gradient: number): IParticleSystem;
  127485. /**
  127486. * Instantiates a GPU particle system.
  127487. * 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.
  127488. * @param name The name of the particle system
  127489. * @param options The options used to create the system
  127490. * @param scene The scene the particle system belongs to
  127491. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  127492. */
  127493. constructor(name: string, options: Partial<{
  127494. capacity: number;
  127495. randomTextureSize: number;
  127496. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  127497. protected _reset(): void;
  127498. private _createUpdateVAO;
  127499. private _createRenderVAO;
  127500. private _initialize;
  127501. /** @hidden */
  127502. _recreateUpdateEffect(): void;
  127503. /** @hidden */
  127504. _recreateRenderEffect(): void;
  127505. /**
  127506. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  127507. * @param preWarm defines if we are in the pre-warmimg phase
  127508. */
  127509. animate(preWarm?: boolean): void;
  127510. private _createFactorGradientTexture;
  127511. private _createSizeGradientTexture;
  127512. private _createAngularSpeedGradientTexture;
  127513. private _createVelocityGradientTexture;
  127514. private _createLimitVelocityGradientTexture;
  127515. private _createDragGradientTexture;
  127516. private _createColorGradientTexture;
  127517. /**
  127518. * Renders the particle system in its current state
  127519. * @param preWarm defines if the system should only update the particles but not render them
  127520. * @returns the current number of particles
  127521. */
  127522. render(preWarm?: boolean): number;
  127523. /**
  127524. * Rebuilds the particle system
  127525. */
  127526. rebuild(): void;
  127527. private _releaseBuffers;
  127528. private _releaseVAOs;
  127529. /**
  127530. * Disposes the particle system and free the associated resources
  127531. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  127532. */
  127533. dispose(disposeTexture?: boolean): void;
  127534. /**
  127535. * Clones the particle system.
  127536. * @param name The name of the cloned object
  127537. * @param newEmitter The new emitter to use
  127538. * @returns the cloned particle system
  127539. */
  127540. clone(name: string, newEmitter: any): GPUParticleSystem;
  127541. /**
  127542. * Serializes the particle system to a JSON object.
  127543. * @returns the JSON object
  127544. */
  127545. serialize(): any;
  127546. /**
  127547. * Parses a JSON object to create a GPU particle system.
  127548. * @param parsedParticleSystem The JSON object to parse
  127549. * @param scene The scene to create the particle system in
  127550. * @param rootUrl The root url to use to load external dependencies like texture
  127551. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  127552. * @returns the parsed GPU particle system
  127553. */
  127554. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  127555. }
  127556. }
  127557. declare module BABYLON {
  127558. /**
  127559. * Represents a set of particle systems working together to create a specific effect
  127560. */
  127561. export class ParticleSystemSet implements IDisposable {
  127562. /**
  127563. * Gets or sets base Assets URL
  127564. */
  127565. static BaseAssetsUrl: string;
  127566. private _emitterCreationOptions;
  127567. private _emitterNode;
  127568. /**
  127569. * Gets the particle system list
  127570. */
  127571. systems: IParticleSystem[];
  127572. /**
  127573. * Gets the emitter node used with this set
  127574. */
  127575. readonly emitterNode: Nullable<TransformNode>;
  127576. /**
  127577. * Creates a new emitter mesh as a sphere
  127578. * @param options defines the options used to create the sphere
  127579. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  127580. * @param scene defines the hosting scene
  127581. */
  127582. setEmitterAsSphere(options: {
  127583. diameter: number;
  127584. segments: number;
  127585. color: Color3;
  127586. }, renderingGroupId: number, scene: Scene): void;
  127587. /**
  127588. * Starts all particle systems of the set
  127589. * @param emitter defines an optional mesh to use as emitter for the particle systems
  127590. */
  127591. start(emitter?: AbstractMesh): void;
  127592. /**
  127593. * Release all associated resources
  127594. */
  127595. dispose(): void;
  127596. /**
  127597. * Serialize the set into a JSON compatible object
  127598. * @returns a JSON compatible representation of the set
  127599. */
  127600. serialize(): any;
  127601. /**
  127602. * Parse a new ParticleSystemSet from a serialized source
  127603. * @param data defines a JSON compatible representation of the set
  127604. * @param scene defines the hosting scene
  127605. * @param gpu defines if we want GPU particles or CPU particles
  127606. * @returns a new ParticleSystemSet
  127607. */
  127608. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  127609. }
  127610. }
  127611. declare module BABYLON {
  127612. /**
  127613. * This class is made for on one-liner static method to help creating particle system set.
  127614. */
  127615. export class ParticleHelper {
  127616. /**
  127617. * Gets or sets base Assets URL
  127618. */
  127619. static BaseAssetsUrl: string;
  127620. /**
  127621. * Create a default particle system that you can tweak
  127622. * @param emitter defines the emitter to use
  127623. * @param capacity defines the system capacity (default is 500 particles)
  127624. * @param scene defines the hosting scene
  127625. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  127626. * @returns the new Particle system
  127627. */
  127628. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  127629. /**
  127630. * This is the main static method (one-liner) of this helper to create different particle systems
  127631. * @param type This string represents the type to the particle system to create
  127632. * @param scene The scene where the particle system should live
  127633. * @param gpu If the system will use gpu
  127634. * @returns the ParticleSystemSet created
  127635. */
  127636. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  127637. /**
  127638. * Static function used to export a particle system to a ParticleSystemSet variable.
  127639. * Please note that the emitter shape is not exported
  127640. * @param systems defines the particle systems to export
  127641. * @returns the created particle system set
  127642. */
  127643. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  127644. }
  127645. }
  127646. declare module BABYLON {
  127647. interface Engine {
  127648. /**
  127649. * Create an effect to use with particle systems.
  127650. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  127651. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  127652. * @param uniformsNames defines a list of attribute names
  127653. * @param samplers defines an array of string used to represent textures
  127654. * @param defines defines the string containing the defines to use to compile the shaders
  127655. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  127656. * @param onCompiled defines a function to call when the effect creation is successful
  127657. * @param onError defines a function to call when the effect creation has failed
  127658. * @returns the new Effect
  127659. */
  127660. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  127661. }
  127662. interface Mesh {
  127663. /**
  127664. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  127665. * @returns an array of IParticleSystem
  127666. */
  127667. getEmittedParticleSystems(): IParticleSystem[];
  127668. /**
  127669. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  127670. * @returns an array of IParticleSystem
  127671. */
  127672. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  127673. }
  127674. /**
  127675. * @hidden
  127676. */
  127677. export var _IDoNeedToBeInTheBuild: number;
  127678. }
  127679. declare module BABYLON {
  127680. /** Defines the 4 color options */
  127681. export enum PointColor {
  127682. /** color value */
  127683. Color = 2,
  127684. /** uv value */
  127685. UV = 1,
  127686. /** random value */
  127687. Random = 0,
  127688. /** stated value */
  127689. Stated = 3
  127690. }
  127691. /**
  127692. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  127693. * 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.
  127694. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  127695. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  127696. *
  127697. * Full documentation here : TO BE ENTERED
  127698. */
  127699. export class PointsCloudSystem implements IDisposable {
  127700. /**
  127701. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  127702. * Example : var p = SPS.particles[i];
  127703. */
  127704. particles: CloudPoint[];
  127705. /**
  127706. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  127707. */
  127708. nbParticles: number;
  127709. /**
  127710. * This a counter for your own usage. It's not set by any SPS functions.
  127711. */
  127712. counter: number;
  127713. /**
  127714. * The PCS name. This name is also given to the underlying mesh.
  127715. */
  127716. name: string;
  127717. /**
  127718. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  127719. */
  127720. mesh: Mesh;
  127721. /**
  127722. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  127723. * Please read :
  127724. */
  127725. vars: any;
  127726. /**
  127727. * @hidden
  127728. */
  127729. _size: number;
  127730. private _scene;
  127731. private _promises;
  127732. private _positions;
  127733. private _indices;
  127734. private _normals;
  127735. private _colors;
  127736. private _uvs;
  127737. private _indices32;
  127738. private _positions32;
  127739. private _colors32;
  127740. private _uvs32;
  127741. private _updatable;
  127742. private _isVisibilityBoxLocked;
  127743. private _alwaysVisible;
  127744. private _groups;
  127745. private _groupCounter;
  127746. private _computeParticleColor;
  127747. private _computeParticleTexture;
  127748. private _computeParticleRotation;
  127749. private _computeBoundingBox;
  127750. private _isReady;
  127751. /**
  127752. * Creates a PCS (Points Cloud System) object
  127753. * @param name (String) is the PCS name, this will be the underlying mesh name
  127754. * @param pointSize (number) is the size for each point
  127755. * @param scene (Scene) is the scene in which the PCS is added
  127756. * @param options defines the options of the PCS e.g.
  127757. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  127758. */
  127759. constructor(name: string, pointSize: number, scene: Scene, options?: {
  127760. updatable?: boolean;
  127761. });
  127762. /**
  127763. * Builds the PCS underlying mesh. Returns a standard Mesh.
  127764. * If no points were added to the PCS, the returned mesh is just a single point.
  127765. * @returns a promise for the created mesh
  127766. */
  127767. buildMeshAsync(): Promise<Mesh>;
  127768. /**
  127769. * @hidden
  127770. */
  127771. private _buildMesh;
  127772. private _addParticle;
  127773. private _randomUnitVector;
  127774. private _getColorIndicesForCoord;
  127775. private _setPointsColorOrUV;
  127776. private _colorFromTexture;
  127777. private _calculateDensity;
  127778. /**
  127779. * Adds points to the PCS in random positions within a unit sphere
  127780. * @param nb (positive integer) the number of particles to be created from this model
  127781. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  127782. * @returns the number of groups in the system
  127783. */
  127784. addPoints(nb: number, pointFunction?: any): number;
  127785. /**
  127786. * Adds points to the PCS from the surface of the model shape
  127787. * @param mesh is any Mesh object that will be used as a surface model for the points
  127788. * @param nb (positive integer) the number of particles to be created from this model
  127789. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127790. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127791. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127792. * @returns the number of groups in the system
  127793. */
  127794. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127795. /**
  127796. * Adds points to the PCS inside the model shape
  127797. * @param mesh is any Mesh object that will be used as a surface model for the points
  127798. * @param nb (positive integer) the number of particles to be created from this model
  127799. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  127800. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  127801. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  127802. * @returns the number of groups in the system
  127803. */
  127804. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  127805. /**
  127806. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  127807. * This method calls `updateParticle()` for each particle of the SPS.
  127808. * For an animated SPS, it is usually called within the render loop.
  127809. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  127810. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  127811. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  127812. * @returns the PCS.
  127813. */
  127814. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  127815. /**
  127816. * Disposes the PCS.
  127817. */
  127818. dispose(): void;
  127819. /**
  127820. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  127821. * doc :
  127822. * @returns the PCS.
  127823. */
  127824. refreshVisibleSize(): PointsCloudSystem;
  127825. /**
  127826. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  127827. * @param size the size (float) of the visibility box
  127828. * note : this doesn't lock the PCS mesh bounding box.
  127829. * doc :
  127830. */
  127831. setVisibilityBox(size: number): void;
  127832. /**
  127833. * Gets whether the PCS is always visible or not
  127834. * doc :
  127835. */
  127836. /**
  127837. * Sets the PCS as always visible or not
  127838. * doc :
  127839. */
  127840. isAlwaysVisible: boolean;
  127841. /**
  127842. * Tells to `setParticles()` to compute the particle rotations or not
  127843. * Default value : false. The PCS is faster when it's set to false
  127844. * Note : particle rotations are only applied to parent particles
  127845. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  127846. */
  127847. computeParticleRotation: boolean;
  127848. /**
  127849. * Tells to `setParticles()` to compute the particle colors or not.
  127850. * Default value : true. The PCS is faster when it's set to false.
  127851. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127852. */
  127853. /**
  127854. * Gets if `setParticles()` computes the particle colors or not.
  127855. * Default value : false. The PCS is faster when it's set to false.
  127856. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  127857. */
  127858. computeParticleColor: boolean;
  127859. /**
  127860. * Gets if `setParticles()` computes the particle textures or not.
  127861. * Default value : false. The PCS is faster when it's set to false.
  127862. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  127863. */
  127864. computeParticleTexture: boolean;
  127865. /**
  127866. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  127867. */
  127868. /**
  127869. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  127870. */
  127871. computeBoundingBox: boolean;
  127872. /**
  127873. * This function does nothing. It may be overwritten to set all the particle first values.
  127874. * The PCS doesn't call this function, you may have to call it by your own.
  127875. * doc :
  127876. */
  127877. initParticles(): void;
  127878. /**
  127879. * This function does nothing. It may be overwritten to recycle a particle
  127880. * The PCS doesn't call this function, you can to call it
  127881. * doc :
  127882. * @param particle The particle to recycle
  127883. * @returns the recycled particle
  127884. */
  127885. recycleParticle(particle: CloudPoint): CloudPoint;
  127886. /**
  127887. * Updates a particle : this function should be overwritten by the user.
  127888. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  127889. * doc :
  127890. * @example : just set a particle position or velocity and recycle conditions
  127891. * @param particle The particle to update
  127892. * @returns the updated particle
  127893. */
  127894. updateParticle(particle: CloudPoint): CloudPoint;
  127895. /**
  127896. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  127897. * This does nothing and may be overwritten by the user.
  127898. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127899. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127900. * @param update the boolean update value actually passed to setParticles()
  127901. */
  127902. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127903. /**
  127904. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  127905. * This will be passed three parameters.
  127906. * This does nothing and may be overwritten by the user.
  127907. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  127908. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  127909. * @param update the boolean update value actually passed to setParticles()
  127910. */
  127911. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  127912. }
  127913. }
  127914. declare module BABYLON {
  127915. /**
  127916. * Represents one particle of a points cloud system.
  127917. */
  127918. export class CloudPoint {
  127919. /**
  127920. * particle global index
  127921. */
  127922. idx: number;
  127923. /**
  127924. * The color of the particle
  127925. */
  127926. color: Nullable<Color4>;
  127927. /**
  127928. * The world space position of the particle.
  127929. */
  127930. position: Vector3;
  127931. /**
  127932. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  127933. */
  127934. rotation: Vector3;
  127935. /**
  127936. * The world space rotation quaternion of the particle.
  127937. */
  127938. rotationQuaternion: Nullable<Quaternion>;
  127939. /**
  127940. * The uv of the particle.
  127941. */
  127942. uv: Nullable<Vector2>;
  127943. /**
  127944. * The current speed of the particle.
  127945. */
  127946. velocity: Vector3;
  127947. /**
  127948. * The pivot point in the particle local space.
  127949. */
  127950. pivot: Vector3;
  127951. /**
  127952. * Must the particle be translated from its pivot point in its local space ?
  127953. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  127954. * Default : false
  127955. */
  127956. translateFromPivot: boolean;
  127957. /**
  127958. * Index of this particle in the global "positions" array (Internal use)
  127959. * @hidden
  127960. */
  127961. _pos: number;
  127962. /**
  127963. * @hidden Index of this particle in the global "indices" array (Internal use)
  127964. */
  127965. _ind: number;
  127966. /**
  127967. * Group this particle belongs to
  127968. */
  127969. _group: PointsGroup;
  127970. /**
  127971. * Group id of this particle
  127972. */
  127973. groupId: number;
  127974. /**
  127975. * Index of the particle in its group id (Internal use)
  127976. */
  127977. idxInGroup: number;
  127978. /**
  127979. * @hidden Particle BoundingInfo object (Internal use)
  127980. */
  127981. _boundingInfo: BoundingInfo;
  127982. /**
  127983. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  127984. */
  127985. _pcs: PointsCloudSystem;
  127986. /**
  127987. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  127988. */
  127989. _stillInvisible: boolean;
  127990. /**
  127991. * @hidden Last computed particle rotation matrix
  127992. */
  127993. _rotationMatrix: number[];
  127994. /**
  127995. * Parent particle Id, if any.
  127996. * Default null.
  127997. */
  127998. parentId: Nullable<number>;
  127999. /**
  128000. * @hidden Internal global position in the PCS.
  128001. */
  128002. _globalPosition: Vector3;
  128003. /**
  128004. * Creates a Point Cloud object.
  128005. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  128006. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  128007. * @param group (PointsGroup) is the group the particle belongs to
  128008. * @param groupId (integer) is the group identifier in the PCS.
  128009. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  128010. * @param pcs defines the PCS it is associated to
  128011. */
  128012. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  128013. /**
  128014. * get point size
  128015. */
  128016. /**
  128017. * Set point size
  128018. */
  128019. size: Vector3;
  128020. /**
  128021. * Legacy support, changed quaternion to rotationQuaternion
  128022. */
  128023. /**
  128024. * Legacy support, changed quaternion to rotationQuaternion
  128025. */
  128026. quaternion: Nullable<Quaternion>;
  128027. /**
  128028. * Returns a boolean. True if the particle intersects a mesh, else false
  128029. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  128030. * @param target is the object (point or mesh) what the intersection is computed against
  128031. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  128032. * @returns true if it intersects
  128033. */
  128034. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  128035. /**
  128036. * get the rotation matrix of the particle
  128037. * @hidden
  128038. */
  128039. getRotationMatrix(m: Matrix): void;
  128040. }
  128041. /**
  128042. * Represents a group of points in a points cloud system
  128043. * * PCS internal tool, don't use it manually.
  128044. */
  128045. export class PointsGroup {
  128046. /**
  128047. * The group id
  128048. * @hidden
  128049. */
  128050. groupID: number;
  128051. /**
  128052. * image data for group (internal use)
  128053. * @hidden
  128054. */
  128055. _groupImageData: Nullable<ArrayBufferView>;
  128056. /**
  128057. * Image Width (internal use)
  128058. * @hidden
  128059. */
  128060. _groupImgWidth: number;
  128061. /**
  128062. * Image Height (internal use)
  128063. * @hidden
  128064. */
  128065. _groupImgHeight: number;
  128066. /**
  128067. * Custom position function (internal use)
  128068. * @hidden
  128069. */
  128070. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  128071. /**
  128072. * density per facet for surface points
  128073. * @hidden
  128074. */
  128075. _groupDensity: number[];
  128076. /**
  128077. * Only when points are colored by texture carries pointer to texture list array
  128078. * @hidden
  128079. */
  128080. _textureNb: number;
  128081. /**
  128082. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  128083. * PCS internal tool, don't use it manually.
  128084. * @hidden
  128085. */
  128086. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  128087. }
  128088. }
  128089. declare module BABYLON {
  128090. interface Scene {
  128091. /** @hidden (Backing field) */
  128092. _physicsEngine: Nullable<IPhysicsEngine>;
  128093. /**
  128094. * Gets the current physics engine
  128095. * @returns a IPhysicsEngine or null if none attached
  128096. */
  128097. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  128098. /**
  128099. * Enables physics to the current scene
  128100. * @param gravity defines the scene's gravity for the physics engine
  128101. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  128102. * @return a boolean indicating if the physics engine was initialized
  128103. */
  128104. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  128105. /**
  128106. * Disables and disposes the physics engine associated with the scene
  128107. */
  128108. disablePhysicsEngine(): void;
  128109. /**
  128110. * Gets a boolean indicating if there is an active physics engine
  128111. * @returns a boolean indicating if there is an active physics engine
  128112. */
  128113. isPhysicsEnabled(): boolean;
  128114. /**
  128115. * Deletes a physics compound impostor
  128116. * @param compound defines the compound to delete
  128117. */
  128118. deleteCompoundImpostor(compound: any): void;
  128119. /**
  128120. * An event triggered when physic simulation is about to be run
  128121. */
  128122. onBeforePhysicsObservable: Observable<Scene>;
  128123. /**
  128124. * An event triggered when physic simulation has been done
  128125. */
  128126. onAfterPhysicsObservable: Observable<Scene>;
  128127. }
  128128. interface AbstractMesh {
  128129. /** @hidden */
  128130. _physicsImpostor: Nullable<PhysicsImpostor>;
  128131. /**
  128132. * Gets or sets impostor used for physic simulation
  128133. * @see http://doc.babylonjs.com/features/physics_engine
  128134. */
  128135. physicsImpostor: Nullable<PhysicsImpostor>;
  128136. /**
  128137. * Gets the current physics impostor
  128138. * @see http://doc.babylonjs.com/features/physics_engine
  128139. * @returns a physics impostor or null
  128140. */
  128141. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  128142. /** Apply a physic impulse to the mesh
  128143. * @param force defines the force to apply
  128144. * @param contactPoint defines where to apply the force
  128145. * @returns the current mesh
  128146. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128147. */
  128148. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  128149. /**
  128150. * Creates a physic joint between two meshes
  128151. * @param otherMesh defines the other mesh to use
  128152. * @param pivot1 defines the pivot to use on this mesh
  128153. * @param pivot2 defines the pivot to use on the other mesh
  128154. * @param options defines additional options (can be plugin dependent)
  128155. * @returns the current mesh
  128156. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  128157. */
  128158. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  128159. /** @hidden */
  128160. _disposePhysicsObserver: Nullable<Observer<Node>>;
  128161. }
  128162. /**
  128163. * Defines the physics engine scene component responsible to manage a physics engine
  128164. */
  128165. export class PhysicsEngineSceneComponent implements ISceneComponent {
  128166. /**
  128167. * The component name helpful to identify the component in the list of scene components.
  128168. */
  128169. readonly name: string;
  128170. /**
  128171. * The scene the component belongs to.
  128172. */
  128173. scene: Scene;
  128174. /**
  128175. * Creates a new instance of the component for the given scene
  128176. * @param scene Defines the scene to register the component in
  128177. */
  128178. constructor(scene: Scene);
  128179. /**
  128180. * Registers the component in a given scene
  128181. */
  128182. register(): void;
  128183. /**
  128184. * Rebuilds the elements related to this component in case of
  128185. * context lost for instance.
  128186. */
  128187. rebuild(): void;
  128188. /**
  128189. * Disposes the component and the associated ressources
  128190. */
  128191. dispose(): void;
  128192. }
  128193. }
  128194. declare module BABYLON {
  128195. /**
  128196. * A helper for physics simulations
  128197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128198. */
  128199. export class PhysicsHelper {
  128200. private _scene;
  128201. private _physicsEngine;
  128202. /**
  128203. * Initializes the Physics helper
  128204. * @param scene Babylon.js scene
  128205. */
  128206. constructor(scene: Scene);
  128207. /**
  128208. * Applies a radial explosion impulse
  128209. * @param origin the origin of the explosion
  128210. * @param radiusOrEventOptions the radius or the options of radial explosion
  128211. * @param strength the explosion strength
  128212. * @param falloff possible options: Constant & Linear. Defaults to Constant
  128213. * @returns A physics radial explosion event, or null
  128214. */
  128215. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  128216. /**
  128217. * Applies a radial explosion force
  128218. * @param origin the origin of the explosion
  128219. * @param radiusOrEventOptions the radius or the options of radial explosion
  128220. * @param strength the explosion strength
  128221. * @param falloff possible options: Constant & Linear. Defaults to Constant
  128222. * @returns A physics radial explosion event, or null
  128223. */
  128224. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  128225. /**
  128226. * Creates a gravitational field
  128227. * @param origin the origin of the explosion
  128228. * @param radiusOrEventOptions the radius or the options of radial explosion
  128229. * @param strength the explosion strength
  128230. * @param falloff possible options: Constant & Linear. Defaults to Constant
  128231. * @returns A physics gravitational field event, or null
  128232. */
  128233. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  128234. /**
  128235. * Creates a physics updraft event
  128236. * @param origin the origin of the updraft
  128237. * @param radiusOrEventOptions the radius or the options of the updraft
  128238. * @param strength the strength of the updraft
  128239. * @param height the height of the updraft
  128240. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  128241. * @returns A physics updraft event, or null
  128242. */
  128243. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  128244. /**
  128245. * Creates a physics vortex event
  128246. * @param origin the of the vortex
  128247. * @param radiusOrEventOptions the radius or the options of the vortex
  128248. * @param strength the strength of the vortex
  128249. * @param height the height of the vortex
  128250. * @returns a Physics vortex event, or null
  128251. * A physics vortex event or null
  128252. */
  128253. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  128254. }
  128255. /**
  128256. * Represents a physics radial explosion event
  128257. */
  128258. class PhysicsRadialExplosionEvent {
  128259. private _scene;
  128260. private _options;
  128261. private _sphere;
  128262. private _dataFetched;
  128263. /**
  128264. * Initializes a radial explosioin event
  128265. * @param _scene BabylonJS scene
  128266. * @param _options The options for the vortex event
  128267. */
  128268. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  128269. /**
  128270. * Returns the data related to the radial explosion event (sphere).
  128271. * @returns The radial explosion event data
  128272. */
  128273. getData(): PhysicsRadialExplosionEventData;
  128274. /**
  128275. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  128276. * @param impostor A physics imposter
  128277. * @param origin the origin of the explosion
  128278. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  128279. */
  128280. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  128281. /**
  128282. * Triggers affecterd impostors callbacks
  128283. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  128284. */
  128285. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  128286. /**
  128287. * Disposes the sphere.
  128288. * @param force Specifies if the sphere should be disposed by force
  128289. */
  128290. dispose(force?: boolean): void;
  128291. /*** Helpers ***/
  128292. private _prepareSphere;
  128293. private _intersectsWithSphere;
  128294. }
  128295. /**
  128296. * Represents a gravitational field event
  128297. */
  128298. class PhysicsGravitationalFieldEvent {
  128299. private _physicsHelper;
  128300. private _scene;
  128301. private _origin;
  128302. private _options;
  128303. private _tickCallback;
  128304. private _sphere;
  128305. private _dataFetched;
  128306. /**
  128307. * Initializes the physics gravitational field event
  128308. * @param _physicsHelper A physics helper
  128309. * @param _scene BabylonJS scene
  128310. * @param _origin The origin position of the gravitational field event
  128311. * @param _options The options for the vortex event
  128312. */
  128313. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  128314. /**
  128315. * Returns the data related to the gravitational field event (sphere).
  128316. * @returns A gravitational field event
  128317. */
  128318. getData(): PhysicsGravitationalFieldEventData;
  128319. /**
  128320. * Enables the gravitational field.
  128321. */
  128322. enable(): void;
  128323. /**
  128324. * Disables the gravitational field.
  128325. */
  128326. disable(): void;
  128327. /**
  128328. * Disposes the sphere.
  128329. * @param force The force to dispose from the gravitational field event
  128330. */
  128331. dispose(force?: boolean): void;
  128332. private _tick;
  128333. }
  128334. /**
  128335. * Represents a physics updraft event
  128336. */
  128337. class PhysicsUpdraftEvent {
  128338. private _scene;
  128339. private _origin;
  128340. private _options;
  128341. private _physicsEngine;
  128342. private _originTop;
  128343. private _originDirection;
  128344. private _tickCallback;
  128345. private _cylinder;
  128346. private _cylinderPosition;
  128347. private _dataFetched;
  128348. /**
  128349. * Initializes the physics updraft event
  128350. * @param _scene BabylonJS scene
  128351. * @param _origin The origin position of the updraft
  128352. * @param _options The options for the updraft event
  128353. */
  128354. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  128355. /**
  128356. * Returns the data related to the updraft event (cylinder).
  128357. * @returns A physics updraft event
  128358. */
  128359. getData(): PhysicsUpdraftEventData;
  128360. /**
  128361. * Enables the updraft.
  128362. */
  128363. enable(): void;
  128364. /**
  128365. * Disables the updraft.
  128366. */
  128367. disable(): void;
  128368. /**
  128369. * Disposes the cylinder.
  128370. * @param force Specifies if the updraft should be disposed by force
  128371. */
  128372. dispose(force?: boolean): void;
  128373. private getImpostorHitData;
  128374. private _tick;
  128375. /*** Helpers ***/
  128376. private _prepareCylinder;
  128377. private _intersectsWithCylinder;
  128378. }
  128379. /**
  128380. * Represents a physics vortex event
  128381. */
  128382. class PhysicsVortexEvent {
  128383. private _scene;
  128384. private _origin;
  128385. private _options;
  128386. private _physicsEngine;
  128387. private _originTop;
  128388. private _tickCallback;
  128389. private _cylinder;
  128390. private _cylinderPosition;
  128391. private _dataFetched;
  128392. /**
  128393. * Initializes the physics vortex event
  128394. * @param _scene The BabylonJS scene
  128395. * @param _origin The origin position of the vortex
  128396. * @param _options The options for the vortex event
  128397. */
  128398. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  128399. /**
  128400. * Returns the data related to the vortex event (cylinder).
  128401. * @returns The physics vortex event data
  128402. */
  128403. getData(): PhysicsVortexEventData;
  128404. /**
  128405. * Enables the vortex.
  128406. */
  128407. enable(): void;
  128408. /**
  128409. * Disables the cortex.
  128410. */
  128411. disable(): void;
  128412. /**
  128413. * Disposes the sphere.
  128414. * @param force
  128415. */
  128416. dispose(force?: boolean): void;
  128417. private getImpostorHitData;
  128418. private _tick;
  128419. /*** Helpers ***/
  128420. private _prepareCylinder;
  128421. private _intersectsWithCylinder;
  128422. }
  128423. /**
  128424. * Options fot the radial explosion event
  128425. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128426. */
  128427. export class PhysicsRadialExplosionEventOptions {
  128428. /**
  128429. * The radius of the sphere for the radial explosion.
  128430. */
  128431. radius: number;
  128432. /**
  128433. * The strenth of the explosion.
  128434. */
  128435. strength: number;
  128436. /**
  128437. * The strenght of the force in correspondence to the distance of the affected object
  128438. */
  128439. falloff: PhysicsRadialImpulseFalloff;
  128440. /**
  128441. * Sphere options for the radial explosion.
  128442. */
  128443. sphere: {
  128444. segments: number;
  128445. diameter: number;
  128446. };
  128447. /**
  128448. * Sphere options for the radial explosion.
  128449. */
  128450. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  128451. }
  128452. /**
  128453. * Options fot the updraft event
  128454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128455. */
  128456. export class PhysicsUpdraftEventOptions {
  128457. /**
  128458. * The radius of the cylinder for the vortex
  128459. */
  128460. radius: number;
  128461. /**
  128462. * The strenth of the updraft.
  128463. */
  128464. strength: number;
  128465. /**
  128466. * The height of the cylinder for the updraft.
  128467. */
  128468. height: number;
  128469. /**
  128470. * The mode for the the updraft.
  128471. */
  128472. updraftMode: PhysicsUpdraftMode;
  128473. }
  128474. /**
  128475. * Options fot the vortex event
  128476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128477. */
  128478. export class PhysicsVortexEventOptions {
  128479. /**
  128480. * The radius of the cylinder for the vortex
  128481. */
  128482. radius: number;
  128483. /**
  128484. * The strenth of the vortex.
  128485. */
  128486. strength: number;
  128487. /**
  128488. * The height of the cylinder for the vortex.
  128489. */
  128490. height: number;
  128491. /**
  128492. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  128493. */
  128494. centripetalForceThreshold: number;
  128495. /**
  128496. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  128497. */
  128498. centripetalForceMultiplier: number;
  128499. /**
  128500. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  128501. */
  128502. centrifugalForceMultiplier: number;
  128503. /**
  128504. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  128505. */
  128506. updraftForceMultiplier: number;
  128507. }
  128508. /**
  128509. * The strenght of the force in correspondence to the distance of the affected object
  128510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128511. */
  128512. export enum PhysicsRadialImpulseFalloff {
  128513. /** Defines that impulse is constant in strength across it's whole radius */
  128514. Constant = 0,
  128515. /** Defines that impulse gets weaker if it's further from the origin */
  128516. Linear = 1
  128517. }
  128518. /**
  128519. * The strength of the force in correspondence to the distance of the affected object
  128520. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128521. */
  128522. export enum PhysicsUpdraftMode {
  128523. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  128524. Center = 0,
  128525. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  128526. Perpendicular = 1
  128527. }
  128528. /**
  128529. * Interface for a physics hit data
  128530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128531. */
  128532. export interface PhysicsHitData {
  128533. /**
  128534. * The force applied at the contact point
  128535. */
  128536. force: Vector3;
  128537. /**
  128538. * The contact point
  128539. */
  128540. contactPoint: Vector3;
  128541. /**
  128542. * The distance from the origin to the contact point
  128543. */
  128544. distanceFromOrigin: number;
  128545. }
  128546. /**
  128547. * Interface for radial explosion event data
  128548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128549. */
  128550. export interface PhysicsRadialExplosionEventData {
  128551. /**
  128552. * A sphere used for the radial explosion event
  128553. */
  128554. sphere: Mesh;
  128555. }
  128556. /**
  128557. * Interface for gravitational field event data
  128558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128559. */
  128560. export interface PhysicsGravitationalFieldEventData {
  128561. /**
  128562. * A sphere mesh used for the gravitational field event
  128563. */
  128564. sphere: Mesh;
  128565. }
  128566. /**
  128567. * Interface for updraft event data
  128568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128569. */
  128570. export interface PhysicsUpdraftEventData {
  128571. /**
  128572. * A cylinder used for the updraft event
  128573. */
  128574. cylinder: Mesh;
  128575. }
  128576. /**
  128577. * Interface for vortex event data
  128578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128579. */
  128580. export interface PhysicsVortexEventData {
  128581. /**
  128582. * A cylinder used for the vortex event
  128583. */
  128584. cylinder: Mesh;
  128585. }
  128586. /**
  128587. * Interface for an affected physics impostor
  128588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  128589. */
  128590. export interface PhysicsAffectedImpostorWithData {
  128591. /**
  128592. * The impostor affected by the effect
  128593. */
  128594. impostor: PhysicsImpostor;
  128595. /**
  128596. * The data about the hit/horce from the explosion
  128597. */
  128598. hitData: PhysicsHitData;
  128599. }
  128600. }
  128601. declare module BABYLON {
  128602. /** @hidden */
  128603. export var blackAndWhitePixelShader: {
  128604. name: string;
  128605. shader: string;
  128606. };
  128607. }
  128608. declare module BABYLON {
  128609. /**
  128610. * Post process used to render in black and white
  128611. */
  128612. export class BlackAndWhitePostProcess extends PostProcess {
  128613. /**
  128614. * Linear about to convert he result to black and white (default: 1)
  128615. */
  128616. degree: number;
  128617. /**
  128618. * Creates a black and white post process
  128619. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  128620. * @param name The name of the effect.
  128621. * @param options The required width/height ratio to downsize to before computing the render pass.
  128622. * @param camera The camera to apply the render pass to.
  128623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128624. * @param engine The engine which the post process will be applied. (default: current engine)
  128625. * @param reusable If the post process can be reused on the same frame. (default: false)
  128626. */
  128627. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128628. }
  128629. }
  128630. declare module BABYLON {
  128631. /**
  128632. * This represents a set of one or more post processes in Babylon.
  128633. * A post process can be used to apply a shader to a texture after it is rendered.
  128634. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  128635. */
  128636. export class PostProcessRenderEffect {
  128637. private _postProcesses;
  128638. private _getPostProcesses;
  128639. private _singleInstance;
  128640. private _cameras;
  128641. private _indicesForCamera;
  128642. /**
  128643. * Name of the effect
  128644. * @hidden
  128645. */
  128646. _name: string;
  128647. /**
  128648. * Instantiates a post process render effect.
  128649. * A post process can be used to apply a shader to a texture after it is rendered.
  128650. * @param engine The engine the effect is tied to
  128651. * @param name The name of the effect
  128652. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  128653. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  128654. */
  128655. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  128656. /**
  128657. * Checks if all the post processes in the effect are supported.
  128658. */
  128659. readonly isSupported: boolean;
  128660. /**
  128661. * Updates the current state of the effect
  128662. * @hidden
  128663. */
  128664. _update(): void;
  128665. /**
  128666. * Attaches the effect on cameras
  128667. * @param cameras The camera to attach to.
  128668. * @hidden
  128669. */
  128670. _attachCameras(cameras: Camera): void;
  128671. /**
  128672. * Attaches the effect on cameras
  128673. * @param cameras The camera to attach to.
  128674. * @hidden
  128675. */
  128676. _attachCameras(cameras: Camera[]): void;
  128677. /**
  128678. * Detaches the effect on cameras
  128679. * @param cameras The camera to detatch from.
  128680. * @hidden
  128681. */
  128682. _detachCameras(cameras: Camera): void;
  128683. /**
  128684. * Detatches the effect on cameras
  128685. * @param cameras The camera to detatch from.
  128686. * @hidden
  128687. */
  128688. _detachCameras(cameras: Camera[]): void;
  128689. /**
  128690. * Enables the effect on given cameras
  128691. * @param cameras The camera to enable.
  128692. * @hidden
  128693. */
  128694. _enable(cameras: Camera): void;
  128695. /**
  128696. * Enables the effect on given cameras
  128697. * @param cameras The camera to enable.
  128698. * @hidden
  128699. */
  128700. _enable(cameras: Nullable<Camera[]>): void;
  128701. /**
  128702. * Disables the effect on the given cameras
  128703. * @param cameras The camera to disable.
  128704. * @hidden
  128705. */
  128706. _disable(cameras: Camera): void;
  128707. /**
  128708. * Disables the effect on the given cameras
  128709. * @param cameras The camera to disable.
  128710. * @hidden
  128711. */
  128712. _disable(cameras: Nullable<Camera[]>): void;
  128713. /**
  128714. * Gets a list of the post processes contained in the effect.
  128715. * @param camera The camera to get the post processes on.
  128716. * @returns The list of the post processes in the effect.
  128717. */
  128718. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  128719. }
  128720. }
  128721. declare module BABYLON {
  128722. /** @hidden */
  128723. export var extractHighlightsPixelShader: {
  128724. name: string;
  128725. shader: string;
  128726. };
  128727. }
  128728. declare module BABYLON {
  128729. /**
  128730. * 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.
  128731. */
  128732. export class ExtractHighlightsPostProcess extends PostProcess {
  128733. /**
  128734. * The luminance threshold, pixels below this value will be set to black.
  128735. */
  128736. threshold: number;
  128737. /** @hidden */
  128738. _exposure: number;
  128739. /**
  128740. * Post process which has the input texture to be used when performing highlight extraction
  128741. * @hidden
  128742. */
  128743. _inputPostProcess: Nullable<PostProcess>;
  128744. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128745. }
  128746. }
  128747. declare module BABYLON {
  128748. /** @hidden */
  128749. export var bloomMergePixelShader: {
  128750. name: string;
  128751. shader: string;
  128752. };
  128753. }
  128754. declare module BABYLON {
  128755. /**
  128756. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  128757. */
  128758. export class BloomMergePostProcess extends PostProcess {
  128759. /** Weight of the bloom to be added to the original input. */
  128760. weight: number;
  128761. /**
  128762. * Creates a new instance of @see BloomMergePostProcess
  128763. * @param name The name of the effect.
  128764. * @param originalFromInput Post process which's input will be used for the merge.
  128765. * @param blurred Blurred highlights post process which's output will be used.
  128766. * @param weight Weight of the bloom to be added to the original input.
  128767. * @param options The required width/height ratio to downsize to before computing the render pass.
  128768. * @param camera The camera to apply the render pass to.
  128769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128770. * @param engine The engine which the post process will be applied. (default: current engine)
  128771. * @param reusable If the post process can be reused on the same frame. (default: false)
  128772. * @param textureType Type of textures used when performing the post process. (default: 0)
  128773. * @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)
  128774. */
  128775. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  128776. /** Weight of the bloom to be added to the original input. */
  128777. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128778. }
  128779. }
  128780. declare module BABYLON {
  128781. /**
  128782. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  128783. */
  128784. export class BloomEffect extends PostProcessRenderEffect {
  128785. private bloomScale;
  128786. /**
  128787. * @hidden Internal
  128788. */
  128789. _effects: Array<PostProcess>;
  128790. /**
  128791. * @hidden Internal
  128792. */
  128793. _downscale: ExtractHighlightsPostProcess;
  128794. private _blurX;
  128795. private _blurY;
  128796. private _merge;
  128797. /**
  128798. * The luminance threshold to find bright areas of the image to bloom.
  128799. */
  128800. threshold: number;
  128801. /**
  128802. * The strength of the bloom.
  128803. */
  128804. weight: number;
  128805. /**
  128806. * Specifies the size of the bloom blur kernel, relative to the final output size
  128807. */
  128808. kernel: number;
  128809. /**
  128810. * Creates a new instance of @see BloomEffect
  128811. * @param scene The scene the effect belongs to.
  128812. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  128813. * @param bloomKernel The size of the kernel to be used when applying the blur.
  128814. * @param bloomWeight The the strength of bloom.
  128815. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  128816. * @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)
  128817. */
  128818. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  128819. /**
  128820. * Disposes each of the internal effects for a given camera.
  128821. * @param camera The camera to dispose the effect on.
  128822. */
  128823. disposeEffects(camera: Camera): void;
  128824. /**
  128825. * @hidden Internal
  128826. */
  128827. _updateEffects(): void;
  128828. /**
  128829. * Internal
  128830. * @returns if all the contained post processes are ready.
  128831. * @hidden
  128832. */
  128833. _isReady(): boolean;
  128834. }
  128835. }
  128836. declare module BABYLON {
  128837. /** @hidden */
  128838. export var chromaticAberrationPixelShader: {
  128839. name: string;
  128840. shader: string;
  128841. };
  128842. }
  128843. declare module BABYLON {
  128844. /**
  128845. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  128846. */
  128847. export class ChromaticAberrationPostProcess extends PostProcess {
  128848. /**
  128849. * The amount of seperation of rgb channels (default: 30)
  128850. */
  128851. aberrationAmount: number;
  128852. /**
  128853. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  128854. */
  128855. radialIntensity: number;
  128856. /**
  128857. * 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))
  128858. */
  128859. direction: Vector2;
  128860. /**
  128861. * 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))
  128862. */
  128863. centerPosition: Vector2;
  128864. /**
  128865. * Creates a new instance ChromaticAberrationPostProcess
  128866. * @param name The name of the effect.
  128867. * @param screenWidth The width of the screen to apply the effect on.
  128868. * @param screenHeight The height of the screen to apply the effect on.
  128869. * @param options The required width/height ratio to downsize to before computing the render pass.
  128870. * @param camera The camera to apply the render pass to.
  128871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128872. * @param engine The engine which the post process will be applied. (default: current engine)
  128873. * @param reusable If the post process can be reused on the same frame. (default: false)
  128874. * @param textureType Type of textures used when performing the post process. (default: 0)
  128875. * @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)
  128876. */
  128877. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128878. }
  128879. }
  128880. declare module BABYLON {
  128881. /** @hidden */
  128882. export var circleOfConfusionPixelShader: {
  128883. name: string;
  128884. shader: string;
  128885. };
  128886. }
  128887. declare module BABYLON {
  128888. /**
  128889. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  128890. */
  128891. export class CircleOfConfusionPostProcess extends PostProcess {
  128892. /**
  128893. * 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.
  128894. */
  128895. lensSize: number;
  128896. /**
  128897. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  128898. */
  128899. fStop: number;
  128900. /**
  128901. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  128902. */
  128903. focusDistance: number;
  128904. /**
  128905. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  128906. */
  128907. focalLength: number;
  128908. private _depthTexture;
  128909. /**
  128910. * Creates a new instance CircleOfConfusionPostProcess
  128911. * @param name The name of the effect.
  128912. * @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.
  128913. * @param options The required width/height ratio to downsize to before computing the render pass.
  128914. * @param camera The camera to apply the render pass to.
  128915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128916. * @param engine The engine which the post process will be applied. (default: current engine)
  128917. * @param reusable If the post process can be reused on the same frame. (default: false)
  128918. * @param textureType Type of textures used when performing the post process. (default: 0)
  128919. * @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)
  128920. */
  128921. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  128922. /**
  128923. * 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.
  128924. */
  128925. depthTexture: RenderTargetTexture;
  128926. }
  128927. }
  128928. declare module BABYLON {
  128929. /** @hidden */
  128930. export var colorCorrectionPixelShader: {
  128931. name: string;
  128932. shader: string;
  128933. };
  128934. }
  128935. declare module BABYLON {
  128936. /**
  128937. *
  128938. * This post-process allows the modification of rendered colors by using
  128939. * a 'look-up table' (LUT). This effect is also called Color Grading.
  128940. *
  128941. * The object needs to be provided an url to a texture containing the color
  128942. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  128943. * Use an image editing software to tweak the LUT to match your needs.
  128944. *
  128945. * For an example of a color LUT, see here:
  128946. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  128947. * For explanations on color grading, see here:
  128948. * @see http://udn.epicgames.com/Three/ColorGrading.html
  128949. *
  128950. */
  128951. export class ColorCorrectionPostProcess extends PostProcess {
  128952. private _colorTableTexture;
  128953. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  128954. }
  128955. }
  128956. declare module BABYLON {
  128957. /** @hidden */
  128958. export var convolutionPixelShader: {
  128959. name: string;
  128960. shader: string;
  128961. };
  128962. }
  128963. declare module BABYLON {
  128964. /**
  128965. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  128966. * input texture to perform effects such as edge detection or sharpening
  128967. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  128968. */
  128969. export class ConvolutionPostProcess extends PostProcess {
  128970. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128971. kernel: number[];
  128972. /**
  128973. * Creates a new instance ConvolutionPostProcess
  128974. * @param name The name of the effect.
  128975. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  128976. * @param options The required width/height ratio to downsize to before computing the render pass.
  128977. * @param camera The camera to apply the render pass to.
  128978. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  128979. * @param engine The engine which the post process will be applied. (default: current engine)
  128980. * @param reusable If the post process can be reused on the same frame. (default: false)
  128981. * @param textureType Type of textures used when performing the post process. (default: 0)
  128982. */
  128983. constructor(name: string,
  128984. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  128985. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  128986. /**
  128987. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128988. */
  128989. static EdgeDetect0Kernel: number[];
  128990. /**
  128991. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128992. */
  128993. static EdgeDetect1Kernel: number[];
  128994. /**
  128995. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  128996. */
  128997. static EdgeDetect2Kernel: number[];
  128998. /**
  128999. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129000. */
  129001. static SharpenKernel: number[];
  129002. /**
  129003. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129004. */
  129005. static EmbossKernel: number[];
  129006. /**
  129007. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  129008. */
  129009. static GaussianKernel: number[];
  129010. }
  129011. }
  129012. declare module BABYLON {
  129013. /**
  129014. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  129015. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  129016. * based on samples that have a large difference in distance than the center pixel.
  129017. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  129018. */
  129019. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  129020. direction: Vector2;
  129021. /**
  129022. * Creates a new instance CircleOfConfusionPostProcess
  129023. * @param name The name of the effect.
  129024. * @param scene The scene the effect belongs to.
  129025. * @param direction The direction the blur should be applied.
  129026. * @param kernel The size of the kernel used to blur.
  129027. * @param options The required width/height ratio to downsize to before computing the render pass.
  129028. * @param camera The camera to apply the render pass to.
  129029. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  129030. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  129031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129032. * @param engine The engine which the post process will be applied. (default: current engine)
  129033. * @param reusable If the post process can be reused on the same frame. (default: false)
  129034. * @param textureType Type of textures used when performing the post process. (default: 0)
  129035. * @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)
  129036. */
  129037. 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);
  129038. }
  129039. }
  129040. declare module BABYLON {
  129041. /** @hidden */
  129042. export var depthOfFieldMergePixelShader: {
  129043. name: string;
  129044. shader: string;
  129045. };
  129046. }
  129047. declare module BABYLON {
  129048. /**
  129049. * Options to be set when merging outputs from the default pipeline.
  129050. */
  129051. export class DepthOfFieldMergePostProcessOptions {
  129052. /**
  129053. * The original image to merge on top of
  129054. */
  129055. originalFromInput: PostProcess;
  129056. /**
  129057. * Parameters to perform the merge of the depth of field effect
  129058. */
  129059. depthOfField?: {
  129060. circleOfConfusion: PostProcess;
  129061. blurSteps: Array<PostProcess>;
  129062. };
  129063. /**
  129064. * Parameters to perform the merge of bloom effect
  129065. */
  129066. bloom?: {
  129067. blurred: PostProcess;
  129068. weight: number;
  129069. };
  129070. }
  129071. /**
  129072. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  129073. */
  129074. export class DepthOfFieldMergePostProcess extends PostProcess {
  129075. private blurSteps;
  129076. /**
  129077. * Creates a new instance of DepthOfFieldMergePostProcess
  129078. * @param name The name of the effect.
  129079. * @param originalFromInput Post process which's input will be used for the merge.
  129080. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  129081. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  129082. * @param options The required width/height ratio to downsize to before computing the render pass.
  129083. * @param camera The camera to apply the render pass to.
  129084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129085. * @param engine The engine which the post process will be applied. (default: current engine)
  129086. * @param reusable If the post process can be reused on the same frame. (default: false)
  129087. * @param textureType Type of textures used when performing the post process. (default: 0)
  129088. * @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)
  129089. */
  129090. 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);
  129091. /**
  129092. * Updates the effect with the current post process compile time values and recompiles the shader.
  129093. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  129094. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  129095. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  129096. * @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
  129097. * @param onCompiled Called when the shader has been compiled.
  129098. * @param onError Called if there is an error when compiling a shader.
  129099. */
  129100. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  129101. }
  129102. }
  129103. declare module BABYLON {
  129104. /**
  129105. * Specifies the level of max blur that should be applied when using the depth of field effect
  129106. */
  129107. export enum DepthOfFieldEffectBlurLevel {
  129108. /**
  129109. * Subtle blur
  129110. */
  129111. Low = 0,
  129112. /**
  129113. * Medium blur
  129114. */
  129115. Medium = 1,
  129116. /**
  129117. * Large blur
  129118. */
  129119. High = 2
  129120. }
  129121. /**
  129122. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  129123. */
  129124. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  129125. private _circleOfConfusion;
  129126. /**
  129127. * @hidden Internal, blurs from high to low
  129128. */
  129129. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  129130. private _depthOfFieldBlurY;
  129131. private _dofMerge;
  129132. /**
  129133. * @hidden Internal post processes in depth of field effect
  129134. */
  129135. _effects: Array<PostProcess>;
  129136. /**
  129137. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  129138. */
  129139. focalLength: number;
  129140. /**
  129141. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  129142. */
  129143. fStop: number;
  129144. /**
  129145. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  129146. */
  129147. focusDistance: number;
  129148. /**
  129149. * 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.
  129150. */
  129151. lensSize: number;
  129152. /**
  129153. * Creates a new instance DepthOfFieldEffect
  129154. * @param scene The scene the effect belongs to.
  129155. * @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.
  129156. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  129157. * @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)
  129158. */
  129159. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  129160. /**
  129161. * Get the current class name of the current effet
  129162. * @returns "DepthOfFieldEffect"
  129163. */
  129164. getClassName(): string;
  129165. /**
  129166. * 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.
  129167. */
  129168. depthTexture: RenderTargetTexture;
  129169. /**
  129170. * Disposes each of the internal effects for a given camera.
  129171. * @param camera The camera to dispose the effect on.
  129172. */
  129173. disposeEffects(camera: Camera): void;
  129174. /**
  129175. * @hidden Internal
  129176. */
  129177. _updateEffects(): void;
  129178. /**
  129179. * Internal
  129180. * @returns if all the contained post processes are ready.
  129181. * @hidden
  129182. */
  129183. _isReady(): boolean;
  129184. }
  129185. }
  129186. declare module BABYLON {
  129187. /** @hidden */
  129188. export var displayPassPixelShader: {
  129189. name: string;
  129190. shader: string;
  129191. };
  129192. }
  129193. declare module BABYLON {
  129194. /**
  129195. * DisplayPassPostProcess which produces an output the same as it's input
  129196. */
  129197. export class DisplayPassPostProcess extends PostProcess {
  129198. /**
  129199. * Creates the DisplayPassPostProcess
  129200. * @param name The name of the effect.
  129201. * @param options The required width/height ratio to downsize to before computing the render pass.
  129202. * @param camera The camera to apply the render pass to.
  129203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129204. * @param engine The engine which the post process will be applied. (default: current engine)
  129205. * @param reusable If the post process can be reused on the same frame. (default: false)
  129206. */
  129207. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129208. }
  129209. }
  129210. declare module BABYLON {
  129211. /** @hidden */
  129212. export var filterPixelShader: {
  129213. name: string;
  129214. shader: string;
  129215. };
  129216. }
  129217. declare module BABYLON {
  129218. /**
  129219. * Applies a kernel filter to the image
  129220. */
  129221. export class FilterPostProcess extends PostProcess {
  129222. /** The matrix to be applied to the image */
  129223. kernelMatrix: Matrix;
  129224. /**
  129225. *
  129226. * @param name The name of the effect.
  129227. * @param kernelMatrix The matrix to be applied to the image
  129228. * @param options The required width/height ratio to downsize to before computing the render pass.
  129229. * @param camera The camera to apply the render pass to.
  129230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129231. * @param engine The engine which the post process will be applied. (default: current engine)
  129232. * @param reusable If the post process can be reused on the same frame. (default: false)
  129233. */
  129234. constructor(name: string,
  129235. /** The matrix to be applied to the image */
  129236. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129237. }
  129238. }
  129239. declare module BABYLON {
  129240. /** @hidden */
  129241. export var fxaaPixelShader: {
  129242. name: string;
  129243. shader: string;
  129244. };
  129245. }
  129246. declare module BABYLON {
  129247. /** @hidden */
  129248. export var fxaaVertexShader: {
  129249. name: string;
  129250. shader: string;
  129251. };
  129252. }
  129253. declare module BABYLON {
  129254. /**
  129255. * Fxaa post process
  129256. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  129257. */
  129258. export class FxaaPostProcess extends PostProcess {
  129259. /** @hidden */
  129260. texelWidth: number;
  129261. /** @hidden */
  129262. texelHeight: number;
  129263. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129264. private _getDefines;
  129265. }
  129266. }
  129267. declare module BABYLON {
  129268. /** @hidden */
  129269. export var grainPixelShader: {
  129270. name: string;
  129271. shader: string;
  129272. };
  129273. }
  129274. declare module BABYLON {
  129275. /**
  129276. * The GrainPostProcess adds noise to the image at mid luminance levels
  129277. */
  129278. export class GrainPostProcess extends PostProcess {
  129279. /**
  129280. * The intensity of the grain added (default: 30)
  129281. */
  129282. intensity: number;
  129283. /**
  129284. * If the grain should be randomized on every frame
  129285. */
  129286. animated: boolean;
  129287. /**
  129288. * Creates a new instance of @see GrainPostProcess
  129289. * @param name The name of the effect.
  129290. * @param options The required width/height ratio to downsize to before computing the render pass.
  129291. * @param camera The camera to apply the render pass to.
  129292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129293. * @param engine The engine which the post process will be applied. (default: current engine)
  129294. * @param reusable If the post process can be reused on the same frame. (default: false)
  129295. * @param textureType Type of textures used when performing the post process. (default: 0)
  129296. * @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)
  129297. */
  129298. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129299. }
  129300. }
  129301. declare module BABYLON {
  129302. /** @hidden */
  129303. export var highlightsPixelShader: {
  129304. name: string;
  129305. shader: string;
  129306. };
  129307. }
  129308. declare module BABYLON {
  129309. /**
  129310. * Extracts highlights from the image
  129311. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  129312. */
  129313. export class HighlightsPostProcess extends PostProcess {
  129314. /**
  129315. * Extracts highlights from the image
  129316. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  129317. * @param name The name of the effect.
  129318. * @param options The required width/height ratio to downsize to before computing the render pass.
  129319. * @param camera The camera to apply the render pass to.
  129320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129321. * @param engine The engine which the post process will be applied. (default: current engine)
  129322. * @param reusable If the post process can be reused on the same frame. (default: false)
  129323. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  129324. */
  129325. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  129326. }
  129327. }
  129328. declare module BABYLON {
  129329. /** @hidden */
  129330. export var mrtFragmentDeclaration: {
  129331. name: string;
  129332. shader: string;
  129333. };
  129334. }
  129335. declare module BABYLON {
  129336. /** @hidden */
  129337. export var geometryPixelShader: {
  129338. name: string;
  129339. shader: string;
  129340. };
  129341. }
  129342. declare module BABYLON {
  129343. /** @hidden */
  129344. export var geometryVertexShader: {
  129345. name: string;
  129346. shader: string;
  129347. };
  129348. }
  129349. declare module BABYLON {
  129350. /** @hidden */
  129351. interface ISavedTransformationMatrix {
  129352. world: Matrix;
  129353. viewProjection: Matrix;
  129354. }
  129355. /**
  129356. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  129357. */
  129358. export class GeometryBufferRenderer {
  129359. /**
  129360. * Constant used to retrieve the position texture index in the G-Buffer textures array
  129361. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  129362. */
  129363. static readonly POSITION_TEXTURE_TYPE: number;
  129364. /**
  129365. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  129366. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  129367. */
  129368. static readonly VELOCITY_TEXTURE_TYPE: number;
  129369. /**
  129370. * Dictionary used to store the previous transformation matrices of each rendered mesh
  129371. * in order to compute objects velocities when enableVelocity is set to "true"
  129372. * @hidden
  129373. */
  129374. _previousTransformationMatrices: {
  129375. [index: number]: ISavedTransformationMatrix;
  129376. };
  129377. /**
  129378. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  129379. * in order to compute objects velocities when enableVelocity is set to "true"
  129380. * @hidden
  129381. */
  129382. _previousBonesTransformationMatrices: {
  129383. [index: number]: Float32Array;
  129384. };
  129385. /**
  129386. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  129387. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  129388. */
  129389. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  129390. private _scene;
  129391. private _multiRenderTarget;
  129392. private _ratio;
  129393. private _enablePosition;
  129394. private _enableVelocity;
  129395. private _positionIndex;
  129396. private _velocityIndex;
  129397. protected _effect: Effect;
  129398. protected _cachedDefines: string;
  129399. /**
  129400. * Set the render list (meshes to be rendered) used in the G buffer.
  129401. */
  129402. renderList: Mesh[];
  129403. /**
  129404. * Gets wether or not G buffer are supported by the running hardware.
  129405. * This requires draw buffer supports
  129406. */
  129407. readonly isSupported: boolean;
  129408. /**
  129409. * Returns the index of the given texture type in the G-Buffer textures array
  129410. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  129411. * @returns the index of the given texture type in the G-Buffer textures array
  129412. */
  129413. getTextureIndex(textureType: number): number;
  129414. /**
  129415. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  129416. */
  129417. /**
  129418. * Sets whether or not objects positions are enabled for the G buffer.
  129419. */
  129420. enablePosition: boolean;
  129421. /**
  129422. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  129423. */
  129424. /**
  129425. * Sets wether or not objects velocities are enabled for the G buffer.
  129426. */
  129427. enableVelocity: boolean;
  129428. /**
  129429. * Gets the scene associated with the buffer.
  129430. */
  129431. readonly scene: Scene;
  129432. /**
  129433. * Gets the ratio used by the buffer during its creation.
  129434. * How big is the buffer related to the main canvas.
  129435. */
  129436. readonly ratio: number;
  129437. /** @hidden */
  129438. static _SceneComponentInitialization: (scene: Scene) => void;
  129439. /**
  129440. * Creates a new G Buffer for the scene
  129441. * @param scene The scene the buffer belongs to
  129442. * @param ratio How big is the buffer related to the main canvas.
  129443. */
  129444. constructor(scene: Scene, ratio?: number);
  129445. /**
  129446. * Checks wether everything is ready to render a submesh to the G buffer.
  129447. * @param subMesh the submesh to check readiness for
  129448. * @param useInstances is the mesh drawn using instance or not
  129449. * @returns true if ready otherwise false
  129450. */
  129451. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  129452. /**
  129453. * Gets the current underlying G Buffer.
  129454. * @returns the buffer
  129455. */
  129456. getGBuffer(): MultiRenderTarget;
  129457. /**
  129458. * Gets the number of samples used to render the buffer (anti aliasing).
  129459. */
  129460. /**
  129461. * Sets the number of samples used to render the buffer (anti aliasing).
  129462. */
  129463. samples: number;
  129464. /**
  129465. * Disposes the renderer and frees up associated resources.
  129466. */
  129467. dispose(): void;
  129468. protected _createRenderTargets(): void;
  129469. private _copyBonesTransformationMatrices;
  129470. }
  129471. }
  129472. declare module BABYLON {
  129473. interface Scene {
  129474. /** @hidden (Backing field) */
  129475. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129476. /**
  129477. * Gets or Sets the current geometry buffer associated to the scene.
  129478. */
  129479. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  129480. /**
  129481. * Enables a GeometryBufferRender and associates it with the scene
  129482. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  129483. * @returns the GeometryBufferRenderer
  129484. */
  129485. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  129486. /**
  129487. * Disables the GeometryBufferRender associated with the scene
  129488. */
  129489. disableGeometryBufferRenderer(): void;
  129490. }
  129491. /**
  129492. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  129493. * in several rendering techniques.
  129494. */
  129495. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  129496. /**
  129497. * The component name helpful to identify the component in the list of scene components.
  129498. */
  129499. readonly name: string;
  129500. /**
  129501. * The scene the component belongs to.
  129502. */
  129503. scene: Scene;
  129504. /**
  129505. * Creates a new instance of the component for the given scene
  129506. * @param scene Defines the scene to register the component in
  129507. */
  129508. constructor(scene: Scene);
  129509. /**
  129510. * Registers the component in a given scene
  129511. */
  129512. register(): void;
  129513. /**
  129514. * Rebuilds the elements related to this component in case of
  129515. * context lost for instance.
  129516. */
  129517. rebuild(): void;
  129518. /**
  129519. * Disposes the component and the associated ressources
  129520. */
  129521. dispose(): void;
  129522. private _gatherRenderTargets;
  129523. }
  129524. }
  129525. declare module BABYLON {
  129526. /** @hidden */
  129527. export var motionBlurPixelShader: {
  129528. name: string;
  129529. shader: string;
  129530. };
  129531. }
  129532. declare module BABYLON {
  129533. /**
  129534. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  129535. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  129536. * As an example, all you have to do is to create the post-process:
  129537. * var mb = new BABYLON.MotionBlurPostProcess(
  129538. * 'mb', // The name of the effect.
  129539. * scene, // The scene containing the objects to blur according to their velocity.
  129540. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  129541. * camera // The camera to apply the render pass to.
  129542. * );
  129543. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  129544. */
  129545. export class MotionBlurPostProcess extends PostProcess {
  129546. /**
  129547. * Defines how much the image is blurred by the movement. Default value is equal to 1
  129548. */
  129549. motionStrength: number;
  129550. /**
  129551. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  129552. */
  129553. /**
  129554. * Sets the number of iterations to be used for motion blur quality
  129555. */
  129556. motionBlurSamples: number;
  129557. private _motionBlurSamples;
  129558. private _geometryBufferRenderer;
  129559. /**
  129560. * Creates a new instance MotionBlurPostProcess
  129561. * @param name The name of the effect.
  129562. * @param scene The scene containing the objects to blur according to their velocity.
  129563. * @param options The required width/height ratio to downsize to before computing the render pass.
  129564. * @param camera The camera to apply the render pass to.
  129565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129566. * @param engine The engine which the post process will be applied. (default: current engine)
  129567. * @param reusable If the post process can be reused on the same frame. (default: false)
  129568. * @param textureType Type of textures used when performing the post process. (default: 0)
  129569. * @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)
  129570. */
  129571. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129572. /**
  129573. * Excludes the given skinned mesh from computing bones velocities.
  129574. * 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.
  129575. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  129576. */
  129577. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129578. /**
  129579. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  129580. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  129581. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  129582. */
  129583. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  129584. /**
  129585. * Disposes the post process.
  129586. * @param camera The camera to dispose the post process on.
  129587. */
  129588. dispose(camera?: Camera): void;
  129589. }
  129590. }
  129591. declare module BABYLON {
  129592. /** @hidden */
  129593. export var refractionPixelShader: {
  129594. name: string;
  129595. shader: string;
  129596. };
  129597. }
  129598. declare module BABYLON {
  129599. /**
  129600. * Post process which applies a refractin texture
  129601. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129602. */
  129603. export class RefractionPostProcess extends PostProcess {
  129604. /** the base color of the refraction (used to taint the rendering) */
  129605. color: Color3;
  129606. /** simulated refraction depth */
  129607. depth: number;
  129608. /** the coefficient of the base color (0 to remove base color tainting) */
  129609. colorLevel: number;
  129610. private _refTexture;
  129611. private _ownRefractionTexture;
  129612. /**
  129613. * Gets or sets the refraction texture
  129614. * Please note that you are responsible for disposing the texture if you set it manually
  129615. */
  129616. refractionTexture: Texture;
  129617. /**
  129618. * Initializes the RefractionPostProcess
  129619. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  129620. * @param name The name of the effect.
  129621. * @param refractionTextureUrl Url of the refraction texture to use
  129622. * @param color the base color of the refraction (used to taint the rendering)
  129623. * @param depth simulated refraction depth
  129624. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  129625. * @param camera The camera to apply the render pass to.
  129626. * @param options The required width/height ratio to downsize to before computing the render pass.
  129627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129628. * @param engine The engine which the post process will be applied. (default: current engine)
  129629. * @param reusable If the post process can be reused on the same frame. (default: false)
  129630. */
  129631. constructor(name: string, refractionTextureUrl: string,
  129632. /** the base color of the refraction (used to taint the rendering) */
  129633. color: Color3,
  129634. /** simulated refraction depth */
  129635. depth: number,
  129636. /** the coefficient of the base color (0 to remove base color tainting) */
  129637. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  129638. /**
  129639. * Disposes of the post process
  129640. * @param camera Camera to dispose post process on
  129641. */
  129642. dispose(camera: Camera): void;
  129643. }
  129644. }
  129645. declare module BABYLON {
  129646. /** @hidden */
  129647. export var sharpenPixelShader: {
  129648. name: string;
  129649. shader: string;
  129650. };
  129651. }
  129652. declare module BABYLON {
  129653. /**
  129654. * The SharpenPostProcess applies a sharpen kernel to every pixel
  129655. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  129656. */
  129657. export class SharpenPostProcess extends PostProcess {
  129658. /**
  129659. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  129660. */
  129661. colorAmount: number;
  129662. /**
  129663. * How much sharpness should be applied (default: 0.3)
  129664. */
  129665. edgeAmount: number;
  129666. /**
  129667. * Creates a new instance ConvolutionPostProcess
  129668. * @param name The name of the effect.
  129669. * @param options The required width/height ratio to downsize to before computing the render pass.
  129670. * @param camera The camera to apply the render pass to.
  129671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  129672. * @param engine The engine which the post process will be applied. (default: current engine)
  129673. * @param reusable If the post process can be reused on the same frame. (default: false)
  129674. * @param textureType Type of textures used when performing the post process. (default: 0)
  129675. * @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)
  129676. */
  129677. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  129678. }
  129679. }
  129680. declare module BABYLON {
  129681. /**
  129682. * PostProcessRenderPipeline
  129683. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129684. */
  129685. export class PostProcessRenderPipeline {
  129686. private engine;
  129687. private _renderEffects;
  129688. private _renderEffectsForIsolatedPass;
  129689. /**
  129690. * List of inspectable custom properties (used by the Inspector)
  129691. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  129692. */
  129693. inspectableCustomProperties: IInspectable[];
  129694. /**
  129695. * @hidden
  129696. */
  129697. protected _cameras: Camera[];
  129698. /** @hidden */
  129699. _name: string;
  129700. /**
  129701. * Gets pipeline name
  129702. */
  129703. readonly name: string;
  129704. /** Gets the list of attached cameras */
  129705. readonly cameras: Camera[];
  129706. /**
  129707. * Initializes a PostProcessRenderPipeline
  129708. * @param engine engine to add the pipeline to
  129709. * @param name name of the pipeline
  129710. */
  129711. constructor(engine: Engine, name: string);
  129712. /**
  129713. * Gets the class name
  129714. * @returns "PostProcessRenderPipeline"
  129715. */
  129716. getClassName(): string;
  129717. /**
  129718. * If all the render effects in the pipeline are supported
  129719. */
  129720. readonly isSupported: boolean;
  129721. /**
  129722. * Adds an effect to the pipeline
  129723. * @param renderEffect the effect to add
  129724. */
  129725. addEffect(renderEffect: PostProcessRenderEffect): void;
  129726. /** @hidden */
  129727. _rebuild(): void;
  129728. /** @hidden */
  129729. _enableEffect(renderEffectName: string, cameras: Camera): void;
  129730. /** @hidden */
  129731. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  129732. /** @hidden */
  129733. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129734. /** @hidden */
  129735. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  129736. /** @hidden */
  129737. _attachCameras(cameras: Camera, unique: boolean): void;
  129738. /** @hidden */
  129739. _attachCameras(cameras: Camera[], unique: boolean): void;
  129740. /** @hidden */
  129741. _detachCameras(cameras: Camera): void;
  129742. /** @hidden */
  129743. _detachCameras(cameras: Nullable<Camera[]>): void;
  129744. /** @hidden */
  129745. _update(): void;
  129746. /** @hidden */
  129747. _reset(): void;
  129748. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  129749. /**
  129750. * Disposes of the pipeline
  129751. */
  129752. dispose(): void;
  129753. }
  129754. }
  129755. declare module BABYLON {
  129756. /**
  129757. * PostProcessRenderPipelineManager class
  129758. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129759. */
  129760. export class PostProcessRenderPipelineManager {
  129761. private _renderPipelines;
  129762. /**
  129763. * Initializes a PostProcessRenderPipelineManager
  129764. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129765. */
  129766. constructor();
  129767. /**
  129768. * Gets the list of supported render pipelines
  129769. */
  129770. readonly supportedPipelines: PostProcessRenderPipeline[];
  129771. /**
  129772. * Adds a pipeline to the manager
  129773. * @param renderPipeline The pipeline to add
  129774. */
  129775. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  129776. /**
  129777. * Attaches a camera to the pipeline
  129778. * @param renderPipelineName The name of the pipeline to attach to
  129779. * @param cameras the camera to attach
  129780. * @param unique if the camera can be attached multiple times to the pipeline
  129781. */
  129782. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  129783. /**
  129784. * Detaches a camera from the pipeline
  129785. * @param renderPipelineName The name of the pipeline to detach from
  129786. * @param cameras the camera to detach
  129787. */
  129788. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  129789. /**
  129790. * Enables an effect by name on a pipeline
  129791. * @param renderPipelineName the name of the pipeline to enable the effect in
  129792. * @param renderEffectName the name of the effect to enable
  129793. * @param cameras the cameras that the effect should be enabled on
  129794. */
  129795. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129796. /**
  129797. * Disables an effect by name on a pipeline
  129798. * @param renderPipelineName the name of the pipeline to disable the effect in
  129799. * @param renderEffectName the name of the effect to disable
  129800. * @param cameras the cameras that the effect should be disabled on
  129801. */
  129802. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  129803. /**
  129804. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  129805. */
  129806. update(): void;
  129807. /** @hidden */
  129808. _rebuild(): void;
  129809. /**
  129810. * Disposes of the manager and pipelines
  129811. */
  129812. dispose(): void;
  129813. }
  129814. }
  129815. declare module BABYLON {
  129816. interface Scene {
  129817. /** @hidden (Backing field) */
  129818. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129819. /**
  129820. * Gets the postprocess render pipeline manager
  129821. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  129822. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129823. */
  129824. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  129825. }
  129826. /**
  129827. * Defines the Render Pipeline scene component responsible to rendering pipelines
  129828. */
  129829. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  129830. /**
  129831. * The component name helpfull to identify the component in the list of scene components.
  129832. */
  129833. readonly name: string;
  129834. /**
  129835. * The scene the component belongs to.
  129836. */
  129837. scene: Scene;
  129838. /**
  129839. * Creates a new instance of the component for the given scene
  129840. * @param scene Defines the scene to register the component in
  129841. */
  129842. constructor(scene: Scene);
  129843. /**
  129844. * Registers the component in a given scene
  129845. */
  129846. register(): void;
  129847. /**
  129848. * Rebuilds the elements related to this component in case of
  129849. * context lost for instance.
  129850. */
  129851. rebuild(): void;
  129852. /**
  129853. * Disposes the component and the associated ressources
  129854. */
  129855. dispose(): void;
  129856. private _gatherRenderTargets;
  129857. }
  129858. }
  129859. declare module BABYLON {
  129860. /**
  129861. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  129862. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  129863. */
  129864. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  129865. private _scene;
  129866. private _camerasToBeAttached;
  129867. /**
  129868. * ID of the sharpen post process,
  129869. */
  129870. private readonly SharpenPostProcessId;
  129871. /**
  129872. * @ignore
  129873. * ID of the image processing post process;
  129874. */
  129875. readonly ImageProcessingPostProcessId: string;
  129876. /**
  129877. * @ignore
  129878. * ID of the Fast Approximate Anti-Aliasing post process;
  129879. */
  129880. readonly FxaaPostProcessId: string;
  129881. /**
  129882. * ID of the chromatic aberration post process,
  129883. */
  129884. private readonly ChromaticAberrationPostProcessId;
  129885. /**
  129886. * ID of the grain post process
  129887. */
  129888. private readonly GrainPostProcessId;
  129889. /**
  129890. * Sharpen post process which will apply a sharpen convolution to enhance edges
  129891. */
  129892. sharpen: SharpenPostProcess;
  129893. private _sharpenEffect;
  129894. private bloom;
  129895. /**
  129896. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  129897. */
  129898. depthOfField: DepthOfFieldEffect;
  129899. /**
  129900. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  129901. */
  129902. fxaa: FxaaPostProcess;
  129903. /**
  129904. * Image post processing pass used to perform operations such as tone mapping or color grading.
  129905. */
  129906. imageProcessing: ImageProcessingPostProcess;
  129907. /**
  129908. * Chromatic aberration post process which will shift rgb colors in the image
  129909. */
  129910. chromaticAberration: ChromaticAberrationPostProcess;
  129911. private _chromaticAberrationEffect;
  129912. /**
  129913. * Grain post process which add noise to the image
  129914. */
  129915. grain: GrainPostProcess;
  129916. private _grainEffect;
  129917. /**
  129918. * Glow post process which adds a glow to emissive areas of the image
  129919. */
  129920. private _glowLayer;
  129921. /**
  129922. * Animations which can be used to tweak settings over a period of time
  129923. */
  129924. animations: Animation[];
  129925. private _imageProcessingConfigurationObserver;
  129926. private _sharpenEnabled;
  129927. private _bloomEnabled;
  129928. private _depthOfFieldEnabled;
  129929. private _depthOfFieldBlurLevel;
  129930. private _fxaaEnabled;
  129931. private _imageProcessingEnabled;
  129932. private _defaultPipelineTextureType;
  129933. private _bloomScale;
  129934. private _chromaticAberrationEnabled;
  129935. private _grainEnabled;
  129936. private _buildAllowed;
  129937. /**
  129938. * Gets active scene
  129939. */
  129940. readonly scene: Scene;
  129941. /**
  129942. * Enable or disable the sharpen process from the pipeline
  129943. */
  129944. sharpenEnabled: boolean;
  129945. private _resizeObserver;
  129946. private _hardwareScaleLevel;
  129947. private _bloomKernel;
  129948. /**
  129949. * Specifies the size of the bloom blur kernel, relative to the final output size
  129950. */
  129951. bloomKernel: number;
  129952. /**
  129953. * Specifies the weight of the bloom in the final rendering
  129954. */
  129955. private _bloomWeight;
  129956. /**
  129957. * Specifies the luma threshold for the area that will be blurred by the bloom
  129958. */
  129959. private _bloomThreshold;
  129960. private _hdr;
  129961. /**
  129962. * The strength of the bloom.
  129963. */
  129964. bloomWeight: number;
  129965. /**
  129966. * The strength of the bloom.
  129967. */
  129968. bloomThreshold: number;
  129969. /**
  129970. * The scale of the bloom, lower value will provide better performance.
  129971. */
  129972. bloomScale: number;
  129973. /**
  129974. * Enable or disable the bloom from the pipeline
  129975. */
  129976. bloomEnabled: boolean;
  129977. private _rebuildBloom;
  129978. /**
  129979. * If the depth of field is enabled.
  129980. */
  129981. depthOfFieldEnabled: boolean;
  129982. /**
  129983. * Blur level of the depth of field effect. (Higher blur will effect performance)
  129984. */
  129985. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  129986. /**
  129987. * If the anti aliasing is enabled.
  129988. */
  129989. fxaaEnabled: boolean;
  129990. private _samples;
  129991. /**
  129992. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  129993. */
  129994. samples: number;
  129995. /**
  129996. * If image processing is enabled.
  129997. */
  129998. imageProcessingEnabled: boolean;
  129999. /**
  130000. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  130001. */
  130002. glowLayerEnabled: boolean;
  130003. /**
  130004. * Gets the glow layer (or null if not defined)
  130005. */
  130006. readonly glowLayer: Nullable<GlowLayer>;
  130007. /**
  130008. * Enable or disable the chromaticAberration process from the pipeline
  130009. */
  130010. chromaticAberrationEnabled: boolean;
  130011. /**
  130012. * Enable or disable the grain process from the pipeline
  130013. */
  130014. grainEnabled: boolean;
  130015. /**
  130016. * @constructor
  130017. * @param name - The rendering pipeline name (default: "")
  130018. * @param hdr - If high dynamic range textures should be used (default: true)
  130019. * @param scene - The scene linked to this pipeline (default: the last created scene)
  130020. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  130021. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  130022. */
  130023. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  130024. /**
  130025. * Get the class name
  130026. * @returns "DefaultRenderingPipeline"
  130027. */
  130028. getClassName(): string;
  130029. /**
  130030. * Force the compilation of the entire pipeline.
  130031. */
  130032. prepare(): void;
  130033. private _hasCleared;
  130034. private _prevPostProcess;
  130035. private _prevPrevPostProcess;
  130036. private _setAutoClearAndTextureSharing;
  130037. private _depthOfFieldSceneObserver;
  130038. private _buildPipeline;
  130039. private _disposePostProcesses;
  130040. /**
  130041. * Adds a camera to the pipeline
  130042. * @param camera the camera to be added
  130043. */
  130044. addCamera(camera: Camera): void;
  130045. /**
  130046. * Removes a camera from the pipeline
  130047. * @param camera the camera to remove
  130048. */
  130049. removeCamera(camera: Camera): void;
  130050. /**
  130051. * Dispose of the pipeline and stop all post processes
  130052. */
  130053. dispose(): void;
  130054. /**
  130055. * Serialize the rendering pipeline (Used when exporting)
  130056. * @returns the serialized object
  130057. */
  130058. serialize(): any;
  130059. /**
  130060. * Parse the serialized pipeline
  130061. * @param source Source pipeline.
  130062. * @param scene The scene to load the pipeline to.
  130063. * @param rootUrl The URL of the serialized pipeline.
  130064. * @returns An instantiated pipeline from the serialized object.
  130065. */
  130066. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  130067. }
  130068. }
  130069. declare module BABYLON {
  130070. /** @hidden */
  130071. export var lensHighlightsPixelShader: {
  130072. name: string;
  130073. shader: string;
  130074. };
  130075. }
  130076. declare module BABYLON {
  130077. /** @hidden */
  130078. export var depthOfFieldPixelShader: {
  130079. name: string;
  130080. shader: string;
  130081. };
  130082. }
  130083. declare module BABYLON {
  130084. /**
  130085. * BABYLON.JS Chromatic Aberration GLSL Shader
  130086. * Author: Olivier Guyot
  130087. * Separates very slightly R, G and B colors on the edges of the screen
  130088. * Inspired by Francois Tarlier & Martins Upitis
  130089. */
  130090. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  130091. /**
  130092. * @ignore
  130093. * The chromatic aberration PostProcess id in the pipeline
  130094. */
  130095. LensChromaticAberrationEffect: string;
  130096. /**
  130097. * @ignore
  130098. * The highlights enhancing PostProcess id in the pipeline
  130099. */
  130100. HighlightsEnhancingEffect: string;
  130101. /**
  130102. * @ignore
  130103. * The depth-of-field PostProcess id in the pipeline
  130104. */
  130105. LensDepthOfFieldEffect: string;
  130106. private _scene;
  130107. private _depthTexture;
  130108. private _grainTexture;
  130109. private _chromaticAberrationPostProcess;
  130110. private _highlightsPostProcess;
  130111. private _depthOfFieldPostProcess;
  130112. private _edgeBlur;
  130113. private _grainAmount;
  130114. private _chromaticAberration;
  130115. private _distortion;
  130116. private _highlightsGain;
  130117. private _highlightsThreshold;
  130118. private _dofDistance;
  130119. private _dofAperture;
  130120. private _dofDarken;
  130121. private _dofPentagon;
  130122. private _blurNoise;
  130123. /**
  130124. * @constructor
  130125. *
  130126. * Effect parameters are as follow:
  130127. * {
  130128. * chromatic_aberration: number; // from 0 to x (1 for realism)
  130129. * edge_blur: number; // from 0 to x (1 for realism)
  130130. * distortion: number; // from 0 to x (1 for realism)
  130131. * grain_amount: number; // from 0 to 1
  130132. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  130133. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  130134. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  130135. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  130136. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  130137. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  130138. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  130139. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  130140. * }
  130141. * Note: if an effect parameter is unset, effect is disabled
  130142. *
  130143. * @param name The rendering pipeline name
  130144. * @param parameters - An object containing all parameters (see above)
  130145. * @param scene The scene linked to this pipeline
  130146. * @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)
  130147. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130148. */
  130149. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  130150. /**
  130151. * Get the class name
  130152. * @returns "LensRenderingPipeline"
  130153. */
  130154. getClassName(): string;
  130155. /**
  130156. * Gets associated scene
  130157. */
  130158. readonly scene: Scene;
  130159. /**
  130160. * Gets or sets the edge blur
  130161. */
  130162. edgeBlur: number;
  130163. /**
  130164. * Gets or sets the grain amount
  130165. */
  130166. grainAmount: number;
  130167. /**
  130168. * Gets or sets the chromatic aberration amount
  130169. */
  130170. chromaticAberration: number;
  130171. /**
  130172. * Gets or sets the depth of field aperture
  130173. */
  130174. dofAperture: number;
  130175. /**
  130176. * Gets or sets the edge distortion
  130177. */
  130178. edgeDistortion: number;
  130179. /**
  130180. * Gets or sets the depth of field distortion
  130181. */
  130182. dofDistortion: number;
  130183. /**
  130184. * Gets or sets the darken out of focus amount
  130185. */
  130186. darkenOutOfFocus: number;
  130187. /**
  130188. * Gets or sets a boolean indicating if blur noise is enabled
  130189. */
  130190. blurNoise: boolean;
  130191. /**
  130192. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  130193. */
  130194. pentagonBokeh: boolean;
  130195. /**
  130196. * Gets or sets the highlight grain amount
  130197. */
  130198. highlightsGain: number;
  130199. /**
  130200. * Gets or sets the highlight threshold
  130201. */
  130202. highlightsThreshold: number;
  130203. /**
  130204. * Sets the amount of blur at the edges
  130205. * @param amount blur amount
  130206. */
  130207. setEdgeBlur(amount: number): void;
  130208. /**
  130209. * Sets edge blur to 0
  130210. */
  130211. disableEdgeBlur(): void;
  130212. /**
  130213. * Sets the amout of grain
  130214. * @param amount Amount of grain
  130215. */
  130216. setGrainAmount(amount: number): void;
  130217. /**
  130218. * Set grain amount to 0
  130219. */
  130220. disableGrain(): void;
  130221. /**
  130222. * Sets the chromatic aberration amount
  130223. * @param amount amount of chromatic aberration
  130224. */
  130225. setChromaticAberration(amount: number): void;
  130226. /**
  130227. * Sets chromatic aberration amount to 0
  130228. */
  130229. disableChromaticAberration(): void;
  130230. /**
  130231. * Sets the EdgeDistortion amount
  130232. * @param amount amount of EdgeDistortion
  130233. */
  130234. setEdgeDistortion(amount: number): void;
  130235. /**
  130236. * Sets edge distortion to 0
  130237. */
  130238. disableEdgeDistortion(): void;
  130239. /**
  130240. * Sets the FocusDistance amount
  130241. * @param amount amount of FocusDistance
  130242. */
  130243. setFocusDistance(amount: number): void;
  130244. /**
  130245. * Disables depth of field
  130246. */
  130247. disableDepthOfField(): void;
  130248. /**
  130249. * Sets the Aperture amount
  130250. * @param amount amount of Aperture
  130251. */
  130252. setAperture(amount: number): void;
  130253. /**
  130254. * Sets the DarkenOutOfFocus amount
  130255. * @param amount amount of DarkenOutOfFocus
  130256. */
  130257. setDarkenOutOfFocus(amount: number): void;
  130258. private _pentagonBokehIsEnabled;
  130259. /**
  130260. * Creates a pentagon bokeh effect
  130261. */
  130262. enablePentagonBokeh(): void;
  130263. /**
  130264. * Disables the pentagon bokeh effect
  130265. */
  130266. disablePentagonBokeh(): void;
  130267. /**
  130268. * Enables noise blur
  130269. */
  130270. enableNoiseBlur(): void;
  130271. /**
  130272. * Disables noise blur
  130273. */
  130274. disableNoiseBlur(): void;
  130275. /**
  130276. * Sets the HighlightsGain amount
  130277. * @param amount amount of HighlightsGain
  130278. */
  130279. setHighlightsGain(amount: number): void;
  130280. /**
  130281. * Sets the HighlightsThreshold amount
  130282. * @param amount amount of HighlightsThreshold
  130283. */
  130284. setHighlightsThreshold(amount: number): void;
  130285. /**
  130286. * Disables highlights
  130287. */
  130288. disableHighlights(): void;
  130289. /**
  130290. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  130291. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  130292. */
  130293. dispose(disableDepthRender?: boolean): void;
  130294. private _createChromaticAberrationPostProcess;
  130295. private _createHighlightsPostProcess;
  130296. private _createDepthOfFieldPostProcess;
  130297. private _createGrainTexture;
  130298. }
  130299. }
  130300. declare module BABYLON {
  130301. /** @hidden */
  130302. export var ssao2PixelShader: {
  130303. name: string;
  130304. shader: string;
  130305. };
  130306. }
  130307. declare module BABYLON {
  130308. /** @hidden */
  130309. export var ssaoCombinePixelShader: {
  130310. name: string;
  130311. shader: string;
  130312. };
  130313. }
  130314. declare module BABYLON {
  130315. /**
  130316. * Render pipeline to produce ssao effect
  130317. */
  130318. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  130319. /**
  130320. * @ignore
  130321. * The PassPostProcess id in the pipeline that contains the original scene color
  130322. */
  130323. SSAOOriginalSceneColorEffect: string;
  130324. /**
  130325. * @ignore
  130326. * The SSAO PostProcess id in the pipeline
  130327. */
  130328. SSAORenderEffect: string;
  130329. /**
  130330. * @ignore
  130331. * The horizontal blur PostProcess id in the pipeline
  130332. */
  130333. SSAOBlurHRenderEffect: string;
  130334. /**
  130335. * @ignore
  130336. * The vertical blur PostProcess id in the pipeline
  130337. */
  130338. SSAOBlurVRenderEffect: string;
  130339. /**
  130340. * @ignore
  130341. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  130342. */
  130343. SSAOCombineRenderEffect: string;
  130344. /**
  130345. * The output strength of the SSAO post-process. Default value is 1.0.
  130346. */
  130347. totalStrength: number;
  130348. /**
  130349. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  130350. */
  130351. maxZ: number;
  130352. /**
  130353. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  130354. */
  130355. minZAspect: number;
  130356. private _samples;
  130357. /**
  130358. * Number of samples used for the SSAO calculations. Default value is 8
  130359. */
  130360. samples: number;
  130361. private _textureSamples;
  130362. /**
  130363. * Number of samples to use for antialiasing
  130364. */
  130365. textureSamples: number;
  130366. /**
  130367. * Ratio object used for SSAO ratio and blur ratio
  130368. */
  130369. private _ratio;
  130370. /**
  130371. * Dynamically generated sphere sampler.
  130372. */
  130373. private _sampleSphere;
  130374. /**
  130375. * Blur filter offsets
  130376. */
  130377. private _samplerOffsets;
  130378. private _expensiveBlur;
  130379. /**
  130380. * If bilateral blur should be used
  130381. */
  130382. expensiveBlur: boolean;
  130383. /**
  130384. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  130385. */
  130386. radius: number;
  130387. /**
  130388. * The base color of the SSAO post-process
  130389. * The final result is "base + ssao" between [0, 1]
  130390. */
  130391. base: number;
  130392. /**
  130393. * Support test.
  130394. */
  130395. static readonly IsSupported: boolean;
  130396. private _scene;
  130397. private _depthTexture;
  130398. private _normalTexture;
  130399. private _randomTexture;
  130400. private _originalColorPostProcess;
  130401. private _ssaoPostProcess;
  130402. private _blurHPostProcess;
  130403. private _blurVPostProcess;
  130404. private _ssaoCombinePostProcess;
  130405. /**
  130406. * Gets active scene
  130407. */
  130408. readonly scene: Scene;
  130409. /**
  130410. * @constructor
  130411. * @param name The rendering pipeline name
  130412. * @param scene The scene linked to this pipeline
  130413. * @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 }
  130414. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130415. */
  130416. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  130417. /**
  130418. * Get the class name
  130419. * @returns "SSAO2RenderingPipeline"
  130420. */
  130421. getClassName(): string;
  130422. /**
  130423. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  130424. */
  130425. dispose(disableGeometryBufferRenderer?: boolean): void;
  130426. private _createBlurPostProcess;
  130427. /** @hidden */
  130428. _rebuild(): void;
  130429. private _bits;
  130430. private _radicalInverse_VdC;
  130431. private _hammersley;
  130432. private _hemisphereSample_uniform;
  130433. private _generateHemisphere;
  130434. private _createSSAOPostProcess;
  130435. private _createSSAOCombinePostProcess;
  130436. private _createRandomTexture;
  130437. /**
  130438. * Serialize the rendering pipeline (Used when exporting)
  130439. * @returns the serialized object
  130440. */
  130441. serialize(): any;
  130442. /**
  130443. * Parse the serialized pipeline
  130444. * @param source Source pipeline.
  130445. * @param scene The scene to load the pipeline to.
  130446. * @param rootUrl The URL of the serialized pipeline.
  130447. * @returns An instantiated pipeline from the serialized object.
  130448. */
  130449. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  130450. }
  130451. }
  130452. declare module BABYLON {
  130453. /** @hidden */
  130454. export var ssaoPixelShader: {
  130455. name: string;
  130456. shader: string;
  130457. };
  130458. }
  130459. declare module BABYLON {
  130460. /**
  130461. * Render pipeline to produce ssao effect
  130462. */
  130463. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  130464. /**
  130465. * @ignore
  130466. * The PassPostProcess id in the pipeline that contains the original scene color
  130467. */
  130468. SSAOOriginalSceneColorEffect: string;
  130469. /**
  130470. * @ignore
  130471. * The SSAO PostProcess id in the pipeline
  130472. */
  130473. SSAORenderEffect: string;
  130474. /**
  130475. * @ignore
  130476. * The horizontal blur PostProcess id in the pipeline
  130477. */
  130478. SSAOBlurHRenderEffect: string;
  130479. /**
  130480. * @ignore
  130481. * The vertical blur PostProcess id in the pipeline
  130482. */
  130483. SSAOBlurVRenderEffect: string;
  130484. /**
  130485. * @ignore
  130486. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  130487. */
  130488. SSAOCombineRenderEffect: string;
  130489. /**
  130490. * The output strength of the SSAO post-process. Default value is 1.0.
  130491. */
  130492. totalStrength: number;
  130493. /**
  130494. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  130495. */
  130496. radius: number;
  130497. /**
  130498. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  130499. * Must not be equal to fallOff and superior to fallOff.
  130500. * Default value is 0.0075
  130501. */
  130502. area: number;
  130503. /**
  130504. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  130505. * Must not be equal to area and inferior to area.
  130506. * Default value is 0.000001
  130507. */
  130508. fallOff: number;
  130509. /**
  130510. * The base color of the SSAO post-process
  130511. * The final result is "base + ssao" between [0, 1]
  130512. */
  130513. base: number;
  130514. private _scene;
  130515. private _depthTexture;
  130516. private _randomTexture;
  130517. private _originalColorPostProcess;
  130518. private _ssaoPostProcess;
  130519. private _blurHPostProcess;
  130520. private _blurVPostProcess;
  130521. private _ssaoCombinePostProcess;
  130522. private _firstUpdate;
  130523. /**
  130524. * Gets active scene
  130525. */
  130526. readonly scene: Scene;
  130527. /**
  130528. * @constructor
  130529. * @param name - The rendering pipeline name
  130530. * @param scene - The scene linked to this pipeline
  130531. * @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 }
  130532. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  130533. */
  130534. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  130535. /**
  130536. * Get the class name
  130537. * @returns "SSAORenderingPipeline"
  130538. */
  130539. getClassName(): string;
  130540. /**
  130541. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  130542. */
  130543. dispose(disableDepthRender?: boolean): void;
  130544. private _createBlurPostProcess;
  130545. /** @hidden */
  130546. _rebuild(): void;
  130547. private _createSSAOPostProcess;
  130548. private _createSSAOCombinePostProcess;
  130549. private _createRandomTexture;
  130550. }
  130551. }
  130552. declare module BABYLON {
  130553. /** @hidden */
  130554. export var standardPixelShader: {
  130555. name: string;
  130556. shader: string;
  130557. };
  130558. }
  130559. declare module BABYLON {
  130560. /**
  130561. * Standard rendering pipeline
  130562. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130563. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  130564. */
  130565. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  130566. /**
  130567. * Public members
  130568. */
  130569. /**
  130570. * Post-process which contains the original scene color before the pipeline applies all the effects
  130571. */
  130572. originalPostProcess: Nullable<PostProcess>;
  130573. /**
  130574. * Post-process used to down scale an image x4
  130575. */
  130576. downSampleX4PostProcess: Nullable<PostProcess>;
  130577. /**
  130578. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  130579. */
  130580. brightPassPostProcess: Nullable<PostProcess>;
  130581. /**
  130582. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  130583. */
  130584. blurHPostProcesses: PostProcess[];
  130585. /**
  130586. * Post-process array storing all the vertical blur post-processes used by the pipeline
  130587. */
  130588. blurVPostProcesses: PostProcess[];
  130589. /**
  130590. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  130591. */
  130592. textureAdderPostProcess: Nullable<PostProcess>;
  130593. /**
  130594. * Post-process used to create volumetric lighting effect
  130595. */
  130596. volumetricLightPostProcess: Nullable<PostProcess>;
  130597. /**
  130598. * Post-process used to smooth the previous volumetric light post-process on the X axis
  130599. */
  130600. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  130601. /**
  130602. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  130603. */
  130604. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  130605. /**
  130606. * Post-process used to merge the volumetric light effect and the real scene color
  130607. */
  130608. volumetricLightMergePostProces: Nullable<PostProcess>;
  130609. /**
  130610. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  130611. */
  130612. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  130613. /**
  130614. * Base post-process used to calculate the average luminance of the final image for HDR
  130615. */
  130616. luminancePostProcess: Nullable<PostProcess>;
  130617. /**
  130618. * Post-processes used to create down sample post-processes in order to get
  130619. * the average luminance of the final image for HDR
  130620. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  130621. */
  130622. luminanceDownSamplePostProcesses: PostProcess[];
  130623. /**
  130624. * Post-process used to create a HDR effect (light adaptation)
  130625. */
  130626. hdrPostProcess: Nullable<PostProcess>;
  130627. /**
  130628. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  130629. */
  130630. textureAdderFinalPostProcess: Nullable<PostProcess>;
  130631. /**
  130632. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  130633. */
  130634. lensFlareFinalPostProcess: Nullable<PostProcess>;
  130635. /**
  130636. * Post-process used to merge the final HDR post-process and the real scene color
  130637. */
  130638. hdrFinalPostProcess: Nullable<PostProcess>;
  130639. /**
  130640. * Post-process used to create a lens flare effect
  130641. */
  130642. lensFlarePostProcess: Nullable<PostProcess>;
  130643. /**
  130644. * Post-process that merges the result of the lens flare post-process and the real scene color
  130645. */
  130646. lensFlareComposePostProcess: Nullable<PostProcess>;
  130647. /**
  130648. * Post-process used to create a motion blur effect
  130649. */
  130650. motionBlurPostProcess: Nullable<PostProcess>;
  130651. /**
  130652. * Post-process used to create a depth of field effect
  130653. */
  130654. depthOfFieldPostProcess: Nullable<PostProcess>;
  130655. /**
  130656. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  130657. */
  130658. fxaaPostProcess: Nullable<FxaaPostProcess>;
  130659. /**
  130660. * Represents the brightness threshold in order to configure the illuminated surfaces
  130661. */
  130662. brightThreshold: number;
  130663. /**
  130664. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  130665. */
  130666. blurWidth: number;
  130667. /**
  130668. * Sets if the blur for highlighted surfaces must be only horizontal
  130669. */
  130670. horizontalBlur: boolean;
  130671. /**
  130672. * Gets the overall exposure used by the pipeline
  130673. */
  130674. /**
  130675. * Sets the overall exposure used by the pipeline
  130676. */
  130677. exposure: number;
  130678. /**
  130679. * Texture used typically to simulate "dirty" on camera lens
  130680. */
  130681. lensTexture: Nullable<Texture>;
  130682. /**
  130683. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  130684. */
  130685. volumetricLightCoefficient: number;
  130686. /**
  130687. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  130688. */
  130689. volumetricLightPower: number;
  130690. /**
  130691. * Used the set the blur intensity to smooth the volumetric lights
  130692. */
  130693. volumetricLightBlurScale: number;
  130694. /**
  130695. * Light (spot or directional) used to generate the volumetric lights rays
  130696. * The source light must have a shadow generate so the pipeline can get its
  130697. * depth map
  130698. */
  130699. sourceLight: Nullable<SpotLight | DirectionalLight>;
  130700. /**
  130701. * For eye adaptation, represents the minimum luminance the eye can see
  130702. */
  130703. hdrMinimumLuminance: number;
  130704. /**
  130705. * For eye adaptation, represents the decrease luminance speed
  130706. */
  130707. hdrDecreaseRate: number;
  130708. /**
  130709. * For eye adaptation, represents the increase luminance speed
  130710. */
  130711. hdrIncreaseRate: number;
  130712. /**
  130713. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130714. */
  130715. /**
  130716. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  130717. */
  130718. hdrAutoExposure: boolean;
  130719. /**
  130720. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  130721. */
  130722. lensColorTexture: Nullable<Texture>;
  130723. /**
  130724. * The overall strengh for the lens flare effect
  130725. */
  130726. lensFlareStrength: number;
  130727. /**
  130728. * Dispersion coefficient for lens flare ghosts
  130729. */
  130730. lensFlareGhostDispersal: number;
  130731. /**
  130732. * Main lens flare halo width
  130733. */
  130734. lensFlareHaloWidth: number;
  130735. /**
  130736. * Based on the lens distortion effect, defines how much the lens flare result
  130737. * is distorted
  130738. */
  130739. lensFlareDistortionStrength: number;
  130740. /**
  130741. * Configures the blur intensity used for for lens flare (halo)
  130742. */
  130743. lensFlareBlurWidth: number;
  130744. /**
  130745. * Lens star texture must be used to simulate rays on the flares and is available
  130746. * in the documentation
  130747. */
  130748. lensStarTexture: Nullable<Texture>;
  130749. /**
  130750. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  130751. * flare effect by taking account of the dirt texture
  130752. */
  130753. lensFlareDirtTexture: Nullable<Texture>;
  130754. /**
  130755. * Represents the focal length for the depth of field effect
  130756. */
  130757. depthOfFieldDistance: number;
  130758. /**
  130759. * Represents the blur intensity for the blurred part of the depth of field effect
  130760. */
  130761. depthOfFieldBlurWidth: number;
  130762. /**
  130763. * Gets how much the image is blurred by the movement while using the motion blur post-process
  130764. */
  130765. /**
  130766. * Sets how much the image is blurred by the movement while using the motion blur post-process
  130767. */
  130768. motionStrength: number;
  130769. /**
  130770. * Gets wether or not the motion blur post-process is object based or screen based.
  130771. */
  130772. /**
  130773. * Sets wether or not the motion blur post-process should be object based or screen based
  130774. */
  130775. objectBasedMotionBlur: boolean;
  130776. /**
  130777. * List of animations for the pipeline (IAnimatable implementation)
  130778. */
  130779. animations: Animation[];
  130780. /**
  130781. * Private members
  130782. */
  130783. private _scene;
  130784. private _currentDepthOfFieldSource;
  130785. private _basePostProcess;
  130786. private _fixedExposure;
  130787. private _currentExposure;
  130788. private _hdrAutoExposure;
  130789. private _hdrCurrentLuminance;
  130790. private _motionStrength;
  130791. private _isObjectBasedMotionBlur;
  130792. private _floatTextureType;
  130793. private _camerasToBeAttached;
  130794. private _ratio;
  130795. private _bloomEnabled;
  130796. private _depthOfFieldEnabled;
  130797. private _vlsEnabled;
  130798. private _lensFlareEnabled;
  130799. private _hdrEnabled;
  130800. private _motionBlurEnabled;
  130801. private _fxaaEnabled;
  130802. private _motionBlurSamples;
  130803. private _volumetricLightStepsCount;
  130804. private _samples;
  130805. /**
  130806. * @ignore
  130807. * Specifies if the bloom pipeline is enabled
  130808. */
  130809. BloomEnabled: boolean;
  130810. /**
  130811. * @ignore
  130812. * Specifies if the depth of field pipeline is enabed
  130813. */
  130814. DepthOfFieldEnabled: boolean;
  130815. /**
  130816. * @ignore
  130817. * Specifies if the lens flare pipeline is enabed
  130818. */
  130819. LensFlareEnabled: boolean;
  130820. /**
  130821. * @ignore
  130822. * Specifies if the HDR pipeline is enabled
  130823. */
  130824. HDREnabled: boolean;
  130825. /**
  130826. * @ignore
  130827. * Specifies if the volumetric lights scattering effect is enabled
  130828. */
  130829. VLSEnabled: boolean;
  130830. /**
  130831. * @ignore
  130832. * Specifies if the motion blur effect is enabled
  130833. */
  130834. MotionBlurEnabled: boolean;
  130835. /**
  130836. * Specifies if anti-aliasing is enabled
  130837. */
  130838. fxaaEnabled: boolean;
  130839. /**
  130840. * Specifies the number of steps used to calculate the volumetric lights
  130841. * Typically in interval [50, 200]
  130842. */
  130843. volumetricLightStepsCount: number;
  130844. /**
  130845. * Specifies the number of samples used for the motion blur effect
  130846. * Typically in interval [16, 64]
  130847. */
  130848. motionBlurSamples: number;
  130849. /**
  130850. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  130851. */
  130852. samples: number;
  130853. /**
  130854. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  130855. * @constructor
  130856. * @param name The rendering pipeline name
  130857. * @param scene The scene linked to this pipeline
  130858. * @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)
  130859. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  130860. * @param cameras The array of cameras that the rendering pipeline will be attached to
  130861. */
  130862. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  130863. private _buildPipeline;
  130864. private _createDownSampleX4PostProcess;
  130865. private _createBrightPassPostProcess;
  130866. private _createBlurPostProcesses;
  130867. private _createTextureAdderPostProcess;
  130868. private _createVolumetricLightPostProcess;
  130869. private _createLuminancePostProcesses;
  130870. private _createHdrPostProcess;
  130871. private _createLensFlarePostProcess;
  130872. private _createDepthOfFieldPostProcess;
  130873. private _createMotionBlurPostProcess;
  130874. private _getDepthTexture;
  130875. private _disposePostProcesses;
  130876. /**
  130877. * Dispose of the pipeline and stop all post processes
  130878. */
  130879. dispose(): void;
  130880. /**
  130881. * Serialize the rendering pipeline (Used when exporting)
  130882. * @returns the serialized object
  130883. */
  130884. serialize(): any;
  130885. /**
  130886. * Parse the serialized pipeline
  130887. * @param source Source pipeline.
  130888. * @param scene The scene to load the pipeline to.
  130889. * @param rootUrl The URL of the serialized pipeline.
  130890. * @returns An instantiated pipeline from the serialized object.
  130891. */
  130892. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  130893. /**
  130894. * Luminance steps
  130895. */
  130896. static LuminanceSteps: number;
  130897. }
  130898. }
  130899. declare module BABYLON {
  130900. /** @hidden */
  130901. export var tonemapPixelShader: {
  130902. name: string;
  130903. shader: string;
  130904. };
  130905. }
  130906. declare module BABYLON {
  130907. /** Defines operator used for tonemapping */
  130908. export enum TonemappingOperator {
  130909. /** Hable */
  130910. Hable = 0,
  130911. /** Reinhard */
  130912. Reinhard = 1,
  130913. /** HejiDawson */
  130914. HejiDawson = 2,
  130915. /** Photographic */
  130916. Photographic = 3
  130917. }
  130918. /**
  130919. * Defines a post process to apply tone mapping
  130920. */
  130921. export class TonemapPostProcess extends PostProcess {
  130922. private _operator;
  130923. /** Defines the required exposure adjustement */
  130924. exposureAdjustment: number;
  130925. /**
  130926. * Creates a new TonemapPostProcess
  130927. * @param name defines the name of the postprocess
  130928. * @param _operator defines the operator to use
  130929. * @param exposureAdjustment defines the required exposure adjustement
  130930. * @param camera defines the camera to use (can be null)
  130931. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  130932. * @param engine defines the hosting engine (can be ignore if camera is set)
  130933. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  130934. */
  130935. constructor(name: string, _operator: TonemappingOperator,
  130936. /** Defines the required exposure adjustement */
  130937. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  130938. }
  130939. }
  130940. declare module BABYLON {
  130941. /** @hidden */
  130942. export var depthVertexShader: {
  130943. name: string;
  130944. shader: string;
  130945. };
  130946. }
  130947. declare module BABYLON {
  130948. /** @hidden */
  130949. export var volumetricLightScatteringPixelShader: {
  130950. name: string;
  130951. shader: string;
  130952. };
  130953. }
  130954. declare module BABYLON {
  130955. /** @hidden */
  130956. export var volumetricLightScatteringPassVertexShader: {
  130957. name: string;
  130958. shader: string;
  130959. };
  130960. }
  130961. declare module BABYLON {
  130962. /** @hidden */
  130963. export var volumetricLightScatteringPassPixelShader: {
  130964. name: string;
  130965. shader: string;
  130966. };
  130967. }
  130968. declare module BABYLON {
  130969. /**
  130970. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  130971. */
  130972. export class VolumetricLightScatteringPostProcess extends PostProcess {
  130973. private _volumetricLightScatteringPass;
  130974. private _volumetricLightScatteringRTT;
  130975. private _viewPort;
  130976. private _screenCoordinates;
  130977. private _cachedDefines;
  130978. /**
  130979. * If not undefined, the mesh position is computed from the attached node position
  130980. */
  130981. attachedNode: {
  130982. position: Vector3;
  130983. };
  130984. /**
  130985. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  130986. */
  130987. customMeshPosition: Vector3;
  130988. /**
  130989. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  130990. */
  130991. useCustomMeshPosition: boolean;
  130992. /**
  130993. * If the post-process should inverse the light scattering direction
  130994. */
  130995. invert: boolean;
  130996. /**
  130997. * The internal mesh used by the post-process
  130998. */
  130999. mesh: Mesh;
  131000. /**
  131001. * @hidden
  131002. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  131003. */
  131004. useDiffuseColor: boolean;
  131005. /**
  131006. * Array containing the excluded meshes not rendered in the internal pass
  131007. */
  131008. excludedMeshes: AbstractMesh[];
  131009. /**
  131010. * Controls the overall intensity of the post-process
  131011. */
  131012. exposure: number;
  131013. /**
  131014. * Dissipates each sample's contribution in range [0, 1]
  131015. */
  131016. decay: number;
  131017. /**
  131018. * Controls the overall intensity of each sample
  131019. */
  131020. weight: number;
  131021. /**
  131022. * Controls the density of each sample
  131023. */
  131024. density: number;
  131025. /**
  131026. * @constructor
  131027. * @param name The post-process name
  131028. * @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)
  131029. * @param camera The camera that the post-process will be attached to
  131030. * @param mesh The mesh used to create the light scattering
  131031. * @param samples The post-process quality, default 100
  131032. * @param samplingModeThe post-process filtering mode
  131033. * @param engine The babylon engine
  131034. * @param reusable If the post-process is reusable
  131035. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  131036. */
  131037. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  131038. /**
  131039. * Returns the string "VolumetricLightScatteringPostProcess"
  131040. * @returns "VolumetricLightScatteringPostProcess"
  131041. */
  131042. getClassName(): string;
  131043. private _isReady;
  131044. /**
  131045. * Sets the new light position for light scattering effect
  131046. * @param position The new custom light position
  131047. */
  131048. setCustomMeshPosition(position: Vector3): void;
  131049. /**
  131050. * Returns the light position for light scattering effect
  131051. * @return Vector3 The custom light position
  131052. */
  131053. getCustomMeshPosition(): Vector3;
  131054. /**
  131055. * Disposes the internal assets and detaches the post-process from the camera
  131056. */
  131057. dispose(camera: Camera): void;
  131058. /**
  131059. * Returns the render target texture used by the post-process
  131060. * @return the render target texture used by the post-process
  131061. */
  131062. getPass(): RenderTargetTexture;
  131063. private _meshExcluded;
  131064. private _createPass;
  131065. private _updateMeshScreenCoordinates;
  131066. /**
  131067. * Creates a default mesh for the Volumeric Light Scattering post-process
  131068. * @param name The mesh name
  131069. * @param scene The scene where to create the mesh
  131070. * @return the default mesh
  131071. */
  131072. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  131073. }
  131074. }
  131075. declare module BABYLON {
  131076. interface Scene {
  131077. /** @hidden (Backing field) */
  131078. _boundingBoxRenderer: BoundingBoxRenderer;
  131079. /** @hidden (Backing field) */
  131080. _forceShowBoundingBoxes: boolean;
  131081. /**
  131082. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  131083. */
  131084. forceShowBoundingBoxes: boolean;
  131085. /**
  131086. * Gets the bounding box renderer associated with the scene
  131087. * @returns a BoundingBoxRenderer
  131088. */
  131089. getBoundingBoxRenderer(): BoundingBoxRenderer;
  131090. }
  131091. interface AbstractMesh {
  131092. /** @hidden (Backing field) */
  131093. _showBoundingBox: boolean;
  131094. /**
  131095. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  131096. */
  131097. showBoundingBox: boolean;
  131098. }
  131099. /**
  131100. * Component responsible of rendering the bounding box of the meshes in a scene.
  131101. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  131102. */
  131103. export class BoundingBoxRenderer implements ISceneComponent {
  131104. /**
  131105. * The component name helpfull to identify the component in the list of scene components.
  131106. */
  131107. readonly name: string;
  131108. /**
  131109. * The scene the component belongs to.
  131110. */
  131111. scene: Scene;
  131112. /**
  131113. * Color of the bounding box lines placed in front of an object
  131114. */
  131115. frontColor: Color3;
  131116. /**
  131117. * Color of the bounding box lines placed behind an object
  131118. */
  131119. backColor: Color3;
  131120. /**
  131121. * Defines if the renderer should show the back lines or not
  131122. */
  131123. showBackLines: boolean;
  131124. /**
  131125. * @hidden
  131126. */
  131127. renderList: SmartArray<BoundingBox>;
  131128. private _colorShader;
  131129. private _vertexBuffers;
  131130. private _indexBuffer;
  131131. private _fillIndexBuffer;
  131132. private _fillIndexData;
  131133. /**
  131134. * Instantiates a new bounding box renderer in a scene.
  131135. * @param scene the scene the renderer renders in
  131136. */
  131137. constructor(scene: Scene);
  131138. /**
  131139. * Registers the component in a given scene
  131140. */
  131141. register(): void;
  131142. private _evaluateSubMesh;
  131143. private _activeMesh;
  131144. private _prepareRessources;
  131145. private _createIndexBuffer;
  131146. /**
  131147. * Rebuilds the elements related to this component in case of
  131148. * context lost for instance.
  131149. */
  131150. rebuild(): void;
  131151. /**
  131152. * @hidden
  131153. */
  131154. reset(): void;
  131155. /**
  131156. * Render the bounding boxes of a specific rendering group
  131157. * @param renderingGroupId defines the rendering group to render
  131158. */
  131159. render(renderingGroupId: number): void;
  131160. /**
  131161. * In case of occlusion queries, we can render the occlusion bounding box through this method
  131162. * @param mesh Define the mesh to render the occlusion bounding box for
  131163. */
  131164. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  131165. /**
  131166. * Dispose and release the resources attached to this renderer.
  131167. */
  131168. dispose(): void;
  131169. }
  131170. }
  131171. declare module BABYLON {
  131172. /** @hidden */
  131173. export var depthPixelShader: {
  131174. name: string;
  131175. shader: string;
  131176. };
  131177. }
  131178. declare module BABYLON {
  131179. /**
  131180. * This represents a depth renderer in Babylon.
  131181. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  131182. */
  131183. export class DepthRenderer {
  131184. private _scene;
  131185. private _depthMap;
  131186. private _effect;
  131187. private readonly _storeNonLinearDepth;
  131188. private readonly _clearColor;
  131189. /** Get if the depth renderer is using packed depth or not */
  131190. readonly isPacked: boolean;
  131191. private _cachedDefines;
  131192. private _camera;
  131193. /**
  131194. * Specifiess that the depth renderer will only be used within
  131195. * the camera it is created for.
  131196. * This can help forcing its rendering during the camera processing.
  131197. */
  131198. useOnlyInActiveCamera: boolean;
  131199. /** @hidden */
  131200. static _SceneComponentInitialization: (scene: Scene) => void;
  131201. /**
  131202. * Instantiates a depth renderer
  131203. * @param scene The scene the renderer belongs to
  131204. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  131205. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  131206. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  131207. */
  131208. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  131209. /**
  131210. * Creates the depth rendering effect and checks if the effect is ready.
  131211. * @param subMesh The submesh to be used to render the depth map of
  131212. * @param useInstances If multiple world instances should be used
  131213. * @returns if the depth renderer is ready to render the depth map
  131214. */
  131215. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  131216. /**
  131217. * Gets the texture which the depth map will be written to.
  131218. * @returns The depth map texture
  131219. */
  131220. getDepthMap(): RenderTargetTexture;
  131221. /**
  131222. * Disposes of the depth renderer.
  131223. */
  131224. dispose(): void;
  131225. }
  131226. }
  131227. declare module BABYLON {
  131228. interface Scene {
  131229. /** @hidden (Backing field) */
  131230. _depthRenderer: {
  131231. [id: string]: DepthRenderer;
  131232. };
  131233. /**
  131234. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  131235. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  131236. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  131237. * @returns the created depth renderer
  131238. */
  131239. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  131240. /**
  131241. * Disables a depth renderer for a given camera
  131242. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  131243. */
  131244. disableDepthRenderer(camera?: Nullable<Camera>): void;
  131245. }
  131246. /**
  131247. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  131248. * in several rendering techniques.
  131249. */
  131250. export class DepthRendererSceneComponent implements ISceneComponent {
  131251. /**
  131252. * The component name helpfull to identify the component in the list of scene components.
  131253. */
  131254. readonly name: string;
  131255. /**
  131256. * The scene the component belongs to.
  131257. */
  131258. scene: Scene;
  131259. /**
  131260. * Creates a new instance of the component for the given scene
  131261. * @param scene Defines the scene to register the component in
  131262. */
  131263. constructor(scene: Scene);
  131264. /**
  131265. * Registers the component in a given scene
  131266. */
  131267. register(): void;
  131268. /**
  131269. * Rebuilds the elements related to this component in case of
  131270. * context lost for instance.
  131271. */
  131272. rebuild(): void;
  131273. /**
  131274. * Disposes the component and the associated ressources
  131275. */
  131276. dispose(): void;
  131277. private _gatherRenderTargets;
  131278. private _gatherActiveCameraRenderTargets;
  131279. }
  131280. }
  131281. declare module BABYLON {
  131282. /** @hidden */
  131283. export var outlinePixelShader: {
  131284. name: string;
  131285. shader: string;
  131286. };
  131287. }
  131288. declare module BABYLON {
  131289. /** @hidden */
  131290. export var outlineVertexShader: {
  131291. name: string;
  131292. shader: string;
  131293. };
  131294. }
  131295. declare module BABYLON {
  131296. interface Scene {
  131297. /** @hidden */
  131298. _outlineRenderer: OutlineRenderer;
  131299. /**
  131300. * Gets the outline renderer associated with the scene
  131301. * @returns a OutlineRenderer
  131302. */
  131303. getOutlineRenderer(): OutlineRenderer;
  131304. }
  131305. interface AbstractMesh {
  131306. /** @hidden (Backing field) */
  131307. _renderOutline: boolean;
  131308. /**
  131309. * Gets or sets a boolean indicating if the outline must be rendered as well
  131310. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  131311. */
  131312. renderOutline: boolean;
  131313. /** @hidden (Backing field) */
  131314. _renderOverlay: boolean;
  131315. /**
  131316. * Gets or sets a boolean indicating if the overlay must be rendered as well
  131317. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  131318. */
  131319. renderOverlay: boolean;
  131320. }
  131321. /**
  131322. * This class is responsible to draw bothe outline/overlay of meshes.
  131323. * It should not be used directly but through the available method on mesh.
  131324. */
  131325. export class OutlineRenderer implements ISceneComponent {
  131326. /**
  131327. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  131328. */
  131329. private static _StencilReference;
  131330. /**
  131331. * The name of the component. Each component must have a unique name.
  131332. */
  131333. name: string;
  131334. /**
  131335. * The scene the component belongs to.
  131336. */
  131337. scene: Scene;
  131338. /**
  131339. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  131340. */
  131341. zOffset: number;
  131342. private _engine;
  131343. private _effect;
  131344. private _cachedDefines;
  131345. private _savedDepthWrite;
  131346. /**
  131347. * Instantiates a new outline renderer. (There could be only one per scene).
  131348. * @param scene Defines the scene it belongs to
  131349. */
  131350. constructor(scene: Scene);
  131351. /**
  131352. * Register the component to one instance of a scene.
  131353. */
  131354. register(): void;
  131355. /**
  131356. * Rebuilds the elements related to this component in case of
  131357. * context lost for instance.
  131358. */
  131359. rebuild(): void;
  131360. /**
  131361. * Disposes the component and the associated ressources.
  131362. */
  131363. dispose(): void;
  131364. /**
  131365. * Renders the outline in the canvas.
  131366. * @param subMesh Defines the sumesh to render
  131367. * @param batch Defines the batch of meshes in case of instances
  131368. * @param useOverlay Defines if the rendering is for the overlay or the outline
  131369. */
  131370. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  131371. /**
  131372. * Returns whether or not the outline renderer is ready for a given submesh.
  131373. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  131374. * @param subMesh Defines the submesh to check readyness for
  131375. * @param useInstances Defines wheter wee are trying to render instances or not
  131376. * @returns true if ready otherwise false
  131377. */
  131378. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  131379. private _beforeRenderingMesh;
  131380. private _afterRenderingMesh;
  131381. }
  131382. }
  131383. declare module BABYLON {
  131384. /**
  131385. * Class used to manage multiple sprites of different sizes on the same spritesheet
  131386. * @see http://doc.babylonjs.com/babylon101/sprites
  131387. */
  131388. export class SpritePackedManager extends SpriteManager {
  131389. /** defines the packed manager's name */
  131390. name: string;
  131391. /**
  131392. * Creates a new sprite manager from a packed sprite sheet
  131393. * @param name defines the manager's name
  131394. * @param imgUrl defines the sprite sheet url
  131395. * @param capacity defines the maximum allowed number of sprites
  131396. * @param scene defines the hosting scene
  131397. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  131398. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  131399. * @param samplingMode defines the smapling mode to use with spritesheet
  131400. * @param fromPacked set to true; do not alter
  131401. */
  131402. constructor(
  131403. /** defines the packed manager's name */
  131404. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  131405. }
  131406. }
  131407. declare module BABYLON {
  131408. /**
  131409. * Defines the list of states available for a task inside a AssetsManager
  131410. */
  131411. export enum AssetTaskState {
  131412. /**
  131413. * Initialization
  131414. */
  131415. INIT = 0,
  131416. /**
  131417. * Running
  131418. */
  131419. RUNNING = 1,
  131420. /**
  131421. * Done
  131422. */
  131423. DONE = 2,
  131424. /**
  131425. * Error
  131426. */
  131427. ERROR = 3
  131428. }
  131429. /**
  131430. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  131431. */
  131432. export abstract class AbstractAssetTask {
  131433. /**
  131434. * Task name
  131435. */ name: string;
  131436. /**
  131437. * Callback called when the task is successful
  131438. */
  131439. onSuccess: (task: any) => void;
  131440. /**
  131441. * Callback called when the task is not successful
  131442. */
  131443. onError: (task: any, message?: string, exception?: any) => void;
  131444. /**
  131445. * Creates a new AssetsManager
  131446. * @param name defines the name of the task
  131447. */
  131448. constructor(
  131449. /**
  131450. * Task name
  131451. */ name: string);
  131452. private _isCompleted;
  131453. private _taskState;
  131454. private _errorObject;
  131455. /**
  131456. * Get if the task is completed
  131457. */
  131458. readonly isCompleted: boolean;
  131459. /**
  131460. * Gets the current state of the task
  131461. */
  131462. readonly taskState: AssetTaskState;
  131463. /**
  131464. * Gets the current error object (if task is in error)
  131465. */
  131466. readonly errorObject: {
  131467. message?: string;
  131468. exception?: any;
  131469. };
  131470. /**
  131471. * Internal only
  131472. * @hidden
  131473. */
  131474. _setErrorObject(message?: string, exception?: any): void;
  131475. /**
  131476. * Execute the current task
  131477. * @param scene defines the scene where you want your assets to be loaded
  131478. * @param onSuccess is a callback called when the task is successfully executed
  131479. * @param onError is a callback called if an error occurs
  131480. */
  131481. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131482. /**
  131483. * Execute the current task
  131484. * @param scene defines the scene where you want your assets to be loaded
  131485. * @param onSuccess is a callback called when the task is successfully executed
  131486. * @param onError is a callback called if an error occurs
  131487. */
  131488. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131489. /**
  131490. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  131491. * This can be used with failed tasks that have the reason for failure fixed.
  131492. */
  131493. reset(): void;
  131494. private onErrorCallback;
  131495. private onDoneCallback;
  131496. }
  131497. /**
  131498. * Define the interface used by progress events raised during assets loading
  131499. */
  131500. export interface IAssetsProgressEvent {
  131501. /**
  131502. * Defines the number of remaining tasks to process
  131503. */
  131504. remainingCount: number;
  131505. /**
  131506. * Defines the total number of tasks
  131507. */
  131508. totalCount: number;
  131509. /**
  131510. * Defines the task that was just processed
  131511. */
  131512. task: AbstractAssetTask;
  131513. }
  131514. /**
  131515. * Class used to share progress information about assets loading
  131516. */
  131517. export class AssetsProgressEvent implements IAssetsProgressEvent {
  131518. /**
  131519. * Defines the number of remaining tasks to process
  131520. */
  131521. remainingCount: number;
  131522. /**
  131523. * Defines the total number of tasks
  131524. */
  131525. totalCount: number;
  131526. /**
  131527. * Defines the task that was just processed
  131528. */
  131529. task: AbstractAssetTask;
  131530. /**
  131531. * Creates a AssetsProgressEvent
  131532. * @param remainingCount defines the number of remaining tasks to process
  131533. * @param totalCount defines the total number of tasks
  131534. * @param task defines the task that was just processed
  131535. */
  131536. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  131537. }
  131538. /**
  131539. * Define a task used by AssetsManager to load meshes
  131540. */
  131541. export class MeshAssetTask extends AbstractAssetTask {
  131542. /**
  131543. * Defines the name of the task
  131544. */
  131545. name: string;
  131546. /**
  131547. * Defines the list of mesh's names you want to load
  131548. */
  131549. meshesNames: any;
  131550. /**
  131551. * Defines the root url to use as a base to load your meshes and associated resources
  131552. */
  131553. rootUrl: string;
  131554. /**
  131555. * Defines the filename of the scene to load from
  131556. */
  131557. sceneFilename: string;
  131558. /**
  131559. * Gets the list of loaded meshes
  131560. */
  131561. loadedMeshes: Array<AbstractMesh>;
  131562. /**
  131563. * Gets the list of loaded particle systems
  131564. */
  131565. loadedParticleSystems: Array<IParticleSystem>;
  131566. /**
  131567. * Gets the list of loaded skeletons
  131568. */
  131569. loadedSkeletons: Array<Skeleton>;
  131570. /**
  131571. * Gets the list of loaded animation groups
  131572. */
  131573. loadedAnimationGroups: Array<AnimationGroup>;
  131574. /**
  131575. * Callback called when the task is successful
  131576. */
  131577. onSuccess: (task: MeshAssetTask) => void;
  131578. /**
  131579. * Callback called when the task is successful
  131580. */
  131581. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  131582. /**
  131583. * Creates a new MeshAssetTask
  131584. * @param name defines the name of the task
  131585. * @param meshesNames defines the list of mesh's names you want to load
  131586. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  131587. * @param sceneFilename defines the filename of the scene to load from
  131588. */
  131589. constructor(
  131590. /**
  131591. * Defines the name of the task
  131592. */
  131593. name: string,
  131594. /**
  131595. * Defines the list of mesh's names you want to load
  131596. */
  131597. meshesNames: any,
  131598. /**
  131599. * Defines the root url to use as a base to load your meshes and associated resources
  131600. */
  131601. rootUrl: string,
  131602. /**
  131603. * Defines the filename of the scene to load from
  131604. */
  131605. sceneFilename: string);
  131606. /**
  131607. * Execute the current task
  131608. * @param scene defines the scene where you want your assets to be loaded
  131609. * @param onSuccess is a callback called when the task is successfully executed
  131610. * @param onError is a callback called if an error occurs
  131611. */
  131612. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131613. }
  131614. /**
  131615. * Define a task used by AssetsManager to load text content
  131616. */
  131617. export class TextFileAssetTask extends AbstractAssetTask {
  131618. /**
  131619. * Defines the name of the task
  131620. */
  131621. name: string;
  131622. /**
  131623. * Defines the location of the file to load
  131624. */
  131625. url: string;
  131626. /**
  131627. * Gets the loaded text string
  131628. */
  131629. text: string;
  131630. /**
  131631. * Callback called when the task is successful
  131632. */
  131633. onSuccess: (task: TextFileAssetTask) => void;
  131634. /**
  131635. * Callback called when the task is successful
  131636. */
  131637. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  131638. /**
  131639. * Creates a new TextFileAssetTask object
  131640. * @param name defines the name of the task
  131641. * @param url defines the location of the file to load
  131642. */
  131643. constructor(
  131644. /**
  131645. * Defines the name of the task
  131646. */
  131647. name: string,
  131648. /**
  131649. * Defines the location of the file to load
  131650. */
  131651. url: string);
  131652. /**
  131653. * Execute the current task
  131654. * @param scene defines the scene where you want your assets to be loaded
  131655. * @param onSuccess is a callback called when the task is successfully executed
  131656. * @param onError is a callback called if an error occurs
  131657. */
  131658. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131659. }
  131660. /**
  131661. * Define a task used by AssetsManager to load binary data
  131662. */
  131663. export class BinaryFileAssetTask extends AbstractAssetTask {
  131664. /**
  131665. * Defines the name of the task
  131666. */
  131667. name: string;
  131668. /**
  131669. * Defines the location of the file to load
  131670. */
  131671. url: string;
  131672. /**
  131673. * Gets the lodaded data (as an array buffer)
  131674. */
  131675. data: ArrayBuffer;
  131676. /**
  131677. * Callback called when the task is successful
  131678. */
  131679. onSuccess: (task: BinaryFileAssetTask) => void;
  131680. /**
  131681. * Callback called when the task is successful
  131682. */
  131683. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  131684. /**
  131685. * Creates a new BinaryFileAssetTask object
  131686. * @param name defines the name of the new task
  131687. * @param url defines the location of the file to load
  131688. */
  131689. constructor(
  131690. /**
  131691. * Defines the name of the task
  131692. */
  131693. name: string,
  131694. /**
  131695. * Defines the location of the file to load
  131696. */
  131697. url: string);
  131698. /**
  131699. * Execute the current task
  131700. * @param scene defines the scene where you want your assets to be loaded
  131701. * @param onSuccess is a callback called when the task is successfully executed
  131702. * @param onError is a callback called if an error occurs
  131703. */
  131704. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131705. }
  131706. /**
  131707. * Define a task used by AssetsManager to load images
  131708. */
  131709. export class ImageAssetTask extends AbstractAssetTask {
  131710. /**
  131711. * Defines the name of the task
  131712. */
  131713. name: string;
  131714. /**
  131715. * Defines the location of the image to load
  131716. */
  131717. url: string;
  131718. /**
  131719. * Gets the loaded images
  131720. */
  131721. image: HTMLImageElement;
  131722. /**
  131723. * Callback called when the task is successful
  131724. */
  131725. onSuccess: (task: ImageAssetTask) => void;
  131726. /**
  131727. * Callback called when the task is successful
  131728. */
  131729. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  131730. /**
  131731. * Creates a new ImageAssetTask
  131732. * @param name defines the name of the task
  131733. * @param url defines the location of the image to load
  131734. */
  131735. constructor(
  131736. /**
  131737. * Defines the name of the task
  131738. */
  131739. name: string,
  131740. /**
  131741. * Defines the location of the image to load
  131742. */
  131743. url: string);
  131744. /**
  131745. * Execute the current task
  131746. * @param scene defines the scene where you want your assets to be loaded
  131747. * @param onSuccess is a callback called when the task is successfully executed
  131748. * @param onError is a callback called if an error occurs
  131749. */
  131750. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131751. }
  131752. /**
  131753. * Defines the interface used by texture loading tasks
  131754. */
  131755. export interface ITextureAssetTask<TEX extends BaseTexture> {
  131756. /**
  131757. * Gets the loaded texture
  131758. */
  131759. texture: TEX;
  131760. }
  131761. /**
  131762. * Define a task used by AssetsManager to load 2D textures
  131763. */
  131764. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  131765. /**
  131766. * Defines the name of the task
  131767. */
  131768. name: string;
  131769. /**
  131770. * Defines the location of the file to load
  131771. */
  131772. url: string;
  131773. /**
  131774. * Defines if mipmap should not be generated (default is false)
  131775. */
  131776. noMipmap?: boolean | undefined;
  131777. /**
  131778. * Defines if texture must be inverted on Y axis (default is false)
  131779. */
  131780. invertY?: boolean | undefined;
  131781. /**
  131782. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131783. */
  131784. samplingMode: number;
  131785. /**
  131786. * Gets the loaded texture
  131787. */
  131788. texture: Texture;
  131789. /**
  131790. * Callback called when the task is successful
  131791. */
  131792. onSuccess: (task: TextureAssetTask) => void;
  131793. /**
  131794. * Callback called when the task is successful
  131795. */
  131796. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  131797. /**
  131798. * Creates a new TextureAssetTask object
  131799. * @param name defines the name of the task
  131800. * @param url defines the location of the file to load
  131801. * @param noMipmap defines if mipmap should not be generated (default is false)
  131802. * @param invertY defines if texture must be inverted on Y axis (default is false)
  131803. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131804. */
  131805. constructor(
  131806. /**
  131807. * Defines the name of the task
  131808. */
  131809. name: string,
  131810. /**
  131811. * Defines the location of the file to load
  131812. */
  131813. url: string,
  131814. /**
  131815. * Defines if mipmap should not be generated (default is false)
  131816. */
  131817. noMipmap?: boolean | undefined,
  131818. /**
  131819. * Defines if texture must be inverted on Y axis (default is false)
  131820. */
  131821. invertY?: boolean | undefined,
  131822. /**
  131823. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131824. */
  131825. samplingMode?: number);
  131826. /**
  131827. * Execute the current task
  131828. * @param scene defines the scene where you want your assets to be loaded
  131829. * @param onSuccess is a callback called when the task is successfully executed
  131830. * @param onError is a callback called if an error occurs
  131831. */
  131832. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131833. }
  131834. /**
  131835. * Define a task used by AssetsManager to load cube textures
  131836. */
  131837. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  131838. /**
  131839. * Defines the name of the task
  131840. */
  131841. name: string;
  131842. /**
  131843. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131844. */
  131845. url: string;
  131846. /**
  131847. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131848. */
  131849. extensions?: string[] | undefined;
  131850. /**
  131851. * Defines if mipmaps should not be generated (default is false)
  131852. */
  131853. noMipmap?: boolean | undefined;
  131854. /**
  131855. * Defines the explicit list of files (undefined by default)
  131856. */
  131857. files?: string[] | undefined;
  131858. /**
  131859. * Gets the loaded texture
  131860. */
  131861. texture: CubeTexture;
  131862. /**
  131863. * Callback called when the task is successful
  131864. */
  131865. onSuccess: (task: CubeTextureAssetTask) => void;
  131866. /**
  131867. * Callback called when the task is successful
  131868. */
  131869. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  131870. /**
  131871. * Creates a new CubeTextureAssetTask
  131872. * @param name defines the name of the task
  131873. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131874. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131875. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131876. * @param files defines the explicit list of files (undefined by default)
  131877. */
  131878. constructor(
  131879. /**
  131880. * Defines the name of the task
  131881. */
  131882. name: string,
  131883. /**
  131884. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  131885. */
  131886. url: string,
  131887. /**
  131888. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  131889. */
  131890. extensions?: string[] | undefined,
  131891. /**
  131892. * Defines if mipmaps should not be generated (default is false)
  131893. */
  131894. noMipmap?: boolean | undefined,
  131895. /**
  131896. * Defines the explicit list of files (undefined by default)
  131897. */
  131898. files?: string[] | undefined);
  131899. /**
  131900. * Execute the current task
  131901. * @param scene defines the scene where you want your assets to be loaded
  131902. * @param onSuccess is a callback called when the task is successfully executed
  131903. * @param onError is a callback called if an error occurs
  131904. */
  131905. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131906. }
  131907. /**
  131908. * Define a task used by AssetsManager to load HDR cube textures
  131909. */
  131910. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  131911. /**
  131912. * Defines the name of the task
  131913. */
  131914. name: string;
  131915. /**
  131916. * Defines the location of the file to load
  131917. */
  131918. url: string;
  131919. /**
  131920. * Defines the desired size (the more it increases the longer the generation will be)
  131921. */
  131922. size: number;
  131923. /**
  131924. * Defines if mipmaps should not be generated (default is false)
  131925. */
  131926. noMipmap: boolean;
  131927. /**
  131928. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131929. */
  131930. generateHarmonics: boolean;
  131931. /**
  131932. * 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)
  131933. */
  131934. gammaSpace: boolean;
  131935. /**
  131936. * Internal Use Only
  131937. */
  131938. reserved: boolean;
  131939. /**
  131940. * Gets the loaded texture
  131941. */
  131942. texture: HDRCubeTexture;
  131943. /**
  131944. * Callback called when the task is successful
  131945. */
  131946. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  131947. /**
  131948. * Callback called when the task is successful
  131949. */
  131950. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  131951. /**
  131952. * Creates a new HDRCubeTextureAssetTask object
  131953. * @param name defines the name of the task
  131954. * @param url defines the location of the file to load
  131955. * @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.
  131956. * @param noMipmap defines if mipmaps should not be generated (default is false)
  131957. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131958. * @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)
  131959. * @param reserved Internal use only
  131960. */
  131961. constructor(
  131962. /**
  131963. * Defines the name of the task
  131964. */
  131965. name: string,
  131966. /**
  131967. * Defines the location of the file to load
  131968. */
  131969. url: string,
  131970. /**
  131971. * Defines the desired size (the more it increases the longer the generation will be)
  131972. */
  131973. size: number,
  131974. /**
  131975. * Defines if mipmaps should not be generated (default is false)
  131976. */
  131977. noMipmap?: boolean,
  131978. /**
  131979. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  131980. */
  131981. generateHarmonics?: boolean,
  131982. /**
  131983. * 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)
  131984. */
  131985. gammaSpace?: boolean,
  131986. /**
  131987. * Internal Use Only
  131988. */
  131989. reserved?: boolean);
  131990. /**
  131991. * Execute the current task
  131992. * @param scene defines the scene where you want your assets to be loaded
  131993. * @param onSuccess is a callback called when the task is successfully executed
  131994. * @param onError is a callback called if an error occurs
  131995. */
  131996. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  131997. }
  131998. /**
  131999. * Define a task used by AssetsManager to load Equirectangular cube textures
  132000. */
  132001. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  132002. /**
  132003. * Defines the name of the task
  132004. */
  132005. name: string;
  132006. /**
  132007. * Defines the location of the file to load
  132008. */
  132009. url: string;
  132010. /**
  132011. * Defines the desired size (the more it increases the longer the generation will be)
  132012. */
  132013. size: number;
  132014. /**
  132015. * Defines if mipmaps should not be generated (default is false)
  132016. */
  132017. noMipmap: boolean;
  132018. /**
  132019. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  132020. * but the standard material would require them in Gamma space) (default is true)
  132021. */
  132022. gammaSpace: boolean;
  132023. /**
  132024. * Gets the loaded texture
  132025. */
  132026. texture: EquiRectangularCubeTexture;
  132027. /**
  132028. * Callback called when the task is successful
  132029. */
  132030. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  132031. /**
  132032. * Callback called when the task is successful
  132033. */
  132034. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  132035. /**
  132036. * Creates a new EquiRectangularCubeTextureAssetTask object
  132037. * @param name defines the name of the task
  132038. * @param url defines the location of the file to load
  132039. * @param size defines the desired size (the more it increases the longer the generation will be)
  132040. * If the size is omitted this implies you are using a preprocessed cubemap.
  132041. * @param noMipmap defines if mipmaps should not be generated (default is false)
  132042. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  132043. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  132044. * (default is true)
  132045. */
  132046. constructor(
  132047. /**
  132048. * Defines the name of the task
  132049. */
  132050. name: string,
  132051. /**
  132052. * Defines the location of the file to load
  132053. */
  132054. url: string,
  132055. /**
  132056. * Defines the desired size (the more it increases the longer the generation will be)
  132057. */
  132058. size: number,
  132059. /**
  132060. * Defines if mipmaps should not be generated (default is false)
  132061. */
  132062. noMipmap?: boolean,
  132063. /**
  132064. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  132065. * but the standard material would require them in Gamma space) (default is true)
  132066. */
  132067. gammaSpace?: boolean);
  132068. /**
  132069. * Execute the current task
  132070. * @param scene defines the scene where you want your assets to be loaded
  132071. * @param onSuccess is a callback called when the task is successfully executed
  132072. * @param onError is a callback called if an error occurs
  132073. */
  132074. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  132075. }
  132076. /**
  132077. * This class can be used to easily import assets into a scene
  132078. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  132079. */
  132080. export class AssetsManager {
  132081. private _scene;
  132082. private _isLoading;
  132083. protected _tasks: AbstractAssetTask[];
  132084. protected _waitingTasksCount: number;
  132085. protected _totalTasksCount: number;
  132086. /**
  132087. * Callback called when all tasks are processed
  132088. */
  132089. onFinish: (tasks: AbstractAssetTask[]) => void;
  132090. /**
  132091. * Callback called when a task is successful
  132092. */
  132093. onTaskSuccess: (task: AbstractAssetTask) => void;
  132094. /**
  132095. * Callback called when a task had an error
  132096. */
  132097. onTaskError: (task: AbstractAssetTask) => void;
  132098. /**
  132099. * Callback called when a task is done (whatever the result is)
  132100. */
  132101. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  132102. /**
  132103. * Observable called when all tasks are processed
  132104. */
  132105. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  132106. /**
  132107. * Observable called when a task had an error
  132108. */
  132109. onTaskErrorObservable: Observable<AbstractAssetTask>;
  132110. /**
  132111. * Observable called when all tasks were executed
  132112. */
  132113. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  132114. /**
  132115. * Observable called when a task is done (whatever the result is)
  132116. */
  132117. onProgressObservable: Observable<IAssetsProgressEvent>;
  132118. /**
  132119. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  132120. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  132121. */
  132122. useDefaultLoadingScreen: boolean;
  132123. /**
  132124. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  132125. * when all assets have been downloaded.
  132126. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  132127. */
  132128. autoHideLoadingUI: boolean;
  132129. /**
  132130. * Creates a new AssetsManager
  132131. * @param scene defines the scene to work on
  132132. */
  132133. constructor(scene: Scene);
  132134. /**
  132135. * Add a MeshAssetTask to the list of active tasks
  132136. * @param taskName defines the name of the new task
  132137. * @param meshesNames defines the name of meshes to load
  132138. * @param rootUrl defines the root url to use to locate files
  132139. * @param sceneFilename defines the filename of the scene file
  132140. * @returns a new MeshAssetTask object
  132141. */
  132142. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  132143. /**
  132144. * Add a TextFileAssetTask to the list of active tasks
  132145. * @param taskName defines the name of the new task
  132146. * @param url defines the url of the file to load
  132147. * @returns a new TextFileAssetTask object
  132148. */
  132149. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  132150. /**
  132151. * Add a BinaryFileAssetTask to the list of active tasks
  132152. * @param taskName defines the name of the new task
  132153. * @param url defines the url of the file to load
  132154. * @returns a new BinaryFileAssetTask object
  132155. */
  132156. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  132157. /**
  132158. * Add a ImageAssetTask to the list of active tasks
  132159. * @param taskName defines the name of the new task
  132160. * @param url defines the url of the file to load
  132161. * @returns a new ImageAssetTask object
  132162. */
  132163. addImageTask(taskName: string, url: string): ImageAssetTask;
  132164. /**
  132165. * Add a TextureAssetTask to the list of active tasks
  132166. * @param taskName defines the name of the new task
  132167. * @param url defines the url of the file to load
  132168. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132169. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  132170. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  132171. * @returns a new TextureAssetTask object
  132172. */
  132173. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  132174. /**
  132175. * Add a CubeTextureAssetTask to the list of active tasks
  132176. * @param taskName defines the name of the new task
  132177. * @param url defines the url of the file to load
  132178. * @param extensions defines the extension to use to load the cube map (can be null)
  132179. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132180. * @param files defines the list of files to load (can be null)
  132181. * @returns a new CubeTextureAssetTask object
  132182. */
  132183. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  132184. /**
  132185. *
  132186. * Add a HDRCubeTextureAssetTask to the list of active tasks
  132187. * @param taskName defines the name of the new task
  132188. * @param url defines the url of the file to load
  132189. * @param size defines the size you want for the cubemap (can be null)
  132190. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132191. * @param generateHarmonics defines if you want to automatically generate (true by default)
  132192. * @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)
  132193. * @param reserved Internal use only
  132194. * @returns a new HDRCubeTextureAssetTask object
  132195. */
  132196. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  132197. /**
  132198. *
  132199. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  132200. * @param taskName defines the name of the new task
  132201. * @param url defines the url of the file to load
  132202. * @param size defines the size you want for the cubemap (can be null)
  132203. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  132204. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  132205. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  132206. * @returns a new EquiRectangularCubeTextureAssetTask object
  132207. */
  132208. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  132209. /**
  132210. * Remove a task from the assets manager.
  132211. * @param task the task to remove
  132212. */
  132213. removeTask(task: AbstractAssetTask): void;
  132214. private _decreaseWaitingTasksCount;
  132215. private _runTask;
  132216. /**
  132217. * Reset the AssetsManager and remove all tasks
  132218. * @return the current instance of the AssetsManager
  132219. */
  132220. reset(): AssetsManager;
  132221. /**
  132222. * Start the loading process
  132223. * @return the current instance of the AssetsManager
  132224. */
  132225. load(): AssetsManager;
  132226. /**
  132227. * Start the loading process as an async operation
  132228. * @return a promise returning the list of failed tasks
  132229. */
  132230. loadAsync(): Promise<void>;
  132231. }
  132232. }
  132233. declare module BABYLON {
  132234. /**
  132235. * Wrapper class for promise with external resolve and reject.
  132236. */
  132237. export class Deferred<T> {
  132238. /**
  132239. * The promise associated with this deferred object.
  132240. */
  132241. readonly promise: Promise<T>;
  132242. private _resolve;
  132243. private _reject;
  132244. /**
  132245. * The resolve method of the promise associated with this deferred object.
  132246. */
  132247. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  132248. /**
  132249. * The reject method of the promise associated with this deferred object.
  132250. */
  132251. readonly reject: (reason?: any) => void;
  132252. /**
  132253. * Constructor for this deferred object.
  132254. */
  132255. constructor();
  132256. }
  132257. }
  132258. declare module BABYLON {
  132259. /**
  132260. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  132261. */
  132262. export class MeshExploder {
  132263. private _centerMesh;
  132264. private _meshes;
  132265. private _meshesOrigins;
  132266. private _toCenterVectors;
  132267. private _scaledDirection;
  132268. private _newPosition;
  132269. private _centerPosition;
  132270. /**
  132271. * Explodes meshes from a center mesh.
  132272. * @param meshes The meshes to explode.
  132273. * @param centerMesh The mesh to be center of explosion.
  132274. */
  132275. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  132276. private _setCenterMesh;
  132277. /**
  132278. * Get class name
  132279. * @returns "MeshExploder"
  132280. */
  132281. getClassName(): string;
  132282. /**
  132283. * "Exploded meshes"
  132284. * @returns Array of meshes with the centerMesh at index 0.
  132285. */
  132286. getMeshes(): Array<Mesh>;
  132287. /**
  132288. * Explodes meshes giving a specific direction
  132289. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  132290. */
  132291. explode(direction?: number): void;
  132292. }
  132293. }
  132294. declare module BABYLON {
  132295. /**
  132296. * Class used to help managing file picking and drag'n'drop
  132297. */
  132298. export class FilesInput {
  132299. /**
  132300. * List of files ready to be loaded
  132301. */
  132302. static readonly FilesToLoad: {
  132303. [key: string]: File;
  132304. };
  132305. /**
  132306. * Callback called when a file is processed
  132307. */
  132308. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  132309. private _engine;
  132310. private _currentScene;
  132311. private _sceneLoadedCallback;
  132312. private _progressCallback;
  132313. private _additionalRenderLoopLogicCallback;
  132314. private _textureLoadingCallback;
  132315. private _startingProcessingFilesCallback;
  132316. private _onReloadCallback;
  132317. private _errorCallback;
  132318. private _elementToMonitor;
  132319. private _sceneFileToLoad;
  132320. private _filesToLoad;
  132321. /**
  132322. * Creates a new FilesInput
  132323. * @param engine defines the rendering engine
  132324. * @param scene defines the hosting scene
  132325. * @param sceneLoadedCallback callback called when scene is loaded
  132326. * @param progressCallback callback called to track progress
  132327. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  132328. * @param textureLoadingCallback callback called when a texture is loading
  132329. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  132330. * @param onReloadCallback callback called when a reload is requested
  132331. * @param errorCallback callback call if an error occurs
  132332. */
  132333. 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);
  132334. private _dragEnterHandler;
  132335. private _dragOverHandler;
  132336. private _dropHandler;
  132337. /**
  132338. * Calls this function to listen to drag'n'drop events on a specific DOM element
  132339. * @param elementToMonitor defines the DOM element to track
  132340. */
  132341. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  132342. /**
  132343. * Release all associated resources
  132344. */
  132345. dispose(): void;
  132346. private renderFunction;
  132347. private drag;
  132348. private drop;
  132349. private _traverseFolder;
  132350. private _processFiles;
  132351. /**
  132352. * Load files from a drop event
  132353. * @param event defines the drop event to use as source
  132354. */
  132355. loadFiles(event: any): void;
  132356. private _processReload;
  132357. /**
  132358. * Reload the current scene from the loaded files
  132359. */
  132360. reload(): void;
  132361. }
  132362. }
  132363. declare module BABYLON {
  132364. /**
  132365. * Defines the root class used to create scene optimization to use with SceneOptimizer
  132366. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132367. */
  132368. export class SceneOptimization {
  132369. /**
  132370. * Defines the priority of this optimization (0 by default which means first in the list)
  132371. */
  132372. priority: number;
  132373. /**
  132374. * Gets a string describing the action executed by the current optimization
  132375. * @returns description string
  132376. */
  132377. getDescription(): string;
  132378. /**
  132379. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132380. * @param scene defines the current scene where to apply this optimization
  132381. * @param optimizer defines the current optimizer
  132382. * @returns true if everything that can be done was applied
  132383. */
  132384. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132385. /**
  132386. * Creates the SceneOptimization object
  132387. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132388. * @param desc defines the description associated with the optimization
  132389. */
  132390. constructor(
  132391. /**
  132392. * Defines the priority of this optimization (0 by default which means first in the list)
  132393. */
  132394. priority?: number);
  132395. }
  132396. /**
  132397. * Defines an optimization used to reduce the size of render target textures
  132398. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132399. */
  132400. export class TextureOptimization extends SceneOptimization {
  132401. /**
  132402. * Defines the priority of this optimization (0 by default which means first in the list)
  132403. */
  132404. priority: number;
  132405. /**
  132406. * 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
  132407. */
  132408. maximumSize: number;
  132409. /**
  132410. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132411. */
  132412. step: number;
  132413. /**
  132414. * Gets a string describing the action executed by the current optimization
  132415. * @returns description string
  132416. */
  132417. getDescription(): string;
  132418. /**
  132419. * Creates the TextureOptimization object
  132420. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132421. * @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
  132422. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132423. */
  132424. constructor(
  132425. /**
  132426. * Defines the priority of this optimization (0 by default which means first in the list)
  132427. */
  132428. priority?: number,
  132429. /**
  132430. * 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
  132431. */
  132432. maximumSize?: number,
  132433. /**
  132434. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  132435. */
  132436. step?: number);
  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 increase or decrease the rendering resolution
  132447. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132448. */
  132449. export class HardwareScalingOptimization extends SceneOptimization {
  132450. /**
  132451. * Defines the priority of this optimization (0 by default which means first in the list)
  132452. */
  132453. priority: number;
  132454. /**
  132455. * Defines the maximum scale to use (2 by default)
  132456. */
  132457. maximumScale: number;
  132458. /**
  132459. * Defines the step to use between two passes (0.5 by default)
  132460. */
  132461. step: number;
  132462. private _currentScale;
  132463. private _directionOffset;
  132464. /**
  132465. * Gets a string describing the action executed by the current optimization
  132466. * @return description string
  132467. */
  132468. getDescription(): string;
  132469. /**
  132470. * Creates the HardwareScalingOptimization object
  132471. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132472. * @param maximumScale defines the maximum scale to use (2 by default)
  132473. * @param step defines the step to use between two passes (0.5 by default)
  132474. */
  132475. constructor(
  132476. /**
  132477. * Defines the priority of this optimization (0 by default which means first in the list)
  132478. */
  132479. priority?: number,
  132480. /**
  132481. * Defines the maximum scale to use (2 by default)
  132482. */
  132483. maximumScale?: number,
  132484. /**
  132485. * Defines the step to use between two passes (0.5 by default)
  132486. */
  132487. step?: number);
  132488. /**
  132489. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132490. * @param scene defines the current scene where to apply this optimization
  132491. * @param optimizer defines the current optimizer
  132492. * @returns true if everything that can be done was applied
  132493. */
  132494. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132495. }
  132496. /**
  132497. * Defines an optimization used to remove shadows
  132498. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132499. */
  132500. export class ShadowsOptimization extends SceneOptimization {
  132501. /**
  132502. * Gets a string describing the action executed by the current optimization
  132503. * @return description string
  132504. */
  132505. getDescription(): string;
  132506. /**
  132507. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132508. * @param scene defines the current scene where to apply this optimization
  132509. * @param optimizer defines the current optimizer
  132510. * @returns true if everything that can be done was applied
  132511. */
  132512. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132513. }
  132514. /**
  132515. * Defines an optimization used to turn post-processes off
  132516. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132517. */
  132518. export class PostProcessesOptimization extends SceneOptimization {
  132519. /**
  132520. * Gets a string describing the action executed by the current optimization
  132521. * @return description string
  132522. */
  132523. getDescription(): string;
  132524. /**
  132525. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132526. * @param scene defines the current scene where to apply this optimization
  132527. * @param optimizer defines the current optimizer
  132528. * @returns true if everything that can be done was applied
  132529. */
  132530. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132531. }
  132532. /**
  132533. * Defines an optimization used to turn lens flares off
  132534. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132535. */
  132536. export class LensFlaresOptimization extends SceneOptimization {
  132537. /**
  132538. * Gets a string describing the action executed by the current optimization
  132539. * @return description string
  132540. */
  132541. getDescription(): string;
  132542. /**
  132543. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132544. * @param scene defines the current scene where to apply this optimization
  132545. * @param optimizer defines the current optimizer
  132546. * @returns true if everything that can be done was applied
  132547. */
  132548. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132549. }
  132550. /**
  132551. * Defines an optimization based on user defined callback.
  132552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132553. */
  132554. export class CustomOptimization extends SceneOptimization {
  132555. /**
  132556. * Callback called to apply the custom optimization.
  132557. */
  132558. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  132559. /**
  132560. * Callback called to get custom description
  132561. */
  132562. onGetDescription: () => string;
  132563. /**
  132564. * Gets a string describing the action executed by the current optimization
  132565. * @returns description string
  132566. */
  132567. getDescription(): string;
  132568. /**
  132569. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132570. * @param scene defines the current scene where to apply this optimization
  132571. * @param optimizer defines the current optimizer
  132572. * @returns true if everything that can be done was applied
  132573. */
  132574. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132575. }
  132576. /**
  132577. * Defines an optimization used to turn particles off
  132578. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132579. */
  132580. export class ParticlesOptimization extends SceneOptimization {
  132581. /**
  132582. * Gets a string describing the action executed by the current optimization
  132583. * @return description string
  132584. */
  132585. getDescription(): string;
  132586. /**
  132587. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132588. * @param scene defines the current scene where to apply this optimization
  132589. * @param optimizer defines the current optimizer
  132590. * @returns true if everything that can be done was applied
  132591. */
  132592. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132593. }
  132594. /**
  132595. * Defines an optimization used to turn render targets off
  132596. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132597. */
  132598. export class RenderTargetsOptimization extends SceneOptimization {
  132599. /**
  132600. * Gets a string describing the action executed by the current optimization
  132601. * @return description string
  132602. */
  132603. getDescription(): string;
  132604. /**
  132605. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132606. * @param scene defines the current scene where to apply this optimization
  132607. * @param optimizer defines the current optimizer
  132608. * @returns true if everything that can be done was applied
  132609. */
  132610. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  132611. }
  132612. /**
  132613. * Defines an optimization used to merge meshes with compatible materials
  132614. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132615. */
  132616. export class MergeMeshesOptimization extends SceneOptimization {
  132617. private static _UpdateSelectionTree;
  132618. /**
  132619. * Gets or sets a boolean which defines if optimization octree has to be updated
  132620. */
  132621. /**
  132622. * Gets or sets a boolean which defines if optimization octree has to be updated
  132623. */
  132624. static UpdateSelectionTree: boolean;
  132625. /**
  132626. * Gets a string describing the action executed by the current optimization
  132627. * @return description string
  132628. */
  132629. getDescription(): string;
  132630. private _canBeMerged;
  132631. /**
  132632. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  132633. * @param scene defines the current scene where to apply this optimization
  132634. * @param optimizer defines the current optimizer
  132635. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  132636. * @returns true if everything that can be done was applied
  132637. */
  132638. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  132639. }
  132640. /**
  132641. * Defines a list of options used by SceneOptimizer
  132642. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132643. */
  132644. export class SceneOptimizerOptions {
  132645. /**
  132646. * Defines the target frame rate to reach (60 by default)
  132647. */
  132648. targetFrameRate: number;
  132649. /**
  132650. * Defines the interval between two checkes (2000ms by default)
  132651. */
  132652. trackerDuration: number;
  132653. /**
  132654. * Gets the list of optimizations to apply
  132655. */
  132656. optimizations: SceneOptimization[];
  132657. /**
  132658. * Creates a new list of options used by SceneOptimizer
  132659. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  132660. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  132661. */
  132662. constructor(
  132663. /**
  132664. * Defines the target frame rate to reach (60 by default)
  132665. */
  132666. targetFrameRate?: number,
  132667. /**
  132668. * Defines the interval between two checkes (2000ms by default)
  132669. */
  132670. trackerDuration?: number);
  132671. /**
  132672. * Add a new optimization
  132673. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  132674. * @returns the current SceneOptimizerOptions
  132675. */
  132676. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  132677. /**
  132678. * Add a new custom optimization
  132679. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  132680. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  132681. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  132682. * @returns the current SceneOptimizerOptions
  132683. */
  132684. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  132685. /**
  132686. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  132687. * @param targetFrameRate defines the target frame rate (60 by default)
  132688. * @returns a SceneOptimizerOptions object
  132689. */
  132690. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132691. /**
  132692. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  132693. * @param targetFrameRate defines the target frame rate (60 by default)
  132694. * @returns a SceneOptimizerOptions object
  132695. */
  132696. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132697. /**
  132698. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  132699. * @param targetFrameRate defines the target frame rate (60 by default)
  132700. * @returns a SceneOptimizerOptions object
  132701. */
  132702. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  132703. }
  132704. /**
  132705. * Class used to run optimizations in order to reach a target frame rate
  132706. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  132707. */
  132708. export class SceneOptimizer implements IDisposable {
  132709. private _isRunning;
  132710. private _options;
  132711. private _scene;
  132712. private _currentPriorityLevel;
  132713. private _targetFrameRate;
  132714. private _trackerDuration;
  132715. private _currentFrameRate;
  132716. private _sceneDisposeObserver;
  132717. private _improvementMode;
  132718. /**
  132719. * Defines an observable called when the optimizer reaches the target frame rate
  132720. */
  132721. onSuccessObservable: Observable<SceneOptimizer>;
  132722. /**
  132723. * Defines an observable called when the optimizer enables an optimization
  132724. */
  132725. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  132726. /**
  132727. * Defines an observable called when the optimizer is not able to reach the target frame rate
  132728. */
  132729. onFailureObservable: Observable<SceneOptimizer>;
  132730. /**
  132731. * Gets a boolean indicating if the optimizer is in improvement mode
  132732. */
  132733. readonly isInImprovementMode: boolean;
  132734. /**
  132735. * Gets the current priority level (0 at start)
  132736. */
  132737. readonly currentPriorityLevel: number;
  132738. /**
  132739. * Gets the current frame rate checked by the SceneOptimizer
  132740. */
  132741. readonly currentFrameRate: number;
  132742. /**
  132743. * Gets or sets the current target frame rate (60 by default)
  132744. */
  132745. /**
  132746. * Gets or sets the current target frame rate (60 by default)
  132747. */
  132748. targetFrameRate: number;
  132749. /**
  132750. * Gets or sets the current interval between two checks (every 2000ms by default)
  132751. */
  132752. /**
  132753. * Gets or sets the current interval between two checks (every 2000ms by default)
  132754. */
  132755. trackerDuration: number;
  132756. /**
  132757. * Gets the list of active optimizations
  132758. */
  132759. readonly optimizations: SceneOptimization[];
  132760. /**
  132761. * Creates a new SceneOptimizer
  132762. * @param scene defines the scene to work on
  132763. * @param options defines the options to use with the SceneOptimizer
  132764. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  132765. * @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)
  132766. */
  132767. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  132768. /**
  132769. * Stops the current optimizer
  132770. */
  132771. stop(): void;
  132772. /**
  132773. * Reset the optimizer to initial step (current priority level = 0)
  132774. */
  132775. reset(): void;
  132776. /**
  132777. * Start the optimizer. By default it will try to reach a specific framerate
  132778. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  132779. */
  132780. start(): void;
  132781. private _checkCurrentState;
  132782. /**
  132783. * Release all resources
  132784. */
  132785. dispose(): void;
  132786. /**
  132787. * Helper function to create a SceneOptimizer with one single line of code
  132788. * @param scene defines the scene to work on
  132789. * @param options defines the options to use with the SceneOptimizer
  132790. * @param onSuccess defines a callback to call on success
  132791. * @param onFailure defines a callback to call on failure
  132792. * @returns the new SceneOptimizer object
  132793. */
  132794. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  132795. }
  132796. }
  132797. declare module BABYLON {
  132798. /**
  132799. * Class used to serialize a scene into a string
  132800. */
  132801. export class SceneSerializer {
  132802. /**
  132803. * Clear cache used by a previous serialization
  132804. */
  132805. static ClearCache(): void;
  132806. /**
  132807. * Serialize a scene into a JSON compatible object
  132808. * @param scene defines the scene to serialize
  132809. * @returns a JSON compatible object
  132810. */
  132811. static Serialize(scene: Scene): any;
  132812. /**
  132813. * Serialize a mesh into a JSON compatible object
  132814. * @param toSerialize defines the mesh to serialize
  132815. * @param withParents defines if parents must be serialized as well
  132816. * @param withChildren defines if children must be serialized as well
  132817. * @returns a JSON compatible object
  132818. */
  132819. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  132820. }
  132821. }
  132822. declare module BABYLON {
  132823. /**
  132824. * Class used to host texture specific utilities
  132825. */
  132826. export class TextureTools {
  132827. /**
  132828. * Uses the GPU to create a copy texture rescaled at a given size
  132829. * @param texture Texture to copy from
  132830. * @param width defines the desired width
  132831. * @param height defines the desired height
  132832. * @param useBilinearMode defines if bilinear mode has to be used
  132833. * @return the generated texture
  132834. */
  132835. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  132836. }
  132837. }
  132838. declare module BABYLON {
  132839. /**
  132840. * This represents the different options available for the video capture.
  132841. */
  132842. export interface VideoRecorderOptions {
  132843. /** Defines the mime type of the video. */
  132844. mimeType: string;
  132845. /** Defines the FPS the video should be recorded at. */
  132846. fps: number;
  132847. /** Defines the chunk size for the recording data. */
  132848. recordChunckSize: number;
  132849. /** The audio tracks to attach to the recording. */
  132850. audioTracks?: MediaStreamTrack[];
  132851. }
  132852. /**
  132853. * This can help with recording videos from BabylonJS.
  132854. * This is based on the available WebRTC functionalities of the browser.
  132855. *
  132856. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  132857. */
  132858. export class VideoRecorder {
  132859. private static readonly _defaultOptions;
  132860. /**
  132861. * Returns whether or not the VideoRecorder is available in your browser.
  132862. * @param engine Defines the Babylon Engine.
  132863. * @returns true if supported otherwise false.
  132864. */
  132865. static IsSupported(engine: Engine): boolean;
  132866. private readonly _options;
  132867. private _canvas;
  132868. private _mediaRecorder;
  132869. private _recordedChunks;
  132870. private _fileName;
  132871. private _resolve;
  132872. private _reject;
  132873. /**
  132874. * True when a recording is already in progress.
  132875. */
  132876. readonly isRecording: boolean;
  132877. /**
  132878. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  132879. * @param engine Defines the BabylonJS Engine you wish to record.
  132880. * @param options Defines options that can be used to customize the capture.
  132881. */
  132882. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  132883. /**
  132884. * Stops the current recording before the default capture timeout passed in the startRecording function.
  132885. */
  132886. stopRecording(): void;
  132887. /**
  132888. * Starts recording the canvas for a max duration specified in parameters.
  132889. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  132890. * If null no automatic download will start and you can rely on the promise to get the data back.
  132891. * @param maxDuration Defines the maximum recording time in seconds.
  132892. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  132893. * @return A promise callback at the end of the recording with the video data in Blob.
  132894. */
  132895. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  132896. /**
  132897. * Releases internal resources used during the recording.
  132898. */
  132899. dispose(): void;
  132900. private _handleDataAvailable;
  132901. private _handleError;
  132902. private _handleStop;
  132903. }
  132904. }
  132905. declare module BABYLON {
  132906. /**
  132907. * Class containing a set of static utilities functions for screenshots
  132908. */
  132909. export class ScreenshotTools {
  132910. /**
  132911. * Captures a screenshot of the current rendering
  132912. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132913. * @param engine defines the rendering engine
  132914. * @param camera defines the source camera
  132915. * @param size This parameter can be set to a single number or to an object with the
  132916. * following (optional) properties: precision, width, height. If a single number is passed,
  132917. * it will be used for both width and height. If an object is passed, the screenshot size
  132918. * will be derived from the parameters. The precision property is a multiplier allowing
  132919. * rendering at a higher or lower resolution
  132920. * @param successCallback defines the callback receives a single parameter which contains the
  132921. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132922. * src parameter of an <img> to display it
  132923. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132924. * Check your browser for supported MIME types
  132925. */
  132926. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  132927. /**
  132928. * Captures a screenshot of the current rendering
  132929. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132930. * @param engine defines the rendering engine
  132931. * @param camera defines the source camera
  132932. * @param size This parameter can be set to a single number or to an object with the
  132933. * following (optional) properties: precision, width, height. If a single number is passed,
  132934. * it will be used for both width and height. If an object is passed, the screenshot size
  132935. * will be derived from the parameters. The precision property is a multiplier allowing
  132936. * rendering at a higher or lower resolution
  132937. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  132938. * Check your browser for supported MIME types
  132939. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132940. * to the src parameter of an <img> to display it
  132941. */
  132942. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  132943. /**
  132944. * Generates an image screenshot from the specified camera.
  132945. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132946. * @param engine The engine to use for rendering
  132947. * @param camera The camera to use for rendering
  132948. * @param size This parameter can be set to a single number or to an object with the
  132949. * following (optional) properties: precision, width, height. If a single number is passed,
  132950. * it will be used for both width and height. If an object is passed, the screenshot size
  132951. * will be derived from the parameters. The precision property is a multiplier allowing
  132952. * rendering at a higher or lower resolution
  132953. * @param successCallback The callback receives a single parameter which contains the
  132954. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  132955. * src parameter of an <img> to display it
  132956. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132957. * Check your browser for supported MIME types
  132958. * @param samples Texture samples (default: 1)
  132959. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132960. * @param fileName A name for for the downloaded file.
  132961. */
  132962. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  132963. /**
  132964. * Generates an image screenshot from the specified camera.
  132965. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  132966. * @param engine The engine to use for rendering
  132967. * @param camera The camera to use for rendering
  132968. * @param size This parameter can be set to a single number or to an object with the
  132969. * following (optional) properties: precision, width, height. If a single number is passed,
  132970. * it will be used for both width and height. If an object is passed, the screenshot size
  132971. * will be derived from the parameters. The precision property is a multiplier allowing
  132972. * rendering at a higher or lower resolution
  132973. * @param mimeType The MIME type of the screenshot image (default: image/png).
  132974. * Check your browser for supported MIME types
  132975. * @param samples Texture samples (default: 1)
  132976. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  132977. * @param fileName A name for for the downloaded file.
  132978. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  132979. * to the src parameter of an <img> to display it
  132980. */
  132981. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  132982. /**
  132983. * Gets height and width for screenshot size
  132984. * @private
  132985. */
  132986. private static _getScreenshotSize;
  132987. }
  132988. }
  132989. declare module BABYLON {
  132990. /**
  132991. * Interface for a data buffer
  132992. */
  132993. export interface IDataBuffer {
  132994. /**
  132995. * Reads bytes from the data buffer.
  132996. * @param byteOffset The byte offset to read
  132997. * @param byteLength The byte length to read
  132998. * @returns A promise that resolves when the bytes are read
  132999. */
  133000. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  133001. /**
  133002. * The byte length of the buffer.
  133003. */
  133004. readonly byteLength: number;
  133005. }
  133006. /**
  133007. * Utility class for reading from a data buffer
  133008. */
  133009. export class DataReader {
  133010. /**
  133011. * The data buffer associated with this data reader.
  133012. */
  133013. readonly buffer: IDataBuffer;
  133014. /**
  133015. * The current byte offset from the beginning of the data buffer.
  133016. */
  133017. byteOffset: number;
  133018. private _dataView;
  133019. private _dataByteOffset;
  133020. /**
  133021. * Constructor
  133022. * @param buffer The buffer to read
  133023. */
  133024. constructor(buffer: IDataBuffer);
  133025. /**
  133026. * Loads the given byte length.
  133027. * @param byteLength The byte length to load
  133028. * @returns A promise that resolves when the load is complete
  133029. */
  133030. loadAsync(byteLength: number): Promise<void>;
  133031. /**
  133032. * Read a unsigned 32-bit integer from the currently loaded data range.
  133033. * @returns The 32-bit integer read
  133034. */
  133035. readUint32(): number;
  133036. /**
  133037. * Read a byte array from the currently loaded data range.
  133038. * @param byteLength The byte length to read
  133039. * @returns The byte array read
  133040. */
  133041. readUint8Array(byteLength: number): Uint8Array;
  133042. /**
  133043. * Read a string from the currently loaded data range.
  133044. * @param byteLength The byte length to read
  133045. * @returns The string read
  133046. */
  133047. readString(byteLength: number): string;
  133048. /**
  133049. * Skips the given byte length the currently loaded data range.
  133050. * @param byteLength The byte length to skip
  133051. */
  133052. skipBytes(byteLength: number): void;
  133053. }
  133054. }
  133055. declare module BABYLON {
  133056. /**
  133057. * A cursor which tracks a point on a path
  133058. */
  133059. export class PathCursor {
  133060. private path;
  133061. /**
  133062. * Stores path cursor callbacks for when an onchange event is triggered
  133063. */
  133064. private _onchange;
  133065. /**
  133066. * The value of the path cursor
  133067. */
  133068. value: number;
  133069. /**
  133070. * The animation array of the path cursor
  133071. */
  133072. animations: Animation[];
  133073. /**
  133074. * Initializes the path cursor
  133075. * @param path The path to track
  133076. */
  133077. constructor(path: Path2);
  133078. /**
  133079. * Gets the cursor point on the path
  133080. * @returns A point on the path cursor at the cursor location
  133081. */
  133082. getPoint(): Vector3;
  133083. /**
  133084. * Moves the cursor ahead by the step amount
  133085. * @param step The amount to move the cursor forward
  133086. * @returns This path cursor
  133087. */
  133088. moveAhead(step?: number): PathCursor;
  133089. /**
  133090. * Moves the cursor behind by the step amount
  133091. * @param step The amount to move the cursor back
  133092. * @returns This path cursor
  133093. */
  133094. moveBack(step?: number): PathCursor;
  133095. /**
  133096. * Moves the cursor by the step amount
  133097. * If the step amount is greater than one, an exception is thrown
  133098. * @param step The amount to move the cursor
  133099. * @returns This path cursor
  133100. */
  133101. move(step: number): PathCursor;
  133102. /**
  133103. * Ensures that the value is limited between zero and one
  133104. * @returns This path cursor
  133105. */
  133106. private ensureLimits;
  133107. /**
  133108. * Runs onchange callbacks on change (used by the animation engine)
  133109. * @returns This path cursor
  133110. */
  133111. private raiseOnChange;
  133112. /**
  133113. * Executes a function on change
  133114. * @param f A path cursor onchange callback
  133115. * @returns This path cursor
  133116. */
  133117. onchange(f: (cursor: PathCursor) => void): PathCursor;
  133118. }
  133119. }
  133120. declare module BABYLON {
  133121. /** @hidden */
  133122. export var blurPixelShader: {
  133123. name: string;
  133124. shader: string;
  133125. };
  133126. }
  133127. declare module BABYLON {
  133128. /** @hidden */
  133129. export var pointCloudVertexDeclaration: {
  133130. name: string;
  133131. shader: string;
  133132. };
  133133. }
  133134. // Mixins
  133135. interface Window {
  133136. mozIndexedDB: IDBFactory;
  133137. webkitIndexedDB: IDBFactory;
  133138. msIndexedDB: IDBFactory;
  133139. webkitURL: typeof URL;
  133140. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  133141. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  133142. WebGLRenderingContext: WebGLRenderingContext;
  133143. MSGesture: MSGesture;
  133144. CANNON: any;
  133145. AudioContext: AudioContext;
  133146. webkitAudioContext: AudioContext;
  133147. PointerEvent: any;
  133148. Math: Math;
  133149. Uint8Array: Uint8ArrayConstructor;
  133150. Float32Array: Float32ArrayConstructor;
  133151. mozURL: typeof URL;
  133152. msURL: typeof URL;
  133153. VRFrameData: any; // WebVR, from specs 1.1
  133154. DracoDecoderModule: any;
  133155. setImmediate(handler: (...args: any[]) => void): number;
  133156. }
  133157. interface HTMLCanvasElement {
  133158. requestPointerLock(): void;
  133159. msRequestPointerLock?(): void;
  133160. mozRequestPointerLock?(): void;
  133161. webkitRequestPointerLock?(): void;
  133162. /** Track wether a record is in progress */
  133163. isRecording: boolean;
  133164. /** Capture Stream method defined by some browsers */
  133165. captureStream(fps?: number): MediaStream;
  133166. }
  133167. interface CanvasRenderingContext2D {
  133168. msImageSmoothingEnabled: boolean;
  133169. }
  133170. interface MouseEvent {
  133171. mozMovementX: number;
  133172. mozMovementY: number;
  133173. webkitMovementX: number;
  133174. webkitMovementY: number;
  133175. msMovementX: number;
  133176. msMovementY: number;
  133177. }
  133178. interface Navigator {
  133179. mozGetVRDevices: (any: any) => any;
  133180. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  133181. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  133182. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  133183. webkitGetGamepads(): Gamepad[];
  133184. msGetGamepads(): Gamepad[];
  133185. webkitGamepads(): Gamepad[];
  133186. }
  133187. interface HTMLVideoElement {
  133188. mozSrcObject: any;
  133189. }
  133190. interface Math {
  133191. fround(x: number): number;
  133192. imul(a: number, b: number): number;
  133193. }
  133194. interface WebGLRenderingContext {
  133195. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  133196. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  133197. vertexAttribDivisor(index: number, divisor: number): void;
  133198. createVertexArray(): any;
  133199. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  133200. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  133201. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  133202. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  133203. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  133204. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  133205. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  133206. // Queries
  133207. createQuery(): WebGLQuery;
  133208. deleteQuery(query: WebGLQuery): void;
  133209. beginQuery(target: number, query: WebGLQuery): void;
  133210. endQuery(target: number): void;
  133211. getQueryParameter(query: WebGLQuery, pname: number): any;
  133212. getQuery(target: number, pname: number): any;
  133213. MAX_SAMPLES: number;
  133214. RGBA8: number;
  133215. READ_FRAMEBUFFER: number;
  133216. DRAW_FRAMEBUFFER: number;
  133217. UNIFORM_BUFFER: number;
  133218. HALF_FLOAT_OES: number;
  133219. RGBA16F: number;
  133220. RGBA32F: number;
  133221. R32F: number;
  133222. RG32F: number;
  133223. RGB32F: number;
  133224. R16F: number;
  133225. RG16F: number;
  133226. RGB16F: number;
  133227. RED: number;
  133228. RG: number;
  133229. R8: number;
  133230. RG8: number;
  133231. UNSIGNED_INT_24_8: number;
  133232. DEPTH24_STENCIL8: number;
  133233. MIN: number;
  133234. MAX: number;
  133235. /* Multiple Render Targets */
  133236. drawBuffers(buffers: number[]): void;
  133237. readBuffer(src: number): void;
  133238. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  133239. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  133240. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  133241. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  133242. // Occlusion Query
  133243. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  133244. ANY_SAMPLES_PASSED: number;
  133245. QUERY_RESULT_AVAILABLE: number;
  133246. QUERY_RESULT: number;
  133247. }
  133248. interface WebGLProgram {
  133249. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  133250. }
  133251. interface EXT_disjoint_timer_query {
  133252. QUERY_COUNTER_BITS_EXT: number;
  133253. TIME_ELAPSED_EXT: number;
  133254. TIMESTAMP_EXT: number;
  133255. GPU_DISJOINT_EXT: number;
  133256. QUERY_RESULT_EXT: number;
  133257. QUERY_RESULT_AVAILABLE_EXT: number;
  133258. queryCounterEXT(query: WebGLQuery, target: number): void;
  133259. createQueryEXT(): WebGLQuery;
  133260. beginQueryEXT(target: number, query: WebGLQuery): void;
  133261. endQueryEXT(target: number): void;
  133262. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  133263. deleteQueryEXT(query: WebGLQuery): void;
  133264. }
  133265. interface WebGLUniformLocation {
  133266. _currentState: any;
  133267. }
  133268. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  133269. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  133270. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  133271. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  133272. interface WebGLRenderingContext {
  133273. readonly RASTERIZER_DISCARD: number;
  133274. readonly DEPTH_COMPONENT24: number;
  133275. readonly TEXTURE_3D: number;
  133276. readonly TEXTURE_2D_ARRAY: number;
  133277. readonly TEXTURE_COMPARE_FUNC: number;
  133278. readonly TEXTURE_COMPARE_MODE: number;
  133279. readonly COMPARE_REF_TO_TEXTURE: number;
  133280. readonly TEXTURE_WRAP_R: number;
  133281. readonly HALF_FLOAT: number;
  133282. readonly RGB8: number;
  133283. readonly RED_INTEGER: number;
  133284. readonly RG_INTEGER: number;
  133285. readonly RGB_INTEGER: number;
  133286. readonly RGBA_INTEGER: number;
  133287. readonly R8_SNORM: number;
  133288. readonly RG8_SNORM: number;
  133289. readonly RGB8_SNORM: number;
  133290. readonly RGBA8_SNORM: number;
  133291. readonly R8I: number;
  133292. readonly RG8I: number;
  133293. readonly RGB8I: number;
  133294. readonly RGBA8I: number;
  133295. readonly R8UI: number;
  133296. readonly RG8UI: number;
  133297. readonly RGB8UI: number;
  133298. readonly RGBA8UI: number;
  133299. readonly R16I: number;
  133300. readonly RG16I: number;
  133301. readonly RGB16I: number;
  133302. readonly RGBA16I: number;
  133303. readonly R16UI: number;
  133304. readonly RG16UI: number;
  133305. readonly RGB16UI: number;
  133306. readonly RGBA16UI: number;
  133307. readonly R32I: number;
  133308. readonly RG32I: number;
  133309. readonly RGB32I: number;
  133310. readonly RGBA32I: number;
  133311. readonly R32UI: number;
  133312. readonly RG32UI: number;
  133313. readonly RGB32UI: number;
  133314. readonly RGBA32UI: number;
  133315. readonly RGB10_A2UI: number;
  133316. readonly R11F_G11F_B10F: number;
  133317. readonly RGB9_E5: number;
  133318. readonly RGB10_A2: number;
  133319. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  133320. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  133321. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  133322. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  133323. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  133324. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  133325. 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;
  133326. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  133327. readonly TRANSFORM_FEEDBACK: number;
  133328. readonly INTERLEAVED_ATTRIBS: number;
  133329. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  133330. createTransformFeedback(): WebGLTransformFeedback;
  133331. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  133332. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  133333. beginTransformFeedback(primitiveMode: number): void;
  133334. endTransformFeedback(): void;
  133335. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  133336. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133337. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133338. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  133339. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  133340. }
  133341. interface ImageBitmap {
  133342. readonly width: number;
  133343. readonly height: number;
  133344. close(): void;
  133345. }
  133346. interface WebGLQuery extends WebGLObject {
  133347. }
  133348. declare var WebGLQuery: {
  133349. prototype: WebGLQuery;
  133350. new(): WebGLQuery;
  133351. };
  133352. interface WebGLSampler extends WebGLObject {
  133353. }
  133354. declare var WebGLSampler: {
  133355. prototype: WebGLSampler;
  133356. new(): WebGLSampler;
  133357. };
  133358. interface WebGLSync extends WebGLObject {
  133359. }
  133360. declare var WebGLSync: {
  133361. prototype: WebGLSync;
  133362. new(): WebGLSync;
  133363. };
  133364. interface WebGLTransformFeedback extends WebGLObject {
  133365. }
  133366. declare var WebGLTransformFeedback: {
  133367. prototype: WebGLTransformFeedback;
  133368. new(): WebGLTransformFeedback;
  133369. };
  133370. interface WebGLVertexArrayObject extends WebGLObject {
  133371. }
  133372. declare var WebGLVertexArrayObject: {
  133373. prototype: WebGLVertexArrayObject;
  133374. new(): WebGLVertexArrayObject;
  133375. };
  133376. // Type definitions for WebVR API
  133377. // Project: https://w3c.github.io/webvr/
  133378. // Definitions by: six a <https://github.com/lostfictions>
  133379. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  133380. interface VRDisplay extends EventTarget {
  133381. /**
  133382. * Dictionary of capabilities describing the VRDisplay.
  133383. */
  133384. readonly capabilities: VRDisplayCapabilities;
  133385. /**
  133386. * z-depth defining the far plane of the eye view frustum
  133387. * enables mapping of values in the render target depth
  133388. * attachment to scene coordinates. Initially set to 10000.0.
  133389. */
  133390. depthFar: number;
  133391. /**
  133392. * z-depth defining the near plane of the eye view frustum
  133393. * enables mapping of values in the render target depth
  133394. * attachment to scene coordinates. Initially set to 0.01.
  133395. */
  133396. depthNear: number;
  133397. /**
  133398. * An identifier for this distinct VRDisplay. Used as an
  133399. * association point in the Gamepad API.
  133400. */
  133401. readonly displayId: number;
  133402. /**
  133403. * A display name, a user-readable name identifying it.
  133404. */
  133405. readonly displayName: string;
  133406. readonly isConnected: boolean;
  133407. readonly isPresenting: boolean;
  133408. /**
  133409. * If this VRDisplay supports room-scale experiences, the optional
  133410. * stage attribute contains details on the room-scale parameters.
  133411. */
  133412. readonly stageParameters: VRStageParameters | null;
  133413. /**
  133414. * Passing the value returned by `requestAnimationFrame` to
  133415. * `cancelAnimationFrame` will unregister the callback.
  133416. * @param handle Define the hanle of the request to cancel
  133417. */
  133418. cancelAnimationFrame(handle: number): void;
  133419. /**
  133420. * Stops presenting to the VRDisplay.
  133421. * @returns a promise to know when it stopped
  133422. */
  133423. exitPresent(): Promise<void>;
  133424. /**
  133425. * Return the current VREyeParameters for the given eye.
  133426. * @param whichEye Define the eye we want the parameter for
  133427. * @returns the eye parameters
  133428. */
  133429. getEyeParameters(whichEye: string): VREyeParameters;
  133430. /**
  133431. * Populates the passed VRFrameData with the information required to render
  133432. * the current frame.
  133433. * @param frameData Define the data structure to populate
  133434. * @returns true if ok otherwise false
  133435. */
  133436. getFrameData(frameData: VRFrameData): boolean;
  133437. /**
  133438. * Get the layers currently being presented.
  133439. * @returns the list of VR layers
  133440. */
  133441. getLayers(): VRLayer[];
  133442. /**
  133443. * Return a VRPose containing the future predicted pose of the VRDisplay
  133444. * when the current frame will be presented. The value returned will not
  133445. * change until JavaScript has returned control to the browser.
  133446. *
  133447. * The VRPose will contain the position, orientation, velocity,
  133448. * and acceleration of each of these properties.
  133449. * @returns the pose object
  133450. */
  133451. getPose(): VRPose;
  133452. /**
  133453. * Return the current instantaneous pose of the VRDisplay, with no
  133454. * prediction applied.
  133455. * @returns the current instantaneous pose
  133456. */
  133457. getImmediatePose(): VRPose;
  133458. /**
  133459. * The callback passed to `requestAnimationFrame` will be called
  133460. * any time a new frame should be rendered. When the VRDisplay is
  133461. * presenting the callback will be called at the native refresh
  133462. * rate of the HMD. When not presenting this function acts
  133463. * identically to how window.requestAnimationFrame acts. Content should
  133464. * make no assumptions of frame rate or vsync behavior as the HMD runs
  133465. * asynchronously from other displays and at differing refresh rates.
  133466. * @param callback Define the eaction to run next frame
  133467. * @returns the request handle it
  133468. */
  133469. requestAnimationFrame(callback: FrameRequestCallback): number;
  133470. /**
  133471. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  133472. * Repeat calls while already presenting will update the VRLayers being displayed.
  133473. * @param layers Define the list of layer to present
  133474. * @returns a promise to know when the request has been fulfilled
  133475. */
  133476. requestPresent(layers: VRLayer[]): Promise<void>;
  133477. /**
  133478. * Reset the pose for this display, treating its current position and
  133479. * orientation as the "origin/zero" values. VRPose.position,
  133480. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  133481. * updated when calling resetPose(). This should be called in only
  133482. * sitting-space experiences.
  133483. */
  133484. resetPose(): void;
  133485. /**
  133486. * The VRLayer provided to the VRDisplay will be captured and presented
  133487. * in the HMD. Calling this function has the same effect on the source
  133488. * canvas as any other operation that uses its source image, and canvases
  133489. * created without preserveDrawingBuffer set to true will be cleared.
  133490. * @param pose Define the pose to submit
  133491. */
  133492. submitFrame(pose?: VRPose): void;
  133493. }
  133494. declare var VRDisplay: {
  133495. prototype: VRDisplay;
  133496. new(): VRDisplay;
  133497. };
  133498. interface VRLayer {
  133499. leftBounds?: number[] | Float32Array | null;
  133500. rightBounds?: number[] | Float32Array | null;
  133501. source?: HTMLCanvasElement | null;
  133502. }
  133503. interface VRDisplayCapabilities {
  133504. readonly canPresent: boolean;
  133505. readonly hasExternalDisplay: boolean;
  133506. readonly hasOrientation: boolean;
  133507. readonly hasPosition: boolean;
  133508. readonly maxLayers: number;
  133509. }
  133510. interface VREyeParameters {
  133511. /** @deprecated */
  133512. readonly fieldOfView: VRFieldOfView;
  133513. readonly offset: Float32Array;
  133514. readonly renderHeight: number;
  133515. readonly renderWidth: number;
  133516. }
  133517. interface VRFieldOfView {
  133518. readonly downDegrees: number;
  133519. readonly leftDegrees: number;
  133520. readonly rightDegrees: number;
  133521. readonly upDegrees: number;
  133522. }
  133523. interface VRFrameData {
  133524. readonly leftProjectionMatrix: Float32Array;
  133525. readonly leftViewMatrix: Float32Array;
  133526. readonly pose: VRPose;
  133527. readonly rightProjectionMatrix: Float32Array;
  133528. readonly rightViewMatrix: Float32Array;
  133529. readonly timestamp: number;
  133530. }
  133531. interface VRPose {
  133532. readonly angularAcceleration: Float32Array | null;
  133533. readonly angularVelocity: Float32Array | null;
  133534. readonly linearAcceleration: Float32Array | null;
  133535. readonly linearVelocity: Float32Array | null;
  133536. readonly orientation: Float32Array | null;
  133537. readonly position: Float32Array | null;
  133538. readonly timestamp: number;
  133539. }
  133540. interface VRStageParameters {
  133541. sittingToStandingTransform?: Float32Array;
  133542. sizeX?: number;
  133543. sizeY?: number;
  133544. }
  133545. interface Navigator {
  133546. getVRDisplays(): Promise<VRDisplay[]>;
  133547. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  133548. }
  133549. interface Window {
  133550. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  133551. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  133552. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  133553. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133554. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  133555. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  133556. }
  133557. interface Gamepad {
  133558. readonly displayId: number;
  133559. }
  133560. type XRSessionMode =
  133561. | "inline"
  133562. | "immersive-vr"
  133563. | "immersive-ar";
  133564. type XRReferenceSpaceType =
  133565. | "viewer"
  133566. | "local"
  133567. | "local-floor"
  133568. | "bounded-floor"
  133569. | "unbounded";
  133570. type XREnvironmentBlendMode =
  133571. | "opaque"
  133572. | "additive"
  133573. | "alpha-blend";
  133574. type XRVisibilityState =
  133575. | "visible"
  133576. | "visible-blurred"
  133577. | "hidden";
  133578. type XRHandedness =
  133579. | "none"
  133580. | "left"
  133581. | "right";
  133582. type XRTargetRayMode =
  133583. | "gaze"
  133584. | "tracked-pointer"
  133585. | "screen";
  133586. type XREye =
  133587. | "none"
  133588. | "left"
  133589. | "right";
  133590. interface XRSpace extends EventTarget {
  133591. }
  133592. interface XRRenderState {
  133593. depthNear?: number;
  133594. depthFar?: number;
  133595. inlineVerticalFieldOfView?: number;
  133596. baseLayer?: XRWebGLLayer;
  133597. }
  133598. interface XRInputSource {
  133599. handedness: XRHandedness;
  133600. targetRayMode: XRTargetRayMode;
  133601. targetRaySpace: XRSpace;
  133602. gripSpace: XRSpace | undefined;
  133603. gamepad: Gamepad | undefined;
  133604. profiles: Array<string>;
  133605. }
  133606. interface XRSession {
  133607. addEventListener: Function;
  133608. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  133609. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  133610. requestAnimationFrame: Function;
  133611. end(): Promise<void>;
  133612. renderState: XRRenderState;
  133613. inputSources: Array<XRInputSource>;
  133614. }
  133615. interface XRReferenceSpace extends XRSpace {
  133616. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  133617. onreset: any;
  133618. }
  133619. interface XRFrame {
  133620. session: XRSession;
  133621. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  133622. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  133623. }
  133624. interface XRViewerPose extends XRPose {
  133625. views: Array<XRView>;
  133626. }
  133627. interface XRPose {
  133628. transform: XRRigidTransform;
  133629. emulatedPosition: boolean;
  133630. }
  133631. interface XRWebGLLayerOptions {
  133632. antialias ?: boolean;
  133633. depth ?: boolean;
  133634. stencil ?: boolean;
  133635. alpha ?: boolean;
  133636. multiview ?: boolean;
  133637. framebufferScaleFactor ?: number;
  133638. }
  133639. declare var XRWebGLLayer: {
  133640. prototype: XRWebGLLayer;
  133641. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  133642. };
  133643. interface XRWebGLLayer {
  133644. framebuffer: WebGLFramebuffer;
  133645. framebufferWidth: number;
  133646. framebufferHeight: number;
  133647. getViewport: Function;
  133648. }
  133649. interface XRRigidTransform {
  133650. position: DOMPointReadOnly;
  133651. orientation: DOMPointReadOnly;
  133652. matrix: Float32Array;
  133653. inverse: XRRigidTransform;
  133654. }
  133655. interface XRView {
  133656. eye: XREye;
  133657. projectionMatrix: Float32Array;
  133658. transform: XRRigidTransform;
  133659. }
  133660. interface XRInputSourceChangeEvent {
  133661. session: XRSession;
  133662. removed: Array<XRInputSource>;
  133663. added: Array<XRInputSource>;
  133664. }